diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-02-16 07:54:16 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-02-16 07:54:16 +0800 |
commit | 7ac8a9c5e8bc272a75bed0c2509b525b907753ba (patch) | |
tree | 46e44dc67e27ad504ed94f4a148d4c9c8489b266 | |
parent | f89ca302d1bc8cdd0a988121523928b80366441a (diff) | |
download | gsoc2013-evolution-7ac8a9c5e8bc272a75bed0c2509b525b907753ba.tar.gz gsoc2013-evolution-7ac8a9c5e8bc272a75bed0c2509b525b907753ba.tar.zst gsoc2013-evolution-7ac8a9c5e8bc272a75bed0c2509b525b907753ba.zip |
Use mail_storage_create_folder
2001-02-15 Jeffrey Stedfast <fejj@ximian.com>
* mail-ops.c (do_scan_subfolders): Use mail_storage_create_folder
* mail-callbacks.c (mail_storage_create_folder): Convenience
function so we can keep all the evolution_storage_add_new_folder()
code in one place as much as possible.
* subscribe-dialog.c (recursive_add_folder): Use 'name' rather
than the no-description bs since that's what all the other places
do.
* mail-callbacks.c (folder_created): New callback to handle the
"folder_created" signal - handles CamelFolderInfo's recursively.
(folder_deleted): Same but for "folder_deleted".
* component-factory.c (storage_create_folder): Instead of doing
the evolution_storage_new_folder() stuff by hand, pass it off to
the new callback: folder_created(). At some point this will be
unecessary as we'll attach this callback to the "folder_created"
signal.
svn path=/trunk/; revision=8247
-rw-r--r-- | mail/ChangeLog | 22 | ||||
-rw-r--r-- | mail/component-factory.c | 15 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 87 | ||||
-rw-r--r-- | mail/mail-callbacks.h | 8 | ||||
-rw-r--r-- | mail/mail-ops.c | 25 | ||||
-rw-r--r-- | mail/subscribe-dialog.c | 2 |
6 files changed, 125 insertions, 34 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 4a00d12d68..df213da3d6 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,27 @@ 2001-02-15 Jeffrey Stedfast <fejj@ximian.com> + * mail-ops.c (do_scan_subfolders): Use mail_storage_create_folder + + * mail-callbacks.c (mail_storage_create_folder): Convenience + function so we can keep all the evolution_storage_add_new_folder() + code in one place as much as possible. + + * subscribe-dialog.c (recursive_add_folder): Use 'name' rather + than the no-description bs since that's what all the other places + do. + + * mail-callbacks.c (folder_created): New callback to handle the + "folder_created" signal - handles CamelFolderInfo's recursively. + (folder_deleted): Same but for "folder_deleted". + + * component-factory.c (storage_create_folder): Instead of doing + the evolution_storage_new_folder() stuff by hand, pass it off to + the new callback: folder_created(). At some point this will be + unecessary as we'll attach this callback to the "folder_created" + signal. + +2001-02-15 Jeffrey Stedfast <fejj@ximian.com> + * message-list.c: Wrapped the address compare functions in a #ifdef (address_compare): #ifdef the use of the smart address sorting diff --git a/mail/component-factory.c b/mail/component-factory.c index 4cedc6e3c0..fef109679f 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -342,18 +342,11 @@ storage_create_folder (EvolutionStorage *storage, const char *path, 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); + + folder_created (store, fi); + camel_store_free_folder_info (store, fi); - + return EVOLUTION_STORAGE_OK; } diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index e166871550..f4fa4f06cd 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -1334,3 +1334,90 @@ stop_threads(BonoboUIComponent *uih, void *user_data, const char *path) camel_operation_cancel(NULL); } + +static void +create_folders (EvolutionStorage *storage, CamelFolderInfo *fi) +{ + char *name, *path; + + if (fi->unread_message_count > 0) + name = g_strdup_printf ("%s (%d)", fi->name, + fi->unread_message_count); + else + name = g_strdup (fi->name); + + path = g_strdup_printf ("/%s", fi->full_name); + evolution_storage_new_folder (storage, path, name, + "mail", fi->url ? fi->url : "", + fi->name, /* description */ + fi->unread_message_count > 0); + g_free (name); + g_free (path); + + if (fi->child) + create_folders (storage, fi->child); + + if (fi->sibling) + create_folders (storage, fi->sibling); +} + +void +folder_created (CamelStore *store, CamelFolderInfo *fi) +{ + EvolutionStorage *storage; + + if ((storage = mail_lookup_storage (store))) { + if (fi) + create_folders (storage, fi); + + gtk_object_unref (GTK_OBJECT (storage)); + } +} + +void +mail_storage_create_folder (EvolutionStorage *storage, CamelStore *store, CamelFolderInfo *fi) +{ + gboolean unref = FALSE; + + if (!storage && store) { + storage = mail_lookup_storage (store); + unref = TRUE; + } + + if (storage) { + if (fi) + create_folders (storage, fi); + + if (unref) + gtk_object_unref (GTK_OBJECT (storage)); + } +} + +static void +delete_folders (EvolutionStorage *storage, CamelFolderInfo *fi) +{ + char *path; + + if (fi->child) + delete_folders (storage, fi->child); + + path = g_strdup_printf ("/%s", fi->full_name); + evolution_storage_removed_folder (storage, path); + g_free (path); + + if (fi->sibling) + delete_folders (storage, fi->sibling); +} + +void +folder_deleted (CamelStore *store, CamelFolderInfo *fi) +{ + EvolutionStorage *storage; + + if ((storage = mail_lookup_storage (store))) { + if (fi) + delete_folders (storage, fi); + + gtk_object_unref (GTK_OBJECT (storage)); + } +} diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h index d6e94b4c2b..e888d47899 100644 --- a/mail/mail-callbacks.h +++ b/mail/mail-callbacks.h @@ -27,6 +27,7 @@ #include <camel/camel.h> #include "composer/e-msg-composer.h" #include "mail-types.h" +#include "evolution-storage.h" #ifdef __cplusplus extern "C" { @@ -85,6 +86,13 @@ void forward_messages (CamelFolder *folder, GPtrArray *uids, gboolean inline) void mail_print_preview_msg (MailDisplay *md); void mail_print_msg (MailDisplay *md); + +/* CamelStore callbacks */ +void folder_created (CamelStore *store, CamelFolderInfo *fi); +void folder_deleted (CamelStore *store, CamelFolderInfo *fi); + +void mail_storage_create_folder (EvolutionStorage *storage, CamelStore *store, CamelFolderInfo *fi); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/mail/mail-ops.c b/mail/mail-ops.c index c6eadddeb0..cb17b8b31a 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -1029,33 +1029,14 @@ int mail_get_folderinfo(CamelStore *store, void (*done)(CamelStore *store, Camel /* ********************************************************************** */ -static void do_add_subfolders(CamelStore *store, CamelFolderInfo *info, EvolutionStorage *storage, const char *prefix) -{ - char *path, *name; - - path = g_strdup_printf("%s/%s", prefix, info->name); - if (info->unread_message_count > 0) - name = g_strdup_printf("%s (%d)", info->name, info->unread_message_count); - else - name = g_strdup(info->name); - - evolution_storage_new_folder(storage, path, name, "mail", info->url?info->url:"", - _("(No description)"), info->unread_message_count > 0); - g_free(name); - if (info->child) - do_add_subfolders(store, info->child, storage, path); - if (info->sibling) - do_add_subfolders(store, info->sibling, storage, prefix); - g_free(path); -} - -static void do_scan_subfolders(CamelStore *store, CamelFolderInfo *info, void *data) +static void +do_scan_subfolders (CamelStore *store, CamelFolderInfo *info, void *data) { EvolutionStorage *storage = data; if (info) { gtk_object_set_data((GtkObject *)storage, "connected", (void *)1); - do_add_subfolders(store, info, storage, ""); + mail_storage_create_folder (storage, store, info); } } diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c index 5c8ee04180..354fc0e780 100644 --- a/mail/subscribe-dialog.c +++ b/mail/subscribe-dialog.c @@ -356,7 +356,7 @@ recursive_add_folder (EvolutionStorage *storage, const char *path, } evolution_storage_new_folder (storage, path, name, "mail", url, - _("(No description)"), FALSE); + name, FALSE); } static void |