diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-03 19:06:10 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:05 +0800 |
commit | 59958c9906eade7264d8564e5448c2b1bea2503d (patch) | |
tree | 829c80e512572b65d1b1be82e3531915dde66991 | |
parent | b35467f9a3f759aee84e3f4f5759856ac3f40799 (diff) | |
download | gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar.gz gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar.bz2 gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar.lz gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar.xz gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.tar.zst gsoc2013-evolution-59958c9906eade7264d8564e5448c2b1bea2503d.zip |
Replace camel_store_folder_uri_equal() with e_mail_folder_uri_equal().
-rw-r--r-- | mail/em-folder-tree-model.c | 7 | ||||
-rw-r--r-- | mail/em-utils.c | 82 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 65 |
3 files changed, 87 insertions, 67 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 7a7a5f8716..072f5e448b 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -46,6 +46,7 @@ #include "em-folder-utils.h" #include "em-event.h" +#include "e-mail-folder-utils.h" #include "e-mail-local.h" #include "e-mail-store.h" #include "shell/e-shell.h" @@ -738,13 +739,15 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, if (si->account && (flags & CAMEL_FOLDER_TYPE_MASK) == 0) { if (!is_drafts && si->account->drafts_folder_uri) { gchar *curi = em_uri_to_camel (si->account->drafts_folder_uri); - is_drafts = camel_store_folder_uri_equal (si->store, fi->uri, curi); + is_drafts = e_mail_folder_uri_equal ( + CAMEL_SESSION (session), fi->uri, curi); g_free (curi); } if (si->account->sent_folder_uri) { gchar *curi = em_uri_to_camel (si->account->sent_folder_uri); - if (camel_store_folder_uri_equal (si->store, fi->uri, curi)) { + if (e_mail_folder_uri_equal ( + CAMEL_SESSION (session), fi->uri, curi)) { add_flags = CAMEL_FOLDER_TYPE_SENT; } g_free (curi); diff --git a/mail/em-utils.c b/mail/em-utils.c index 13b55eddae..ecd787c63b 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -70,6 +70,7 @@ #include "em-utils.h" #include "em-composer-utils.h" #include "em-format-quote.h" +#include "e-mail-folder-utils.h" #include "e-mail-local.h" #include "e-mail-session.h" @@ -230,7 +231,7 @@ em_utils_check_user_can_send_mail (void) account_list = e_get_account_list (); - if (e_list_length ((EList *) account_list) == 0) + if (e_list_length (E_LIST (account_list)) == 0) return FALSE; if (!(account = e_get_default_account ())) @@ -1003,11 +1004,12 @@ gboolean em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) { CamelFolder *local_templates_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_templates = FALSE; gchar *templates_uri; local_templates_folder = @@ -1019,21 +1021,20 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_templates && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->templates_folder_uri) { - templates_uri = em_uri_to_camel (account->templates_folder_uri); - if (camel_store_folder_uri_equal (parent_store, templates_uri, uri)) { - g_free (templates_uri); - is = TRUE; - break; - } + templates_uri = em_uri_to_camel ( + account->templates_folder_uri); + is_templates = e_mail_folder_uri_equal ( + session, templates_uri, uri); g_free (templates_uri); } @@ -1042,7 +1043,7 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_templates; } /** @@ -1058,11 +1059,12 @@ gboolean em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) { CamelFolder *local_drafts_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_drafts = FALSE; gchar *drafts_uri; local_drafts_folder = @@ -1074,21 +1076,20 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_drafts && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->drafts_folder_uri) { - drafts_uri = em_uri_to_camel (account->drafts_folder_uri); - if (camel_store_folder_uri_equal (parent_store, drafts_uri, uri)) { - g_free (drafts_uri); - is = TRUE; - break; - } + drafts_uri = em_uri_to_camel ( + account->drafts_folder_uri); + is_drafts = e_mail_folder_uri_equal ( + session, drafts_uri, uri); g_free (drafts_uri); } @@ -1097,7 +1098,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_drafts; } /** @@ -1113,14 +1114,16 @@ gboolean em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) { CamelFolder *local_sent_folder; - CamelStore *parent_store; + CamelSession *session; + CamelStore *store; EAccountList *account_list; EAccount *account; EIterator *iterator; - gint is = FALSE; + gint is_sent = FALSE; gchar *sent_uri; - local_sent_folder = e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); + local_sent_folder = + e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_SENT); if (folder == local_sent_folder) return TRUE; @@ -1128,21 +1131,20 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) if (folder == NULL || uri == NULL) return FALSE; - parent_store = camel_folder_get_parent_store (folder); + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); account_list = e_get_account_list (); iterator = e_list_get_iterator (E_LIST (account_list)); - while (e_iterator_is_valid (iterator)) { + while (!is_sent && e_iterator_is_valid (iterator)) { account = (EAccount *)e_iterator_get (iterator); if (account->sent_folder_uri) { - sent_uri = em_uri_to_camel (account->sent_folder_uri); - if (camel_store_folder_uri_equal (parent_store, sent_uri, uri)) { - g_free (sent_uri); - is = TRUE; - break; - } + sent_uri = em_uri_to_camel ( + account->sent_folder_uri); + is_sent = e_mail_folder_uri_equal ( + session, sent_uri, uri); g_free (sent_uri); } @@ -1151,7 +1153,7 @@ em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri) g_object_unref (iterator); - return is; + return is_sent; } /** @@ -1167,6 +1169,8 @@ gboolean em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri) { CamelFolder *local_outbox_folder; + CamelSession *session; + CamelStore *store; const gchar *local_outbox_folder_uri; local_outbox_folder = @@ -1180,9 +1184,11 @@ em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri) if (uri == NULL) return FALSE; - return camel_store_folder_uri_equal ( - camel_folder_get_parent_store (local_outbox_folder), - local_outbox_folder_uri, uri); + store = camel_folder_get_parent_store (local_outbox_folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + return e_mail_folder_uri_equal ( + session, local_outbox_folder_uri, uri); } /* ********************************************************************** */ diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index aa13589ab2..0f98528d16 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -35,6 +35,7 @@ #include "e-mail-backend.h" #include "e-mail-session.h" +#include "e-mail-folder-utils.h" #include "em-folder-tree-model.h" #include "em-utils.h" #include "em-vfolder-context.h" @@ -333,10 +334,12 @@ vfolder_adduri (EMailSession *session, /* ********************************************************************** */ static GList * -mv_find_folder (GList *l, CamelStore *store, const gchar *uri) +mv_find_folder (GList *l, EMailSession *session, const gchar *uri) { + CamelSession *camel_session = CAMEL_SESSION (session); + while (l) { - if (camel_store_folder_uri_equal (store, l->data, uri)) + if (e_mail_folder_uri_equal (camel_session, l->data, uri)) break; l = l->next; } @@ -345,11 +348,12 @@ mv_find_folder (GList *l, CamelStore *store, const gchar *uri) /* uri is a camel uri */ static gint -uri_is_ignore (CamelStore *store, const gchar *uri) +uri_is_ignore (EMailSession *session, const gchar *uri) { EAccountList *accounts; EAccount *account; EIterator *iter; + CamelSession *camel_session; const gchar *local_drafts_uri; const gchar *local_outbox_uri; const gchar *local_sent_uri; @@ -359,17 +363,16 @@ uri_is_ignore (CamelStore *store, const gchar *uri) local_outbox_uri = e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_OUTBOX); local_sent_uri = e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_SENT); - d(printf("checking '%s' against:\n %s\n %s\n %s\n", uri, - local_outbox_uri, - local_sent_uri, - local_drafts_uri)); + camel_session = CAMEL_SESSION (session); - found = camel_store_folder_uri_equal (store, local_outbox_uri, uri) - || camel_store_folder_uri_equal (store, local_sent_uri, uri) - || camel_store_folder_uri_equal (store, local_drafts_uri, uri); + if (e_mail_folder_uri_equal (camel_session, local_outbox_uri, uri)) + return TRUE; - if (found) - return found; + if (e_mail_folder_uri_equal (camel_session, local_sent_uri, uri)) + return TRUE; + + if (e_mail_folder_uri_equal (camel_session, local_drafts_uri, uri)) + return TRUE; accounts = e_get_account_list (); iter = e_list_get_iterator ((EList *) accounts); @@ -381,14 +384,16 @@ uri_is_ignore (CamelStore *store, const gchar *uri) d(printf("checking sent_folder_uri '%s' == '%s'\n", account->sent_folder_uri ? account->sent_folder_uri : "empty", uri)); - if (account->sent_folder_uri) { + if (account->sent_folder_uri != NULL) { curi = em_uri_to_camel (account->sent_folder_uri); - found = camel_store_folder_uri_equal (store, uri, curi); + found = e_mail_folder_uri_equal ( + camel_session, uri, curi); g_free (curi); } - if (!found && account->drafts_folder_uri) { + if (!found && account->drafts_folder_uri != NULL) { curi = em_uri_to_camel (account->drafts_folder_uri); - found = camel_store_folder_uri_equal (store, uri, curi); + found = e_mail_folder_uri_equal ( + camel_session, uri, curi); g_free (curi); } @@ -481,7 +486,7 @@ mail_vfolder_add_uri (EMailSession *session, g_return_if_fail (mail_in_main_thread ()); - is_ignore = uri_is_ignore (store, curi); + is_ignore = uri_is_ignore (session, curi); G_LOCK (vfolder); @@ -492,12 +497,12 @@ mail_vfolder_add_uri (EMailSession *session, is_ignore = TRUE; } else if (remove) { if (remote) { - if ((link = mv_find_folder (source_folders_remote, store, curi)) != NULL) { + if ((link = mv_find_folder (source_folders_remote, session, curi)) != NULL) { g_free (link->data); source_folders_remote = g_list_remove_link (source_folders_remote, link); } } else { - if ((link = mv_find_folder (source_folders_local, store, curi)) != NULL) { + if ((link = mv_find_folder (source_folders_local, session, curi)) != NULL) { g_free (link->data); source_folders_local = g_list_remove_link (source_folders_local, link); } @@ -505,10 +510,10 @@ mail_vfolder_add_uri (EMailSession *session, } else if (!is_ignore) { /* we ignore drafts/sent/outbox here */ if (remote) { - if (mv_find_folder (source_folders_remote, store, curi) == NULL) + if (mv_find_folder (source_folders_remote, session, curi) == NULL) source_folders_remote = g_list_prepend (source_folders_remote, g_strdup (curi)); } else { - if (mv_find_folder (source_folders_local, store, curi) == NULL) + if (mv_find_folder (source_folders_local, session, curi) == NULL) source_folders_local = g_list_prepend (source_folders_local, g_strdup (curi)); } } @@ -538,8 +543,8 @@ mail_vfolder_add_uri (EMailSession *session, (EMVFolderRule *)rule, source))) { gchar *csource; csource = em_uri_to_camel (source); - found = camel_store_folder_uri_equal (store, curi, csource); - d(printf(found?" '%s' == '%s'?\n":" '%s' != '%s'\n", curi, csource)); + found = e_mail_folder_uri_equal ( + CAMEL_SESSION (session), curi, csource); g_free (csource); } @@ -622,6 +627,7 @@ mail_vfolder_delete_uri (EMailBackend *backend, const gchar *curi) { EFilterRule *rule; + EMailSession *session; const gchar *source; CamelVeeFolder *vf; GString *changed; @@ -642,6 +648,8 @@ mail_vfolder_delete_uri (EMailBackend *backend, g_return_if_fail (mail_in_main_thread ()); + session = e_mail_backend_get_session (backend); + changed_count = 0; changed = g_string_new (""); @@ -665,7 +673,7 @@ mail_vfolder_delete_uri (EMailBackend *backend, /* Remove all sources that match, ignore changed events though because the adduri call above does the work async */ - if (camel_store_folder_uri_equal (store, curi, csource)) { + if (e_mail_folder_uri_equal (CAMEL_SESSION (session), curi, csource)) { vf = g_hash_table_lookup (vfolder_hash, rule->name); if (!vf) { g_warning ("vf is NULL for %s\n", rule->name); @@ -694,12 +702,12 @@ mail_vfolder_delete_uri (EMailBackend *backend, } done: - if ((link = mv_find_folder (source_folders_remote, store, curi)) != NULL) { + if ((link = mv_find_folder (source_folders_remote, session, curi)) != NULL) { g_free (link->data); source_folders_remote = g_list_remove_link (source_folders_remote, link); } - if ((link = mv_find_folder (source_folders_local, store, curi)) != NULL) { + if ((link = mv_find_folder (source_folders_local, session, curi)) != NULL) { g_free (link->data); source_folders_local = g_list_remove_link (source_folders_local, link); } @@ -743,6 +751,7 @@ mail_vfolder_rename_uri (CamelStore *store, const gchar *cfrom, const gchar *cto EFilterRule *rule; const gchar *source; CamelVeeFolder *vf; + CamelSession *session; gint changed = 0; gchar *from, *to; @@ -753,6 +762,8 @@ mail_vfolder_rename_uri (CamelStore *store, const gchar *cfrom, const gchar *cto g_return_if_fail (mail_in_main_thread ()); + session = camel_service_get_session (CAMEL_SERVICE (store)); + from = em_uri_from_camel (cfrom); to = em_uri_from_camel (cto); @@ -767,7 +778,7 @@ mail_vfolder_rename_uri (CamelStore *store, const gchar *cfrom, const gchar *cto /* Remove all sources that match, ignore changed events though because the adduri call above does the work async */ - if (camel_store_folder_uri_equal (store, cfrom, csource)) { + if (e_mail_folder_uri_equal (session, cfrom, csource)) { vf = g_hash_table_lookup (vfolder_hash, rule->name); if (!vf) { g_warning ("vf is NULL for %s\n", rule->name); |