diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-06-23 10:11:38 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-06-23 10:11:38 +0800 |
commit | d12be02179f502780ab5d8219dceac8c7b2d36e9 (patch) | |
tree | 1a2f0d9bb33e83bfc1b3f533ab92b24e13b36b8f /mail | |
parent | 61ec5b754bb8acf189d0ac083bf8e0cb0c98ebc0 (diff) | |
download | gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.gz gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.zst gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.zip |
add handling for loading "news:" folders.
2000-06-22 Chris Toshok <toshok@helixcode.com>
* folder-browser.c (folder_browser_load_folder): add handling for
loading "news:" folders.
* component-factory.c (create_news_storage): add a root for news
source.
(owner_set_cb): call create_news_storage.
svn path=/trunk/; revision=3703
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 9 | ||||
-rw-r--r-- | mail/component-factory.c | 80 | ||||
-rw-r--r-- | mail/folder-browser.c | 9 |
3 files changed, 98 insertions, 0 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index c6f34b0486..14c752f9a4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,12 @@ +2000-06-22 Chris Toshok <toshok@helixcode.com> + + * folder-browser.c (folder_browser_load_folder): add handling for + loading "news:" folders. + + * component-factory.c (create_news_storage): add a root for news + source. + (owner_set_cb): call create_news_storage. + 2000-06-22 Jeffrey Stedfast <fejj@helixcode.com> * folder-browser.c (folder_browser_load_folder): Updated to diff --git a/mail/component-factory.c b/mail/component-factory.c index 5337a5e6f9..19969c7098 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -120,6 +120,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, create_vfolder_storage (shell_component); create_imap_storage (shell_component); + create_news_storage (shell_component); } static void @@ -333,5 +334,84 @@ create_imap_storage (EvolutionShellComponent *shell_component) camel_exception_free (ex); } +static void +create_news_storage (EvolutionShellComponent *shell_component) +{ + /* FIXME: KLUDGE! */ + extern gchar *evolution_dir; + Evolution_Shell corba_shell; + EvolutionStorage *storage; + char *cpath, *source, *server, *p; + CamelStore *store; + CamelFolder *folder; + CamelException *ex; + GPtrArray *lsub; + int i, max; + + cpath = g_strdup_printf ("=%s/config=/news/source", evolution_dir); + source = gnome_config_get_string (cpath); + g_free (cpath); + + if (!source || strncasecmp (source, "news://", 7)) + return; + + corba_shell = evolution_shell_component_get_owner (shell_component); + if (corba_shell == CORBA_OBJECT_NIL) { + g_warning ("We have no shell!?"); + g_free (source); + return; + } + + server = source + 7; + 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"); + g_free (source); + return; + } + + /* save the storage for later */ + 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); + + max = lsub->len; + for (i = 0; i < max; i++) { + char *path, *buf; + + path = g_strdup_printf ("/%s", (char *)lsub->pdata[i]); + buf = g_strdup_printf ("%s%s", source, path); + g_print ("Adding %s\n", path); + evolution_storage_new_folder (storage, path, "mail", buf, "description"); + } + + cleanup: + camel_exception_free (ex); +} + diff --git a/mail/folder-browser.c b/mail/folder-browser.c index b880a867b6..0220252e59 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -131,6 +131,15 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name) g_free (folder_name); } } + } else if (!strncmp(name, "news:", 5)) { + store = camel_session_get_store (session, name, ex); + if (store) { + const char *folder_name; + + folder_name = name + 5; + + new_folder = camel_store_get_folder (store, folder_name, FALSE, ex); + } } else if (!strncmp (name, "file:", 5)) { /* Change "file:" to "mbox:". */ store_name = g_strdup_printf ("mbox:%s", name + 5); |