aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@src.gnome.org>2000-06-20 12:57:39 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-06-20 12:57:39 +0800
commit1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b (patch)
treeee0f8501c411c0f5294f1d9d762cd8d27f65e03a
parent12da85716e3fa1734a363a240d302e72fbf422f8 (diff)
downloadgsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar.gz
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar.bz2
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar.lz
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar.xz
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.tar.zst
gsoc2013-evolution-1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b.zip
basically got IMAP into the tree view
svn path=/trunk/; revision=3643
-rw-r--r--camel/ChangeLog18
-rw-r--r--camel/providers/imap/camel-imap-folder.c119
-rw-r--r--camel/providers/imap/camel-imap-folder.h2
-rw-r--r--camel/providers/imap/camel-imap-store.c1
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/component-factory.c83
-rw-r--r--mail/folder-browser.c12
7 files changed, 192 insertions, 48 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 5b4d5aabd6..693a9cd7fa 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,15 +1,23 @@
+2000-06-20 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * providers/imap/camel-imap-folder.c: Added namespace stuff
+ which we will need later on...
+ (imap_parse_subfolder_line): Convenience function for use in
+ get_subfolder_names()
+ (imap_get_subfolder_names): Updated.
+
2000-06-19 Jeffrey Stedfast <fejj@helixcode.com>
- * providers/imap/camel-imap-folder.c (camel_imap_folder_init):
- Set summary equal to NULL.
+ * providers/imap/camel-imap-folder.c (camel_imap_folder_init): Set
+ summary equal to NULL.
(imap_get_summary): Store the summary in the ImapFolder
(imap_summary_get_by_uid): If we have a summary cache in the
ImapFolder, first check to see if that message info is in the
cached summary first, if not fetch it directly from the IMAP
server and append it to the summary cache.
- (imap_get_message_flags): Don't free the message info that we
- get back from summary_get_by_uid as we don't want to be
- corrupting our cached summary.
+ (imap_get_message_flags): Don't free the message info that we get
+ back from summary_get_by_uid as we don't want to be corrupting our
+ cached summary.
2000-06-19 Peter Williams <peterw@curious-george.helixcode.com>
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 55d21d9511..729a620820 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -70,6 +70,7 @@ static gboolean imap_delete_messages (CamelFolder *folder, CamelException *ex);
static gint imap_get_message_count (CamelFolder *folder, CamelException *ex);
static void imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelException *ex);
static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex);
+static gboolean imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder);
static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex);
static GPtrArray *imap_get_summary (CamelFolder *folder, CamelException *ex);
static void imap_free_summary (CamelFolder *folder, GPtrArray *array);
@@ -103,7 +104,6 @@ static gboolean imap_get_message_user_flag (CamelFolder *folder, const char *uid
static void imap_set_message_user_flag (CamelFolder *folder, const char *uid, const char *name,
gboolean value, CamelException *ex);
-
static void
camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
{
@@ -153,6 +153,7 @@ camel_imap_folder_init (gpointer object, gpointer klass)
folder->has_summary_capability = TRUE;
folder->has_search_capability = FALSE; /* default - we have to query IMAP to know for sure */
+ imap_folder->namespace = NULL;
imap_folder->summary = NULL;
imap_folder->count = -1;
}
@@ -191,6 +192,19 @@ camel_imap_folder_new (CamelStore *parent, CamelException *ex)
return folder;
}
+void
+camel_imap_folder_set_namespace (CamelFolder *folder, gchar *namespace)
+{
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
+ g_return_if_fail (folder != NULL);
+ g_return_if_fail (namespace != NULL);
+
+ if (imap_folder->namespace)
+ g_free (imap_folder->namespace);
+
+ imap_folder->namespace = g_strdup (namespace);
+}
+
static void
imap_finalize (GtkObject *object)
{
@@ -254,6 +268,8 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo
imap_folder->search = NULL;
imap_folder->summary = NULL;
+ if (!imap_folder->namespace)
+ imap_folder->namespace = g_strdup("mail");
/* SELECT the IMAP mail spool */
status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
@@ -502,21 +518,67 @@ imap_get_uids (CamelFolder *folder, CamelException *ex)
return array;
}
+static gboolean
+imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder)
+{
+ gchar *ptr, *eptr;
+
+ *flags = NULL;
+ *sep = NULL;
+ *folder = NULL;
+
+ if (strncasecmp (buf, "* LIST", 6))
+ return FALSE;
+
+ ptr = strstr (buf + 6, "(");
+ if (!ptr)
+ return FALSE;
+
+ ptr++;
+ eptr = strstr (ptr, ")");
+ if (!eptr)
+ return FALSE;
+
+ *flags = g_strndup (ptr, (gint)(eptr - ptr));
+
+ ptr = strstr (eptr, "\"");
+ if (!ptr)
+ return FALSE;
+
+ ptr++;
+ eptr = strstr (ptr, "\"");
+ if (!eptr)
+ return FALSE;
+
+ *sep = g_strndup (ptr, (gint)(eptr - ptr));
+
+ ptr = eptr + 1;
+ *folder = g_strdup (ptr);
+ g_strstrip (*folder);
+
+ return TRUE;
+}
+
static GPtrArray *
imap_get_subfolder_names (CamelFolder *folder, CamelException *ex)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *listing;
gint status;
- gchar *result;
+ gchar *result, *fname;
g_return_val_if_fail (folder != NULL, g_ptr_array_new());
if (imap_folder->count != -1)
return g_ptr_array_new ();
+
+ if (!strcmp (folder->full_name, "INBOX"))
+ fname = imap_folder->namespace;
+ else
+ fname = folder->full_name;
status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder,
- &result, "LSUB \"\" \"%s\"", folder->full_name);
+ &result, "LIST \"\" \"%s/*\"", fname);
if (status != CAMEL_IMAP_OK) {
CamelService *service = CAMEL_SERVICE (folder->parent_store);
@@ -531,40 +593,43 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex)
/* parse out the subfolders */
listing = g_ptr_array_new ();
- g_ptr_array_add (listing, g_strdup("INBOX"));
+ /*g_ptr_array_add (listing, g_strdup("INBOX"));*/
if (result) {
char *ptr = result;
- while (*ptr == '*') {
- gchar *flags, *end, *dir_sep, *param = NULL;
+ while (ptr && *ptr == '*') {
+ gchar *flags, *sep, *folder, *buf, *end, *f;
+ gboolean ret;
+
+ for (end = ptr; *end && *end != '\n'; end++);
+ buf = g_strndup (ptr, (gint)(end - ptr));
+ ptr = end;
- ptr = flags = strchr (ptr, '(') + 1; /* jump to the flags section */
- end = strchr (flags, ')'); /* locate end of flags */
- flags = g_strndup(flags, (gint)(end - flags));
+ ret = imap_parse_subfolder_line (buf, &flags, &sep, &folder);
+ g_free (buf);
- if (strstr (flags, "\\NoSelect")) {
+ if (!ret || (flags && strstr (flags, "NoSelect"))) {
g_free (flags);
+ g_free (sep);
+ g_free (folder);
+
+ if (*ptr == '\n')
+ ptr++;
+
continue;
}
g_free (flags);
- ptr = dir_sep = strchr (ptr, '"') + 1; /* jump to the first param */
- end = strchr (param, '"'); /* locate the end of the param */
- dir_sep = g_strndup (dir_sep, (gint)(end - param));
-
- /* skip to the actual directory parameter */
- for (ptr = end++; *ptr == ' '; ptr++);
- for (end = ptr; *end && *end != '\n'; end++);
- param = g_strndup (ptr, (gint)(end - ptr));
-
- g_ptr_array_add (listing, param);
-
- g_free (dir_sep); /* TODO: decide if we really need dir_sep */
+ f = folder + strlen (fname) + 1;
+ memmove (folder, f, strlen (f) + 1);
+ printf ("adding folder: %s\n", folder);
+
+ g_ptr_array_add (listing, folder);
- if (*end)
- ptr = end + 1;
- else
- ptr = end;
+ g_free (sep); /* TODO: decide if we really need dir_sep */
+
+ if (*ptr == '\n')
+ ptr++;
}
}
g_free(result);
@@ -675,8 +740,6 @@ get_header_field (gchar *header, gchar *field)
GPtrArray *
imap_get_summary (CamelFolder *folder, CamelException *ex)
{
- /* FIXME: we leak mem here if the summary already exists
- * Q: where do we want to free the pre-existing summary? */
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *array = NULL;
CamelMessageInfo *info;
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index ea96b2facb..625b91a06f 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -47,6 +47,7 @@ typedef struct {
CamelFolderSearch *search; /* used to run searches */
GPtrArray *summary;
+ gchar *namespace;
gint count;
} CamelImapFolder;
@@ -61,6 +62,7 @@ typedef struct {
/* public methods */
CamelFolder *camel_imap_folder_new (CamelStore *parent, CamelException *ex);
+void camel_imap_folder_set_namespace (CamelFolder *folder, gchar *namespace);
/* Standard Gtk function */
GtkType camel_imap_folder_get_type (void);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 77379f03d8..76af3348e1 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -556,6 +556,7 @@ camel_imap_command_extended (CamelImapStore *store, CamelFolder *folder, char **
respbuf = camel_stream_buffer_read_line (stream);
if (!respbuf || !strncmp(respbuf, cmdid, strlen(cmdid)) ) {
/* IMAP's last response starts with our command id */
+ fprintf(stderr, "received: %s\n", respbuf ? respbuf : "(null)");
break;
}
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f667f7524f..4d647f134d 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2000-06-20 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * component-factory.c (create_imap_storage): Now creates the IMAP
+ storage (listing subfolders and such)
+
2000-06-19 Dan Winship <danw@helixcode.com>
* mail-format.c (find_preferred_alternative): add an option to
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 30658a3596..a12a7f8c58 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -27,6 +27,8 @@
#include <bonobo.h>
+#include "camel.h"
+
#include "Evolution.h"
#include "evolution-storage.h"
@@ -39,7 +41,7 @@
#include "component-factory.h"
static void create_vfolder_storage (EvolutionShellComponent *shell_component);
-/*static void create_imap_storage (EvolutionShellComponent *shell_component);*/
+static void create_imap_storage (EvolutionShellComponent *shell_component);
#ifdef USING_OAF
#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:evolution-mail:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"
@@ -83,8 +85,8 @@ create_view (EvolutionShellComponent *shell_component,
browsers = g_list_prepend (browsers, folder_browser_widget);
/* dum de dum, hack to let the folder browser know the storage its in */
- gtk_object_set_data(GTK_OBJECT (folder_browser_widget), "e-storage",
- gtk_object_get_data(GTK_OBJECT (shell_component), "e-storage"));
+ gtk_object_set_data (GTK_OBJECT (folder_browser_widget), "e-storage",
+ gtk_object_get_data(GTK_OBJECT (shell_component), "e-storage"));
*control_return = control;
@@ -104,9 +106,7 @@ create_folder (EvolutionShellComponent *shell_component,
CORBA_exception_init (&ev);
- Evolution_ShellComponentListener_report_result (listener,
- Evolution_ShellComponentListener_OK,
- &ev);
+ Evolution_ShellComponentListener_report_result (listener, Evolution_ShellComponentListener_OK, &ev);
CORBA_exception_free (&ev);
}
@@ -119,6 +119,7 @@ owner_set_cb (EvolutionShellComponent *shell_component,
g_print ("evolution-mail: Yeeeh! We have an owner!\n"); /* FIXME */
create_vfolder_storage (shell_component);
+ create_imap_storage (shell_component);
}
static void
@@ -245,28 +246,86 @@ create_vfolder_storage (EvolutionShellComponent *shell_component)
}
}
-#if 0
static void
create_imap_storage (EvolutionShellComponent *shell_component)
{
+ /* FIXME: KLUDGE! */
+ extern gchar *evolution_dir;
Evolution_Shell corba_shell;
EvolutionStorage *storage;
+ char *path, *source, *server, *p;
+ CamelStore *store;
+ CamelFolder *folder;
+ CamelException *ex;
+ GPtrArray *lsub;
+ int i, max;
+
+ path = g_strdup_printf ("=%s/config=/mail/source", evolution_dir);
+ source = gnome_config_get_string (path);
+ g_free (path);
+
+ if (strncasecmp (source, "imap://", 7))
+ return;
corba_shell = evolution_shell_component_get_owner (shell_component);
if (corba_shell == CORBA_OBJECT_NIL) {
g_warning ("We have no shell!?");
return;
}
-
- storage = evolution_storage_new ("IMAP Folders");
+
+ if (!(server = strchr (source, '@')))
+ return;
+ server++;
+ for (p = server; *p && *p != '/'; p++);
+
+ server = g_strndup (server, (gint)(p - server));
+
+ storage = evolution_storage_new (server);
+ g_free (server);
+
if (evolution_storage_register_on_shell (storage, corba_shell) != EVOLUTION_STORAGE_OK) {
g_warning ("Cannot register storage");
return;
}
/* save the storage for later */
- gtk_object_set_data(GTK_OBJECT (shell_component), "e-storage", storage);
+ gtk_object_set_data (GTK_OBJECT (shell_component), "e-storage", storage);
+
+ ex = camel_exception_new ();
+
+ store = camel_session_get_store (session, source, ex);
+ if (!store) {
+ goto cleanup;
+ }
+
+ camel_service_connect (CAMEL_SERVICE (store), ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ goto cleanup;
+ }
+
+ folder = camel_store_get_root_folder (store, ex);
+ if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
+ goto cleanup;
+ }
+
+ /* we need a way to set the namespace */
+ lsub = camel_folder_get_subfolder_names (folder, ex);
+
+ evolution_storage_new_folder (storage, "/INBOX", "mail", source, "description");
+
+ max = lsub->len;
+ fprintf (stderr, "\n************* We have %d folders\n\n", max + 1);
+ for (i = 0; i < max; i++) {
+ char *path;
- evolution_storage_new_folder (storage, "name", "mail", "some string or other", "description");
+ path = g_strdup_printf ("/%s", (char *)lsub->pdata[i]);
+ g_print ("Adding %s\n", path);
+ evolution_storage_new_folder (storage, path, "mail", source, "description");
+ }
+
+ cleanup:
+ camel_exception_free (ex);
}
-#endif
+
+
+
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 3a94659423..2831f8bc24 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -102,13 +102,19 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
} else if (!strncmp(name, "imap:", 5)) {
/* uhm, I'm just guessing here - this code might be wrong */
- fprintf(stderr, "\n*** name = %s ***\n\n", name);
+ fprintf (stderr, "\n****** name = %s ******\n\n", name);
store = camel_session_get_store (session, name, ex);
if (store) {
char *folder_name;
- folder_name = name += 5;
- new_folder = camel_store_get_folder (store, folder_name, TRUE, ex);
+ folder_name = strstr (name, "//");
+ if (folder_name) {
+ for (folder_name += 2; *folder_name && *folder_name != '/'; folder_name++);
+ if (*folder_name) {
+ folder_name++;
+ new_folder = camel_store_get_folder (store, folder_name, TRUE, ex);
+ }
+ }
}
} else if (!strncmp(name, "file:", 5)) {
/* Change "file:" to "mbox:". */