From 5b20214853dcf7416c0e9b2590fed93af2c635e0 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Fri, 9 Nov 2007 10:00:27 +0000 Subject: [PATCH] * src/modest-tny-account-store.[ch]: * Enable loading of connection specific smtp accounts on startup. * Make public the function to get a connection specific account. This function does not return the server one if specific ones do not exist. * src/modest-tny-account.[ch]: * Now standard transport accounts are ModestTransportAccountDecorator instead of TnyCamelTransportAccount. * (modest_tny_account_new_from_server_name): now it's only used for creating connection specific accounts. * (modest_tny_account_new_from_server_account_name): now it gets the proper TnyGetPassFunc and TnyForgetPassFunc. * Added src/modest-transport-account-decorator.[ch]: * This inherits from TnyCamelTransportAccount. * The only difference is send method, which is redefined. It sends through connection specific transports if required, or through itself (calling parent implementation) if not. * src/Makefile.am: * Add the ModestTransportAccountDecorator to build. * src/modest-account-mgr-helpers.[ch]: * (modest_account_mgr_set_connection_specific_smtp): fix a bug updating the list of accounts. * src/modest-defs.h: * Fix the specific_smtp gconf key to be stored in modest namespace. * src/modest-ui-actions.c: * (..._on_send): now we always use the standard server accounts, no reference to open connection account. As specific connection smtp is handled internally in those accounts. * src/maemo/modest-connection-specific-smtp-window.c: * Fix handling to update and insert properly the new accounts. * src/maemo/modest-account-settings-dialog.c: * Mark as modified each time we show the connection specific smtp dialog pmo-trunk-r3678 --- src/Makefile.am | 2 + src/maemo/modest-account-settings-dialog.c | 1 + src/maemo/modest-connection-specific-smtp-window.c | 14 +- src/modest-account-mgr-helpers.c | 6 +- src/modest-account-mgr.c | 2 +- src/modest-defs.h | 2 +- src/modest-tny-account-store.c | 67 +++++--- src/modest-tny-account-store.h | 16 ++ src/modest-tny-account.c | 29 +++- src/modest-tny-account.h | 4 +- src/modest-transport-account-decorator.c | 165 ++++++++++++++++++++ src/modest-transport-account-decorator.h | 85 ++++++++++ src/modest-ui-actions.c | 16 +- 13 files changed, 372 insertions(+), 37 deletions(-) create mode 100644 src/modest-transport-account-decorator.c create mode 100644 src/modest-transport-account-decorator.h diff --git a/src/Makefile.am b/src/Makefile.am index e2b6483..08ba46e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,8 @@ modest_SOURCES=\ modest-tny-platform-factory.h \ modest-tny-send-queue.c \ modest-tny-send-queue.h \ + modest-transport-account-decorator.c \ + modest-transport-account-decorator.h \ modest-stream-text-to-html.c \ modest-stream-text-to-html.h \ modest-ui-actions.c \ diff --git a/src/maemo/modest-account-settings-dialog.c b/src/maemo/modest-account-settings-dialog.c index 897b91e..d909426 100644 --- a/src/maemo/modest-account-settings-dialog.c +++ b/src/maemo/modest-account-settings-dialog.c @@ -706,6 +706,7 @@ on_button_outgoing_smtp_servers (GtkButton *button, gpointer user_data) gtk_window_set_transient_for (GTK_WINDOW (self->specific_window), GTK_WINDOW (self)); gtk_window_set_modal (GTK_WINDOW (self->specific_window), TRUE); gtk_widget_show (self->specific_window); + self->modified = TRUE; } static void diff --git a/src/maemo/modest-connection-specific-smtp-window.c b/src/maemo/modest-connection-specific-smtp-window.c index 68d9746..45ce533 100644 --- a/src/maemo/modest-connection-specific-smtp-window.c +++ b/src/maemo/modest-connection-specific-smtp-window.c @@ -49,6 +49,7 @@ #include "modest-maemo-utils.h" #include +#include G_DEFINE_TYPE (ModestConnectionSpecificSmtpWindow, modest_connection_specific_smtp_window, GTK_TYPE_DIALOG); @@ -500,11 +501,13 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe gchar *id = NULL; gchar *connection_name = NULL; gchar *server_account_name = NULL; + gchar *server_name = NULL; ModestServerAccountData *data = NULL; gtk_tree_model_get (priv->model, &iter, MODEL_COL_ID, &id, MODEL_COL_NAME, &connection_name, + MODEL_COL_SERVER_NAME, &server_name, MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name, MODEL_COL_SERVER_ACCOUNT_DATA, &data, -1); @@ -526,6 +529,13 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe MODEST_PROTOCOL_TRANSPORT_SMTP, data->security, data->secure_auth); + if (success) { + TnyAccount *account = TNY_ACCOUNT (modest_tny_account_store_new_connection_specific_transport_account + (modest_runtime_get_account_store (), + server_account_name)); + if (account) + g_object_unref (account); + } /* associate the specific server account with this connection for this account: */ success = success && modest_account_mgr_set_connection_specific_smtp ( @@ -554,7 +564,8 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe modest_account_mgr_set_server_account_port (priv->account_manager, server_account_name, data->port); } - } else if (connection_name) { + } else if (connection_name && server_name && + !strcmp (server_name, _("mcen_ia_optionalsmtp_notdefined"))) { modest_account_mgr_remove_connection_specific_smtp (priv->account_manager, connection_name); gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter, @@ -564,6 +575,7 @@ modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpe g_free (connection_name); g_free (id); g_free (server_account_name); + g_free (server_name); if (!success) return FALSE; diff --git a/src/modest-account-mgr-helpers.c b/src/modest-account-mgr-helpers.c index 3891d64..9ff28f3 100644 --- a/src/modest-account-mgr-helpers.c +++ b/src/modest-account-mgr-helpers.c @@ -107,11 +107,11 @@ gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self result = FALSE; } else { /* The server account is in the item after the connection name: */ - GSList *list_connection = g_slist_append (list, (gpointer)connection_name); - list_connection = g_slist_append (list_connection, (gpointer)server_account_name); + list = g_slist_append (list, (gpointer)connection_name); + list = g_slist_append (list, (gpointer)server_account_name); /* Reset the changed list: */ - modest_conf_set_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list_connection, + modest_conf_set_list (conf, MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST, list, MODEST_CONF_VALUE_STRING, &err); if (err) { g_printerr ("modest: %s: error setting list: %s.\n", __FUNCTION__, err->message); diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index 0999a90..bbbb2e8 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -472,7 +472,7 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, /* Add the security settings: */ modest_account_mgr_set_server_account_security (self, name, security); - + cleanup: if (!ok) { g_printerr ("modest: failed to add server account\n"); diff --git a/src/modest-defs.h b/src/modest-defs.h index e584fd5..8652da4 100644 --- a/src/modest-defs.h +++ b/src/modest-defs.h @@ -127,7 +127,7 @@ * alernating between a connection name, followed by a corresponding server account name. * That's not pretty, but it's nicer than dealing with escaping of a = separator if * putting them both in one string. */ -#define MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST "/specific_smtp" /* one list used for all accounts. */ +#define MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST MODEST_CONF_NAMESPACE "/specific_smtp" /* one list used for all accounts. */ #define MODEST_ACCOUNT_USE_CONNECTION_SPECIFIC_SMTP "use_specific_smtp" /* boolean */ /* server account keys */ diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 7ae950b..d5b06a1 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -958,7 +958,7 @@ modest_tny_account_store_new (ModestAccountMgr *account_mgr, it will return NULL because there is no outbox folder for this specific transport accounts, and it's a must that the send queue returns an outbox */ - if (FALSE) + if (TRUE) /* Add connection-specific transport accounts */ add_connection_specific_transport_accounts (MODEST_TNY_ACCOUNT_STORE(obj)); @@ -1321,9 +1321,9 @@ modest_tny_account_store_get_server_account (ModestTnyAccountStore *self, return retval; } -static TnyAccount* -get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *self, - const gchar *account_name) +TnyAccount* +modest_tny_account_store_get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *self, + const gchar *account_name) { /* Get the current connection: */ TnyDevice *device = modest_runtime_get_device (); @@ -1397,7 +1397,7 @@ modest_tny_account_store_get_transport_account_for_open_connection (ModestTnyAcc /* Get the connection-specific transport acccount, if any: */ /* Note: This gives us a reference: */ TnyAccount *account = - get_smtp_specific_transport_account_for_open_connection (self, account_name); + modest_tny_account_store_get_smtp_specific_transport_account_for_open_connection (self, account_name); /* If there is no connection-specific transport account (the common case), * just get the regular transport account: */ @@ -1676,6 +1676,40 @@ on_account_removed (ModestAccountMgr *acc_mgr, } } +TnyTransportAccount * +modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAccountStore *self, + const gchar *name) +{ + ModestTnyAccountStorePrivate *priv = NULL; + TnyAccount * tny_account = NULL; + + priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self); + + /* Add the account: */ + tny_account = + modest_tny_account_new_from_server_account_name (priv->account_mgr, + priv->session, + name, + get_password, + forget_password); + if (tny_account) { + g_object_set_data (G_OBJECT(tny_account), + "account_store", + (gpointer)self); + + tny_list_append (priv->transport_accounts, G_OBJECT (tny_account)); + add_outbox_from_transport_account_to_global_outbox (self, + name, + tny_account); + + } else + g_printerr ("modest: failed to create smtp-specific account for %s\n", + name); + + return TNY_TRANSPORT_ACCOUNT (tny_account); +} + + static void add_connection_specific_transport_accounts (ModestTnyAccountStore *self) { @@ -1704,24 +1738,11 @@ add_connection_specific_transport_accounts (ModestTnyAccountStore *self) iter = g_slist_next (iter); if (iter) { const gchar* transport_account_name = (const gchar*) (iter->data); - if (transport_account_name) { - TnyAccount * tny_account = NULL; - /* Add the account: */ - tny_account = - modest_tny_account_new_from_server_account_name (priv->account_mgr, - priv->session, - transport_account_name); - if (tny_account) { - g_object_set_data (G_OBJECT(tny_account), - "account_store", - (gpointer)self); - - tny_list_append (priv->transport_accounts, G_OBJECT (tny_account)); - g_object_unref (tny_account); - } else - g_printerr ("modest: failed to create smtp-specific account for %s\n", - transport_account_name); - } + TnyTransportAccount * account = NULL; + account = modest_tny_account_store_new_connection_specific_transport_account ( + self, transport_account_name); + if (account) + g_object_unref (account); } iter = g_slist_next (iter); } diff --git a/src/modest-tny-account-store.h b/src/modest-tny-account-store.h index df87c3c..3f1f52f 100644 --- a/src/modest-tny-account-store.h +++ b/src/modest-tny-account-store.h @@ -151,6 +151,9 @@ TnyAccount* modest_tny_account_store_get_server_account (ModestTnyAccountStore * TnyAccount* modest_tny_account_store_get_transport_account_for_open_connection (ModestTnyAccountStore *self, const gchar *account_name); +TnyAccount* modest_tny_account_store_get_smtp_specific_transport_account_for_open_connection (ModestTnyAccountStore *self, + const gchar *account_name); + /** * tny_account_store_get_session * @self: a TnyAccountStore instance @@ -215,6 +218,19 @@ TnyTransportAccount * modest_tny_account_store_get_transport_account_from_outbox_header(ModestTnyAccountStore *self, TnyHeader *header); +/** + * modest_tny_account_store_new_connection_specific_transport_account: + * @self: a #ModestTnyAccountStore + * @name: the name of the connection specific smtp transport account + * + * Creates a connection specific transport account and put it in the merged outbox + * + * Returns: the new #TnyTransportAccount + */ +TnyTransportAccount * +modest_tny_account_store_new_connection_specific_transport_account (ModestTnyAccountStore *self, + const gchar *name); + G_END_DECLS #endif /* __MODEST_TNY_ACCOUNT_STORE_H__ */ diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 9b55d10..2527fbe 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,10 @@ #include #endif +/* we need these dummy functions, or tinymail will complain */ +static gchar * get_pass_dummy (TnyAccount *account, const gchar *prompt, gboolean *cancel); +static void forget_pass_dummy (TnyAccount *account); + TnyFolder * modest_tny_account_get_special_folder (TnyAccount *account, TnyFolderType special_type) @@ -186,7 +191,7 @@ create_tny_account (ModestAccountMgr *account_mgr, switch (account_data->proto) { case MODEST_PROTOCOL_TRANSPORT_SENDMAIL: case MODEST_PROTOCOL_TRANSPORT_SMTP: - tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break; + tny_account = TNY_ACCOUNT (modest_transport_account_decorator_new ()); break; case MODEST_PROTOCOL_STORE_POP: tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break; case MODEST_PROTOCOL_STORE_IMAP: @@ -388,7 +393,9 @@ update_tny_account (TnyAccount *tny_account, ModestAccountMgr *account_mgr, TnyAccount* modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr, TnySessionCamel *session, - const gchar *server_account_name) + const gchar *server_account_name, + TnyGetPassFunc get_pass_func, + TnyForgetPassFunc forget_pass_func) { ModestServerAccountData *account_data; TnyAccount *tny_account; @@ -401,11 +408,27 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr, if (!account_data) return NULL; - tny_account = create_tny_account (account_mgr, session, account_data); + tny_account = TNY_ACCOUNT (tny_camel_transport_account_new ()); + + if (tny_account) { + const gchar* proto_name = NULL; + tny_account_set_id (tny_account, account_data->account_name); + tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session); + proto_name = modest_protocol_info_get_transport_store_protocol_name(account_data->proto); + tny_account_set_proto (tny_account, proto_name); + modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, server_account_name); + } + if (!tny_account) g_warning ("%s: failed to create tny_account", __FUNCTION__); else if (!update_tny_account (tny_account, account_mgr, account_data)) g_warning ("%s: failed to initialize tny_account", __FUNCTION__); + else { + tny_account_set_forget_pass_func (tny_account, + forget_pass_func ? forget_pass_func : forget_pass_dummy); + tny_account_set_pass_func (tny_account, + get_pass_func ? get_pass_func: get_pass_dummy); + } modest_account_mgr_free_server_account_data (account_mgr, account_data); diff --git a/src/modest-tny-account.h b/src/modest-tny-account.h index 56589a9..915fe3f 100644 --- a/src/modest-tny-account.h +++ b/src/modest-tny-account.h @@ -118,7 +118,9 @@ TnyAccount* modest_tny_account_new_for_per_account_local_outbox_folder ( TnyAccount* modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr, TnySessionCamel *session, - const gchar* server_account_name); + const gchar* server_account_name, + TnyGetPassFunc get_pass_func, + TnyForgetPassFunc forget_pass_func); #if 0 /** diff --git a/src/modest-transport-account-decorator.c b/src/modest-transport-account-decorator.c new file mode 100644 index 0000000..e0024c8 --- /dev/null +++ b/src/modest-transport-account-decorator.c @@ -0,0 +1,165 @@ +/* Copyright (c) 2006, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include /* strcmp */ + +/* 'private'/'protected' functions */ +static void modest_transport_account_decorator_class_init (ModestTransportAccountDecoratorClass *klass); +static void modest_transport_account_decorator_finalize (GObject *obj); +static void modest_transport_account_decorator_instance_init (GTypeInstance *instance, gpointer g_class); +static void modest_transport_account_decorator_send (TnyTransportAccount *self, TnyMsg *msg, GError **err); + +/* list my signals */ +/* enum { */ +/* /\* MY_SIGNAL_1, *\/ */ +/* /\* MY_SIGNAL_2, *\/ */ +/* LAST_SIGNAL */ +/* }; */ + +/* typedef struct _ModestTransportAccountDecoratorPrivate ModestTransportAccountDecoratorPrivate; */ +/* struct _ModestTransportAccountDecoratorPrivate { */ +/* }; */ + +/* #define MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ */ +/* MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR, \ */ +/* ModestTransportAccountDecoratorPrivate)) */ + +/* globals */ +static TnyCamelTransportAccountClass *parent_class = NULL; + +/* uncomment the following if you have defined any signals */ +/* static guint signals[LAST_SIGNAL] = {0}; */ + +/* + * this thread actually tries to send all the mails in the outbox and keeps + * track of their state. + */ +static void +modest_transport_account_decorator_send (TnyTransportAccount *self, TnyMsg *msg, GError **err) +{ + TnyTransportAccount *connection_specific_account = NULL; +/* ModestTransportAccountDecoratorPrivate *priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (self); */ + ModestTnyAccountStore *store = modest_runtime_get_account_store (); + const gchar *account_name; + + account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (TNY_ACCOUNT (self)); + if (account_name) { + connection_specific_account = TNY_TRANSPORT_ACCOUNT + (modest_tny_account_store_get_smtp_specific_transport_account_for_open_connection (store, account_name)); + } + + if (connection_specific_account) { + tny_transport_account_send (connection_specific_account, msg, err); + } else { + TNY_CAMEL_TRANSPORT_ACCOUNT_CLASS(parent_class)->send_func (self, msg, err); + } +} + +static void +modest_transport_account_decorator_class_init (ModestTransportAccountDecoratorClass *klass) +{ + GObjectClass *gobject_class; + TnyCamelTransportAccountClass *transport_class; + + gobject_class = (GObjectClass*) klass; + transport_class = (TnyCamelTransportAccountClass *) klass; + + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = modest_transport_account_decorator_finalize; + + transport_class->send_func = modest_transport_account_decorator_send; + +/* g_type_class_add_private (gobject_class, sizeof(ModestTransportAccountDecoratorPrivate)); */ +} + +static void +modest_transport_account_decorator_instance_init (GTypeInstance *instance, gpointer g_class) +{ +/* ModestTransportAccountDecoratorPrivate *priv; */ + +/* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (instance); */ +} + +static void +modest_transport_account_decorator_finalize (GObject *obj) +{ +/* ModestTransportAccountDecoratorPrivate *priv; */ + +/* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (obj); */ + + G_OBJECT_CLASS(parent_class)->finalize (obj); +} + +ModestTransportAccountDecorator* +modest_transport_account_decorator_new (void) +{ + ModestTransportAccountDecorator *self; +/* ModestTransportAccountDecoratorPrivate *priv; */ + + self = MODEST_TRANSPORT_ACCOUNT_DECORATOR(g_object_new(MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR, NULL)); +/* priv = MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_PRIVATE (self); */ + + return self; +} + +GType +modest_transport_account_decorator_get_type (void) +{ + static GType my_type = 0; + + if (my_type == 0) { + static const GTypeInfo my_info = { + sizeof(ModestTransportAccountDecoratorClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) modest_transport_account_decorator_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof(ModestTransportAccountDecorator), + 0, /* n_preallocs */ + (GInstanceInitFunc) modest_transport_account_decorator_instance_init, + NULL + }; + + my_type = g_type_register_static (TNY_TYPE_CAMEL_TRANSPORT_ACCOUNT, + "ModestTransportAccountDecorator", + &my_info, 0); + } + return my_type; +} + diff --git a/src/modest-transport-account-decorator.h b/src/modest-transport-account-decorator.h new file mode 100644 index 0000000..fc7642d --- /dev/null +++ b/src/modest-transport-account-decorator.h @@ -0,0 +1,85 @@ +/* Copyright (c) 2007, Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Nokia Corporation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +#ifndef __MODEST_TRANSPORT_ACCOUNT_DECORATOR_H__ +#define __MODEST_TRANSPORT_ACCOUNT_DECORATOR_H__ + +G_BEGIN_DECLS + +/* convenience macros */ +#define MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR (modest_transport_account_decorator_get_type()) +#define MODEST_TRANSPORT_ACCOUNT_DECORATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR,ModestTransportAccountDecorator)) +#define MODEST_TRANSPORT_ACCOUNT_DECORATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR,TransportAccountDecorator)) +#define MODEST_IS_TRANSPORT_ACCOUNT_DECORATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR)) +#define MODEST_IS_TRANSPORT_ACCOUNT_DECORATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR)) +#define MODEST_TRANSPORT_ACCOUNT_DECORATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_TRANSPORT_ACCOUNT_DECORATOR,ModestTransportAccountDecoratorClass)) + +typedef struct _ModestTransportAccountDecorator ModestTransportAccountDecorator; +typedef struct _ModestTransportAccountDecoratorClass ModestTransportAccountDecoratorClass; + +struct _ModestTransportAccountDecorator { + TnyCamelTransportAccount parent; +}; + +struct _ModestTransportAccountDecoratorClass { + TnyCamelTransportAccountClass parent_class; + +}; + +/** + * modest_transport_account_decorator_get_type: + * + * get the #GType for #ModestTransportAccountDecorator + * + * Returns: the #GType + */ +GType modest_transport_account_decorator_get_type (void) G_GNUC_CONST; + + +/** + * modest_transport_account_decorator_new: + * @account: a valid transport account + * + * create a new #ModestTransportAccountDecorator decorating @account + * + * Returns: a new #ModestTransportAccountDecorator instance, or NULL in case + * of any error + */ +ModestTransportAccountDecorator* modest_transport_account_decorator_new (void); + +G_END_DECLS + +#endif /* __MODEST_TRANSPORT_ACCOUNT_DECORATOR_H__ */ + diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 8824c78..9368b17 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -2278,6 +2278,8 @@ modest_ui_actions_on_save_to_drafts (GtkWidget *widget, ModestMsgEditWindow *edi void modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) { + TnyTransportAccount *transport_account = NULL; + g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window)); if (!modest_msg_edit_window_check_names (edit_window, TRUE)) @@ -2304,10 +2306,16 @@ modest_ui_actions_on_send (GtkWidget *widget, ModestMsgEditWindow *edit_window) } /* Get the currently-active transport account for this modest account: */ - TnyTransportAccount *transport_account = - TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection - (modest_runtime_get_account_store(), - account_name)); +/* TnyTransportAccount *transport_account = */ +/* TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_transport_account_for_open_connection */ +/* (modest_runtime_get_account_store(), */ +/* account_name)); */ + if (strcmp (account_name, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) != 0) { + transport_account = TNY_TRANSPORT_ACCOUNT(modest_tny_account_store_get_server_account + (modest_runtime_get_account_store(), + account_name, TNY_ACCOUNT_TYPE_TRANSPORT)); + } + if (!transport_account) { /* Run account setup wizard */ if (!modest_ui_actions_run_account_setup_wizard(MODEST_WINDOW(edit_window))) -- 1.7.9.5