* Fixes the problem present when creating a new account, the account view was showing the account id of the account instead of the display account
* Now, every account that is added is automatically refreshed
pmo-trunk-r3462
return FALSE;
}
+ const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
+ const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
+ const gchar *retrieve = MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
/* Create the account, which will contain the two "server accounts": */
- created = modest_account_mgr_add_account (self->account_manager, account_name,
- store_name, /* The name of our POP/IMAP server account. */
- transport_name, /* The name of our SMTP server account. */
+ created = modest_account_mgr_add_account (self->account_manager,
+ account_name,
+ display_name,
+ user_fullname,
+ emailaddress,
+ retrieve,
+ store_name,
+ transport_name,
enabled);
g_free (store_name);
g_free (transport_name);
if(!modest_account_mgr_has_accounts (self->account_manager, FALSE))
g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
- /* The user name and email address must be set additionally: */
- const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
- modest_account_mgr_set_server_account_user_fullname (self->account_manager, account_name, user_name);
-
- const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
- modest_account_mgr_set_server_account_user_email (self->account_manager, account_name, emailaddress);
-
- /* Set the display name: */
- modest_account_mgr_set_display_name (self->account_manager, account_name, display_name);
-
- /* Set retrieve type */
- const gchar *retrieve = MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
- modest_account_mgr_set_retrieve_type (self->account_manager, account_name, retrieve);
-
/* Save the connection-specific SMTP server accounts. */
modest_account_mgr_set_use_connection_specific_smtp(self->account_manager, account_name,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->checkbox_outgoing_smtp_specific)));
/* Set the account data from the widgets: */
const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
- modest_account_mgr_set_server_account_user_fullname (dialog->account_manager,
- account_name,
- user_fullname);
+ modest_account_mgr_set_user_fullname (dialog->account_manager,
+ account_name,
+ user_fullname);
const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
- modest_account_mgr_set_server_account_user_email (dialog->account_manager, account_name,
- emailaddress);
+ modest_account_mgr_set_user_email (dialog->account_manager, account_name,
+ emailaddress);
/* Signature: */
if (dialog->signature_dialog) {
static void save_state (ModestWindow *self);
-static void
-update_menus (ModestMainWindow* self);
+static void update_menus (ModestMainWindow* self);
static void modest_main_window_show_toolbar (ModestWindow *window,
gboolean show_toolbar);
}
/* We need to call this in order to ensure
that the new actions are added in the right
- order (alphabetical */
+ order (alphabetical) */
gtk_ui_manager_ensure_update (parent_priv->ui_manager);
} else
groups = g_list_next (groups);
priv->view_additions_group = gtk_action_group_new (MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS);
radio_group = NULL;
for (i = 0; i < num_accounts; i++) {
- gchar *display_name = NULL;
-
+ gchar *display_name = NULL;
ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i);
- /* Create display name. The UI specification specifies a different format string
- * to use for the default account, though both seem to be "%s", so
- * I don't see what the point is. murrayc. */
if (default_account && account_data->account_name &&
!(strcmp (default_account, account_data->account_name) == 0)) {
display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"),
/** You must use modest_account_mgr_free_account_data() on the result.
*/
-ModestAccountData*
-modest_account_mgr_get_account_data (ModestAccountMgr *self, const gchar* name)
+ModestAccountData *
+modest_account_mgr_get_account_data (ModestAccountMgr *self,
+ const gchar* name)
{
ModestAccountData *data;
gchar *server_account;
void
-modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self,
- const gchar *account_name,
- const gchar *fullname)
+modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *fullname)
{
modest_account_mgr_set_string (self,
account_name,
}
void
-modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self,
- const gchar *account_name,
- const gchar *email)
+modest_account_mgr_set_user_email (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *email)
{
modest_account_mgr_set_string (self,
account_name,
const gchar *account_name,
const gchar *retrieve_type);
-void modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self,
- const gchar *account_name,
- const gchar *fullname);
+void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *fullname);
-void modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self,
- const gchar *account_name,
- const gchar *email);
+void modest_account_mgr_set_user_email (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *email);
G_END_DECLS
gboolean
modest_account_mgr_add_account (ModestAccountMgr *self,
const gchar *name,
+ const gchar *display_name,
+ const gchar *user_fullname,
+ const gchar *user_email,
+ const gchar *retrieve_type,
const gchar *store_account,
const gchar *transport_account,
gboolean enabled)
modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_LEAVE_ON_SERVER, TRUE, FALSE);
modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_ENABLED, enabled,FALSE);
+ /* Fill other data */
+ modest_account_mgr_set_string (self, name,
+ MODEST_ACCOUNT_DISPLAY_NAME,
+ display_name, FALSE);
+ modest_account_mgr_set_string (self, name,
+ MODEST_ACCOUNT_FULLNAME,
+ user_fullname, FALSE);
+ modest_account_mgr_set_string (self, name,
+ MODEST_ACCOUNT_EMAIL,
+ user_email, FALSE);
+ modest_account_mgr_set_string (self, name,
+ MODEST_ACCOUNT_RETRIEVE,
+ retrieve_type, FALSE);
+
/* Notify the observers */
g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
* Returns: TRUE if the creation succeeded, FALSE otherwise,
*/
gboolean modest_account_mgr_add_account (ModestAccountMgr *self,
- const gchar* name,
+ const gchar *name,
+ const gchar *display_name,
+ const gchar *user_fullname,
+ const gchar *user_email,
+ const gchar *retrieve_type,
const gchar* store_name,
const gchar* transport_name,
gboolean enabled);
typedef struct _ModestMailOperationPrivate ModestMailOperationPrivate;
struct _ModestMailOperationPrivate {
TnyAccount *account;
- gchar *account_name;
guint done;
guint total;
GObject *source;
priv->total = 0;
if (priv->account != NULL)
g_object_unref (priv->account);
- priv->account = g_object_ref (info->transport_account);
+
+ if (info->transport_account) {
+ priv->account = g_object_ref (info->transport_account);
- send_queue = modest_runtime_get_send_queue (info->transport_account);
- if (send_queue) {
- modest_tny_send_queue_try_to_send (send_queue);
- } else {
- g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
- "cannot create a send queue for %s\n",
- tny_account_get_name (TNY_ACCOUNT (info->transport_account)));
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ send_queue = modest_runtime_get_send_queue (info->transport_account);
+ if (send_queue) {
+ modest_tny_send_queue_try_to_send (send_queue);
+ } else {
+ g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+ MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
+ "cannot create a send queue for %s\n",
+ tny_account_get_name (TNY_ACCOUNT (info->transport_account)));
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ }
}
/* Check if the operation was a success */
}
out:
-
+ /* Set the account back to not busy */
+ modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr(),
+ info->account_name, FALSE);
+
if (info->callback) {
UpdateAccountInfo *idle_info;
if (all_folders)
g_object_unref (all_folders);
g_object_unref (info->account);
- g_object_unref (info->transport_account);
+ if (info->transport_account)
+ g_object_unref (info->transport_account);
+ g_free (info->account_name);
g_free (info->retrieve_type);
g_slice_free (UpdateAccountInfo, info);
info->account = store_account;
info->transport_account = transport_account;
info->callback = callback;
+ info->account_name = g_strdup (account_name);
info->user_data = user_data;
/* Get the message size limit */
/* Set account busy */
modest_account_mgr_set_account_busy(mgr, account_name, TRUE);
- priv->account_name = g_strdup(account_name);
modest_mail_operation_notify_start (self);
thread = g_thread_create (update_account_thread, info, FALSE, NULL);
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
- /* Set the account back to not busy */
- if (priv->account_name) {
- modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr(),
- priv->account_name, FALSE);
- g_free(priv->account_name);
- priv->account_name = NULL;
- }
-
/* Notify the observers about the mail operation end. We do
not wrapp this emission because we assume that this
function is always called from within the main lock */
g_object_unref (per_account_outbox);
}
-
/*
* This function will be used for both adding new accounts and for the
* initialization. In the initialization we do not want to emit
store_account = create_tny_account (self, account, TNY_ACCOUNT_TYPE_STORE);
transport_account = create_tny_account (self, account, TNY_ACCOUNT_TYPE_TRANSPORT);
- /* Add to the list, and notify the observers */
- if (store_account) {
- tny_list_append (priv->store_accounts, G_OBJECT (store_account));
- if (notify)
- g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, store_account);
- g_object_unref (store_account);
- }
+ g_assert (store_account);
+ g_assert (transport_account);
- /* Add to the list, and notify the observers */
- if (transport_account) {
- /* Add account to the list */
- tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
- g_assert (TNY_IS_ACCOUNT (transport_account));
-
- /* Create a new pseudo-account with an outbox for this
- transport account and add it to the global outbox
- in the local account */
- add_outbox_from_transport_account_to_global_outbox (self, account, transport_account);
-
- if (notify) {
- TnyAccount *local_account = NULL;
-
- /* Notify that the local account changed */
- local_account = modest_tny_account_store_get_local_folders_account (self);
- g_signal_emit (G_OBJECT (self), signals [ACCOUNT_CHANGED_SIGNAL], 0, local_account);
- g_object_unref (local_account);
-
- /* Notify the observers about the new account */
- g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, transport_account);
- }
+ /* Add accounts to the lists */
+ tny_list_append (priv->store_accounts, G_OBJECT (store_account));
+ tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
- g_object_unref (transport_account);
+ /* Create a new pseudo-account with an outbox for this
+ transport account and add it to the global outbox
+ in the local account */
+ add_outbox_from_transport_account_to_global_outbox (self, account, transport_account);
+
+ /* Notify the observers. We do it after everything is
+ created */
+ if (notify) {
+ TnyAccount *local_account = NULL;
+
+ /* Notify the observers about the new server & transport accounts */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, store_account);
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, transport_account);
+
+ /* Notify that the local account changed */
+ local_account = modest_tny_account_store_get_local_folders_account (self);
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_CHANGED_SIGNAL], 0, local_account);
+ g_object_unref (local_account);
}
+
+ /* Frees */
+ g_object_unref (store_account);
+ g_object_unref (transport_account);
}
static void
TnyFolder *folder,
gpointer user_data);
-static void _on_send_receive_progress_changed (ModestMailOperation *mail_op,
- ModestMailOperationState *state,
- gpointer user_data);
+static void on_send_receive_finished (ModestMailOperation *mail_op,
+ gpointer user_data);
static gint header_list_count_uncached_msgs (TnyList *header_list);
static gboolean connect_to_get_msg (
modest_ui_actions_send_receive_error_handler,
NULL);
- g_signal_connect (G_OBJECT(mail_op), "progress-changed",
- G_CALLBACK (_on_send_receive_progress_changed),
+ g_signal_connect (G_OBJECT(mail_op), "operation-finished",
+ G_CALLBACK (on_send_receive_finished),
win);
/* Send & receive. */
}
static void
-_on_send_receive_progress_changed (ModestMailOperation *mail_op,
- ModestMailOperationState *state,
- gpointer user_data)
+on_send_receive_finished (ModestMailOperation *mail_op,
+ gpointer user_data)
{
- g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data));
-
/* Set send/receive operation finished */
- if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
- modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data));
-
+ modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW (user_data));
}
#include <modest-widget-memory.h>
#include <modest-ui-actions.h>
#include "modest-dnd.h"
+#include "widgets/modest-window.h"
/* Folder view drag types */
const GtkTargetEntry folder_view_drag_types[] =
}
static void
+on_connection_status_changed (TnyAccount *self,
+ TnyConnectionStatus status,
+ gpointer user_data)
+{
+ /* If the account becomes online then refresh it */
+ if (status == TNY_CONNECTION_STATUS_CONNECTED) {
+ const gchar *acc_name;
+ GtkWidget *my_window;
+
+ my_window = gtk_widget_get_ancestor (GTK_WIDGET (user_data), MODEST_TYPE_WINDOW);
+ acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (self);
+ modest_ui_actions_do_send_receive (acc_name, MODEST_WINDOW (my_window));
+ }
+}
+
+static void
on_account_inserted (TnyAccountStore *account_store,
TnyAccount *account,
gpointer user_data)
tny_list_append (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
G_OBJECT (account));
+
+ /* When the store account gets online refresh it */
+ g_signal_connect (account, "connection_status_changed",
+ G_CALLBACK (on_connection_status_changed),
+ MODEST_FOLDER_VIEW (user_data));
}