From cb6f0cd1110c86eca9efd3e0c90127792e4431b4 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 14 Feb 2001 21:52:43 +0000 Subject: Connect to the "create_folder" signal on the storage. * component-factory.c (add_storage): Connect to the "create_folder" signal on the storage. (storage_create_folder): Do folder creation. svn path=/trunk/; revision=8232 --- mail/ChangeLog | 6 ++++++ mail/component-factory.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/mail/ChangeLog b/mail/ChangeLog index bbd36988bc..8fd9089b64 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2001-02-14 Dan Winship + + * component-factory.c (add_storage): Connect to the + "create_folder" signal on the storage. + (storage_create_folder): Do folder creation. + 2001-02-14 Jeffrey Stedfast * component-factory.c (owner_set_cb): Setup the Trash folder. diff --git a/mail/component-factory.c b/mail/component-factory.c index f46a0a5f9b..4cedc6e3c0 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -306,6 +306,57 @@ component_factory_init (void) } } +static int +storage_create_folder (EvolutionStorage *storage, const char *path, + const char *type, const char *description, + const char *parent_physical_uri, gpointer user_data) +{ + CamelStore *store = user_data; + char *name; + CamelURL *url; + CamelException ex; + CamelFolderInfo *fi; + + if (strcmp (type, "mail") != 0) + return EVOLUTION_STORAGE_ERROR_UNSUPPORTED_TYPE; + name = strrchr (path, '/'); + if (!name++) + return EVOLUTION_STORAGE_ERROR_INVALID_URI; + + camel_exception_init (&ex); + if (*parent_physical_uri) { + url = camel_url_new (parent_physical_uri, NULL); + if (!url) + return EVOLUTION_STORAGE_ERROR_INVALID_URI; + + fi = camel_store_create_folder (store, url->path + 1, name, &ex); + camel_url_free (url); + } else + fi = camel_store_create_folder (store, NULL, name, &ex); + + if (camel_exception_is_set (&ex)) { + /* FIXME: do better than this */ + camel_exception_clear (&ex); + return EVOLUTION_STORAGE_ERROR_INVALID_URI; + } + + if (camel_store_supports_subscriptions (store)) + camel_store_subscribe_folder (store, fi->full_name, NULL); + + if (fi->unread_message_count > 0) { + name = g_strdup_printf ("%s (%d)", fi->name, + fi->unread_message_count); + } else + name = g_strdup (fi->name); + evolution_storage_new_folder (storage, path, name, type, + fi->url ? fi->url : "", description, + fi->unread_message_count > 0); + g_free (name); + camel_store_free_folder_info (store, fi); + + return EVOLUTION_STORAGE_OK; +} + static void add_storage (const char *name, const char *uri, CamelService *store, GNOME_Evolution_Shell corba_shell, CamelException *ex) @@ -314,6 +365,9 @@ add_storage (const char *name, const char *uri, CamelService *store, EvolutionStorageResult res; storage = evolution_storage_new (name, uri, "mailstorage"); + gtk_signal_connect (GTK_OBJECT (storage), "create_folder", + GTK_SIGNAL_FUNC (storage_create_folder), + store); res = evolution_storage_register_on_shell (storage, corba_shell); -- cgit v1.2.3