aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-08-18 09:21:22 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-08-18 10:27:46 +0800
commitdd57574c0427b4571c1daac42b6ffa636a8c80c1 (patch)
treecfd6429d8c551ac48405f304326320a99eef3dfa
parentf20ec31e2069d4278cc7d5d4a96a334c9bbccb40 (diff)
downloadgsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar.gz
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar.bz2
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar.lz
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar.xz
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.tar.zst
gsoc2013-evolution-dd57574c0427b4571c1daac42b6ffa636a8c80c1.zip
Use new CamelService:display-name property.
Simplify, simplify...
-rw-r--r--mail/e-mail-backend.c12
-rw-r--r--mail/e-mail-local.c2
-rw-r--r--mail/e-mail-session.c10
-rw-r--r--mail/e-mail-store.c47
-rw-r--r--mail/e-mail-store.h5
-rw-r--r--mail/em-composer-utils.c14
-rw-r--r--mail/em-folder-selection-button.c3
-rw-r--r--mail/em-folder-tree-model.c14
-rw-r--r--mail/em-folder-tree-model.h3
-rw-r--r--mail/em-subscription-editor.c14
-rw-r--r--mail/mail-vfolder.c19
-rw-r--r--mail/message-list.c14
-rw-r--r--modules/mail/e-mail-shell-backend.c3
-rw-r--r--modules/mail/e-mail-shell-view-actions.c3
-rw-r--r--plugins/mail-notification/mail-notification.c15
15 files changed, 71 insertions, 107 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 17007f2c72..479b92ed59 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -107,7 +107,6 @@ mail_backend_store_operation_done_cb (CamelStore *store,
/* Helper for mail_backend_prepare_for_offline_cb() */
static void
mail_store_prepare_for_offline_cb (CamelService *service,
- gpointer unused,
EActivity *activity)
{
/* FIXME Not passing a GCancellable. */
@@ -141,13 +140,12 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
}
e_mail_store_foreach (
- (GHFunc) mail_store_prepare_for_offline_cb, activity);
+ (GFunc) mail_store_prepare_for_offline_cb, activity);
}
/* Helper for mail_backend_prepare_for_online_cb() */
static void
mail_store_prepare_for_online_cb (CamelService *service,
- gpointer unused,
EActivity *activity)
{
/* FIXME Not passing a GCancellable. */
@@ -168,13 +166,12 @@ mail_backend_prepare_for_online_cb (EShell *shell,
camel_session_set_online (CAMEL_SESSION (session), TRUE);
e_mail_store_foreach (
- (GHFunc) mail_store_prepare_for_online_cb, activity);
+ (GFunc) mail_store_prepare_for_online_cb, activity);
}
/* Helper for mail_backend_prepare_for_quit_cb() */
static void
mail_backend_delete_junk (CamelStore *store,
- gpointer unused,
EMailBackend *backend)
{
CamelFolder *folder;
@@ -206,7 +203,6 @@ mail_backend_delete_junk (CamelStore *store,
/* Helper for mail_backend_prepare_for_quit_cb() */
static void
mail_backend_final_sync (CamelStore *store,
- gpointer unused,
gpointer user_data)
{
struct {
@@ -268,12 +264,12 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
if (delete_junk)
e_mail_store_foreach (
- (GHFunc) mail_backend_delete_junk, backend);
+ (GFunc) mail_backend_delete_junk, backend);
sync_data.activity = activity;
sync_data.empty_trash = empty_trash;
- e_mail_store_foreach ((GHFunc) mail_backend_final_sync, &sync_data);
+ e_mail_store_foreach ((GFunc) mail_backend_final_sync, &sync_data);
/* Now we poll until all activities are actually cancelled or finished.
* Reffing the activity delays quitting; the reference count
diff --git a/mail/e-mail-local.c b/mail/e-mail-local.c
index 183635a30b..1f33c08ab8 100644
--- a/mail/e-mail-local.c
+++ b/mail/e-mail-local.c
@@ -78,6 +78,8 @@ e_mail_local_init (EMailSession *session,
CAMEL_PROVIDER_STORE, &error);
g_free (temp);
+ camel_service_set_display_name (service, _("On This Computer"));
+
/* Shouldn't need to worry about other mail applications
* altering files in our local mail store. */
g_object_set (service, "need-summary-check", FALSE, NULL);
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index 6c96eca4be..ffcbb57e58 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -819,10 +819,12 @@ mail_session_get_password (CamelSession *session,
GError **error)
{
EAccount *account = NULL;
+ const gchar *display_name = NULL;
const gchar *uid = NULL;
gchar *ret = NULL;
if (CAMEL_IS_SERVICE (service)) {
+ display_name = camel_service_get_display_name (service);
uid = camel_service_get_uid (service);
account = e_get_account_by_uid (uid);
}
@@ -856,18 +858,18 @@ mail_session_get_password (CamelSession *session,
gchar *title;
if (flags & CAMEL_SESSION_PASSPHRASE) {
- if (account)
+ if (display_name != NULL)
title = g_strdup_printf (
_("Enter Passphrase for %s"),
- account->name);
+ display_name);
else
title = g_strdup (
_("Enter Passphrase"));
} else {
- if (account)
+ if (display_name != NULL)
title = g_strdup_printf (
_("Enter Password for %s"),
- account->name);
+ display_name);
else
title = g_strdup (
_("Enter Password"));
diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c
index 948683d5e4..f9d18456b4 100644
--- a/mail/e-mail-store.c
+++ b/mail/e-mail-store.c
@@ -50,7 +50,6 @@ struct _StoreInfo {
gint ref_count;
CamelStore *store;
- gchar *display_name;
/* Hold a reference to keep them alive. */
CamelFolder *vtrash;
@@ -65,27 +64,17 @@ CamelStore *vfolder_store; /* XXX write a get () function for this */
static GHashTable *store_table;
static StoreInfo *
-store_info_new (CamelStore *store,
- const gchar *display_name)
+store_info_new (CamelStore *store)
{
- CamelService *service;
StoreInfo *store_info;
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
- service = CAMEL_SERVICE (store);
-
store_info = g_slice_new0 (StoreInfo);
store_info->ref_count = 1;
store_info->store = g_object_ref (store);
- if (display_name == NULL)
- store_info->display_name =
- camel_service_get_name (service, TRUE);
- else
- store_info->display_name = g_strdup (display_name);
-
/* If these are vfolders then they need to be opened now,
* otherwise they won't keep track of all folders. */
if (store->flags & CAMEL_STORE_VTRASH)
@@ -118,7 +107,6 @@ store_info_unref (StoreInfo *store_info)
if (g_atomic_int_dec_and_test (&store_info->ref_count)) {
g_object_unref (store_info->store);
- g_free (store_info->display_name);
if (store_info->vtrash != NULL)
g_object_unref (store_info->vtrash);
@@ -167,7 +155,6 @@ mail_store_note_store_cb (MailFolderCache *folder_cache,
static void
mail_store_add (EMailSession *session,
CamelStore *store,
- const gchar *display_name,
AddStoreCallback callback)
{
EMFolderTreeModel *default_model;
@@ -187,13 +174,12 @@ mail_store_add (EMailSession *session,
default_model = em_folder_tree_model_get_default ();
folder_cache = e_mail_session_get_folder_cache (session);
- store_info = store_info_new (store, display_name);
+ store_info = store_info_new (store);
store_info->callback = callback;
g_hash_table_insert (store_table, store, store_info);
- em_folder_tree_model_add_store (
- default_model, store, store_info->display_name);
+ em_folder_tree_model_add_store (default_model, store);
mail_folder_cache_note_store (
folder_cache, CAMEL_SESSION (session), store, NULL,
@@ -231,8 +217,8 @@ mail_store_load_accounts (EMailSession *session,
local_store = e_mail_local_get_store ();
mail_store_add (
- session, local_store, _("On This Computer"),
- (AddStoreCallback) mail_store_add_local_done_cb);
+ session, local_store, (AddStoreCallback)
+ mail_store_add_local_done_cb);
/* Set up remote stores. */
@@ -280,14 +266,12 @@ e_mail_store_init (EMailSession *session,
void
e_mail_store_add (EMailSession *session,
- CamelStore *store,
- const gchar *display_name)
+ CamelStore *store)
{
g_return_if_fail (E_IS_MAIL_SESSION (session));
g_return_if_fail (CAMEL_IS_STORE (store));
- g_return_if_fail (display_name != NULL);
- mail_store_add (session, store, display_name, NULL);
+ mail_store_add (session, store, NULL);
}
CamelStore *
@@ -319,6 +303,8 @@ e_mail_store_add_by_account (EMailSession *session,
account->uid, account->source->url,
CAMEL_PROVIDER_STORE, &error);
+ camel_service_set_display_name (service, account->name);
+
handle_transport:
if (account->transport) {
@@ -358,8 +344,7 @@ handle_transport:
}
if (!skip && (provider->flags & CAMEL_PROVIDER_IS_STORAGE))
- e_mail_store_add (
- session, CAMEL_STORE (service), account->name);
+ e_mail_store_add (session, CAMEL_STORE (service));
return CAMEL_STORE (service);
@@ -434,11 +419,11 @@ e_mail_store_remove_by_account (EMailSession *session,
}
void
-e_mail_store_foreach (GHFunc func,
+e_mail_store_foreach (GFunc func,
gpointer user_data)
{
GHashTableIter iter;
- gpointer key, value;
+ gpointer store;
g_return_if_fail (func != NULL);
@@ -448,13 +433,11 @@ e_mail_store_foreach (GHFunc func,
g_hash_table_iter_init (&iter, store_table);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- StoreInfo *store_info = value;
+ while (g_hash_table_iter_next (&iter, &store, NULL)) {
/* Just being paranoid. */
- g_return_if_fail (CAMEL_IS_STORE (key));
- g_return_if_fail (store_info != NULL);
+ g_return_if_fail (CAMEL_IS_STORE (store));
- func (key, store_info->display_name, user_data);
+ func (store, user_data);
}
}
diff --git a/mail/e-mail-store.h b/mail/e-mail-store.h
index 76a6ee5701..b26b4c15ad 100644
--- a/mail/e-mail-store.h
+++ b/mail/e-mail-store.h
@@ -31,15 +31,14 @@ G_BEGIN_DECLS
void e_mail_store_init (EMailSession *session,
const gchar *data_dir);
void e_mail_store_add (EMailSession *session,
- CamelStore *store,
- const gchar *display_name);
+ CamelStore *store);
CamelStore * e_mail_store_add_by_account (EMailSession *session,
EAccount *account);
void e_mail_store_remove (EMailSession *session,
CamelStore *store);
void e_mail_store_remove_by_account (EMailSession *session,
EAccount *account);
-void e_mail_store_foreach (GHFunc func,
+void e_mail_store_foreach (GFunc func,
gpointer user_data);
G_END_DECLS
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 161eb5b613..afbf81ccfa 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -992,7 +992,7 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
{
EMsgComposer *composer;
EComposerHeaderTable *table;
- EAccount *account = NULL;
+ CamelService *service = NULL;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -1008,15 +1008,17 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
if (folder != NULL) {
CamelStore *store;
- const gchar *uid;
store = camel_folder_get_parent_store (folder);
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
+ service = CAMEL_SERVICE (store);
}
- if (account != NULL)
- e_composer_header_table_set_account_name (table, account->name);
+ if (service != NULL) {
+ const gchar *display_name;
+
+ display_name = camel_service_get_display_name (service);
+ e_composer_header_table_set_account_name (table, display_name);
+ }
composer_set_no_change (composer);
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index 0b43812e82..e675fc0eee 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -282,8 +282,7 @@ folder_selection_button_clicked (GtkButton *button)
model = em_folder_tree_model_new ();
em_folder_tree_model_set_session (model, session);
em_folder_tree_model_add_store (
- model, CAMEL_STORE (service),
- priv->account->name);
+ model, CAMEL_STORE (service));
}
}
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index f9ed371430..295d9d0865 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -228,8 +228,7 @@ account_changed_cb (EAccountList *accounts,
em_utils_is_local_delivery_mbox_file (camel_service_get_camel_url (service)))
return;
- em_folder_tree_model_add_store (
- model, CAMEL_STORE (service), account->name);
+ em_folder_tree_model_add_store (model, CAMEL_STORE (service));
}
static void
@@ -1005,20 +1004,20 @@ folder_renamed_cb (CamelStore *store,
void
em_folder_tree_model_add_store (EMFolderTreeModel *model,
- CamelStore *store,
- const gchar *display_name)
+ CamelStore *store)
{
EMFolderTreeModelStoreInfo *si;
GtkTreeRowReference *reference;
GtkTreeStore *tree_store;
GtkTreeIter root, iter;
GtkTreePath *path;
+ CamelService *service;
CamelURL *service_url;
+ const gchar *display_name;
gchar *uri;
g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
g_return_if_fail (CAMEL_IS_STORE (store));
- g_return_if_fail (display_name != NULL);
tree_store = GTK_TREE_STORE (model);
@@ -1026,7 +1025,10 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model,
if (si != NULL)
em_folder_tree_model_remove_store (model, store);
- service_url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ service_url = camel_service_get_camel_url (service);
+ display_name = camel_service_get_display_name (service);
+
uri = camel_url_to_string (service_url, CAMEL_URL_HIDE_ALL);
/* Add the store to the tree. */
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index 40c2afc741..66984fc904 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -132,8 +132,7 @@ void em_folder_tree_model_set_folder_info
gint fully_loaded);
void em_folder_tree_model_add_store
(EMFolderTreeModel *model,
- CamelStore *store,
- const gchar *display_name);
+ CamelStore *store);
void em_folder_tree_model_remove_store
(EMFolderTreeModel *model,
CamelStore *store);
diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c
index 6c24e841c3..e484b5a121 100644
--- a/mail/em-subscription-editor.c
+++ b/mail/em-subscription-editor.c
@@ -805,7 +805,7 @@ subscription_editor_add_store (EMSubscriptionEditor *editor,
CamelStore *store)
{
StoreData *data;
- EAccount *account;
+ CamelService *service;
GtkListStore *list_store;
GtkTreeStore *tree_store;
GtkTreeViewColumn *column;
@@ -814,17 +814,13 @@ subscription_editor_add_store (EMSubscriptionEditor *editor,
GtkComboBoxText *combo_box;
GtkWidget *container;
GtkWidget *widget;
- const gchar *uid;
+ const gchar *display_name;
- /* Neither of the built-in stores ("local" or "vfolder") support
- * folder subscriptions. Therefore there should be a corresponding
- * EAccount for the store from which we can grab a display name. */
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
- g_return_if_fail (account != NULL);
+ service = CAMEL_SERVICE (store);
+ display_name = camel_service_get_display_name (service);
combo_box = GTK_COMBO_BOX_TEXT (editor->priv->combo_box);
- gtk_combo_box_text_append_text (combo_box, account->name);
+ gtk_combo_box_text_append_text (combo_box, display_name);
tree_store = gtk_tree_store_new (
N_COLUMNS,
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 64b31f3497..a24d9dcb45 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -208,11 +208,10 @@ struct _adduri_msg {
static gchar *
vfolder_adduri_desc (struct _adduri_msg *m)
{
- EAccount *account;
CamelStore *store;
+ CamelService *service;
EMailSession *session;
const gchar *display_name;
- const gchar *uid;
gchar *folder_name;
gchar *description;
gboolean success;
@@ -226,13 +225,8 @@ vfolder_adduri_desc (struct _adduri_msg *m)
if (!success)
return NULL;
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
-
- if (account != NULL)
- display_name = account->name;
- else
- display_name = _("On This Computer");
+ service = CAMEL_SERVICE (store);
+ display_name = camel_service_get_display_name (service);
description = g_strdup_printf (
_("Updating Search Folders for '%s' : %s"),
@@ -1123,9 +1117,10 @@ vfolder_load_storage (EMailBackend *backend)
service = camel_session_add_service (
CAMEL_SESSION (session), "vfolder",
storeuri, CAMEL_PROVIDER_STORE, NULL);
- if (service != NULL)
+ if (service != NULL) {
+ camel_service_set_display_name (service, _("Search Folders"));
em_utils_connect_service_sync (service, NULL, NULL);
- else {
+ } else {
g_warning("Cannot open vfolder store - no vfolders available");
return;
}
@@ -1162,7 +1157,7 @@ vfolder_load_storage (EMailBackend *backend)
G_CALLBACK (context_rule_removed), context);
/* load store to mail component */
- e_mail_store_add (session, vfolder_store, _("Search Folders"));
+ e_mail_store_add (session, vfolder_store);
/* and setup the rules we have */
rule = NULL;
diff --git a/mail/message-list.c b/mail/message-list.c
index 66432a930f..70922b8e05 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1688,12 +1688,11 @@ ml_tree_value_at_ex (ETreeModel *etm,
}
case COL_LOCATION: {
/* Fixme : freeing memory stuff (mem leaks) */
- CamelFolder *folder;
CamelStore *store;
- EAccount *account;
+ CamelFolder *folder;
+ CamelService *service;
const gchar *store_name;
const gchar *folder_name;
- const gchar *uid;
folder = message_list->folder;
@@ -1705,13 +1704,8 @@ ml_tree_value_at_ex (ETreeModel *etm,
store = camel_folder_get_parent_store (folder);
folder_name = camel_folder_get_full_name (folder);
- uid = camel_service_get_uid (CAMEL_SERVICE (store));
- account = e_get_account_by_uid (uid);
-
- if (account != NULL)
- store_name = account->name;
- else
- store_name = _("On This Computer");
+ service = CAMEL_SERVICE (store);
+ store_name = camel_service_get_display_name (service);
return g_strdup_printf ("%s : %s", store_name, folder_name);
}
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index cc75844c2d..76762c308c 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -219,7 +219,6 @@ mail_shell_backend_sync_store_done_cb (CamelStore *store,
static void
mail_shell_backend_sync_store_cb (CamelStore *store,
- const gchar *display_name,
EMailShellBackend *mail_shell_backend)
{
mail_shell_backend->priv->mail_sync_in_progress++;
@@ -248,7 +247,7 @@ mail_shell_backend_mail_sync (EMailShellBackend *mail_shell_backend)
goto exit;
e_mail_store_foreach (
- (GHFunc) mail_shell_backend_sync_store_cb,
+ (GFunc) mail_shell_backend_sync_store_cb,
mail_shell_backend);
exit:
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 53cd908734..3569d1b144 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -197,7 +197,6 @@ action_mail_download_finished_cb (CamelStore *store,
static void
action_mail_download_foreach_cb (CamelStore *store,
- const gchar *display_name,
EMailReader *reader)
{
EActivity *activity;
@@ -226,7 +225,7 @@ action_mail_download_cb (GtkAction *action,
reader = E_MAIL_READER (mail_view);
e_mail_store_foreach (
- (GHFunc) action_mail_download_foreach_cb, reader);
+ (GFunc) action_mail_download_foreach_cb, reader);
}
static void
diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c
index fb2d973dcd..99224eb288 100644
--- a/plugins/mail-notification/mail-notification.c
+++ b/plugins/mail-notification/mail-notification.c
@@ -373,18 +373,15 @@ new_notify_status (EMEventTargetFolder *t)
gchar *text;
if (!status_count) {
- EAccount *account;
+ CamelService *service;
+ const gchar *store_name;
gchar *folder_name;
- const gchar *uid;
- uid = camel_service_get_uid (CAMEL_SERVICE (t->store));
- account = e_get_account_by_uid (uid);
+ service = CAMEL_SERVICE (t->store);
+ store_name = camel_service_get_display_name (service);
- if (account != NULL)
- folder_name = g_strdup_printf (
- "%s/%s", account->name, t->folder_name);
- else
- folder_name = g_strdup (t->folder_name);
+ folder_name = g_strdup_printf (
+ "%s/%s", store_name, t->folder_name);
status_count = t->new;