aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-features
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-07 11:38:52 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-13 01:58:59 +0800
commita06e4484b8df804124b5bcf88d94dec5acfba270 (patch)
tree4fa42793d7dc461f2b3767296d76592182c48222 /plugins/groupwise-features
parent5e0758bb6934a7859b1d8a247c8fb21c156772cf (diff)
downloadgsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.gz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.bz2
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.lz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.xz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.zst
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.zip
Give MailSession a permanent home.
Global variables in shared libraries are a bad idea. EMailBackend now owns the MailSession instance, which is actually now EMailSession. Move the blocking utility functions in mail-tools.c to e-mail-session.c and add asynchronous variants. Same approach as Camel. Replace EMailReader.get_shell_backend() with EMailReader.get_backend(), which returns an EMailBackend. Easier access to the EMailSession.
Diffstat (limited to 'plugins/groupwise-features')
-rw-r--r--plugins/groupwise-features/install-shared.c10
-rw-r--r--plugins/groupwise-features/proxy-login.c19
-rw-r--r--plugins/groupwise-features/proxy.c13
-rw-r--r--plugins/groupwise-features/share-folder-common.c22
4 files changed, 52 insertions, 12 deletions
diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c
index 92d5ae6aab..b216d49085 100644
--- a/plugins/groupwise-features/install-shared.c
+++ b/plugins/groupwise-features/install-shared.c
@@ -31,6 +31,7 @@
#include <gconf/gconf-client.h>
#include <e-util/e-config.h>
#include <shell/e-shell.h>
+#include <mail/e-mail-backend.h>
#include <mail/em-config.h>
#include <mail/em-event.h>
#include <mail/em-folder-tree.h>
@@ -155,17 +156,24 @@ accept_free (gpointer data)
static void
apply_clicked (GtkAssistant *assistant, CamelMimeMessage *msg)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EMailSession *session;
EMFolderTree *folder_tree;
GtkWidget *dialog;
struct AcceptData *accept_data;
gchar *uri;
gpointer parent;
+ shell = e_shell_get_default ();
+ shell_backend = e_shell_get_backend_by_name (shell, "mail");
+ session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
parent = gtk_widget_get_toplevel (GTK_WIDGET (assistant));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
accept_data = g_new0 (struct AcceptData, 1);
- folder_tree = (EMFolderTree *) em_folder_tree_new ();
+ folder_tree = (EMFolderTree *) em_folder_tree_new (session);
dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
uri = em_folder_tree_get_selected_uri (folder_tree);
diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c
index 12d095bb31..74b67f0ef5 100644
--- a/plugins/groupwise-features/proxy-login.c
+++ b/plugins/groupwise-features/proxy-login.c
@@ -30,6 +30,7 @@
#include <libedataserverui/e-passwords.h>
#include <mail/em-folder-tree.h>
+#include <mail/e-mail-backend.h>
#include <mail/e-mail-store.h>
#include <mail/mail-config.h>
#include <mail/em-folder-selector.h>
@@ -307,6 +308,9 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent)
EAccountList *accounts = e_get_account_list ();
EAccount *srcAccount;
EAccount *dstAccount;
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EMailSession *session;
EGwConnection *proxy_cnc, *cnc;
CamelURL *uri = NULL, *parent = NULL;
gchar *password = NULL, *user_name = NULL;
@@ -315,6 +319,10 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent)
gint i;
gint permissions = 0;
+ shell = e_shell_get_default ();
+ shell_backend = e_shell_get_backend_by_name (shell, "mail");
+ session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
for (i=0; email[i]!='\0' && email[i]!='@' ; i++);
if (email[i]=='@')
name = g_strndup (email, i);
@@ -360,7 +368,7 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent)
e_account_list_change (accounts, srcAccount);
e_account_list_save (accounts);
g_object_set_data ((GObject *)dstAccount, "permissions", GINT_TO_POINTER(permissions));
- mail_get_store (e_account_get_string (dstAccount, E_ACCOUNT_SOURCE_URL), NULL, proxy_login_add_new_store, dstAccount);
+ mail_get_store (session, e_account_get_string (dstAccount, E_ACCOUNT_SOURCE_URL), NULL, proxy_login_add_new_store, dstAccount);
g_free (proxy_source_url);
g_free (parent_source_url);
@@ -381,9 +389,16 @@ proxy_soap_login (gchar *email, GtkWindow *error_parent)
static void
proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data)
{
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EMailSession *session;
EAccount *account = user_data;
gint permissions = GPOINTER_TO_INT(g_object_get_data ((GObject *)account, "permissions"));
+ shell = e_shell_get_default ();
+ shell_backend = e_shell_get_backend_by_name (shell, "mail");
+ session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
if (store == NULL)
return;
@@ -391,7 +406,7 @@ proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data)
store->mode &= !CAMEL_STORE_WRITE;
store->flags |= CAMEL_STORE_PROXY;
- e_mail_store_add (store, account->name);
+ e_mail_store_add (session, store, account->name);
}
static void
diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c
index beb1c94b30..3d350232db 100644
--- a/plugins/groupwise-features/proxy.c
+++ b/plugins/groupwise-features/proxy.c
@@ -40,7 +40,8 @@
#include <mail/em-account-editor.h>
#include <mail/em-config.h>
#include <mail/mail-ops.h>
-#include <mail/mail-session.h>
+#include <mail/e-mail-backend.h>
+#include <shell/e-shell.h>
#include <libedataserver/e-account.h>
#include <libedataserver/e-account-list.h>
#include <e-util/e-icon-factory.h>
@@ -637,6 +638,9 @@ GtkWidget*
org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
+ EShell *shell;
+ EShellBackend *shell_backend;
+ EMailSession *session;
EAccount *account;
GtkButton *addProxy, *removeProxy, *editProxy;
proxyDialog *prd;
@@ -644,13 +648,18 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data)
CamelOfflineStore *store;
gint pag_num;
+ shell = e_shell_get_default ();
+ shell_backend = e_shell_get_backend_by_name (shell, "mail");
+ session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
target_account = (EMConfigTargetAccount *)data->config->target;
account = target_account->account;
/* We are using some g_object_set on this. We shuold also avoid double-free later. So reffing */
g_object_ref (account);
store = (CamelOfflineStore *) camel_session_get_service (
- session, e_account_get_string (account, E_ACCOUNT_SOURCE_URL),
+ CAMEL_SESSION (session),
+ e_account_get_string (account, E_ACCOUNT_SOURCE_URL),
CAMEL_PROVIDER_STORE, NULL);
if (store == NULL)
return NULL;
diff --git a/plugins/groupwise-features/share-folder-common.c b/plugins/groupwise-features/share-folder-common.c
index 387c960b27..adb373d6c6 100644
--- a/plugins/groupwise-features/share-folder-common.c
+++ b/plugins/groupwise-features/share-folder-common.c
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <e-util/e-config.h>
+#include <mail/e-mail-backend.h>
#include <mail/em-config.h>
#include <mail/em-folder-properties.h>
#include <mail/em-folder-tree.h>
@@ -243,6 +244,7 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi)
struct _EMFolderTreeModelStoreInfo *si;
EMFolderSelector *emfs = ssi->emfs;
const gchar *uri, *path;
+ EMailSession *session;
CamelStore *store;
if (response != GTK_RESPONSE_OK) {
@@ -253,11 +255,12 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi)
uri = em_folder_selector_get_selected_uri (emfs);
path = em_folder_selector_get_selected_path (emfs);
+ session = em_folder_tree_get_session (emfs->emft);
d(printf ("Creating new folder: %s (%s)\n", path, uri));
store = (CamelStore *) camel_session_get_service (
- session, uri, CAMEL_PROVIDER_STORE, NULL);
+ CAMEL_SESSION (session), uri, CAMEL_PROVIDER_STORE, NULL);
if (store == NULL)
return;
@@ -268,14 +271,14 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi)
}
if (CAMEL_IS_VEE_STORE (store)) {
- EMVFolderRule *rule;
+ EFilterRule *rule;
/* ensures vfolder is running */
- vfolder_load_storage ();
+ vfolder_load_storage (session);
- rule = em_vfolder_rule_new ();
- e_filter_rule_set_name ((EFilterRule *)rule, path);
- vfolder_gui_add_rule (rule);
+ rule = em_vfolder_rule_new (session);
+ e_filter_rule_set_name (rule, path);
+ vfolder_gui_add_rule (EM_VFOLDER_RULE (rule));
gtk_widget_destroy ((GtkWidget *)emfs);
} else {
g_object_ref (emfs);
@@ -336,12 +339,17 @@ void
gw_new_shared_folder_cb (GtkAction *action, EShellView *shell_view)
{
EMFolderTree *folder_tree;
+ EShellBackend *shell_backend;
+ EMailSession *session;
GtkWidget *dialog;
gchar *uri;
gpointer parent;
parent = e_shell_view_get_shell_window (shell_view);
- folder_tree = (EMFolderTree *) em_folder_tree_new ();
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend));
+
+ folder_tree = (EMFolderTree *) em_folder_tree_new (session);
emu_restore_folder_tree_state (folder_tree);
dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));