diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-12-08 00:05:26 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-12-08 00:05:26 +0800 |
commit | 63b393f318dd89330466e48f15396ae44f2cd7ea (patch) | |
tree | 66da11236b449913529065767669d8151cc85c9c /mail | |
parent | 194ab4aebcca2958d1d9f794086fa997310a6c07 (diff) | |
download | gsoc2013-evolution-63b393f318dd89330466e48f15396ae44f2cd7ea.tar.gz gsoc2013-evolution-63b393f318dd89330466e48f15396ae44f2cd7ea.tar.zst gsoc2013-evolution-63b393f318dd89330466e48f15396ae44f2cd7ea.zip |
Remove 'vfolder_store' global variable.
Fetch the CamelService by its UID ("vfolder") as needed.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/mail-vfolder.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 80d6f1ec0c..e30fd0a328 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -52,10 +52,11 @@ #include "e-mail-local.h" #include "e-mail-store.h" +#define VFOLDER_SERVICE_UID "vfolder" + #define d(x) /* (printf("%s:%s: ", G_STRLOC, G_STRFUNC), (x))*/ static EMVFolderContext *context; /* context remains open all time */ -CamelStore *vfolder_store; /* the 1 static vfolder store */ /* lock for accessing shared resources (below) */ G_LOCK_DEFINE_STATIC (vfolder); @@ -778,6 +779,7 @@ rule_changed (EFilterRule *rule, { EMailBackend *backend; EMailSession *session; + CamelService *service; GList *sources_uri = NULL, *sources_folder = NULL; GString *query; const gchar *full_name; @@ -786,6 +788,10 @@ rule_changed (EFilterRule *rule, backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule)); session = e_mail_backend_get_session (backend); + service = camel_session_get_service ( + CAMEL_SESSION (session), VFOLDER_SERVICE_UID); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + /* if the folder has changed name, then add it, then remove the old manually */ if (strcmp (full_name, rule->name) != 0) { gchar *oldname; @@ -808,7 +814,8 @@ rule_changed (EFilterRule *rule, oldname = g_strdup (full_name); /* FIXME Not passing a GCancellable or GError. */ camel_store_rename_folder_sync ( - vfolder_store, oldname, rule->name, NULL, NULL); + CAMEL_STORE (service), + oldname, rule->name, NULL, NULL); g_free (oldname); } @@ -848,14 +855,24 @@ static void context_rule_added (ERuleContext *ctx, EFilterRule *rule) { + EMailBackend *backend; + EMailSession *session; CamelFolder *folder; + CamelService *service; d(printf("rule added: %s\n", rule->name)); + backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule)); + session = e_mail_backend_get_session (backend); + + service = camel_session_get_service ( + CAMEL_SESSION (session), VFOLDER_SERVICE_UID); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + /* this always runs quickly */ /* FIXME Not passing a GCancellable or GError. */ folder = camel_store_get_folder_sync ( - vfolder_store, rule->name, 0, NULL, NULL); + CAMEL_STORE (service), rule->name, 0, NULL, NULL); if (folder) { g_signal_connect (rule, "changed", G_CALLBACK(rule_changed), folder); @@ -871,10 +888,20 @@ static void context_rule_removed (ERuleContext *ctx, EFilterRule *rule) { + EMailBackend *backend; + EMailSession *session; + CamelService *service; gpointer key, folder = NULL; d(printf("rule removed; %s\n", rule->name)); + backend = em_vfolder_rule_get_backend (EM_VFOLDER_RULE (rule)); + session = e_mail_backend_get_session (backend); + + service = camel_session_get_service ( + CAMEL_SESSION (session), VFOLDER_SERVICE_UID); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + /* TODO: remove from folder info cache? */ G_LOCK (vfolder); @@ -886,7 +913,7 @@ context_rule_removed (ERuleContext *ctx, /* FIXME Not passing a GCancellable or GError. */ camel_store_delete_folder_sync ( - vfolder_store, rule->name, NULL, NULL); + CAMEL_STORE (service), rule->name, NULL, NULL); /* this must be unref'd after its deleted */ if (folder) g_object_unref ((CamelFolder *) folder); @@ -1068,8 +1095,6 @@ vfolder_load_storage (EMailBackend *backend) g_return_if_fail (CAMEL_IS_STORE (service)); - vfolder_store = CAMEL_STORE (service); - g_signal_connect ( service, "folder-deleted", G_CALLBACK (store_folder_deleted_cb), backend); @@ -1098,7 +1123,7 @@ vfolder_load_storage (EMailBackend *backend) G_CALLBACK (context_rule_removed), context); /* load store to mail component */ - e_mail_store_add (session, vfolder_store); + e_mail_store_add (session, CAMEL_STORE (service)); /* and setup the rules we have */ rule = NULL; @@ -1432,11 +1457,6 @@ mail_vfolder_shutdown (void) vfolder_hash = NULL; } - if (vfolder_store) { - g_object_unref (vfolder_store); - vfolder_store = NULL; - } - if (context) { g_object_unref (context); context = NULL; |