aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/pop3
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-05-19 08:47:36 +0800
committerDan Winship <danw@src.gnome.org>2000-05-19 08:47:36 +0800
commita909e956daf6879cd5a4bcc1ed8f5d09ea173563 (patch)
tree8f8d55f79112de99d9224fc2e4999872b7bb7890 /camel/providers/pop3
parente46d64caa7b900342b1f1823aad7938b0f90cbbe (diff)
downloadgsoc2013-evolution-a909e956daf6879cd5a4bcc1ed8f5d09ea173563.tar.gz
gsoc2013-evolution-a909e956daf6879cd5a4bcc1ed8f5d09ea173563.tar.zst
gsoc2013-evolution-a909e956daf6879cd5a4bcc1ed8f5d09ea173563.zip
remove message_number_capability and require uid capatibility.
* camel-folder.c: remove message_number_capability and require uid capatibility. (camel_folder_list_subfolders, camel_folder_get_uid_list, camel_folder_get_subfolder_info, camel_folder_get_message_info): removed (camel_folder_get_subfolder_names, camel_folder_free_subfolder_names): new subfolder interfaces. (camel_folder_get_uids, camel_folder_free_uids): new uid interfaces (camel_folder_get_summary, camel_folder_free_summary): new summary interfaces * providers/mbox/camel-mbox-folder.c, * providers/nntp/camel-nntp-folder.c: * providers/vee/camel-vee-folder.c: Update for changes * providers/pop3/camel-pop3-folder.c: Implement get_uids, update for other changes. svn path=/trunk/; revision=3126
Diffstat (limited to 'camel/providers/pop3')
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c84
-rw-r--r--camel/providers/pop3/camel-pop3-folder.h3
2 files changed, 52 insertions, 35 deletions
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 838f247ac6..45687e4f33 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -30,6 +30,7 @@
#include "camel-mime-message.h"
#include <stdlib.h>
+#include <string.h>
#define CF_CLASS(o) (CAMEL_FOLDER_CLASS (GTK_OBJECT (o)->klass))
static CamelFolderClass *parent_class;
@@ -39,13 +40,14 @@ static void pop3_open (CamelFolder *folder, CamelFolderOpenMode mode,
static void pop3_close (CamelFolder *folder, gboolean expunge,
CamelException *ex);
static gboolean delete_messages (CamelFolder *folder, CamelException *ex);
-static gboolean has_message_number_capability (CamelFolder *folder);
-static CamelMimeMessage *get_message_by_number (CamelFolder *folder,
- gint number,
- CamelException *ex);
-static void delete_message_by_number (CamelFolder *folder, gint number,
- CamelException *ex);
+
static gint get_message_count (CamelFolder *folder, CamelException *ex);
+static GPtrArray *get_uids (CamelFolder *folder, CamelException *ex);
+static CamelMimeMessage *get_message_by_uid (CamelFolder *folder,
+ const char *uid,
+ CamelException *ex);
+static void delete_message_by_uid (CamelFolder *folder, const char *uid,
+ CamelException *ex);
static void
@@ -60,33 +62,28 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
camel_folder_class->open = pop3_open;
camel_folder_class->close = pop3_close;
camel_folder_class->delete_messages = delete_messages;
- 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->delete_message_by_number =
- delete_message_by_number;
- camel_folder_class->get_message_count =
- get_message_count;
-}
+ camel_folder_class->get_message_count = get_message_count;
+ camel_folder_class->get_uids = get_uids;
+
+ camel_folder_class->get_message_by_uid = get_message_by_uid;
+ camel_folder_class->delete_message_by_uid = delete_message_by_uid;
+}
static void
camel_pop3_folder_init (gpointer object, gpointer klass)
{
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (object);
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;
-}
-
+ pop3_folder->count = -1;
+}
GtkType
@@ -168,14 +165,8 @@ delete_messages (CamelFolder *folder, CamelException *ex)
}
-static gboolean
-has_message_number_capability (CamelFolder *folder)
-{
- return TRUE;
-}
-
static CamelMimeMessage *
-get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+get_message_by_uid (CamelFolder *folder, const char *uid, CamelException *ex)
{
int status;
char *result, *body;
@@ -183,7 +174,7 @@ get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
CamelMimeMessage *msg;
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
- &result, "RETR %d", number);
+ &result, "RETR %d", atoi (uid));
if (status != CAMEL_POP3_OK) {
CamelService *service = CAMEL_SERVICE (folder->parent_store);
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
@@ -216,17 +207,18 @@ get_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
}
static void
-delete_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
+delete_message_by_uid (CamelFolder *folder, const char *uid,
+ CamelException *ex)
{
int status;
char *resp;
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
- &resp, "DELE %d", number);
+ &resp, "DELE %d", atoi (uid));
if (status != CAMEL_POP3_OK) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
- "Unable to delete message %d%s%s",
- number, resp ? ": " : "",
+ "Unable to delete message %s%s%s",
+ uid, resp ? ": " : "",
resp ? resp : "");
}
g_free (resp);
@@ -235,9 +227,13 @@ delete_message_by_number (CamelFolder *folder, gint number, CamelException *ex)
static gint
get_message_count (CamelFolder *folder, CamelException *ex)
{
- int status, count;
+ CamelPop3Folder *pop3_folder = CAMEL_POP3_FOLDER (folder);
+ int status;
char *result;
+ if (pop3_folder->count != -1)
+ return pop3_folder->count;
+
status = camel_pop3_command (CAMEL_POP3_STORE (folder->parent_store),
&result, "STAT");
if (status != CAMEL_POP3_OK) {
@@ -251,7 +247,25 @@ get_message_count (CamelFolder *folder, CamelException *ex)
return -1;
}
- count = atoi (result);
+ pop3_folder->count = atoi (result);
g_free (result);
- return count;
+ return pop3_folder->count;
+}
+
+static GPtrArray *
+get_uids (CamelFolder *folder, CamelException *ex)
+{
+ int count, i;
+ GPtrArray *array;
+
+ count = get_message_count (folder, ex);
+ if (count == -1)
+ return NULL;
+
+ array = g_ptr_array_new ();
+ g_ptr_array_set_size (array, count);
+ for (i = 0; i < count; i++)
+ array->pdata[i] = g_strdup_printf ("%d", i + 1);
+
+ return array;
}
diff --git a/camel/providers/pop3/camel-pop3-folder.h b/camel/providers/pop3/camel-pop3-folder.h
index 4199e30ead..2a478dc283 100644
--- a/camel/providers/pop3/camel-pop3-folder.h
+++ b/camel/providers/pop3/camel-pop3-folder.h
@@ -45,6 +45,9 @@ extern "C" {
typedef struct {
CamelFolder parent_object;
+ CamelMessageInfo *msg_info;
+ int count;
+
} CamelPop3Folder;