#include <tny-fs-stream.h>
#include <tny-vfs-stream.h>
#include <tny-camel-mem-stream.h>
+#include <modest-account-protocol.h>
#include <config.h>
GSList *cursor = accounts;
while (cursor) {
gchar *account_name = cursor->data;
- gchar *from_string = NULL;
if (account_name) {
- from_string = modest_account_mgr_get_from_string (account_mgr,
- account_name);
- }
-
- if (from_string && account_name) {
- gchar *name = account_name;
- ModestPair *pair = modest_pair_new ((gpointer) name,
- (gpointer) from_string , TRUE);
- transports = g_slist_prepend (transports, pair);
+
+ gchar *transport_account;
+ gboolean multi_mailbox = FALSE;
+ gchar *proto;
+
+ transport_account = modest_account_mgr_get_server_account_name (modest_runtime_get_account_mgr (),
+ account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ if (transport_account) {
+ proto = modest_account_mgr_get_string (modest_runtime_get_account_mgr (), transport_account,
+ MODEST_ACCOUNT_PROTO, TRUE);
+ if (proto != NULL) {
+ ModestProtocol *protocol =
+ modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
+ MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
+ proto);
+ if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
+ ModestPairList *pair_list;
+ pair_list = modest_account_protocol_get_from_list (MODEST_ACCOUNT_PROTOCOL (protocol),
+ account_name);
+ if (pair_list) {
+ transports = g_slist_concat (transports, pair_list);
+ multi_mailbox = TRUE;
+ }
+ }
+ }
+ g_free (proto);
+ }
+
+ if (!multi_mailbox) {
+ gchar *from_string = NULL;
+
+ from_string = modest_account_mgr_get_from_string (account_mgr,
+ account_name, NULL);
+ if (from_string && account_name) {
+ gchar *name = account_name;
+ ModestPair *pair = modest_pair_new ((gpointer) name,
+ (gpointer) from_string , TRUE);
+ transports = g_slist_prepend (transports, pair);
+ }
+ }
}
cursor = cursor->next;
/* Menubar. Update the state of some toggles */
priv->from_field_protos = get_transports ();
modest_selector_picker_set_pair_list (MODEST_SELECTOR_PICKER (priv->from_field), priv->from_field_protos);
- modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) account_name);
+ if (mailbox && modest_pair_list_find_by_first_as_string (priv->from_field_protos, mailbox)) {
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) mailbox);
+ } else {
+ modest_selector_picker_set_active_id (MODEST_SELECTOR_PICKER (priv->from_field), (gpointer) account_name);
+ }
priv->last_from_account = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
hildon_button_set_title (HILDON_BUTTON (priv->from_field),
_("mail_va_from"));
/* don't free these (except from) */
data = g_slice_new0 (MsgData);
- data->from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
- account_name);
+ data->from = g_strdup ((gchar *) modest_selector_picker_get_active_display_name (MODEST_SELECTOR_PICKER (priv->from_field)));
data->account_name = g_strdup (account_name);
data->to = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->to_field)));
data->cc = g_strdup (modest_recpt_editor_get_recipients (MODEST_RECPT_EDITOR (priv->cc_field)));
if (gtk_text_buffer_get_modified (priv->text_buffer))
return TRUE;
- /* TODO: check the mailbox too here */
account_name = modest_selector_picker_get_active_id (MODEST_SELECTOR_PICKER (priv->from_field));
+ if ((priv->original_mailbox) &&
+ (!account_name || strcmp (account_name, priv->original_mailbox)))
+ return TRUE;
if (!priv->original_account_name || strcmp(account_name, priv->original_account_name)) {
return TRUE;
}
#include <modest-defs.h>
#include <string.h>
#include <strings.h>
+#include <modest-account-protocol.h>
static const gchar * null_means_empty (const gchar * str);
gchar*
modest_account_mgr_get_from_string (ModestAccountMgr *self, const gchar* name, const gchar *mailbox)
{
- gchar **from;
+ gchar *from;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (name, NULL);
ModestProtocol *protocol =
modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),
MODEST_PROTOCOL_REGISTRY_TRANSPORT_PROTOCOLS,
- TRUE);
+ proto);
if (MODEST_IS_ACCOUNT_PROTOCOL (protocol)) {
from = modest_account_protocol_get_from (MODEST_ACCOUNT_PROTOCOL (protocol),
name,
gboolean modest_account_mgr_singleton_protocol_exists (ModestAccountMgr *mgr,
ModestProtocolType protocol_type);
+gchar * modest_account_mgr_get_string (ModestAccountMgr *self, const gchar *name,
+ const gchar *key, gboolean server_account);
G_END_DECLS
#endif /* __MODEST_ACCOUNT_MGR_H__ */
g_printerr ("modest: failed to find Drafts folder\n");
goto cleanup;
}
- from_str = modest_account_mgr_get_from_string (mgr, account_name);
+ from_str = modest_account_mgr_get_from_string (mgr, account_name, mailbox);
if (!from_str) {
g_printerr ("modest: failed get from string for '%s'\n", account_name);
goto cleanup;
goto cleanup;
from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
- rf_helper->account_name);
- signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr(),
- rf_helper->account_name,
+ rf_helper->account_name, NULL);
+ signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr(),
+ rf_helper->account_name,
&use_signature);
/* Create reply mail */
TnyTransportAccount *transport_account;
ModestMailOperation *mail_operation;
MsgData *data;
- gchar *account_name, *from;
+ gchar *account_name;
ModestAccountMgr *account_mgr;
gboolean had_error = FALSE;
ModestMainWindow *win = NULL;
modest_msg_edit_window_free_msg_data (edit_window, data);
return FALSE;
}
- from = modest_account_mgr_get_from_string (account_mgr, account_name);
/* Create the mail operation */
mail_operation = modest_mail_operation_new_with_error_handling (NULL, modest_ui_actions_disk_operations_error_handler,
modest_mail_operation_save_to_drafts (mail_operation,
transport_account,
data->draft_msg,
- from,
- data->to,
- data->cc,
+ data->from,
+ data->to,
+ data->cc,
data->bcc,
data->subject,
data->plain_body,
modest_msg_edit_window_set_modified (edit_window, FALSE);
/* Frees */
- g_free (from);
g_free (account_name);
g_object_unref (G_OBJECT (transport_account));
g_object_unref (G_OBJECT (mail_operation));
MsgData *data;
ModestAccountMgr *account_mgr;
gchar *account_name;
- gchar *from;
ModestMailOperation *mail_operation;
g_return_val_if_fail (MODEST_IS_MSG_EDIT_WINDOW(edit_window), TRUE);
/* Create the mail operation */
- from = modest_account_mgr_get_from_string (account_mgr, account_name);
mail_operation = modest_mail_operation_new_with_error_handling (NULL, modest_ui_actions_disk_operations_error_handler, NULL, NULL);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
modest_mail_operation_send_new_mail (mail_operation,
transport_account,
data->draft_msg,
- from,
+ data->from,
data->to,
data->cc,
data->bcc,
}
/* Free data: */
- g_free (from);
g_free (account_name);
g_object_unref (G_OBJECT (transport_account));
g_object_unref (G_OBJECT (mail_operation));
gchar *proto;
from =
- modest_account_mgr_get_from_string (mgr, node->data);
+ modest_account_mgr_get_from_string (mgr, node->data, NULL);
if (from) {
gchar *from_email =
g_free (from_header_email);
g_free (from);
}
- proto = modest_account_mgr_get_string (self, node->data, MODEST_ACCOUNT_PROTO, TRUE);
+ proto = modest_account_mgr_get_string (mgr, node->data, MODEST_ACCOUNT_PROTO, TRUE);
if (proto != NULL) {
ModestProtocol *protocol =
modest_protocol_registry_get_protocol_by_name (modest_runtime_get_protocol_registry (),