aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3/camel-pop3-folder.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-03-23 00:55:28 +0800
committerDan Winship <danw@src.gnome.org>2000-03-23 00:55:28 +0800
commit07baaeb9c606395a98853be164b04b56560f547a (patch)
tree89e381f6da58cc9d497fff7e99b0522290dac3e0 /camel/providers/pop3/camel-pop3-folder.c
parentaf50786d6f38bccab9b4ec69a5268668cb440191 (diff)
downloadgsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.gz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.bz2
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.lz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.xz
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.tar.zst
gsoc2013-evolution-07baaeb9c606395a98853be164b04b56560f547a.zip
fill this in partially make camel_pop3_command return the text after
* providers/pop3/camel-pop3-folder.c: fill this in partially * providers/pop3/camel-pop3-store.c: make camel_pop3_command return the text after "+OK"/"-ERR" and add a separate camel_pop3_get_additional_data to get the message body or whatever. Also make them take a CamelPop3Store rather than a CamelStreamBuffer. svn path=/trunk/; revision=2143
Diffstat (limited to 'camel/providers/pop3/camel-pop3-folder.c')
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
new file mode 100644
index 0000000000..f5dd28e596
--- /dev/null
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -0,0 +1,156 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-pop3-folder.c : class for a pop3 folder */
+
+/*
+ * Authors:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * Copyright (C) 2000 Helix Code, Inc. (www.helixcode.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include "camel-pop3-folder.h"
+
+#define CF_CLASS (o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass))
+
+static gboolean has_message_number_capability (CamelFolder *folder);
+static CamelMimeMessage *get_message_by_number (CamelFolder *folder,
+ gint number,
+ CamelException *ex);
+static gint get_message_count (CamelFolder *folder, CamelException *ex);
+
+
+static void
+camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
+{
+ CamelFolderClass *camel_folder_class =
+ CAMEL_FOLDER_CLASS (camel_pop3_folder_class);
+
+ /* virtual method overload */
+ camel_folder_class->has_message_number_capability =
+ has_message_number_capability;
+ camel_folder_class->get_message_by_number =
+ get_message_by_number;
+ camel_folder_class->get_message_count =
+ get_message_count;
+}
+
+
+
+static void
+camel_pop3_folder_init (gpointer object, gpointer klass)
+{
+ CamelFolder *folder = CAMEL_FOLDER (object);
+
+ folder->can_hold_messages = TRUE;
+ folder->can_hold_folders = FALSE;
+
+ /* Hi. I'm CamelPop3Folder. I'm useless. */
+ folder->has_summary_capability = FALSE;
+ folder->has_uid_capability = FALSE;
+ folder->has_search_capability = FALSE;
+}
+
+
+
+
+GtkType
+camel_pop3_folder_get_type (void)
+{
+ static GtkType camel_pop3_folder_type = 0;
+
+ if (!camel_pop3_folder_type) {
+ GtkTypeInfo camel_pop3_folder_info =
+ {
+ "CamelPop3Folder",
+ sizeof (CamelPop3Folder),
+ sizeof (CamelPop3FolderClass),
+ (GtkClassInitFunc) camel_pop3_folder_class_init,
+ (GtkObjectInitFunc) camel_pop3_folder_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ camel_pop3_folder_type = gtk_type_unique (CAMEL_FOLDER_TYPE, &camel_pop3_folder_info);
+ }
+
+ return camel_pop3_folder_type;
+}
+
+
+CamelFolder *camel_pop3_folder_new (CamelStore *parent, CamelException *ex)
+{
+ CamelFolder *folder =
+ CAMEL_FOLDER (gtk_object_new (camel_pop3_folder_get_type ()));
+
+ CF_CLASS (folder)->init (folder, parent, NULL, "inbox", '/', ex);
+ return folder;
+}
+
+static gboolean
+has_message_number_capability (CamelFolder *folder)
+{
+ return TRUE;
+}
+
+static CamelMimeMessage *
+get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+{
+ int status;
+ char *body;
+
+ status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
+ NULL, "RETR %d", number);
+ if (status != CAMEL_POP3_OK) {
+ CamelService *service = CAMEL_SERVICE (folder->parent_store);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not retrieve message from POP "
+ "server %s: %s.", service->url->host,
+ status == CAMEL_POP3_ERR ? result :
+ "Unknown error");
+ g_free (result);
+ return -1;
+ }
+
+ /* XXX finish this */
+ return NULL
+}
+
+
+static gint get_message_count (CamelFolder *folder, CamelException *ex);
+{
+ int status, count;
+ char *result;
+
+ status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
+ &result, "STAT");
+ if (status != CAMEL_POP3_OK) {
+ CamelService *service = CAMEL_SERVICE (folder->parent_store);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ "Could not get message count from POP "
+ "server %s: %s.", service->url->host,
+ status == CAMEL_POP3_ERR ? result :
+ "Unknown error");
+ g_free (result);
+ return -1;
+ }
+
+ count = atoi (result);
+ g_free (result);
+ return count;
+}