From 1ede35fcdd55e7d95faa2fc7d2b26e0388fc200b Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 20 Jun 2000 04:57:39 +0000 Subject: basically got IMAP into the tree view svn path=/trunk/; revision=3643 --- mail/ChangeLog | 5 +++ mail/component-factory.c | 83 +++++++++++++++++++++++++++++++++++++++++------- mail/folder-browser.c | 12 +++++-- 3 files changed, 85 insertions(+), 15 deletions(-) (limited to 'mail') 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 + + * component-factory.c (create_imap_storage): Now creates the IMAP + storage (listing subfolders and such) + 2000-06-19 Dan Winship * 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 +#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:". */ -- cgit v1.2.3