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/component-factory.c | |
parent | 61ec5b754bb8acf189d0ac083bf8e0cb0c98ebc0 (diff) | |
download | gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.gz gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.bz2 gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.lz gsoc2013-evolution-d12be02179f502780ab5d8219dceac8c7b2d36e9.tar.xz 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/component-factory.c')
-rw-r--r-- | mail/component-factory.c | 80 |
1 files changed, 80 insertions, 0 deletions
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); +} + |