* Fixed a hang when creating the first account, now the accounts are not updated if the status is connecting
pmo-trunk-r3376
gpointer user_data);
static void
-on_account_changed (ModestAccountMgr* mgr,
- const gchar* account,
- gpointer user_data);
+on_default_account_changed (ModestAccountMgr* mgr,
+ gpointer user_data);
static gboolean on_inner_widgets_key_pressed (GtkWidget *widget,
GdkEventKey *event,
/* Signal handler UIDs */
GList *queue_err_signals;
GSList *sighandlers;
-
- ModestConfNotificationId notification_id;
};
#define MODEST_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_MAIN_WINDOW, \
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
- if (priv->notification_id) {
- modest_conf_forget_namespace (modest_runtime_get_conf (),
- MODEST_CONF_NAMESPACE,
- priv->notification_id);
- }
-
/* Sanity check: shouldn't be needed, the window mgr should
call this function before */
modest_main_window_disconnect_signals (MODEST_WINDOW (obj));
"queue-changed", G_CALLBACK (on_queue_changed), self);
/* Track changes in the device name */
- priv->notification_id = modest_conf_listen_to_namespace (modest_runtime_get_conf (),
- MODEST_CONF_NAMESPACE);
priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT(modest_runtime_get_conf ()),
"key_changed", G_CALLBACK (on_configuration_key_changed),
self);
/* We need to refresh the send & receive menu to change the bold
* account when the default account changes. */
- priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,G_OBJECT (modest_runtime_get_account_mgr ()),
- "account_changed", G_CALLBACK (on_account_changed),
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (modest_runtime_get_account_mgr ()),
+ "default_account_changed",
+ G_CALLBACK (on_default_account_changed),
self);
/* Account store */
}
static void
-on_account_changed (ModestAccountMgr* mgr,
- const gchar* account,
- gpointer user_data)
+on_default_account_changed (ModestAccountMgr* mgr,
+ gpointer user_data)
{
- gchar *default_account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr ());
-
- /* Actually, we only want to know when another account has become
- * the default account, but there is no default_account_changed
- * signal in ModestAccountMgr. */
- if(strcmp(account, default_account) == 0)
- update_menus (MODEST_MAIN_WINDOW (user_data));
-
- g_free (default_account);
+ update_menus (MODEST_MAIN_WINDOW (user_data));
}
static void
ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
TnyAccount *account = NULL;
- if (!key ||
- priv->notification_id != id ||
- strcmp (key, MODEST_CONF_DEVICE_NAME))
+ if (!key || strcmp (key, MODEST_CONF_DEVICE_NAME))
return;
if (priv->contents_style != MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS)
return;
+
if (priv->folder_view)
account = (TnyAccount *) modest_folder_view_get_selected (priv->folder_view);
+
if (account && TNY_IS_ACCOUNT (account) &&
strcmp (tny_account_get_id (account), MODEST_LOCAL_FOLDERS_ACCOUNT_ID) == 0) {
GList *children;
ACCOUNT_CHANGED_SIGNAL,
ACCOUNT_REMOVED_SIGNAL,
ACCOUNT_BUSY_SIGNAL,
+ DEFAULT_ACCOUNT_CHANGED_SIGNAL,
LAST_SIGNAL
};
while (cursor) {
const gchar *account = cursor->data;
if (account)
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
+ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
account);
cursor = g_slist_next (cursor);
}
gboolean is_server_account;
gchar* account_name = NULL;
- /* there is only one not-really-account key which will still emit
- * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
+ /* Notify that the default account has changed */
if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- /* Get the default account instead. */
- gchar *default_account = modest_account_mgr_get_default_account (self);
- if (!default_account) {
- g_warning ("BUG: cannot find default account");
- return;
- } else {
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
- default_account);
- g_free(default_account);
- return;
- }
+ g_signal_emit (G_OBJECT(self), signals[DEFAULT_ACCOUNT_CHANGED_SIGNAL], 0);
+ return;
}
is_account_key = FALSE;
if (!account_name)
return;
- /* ignore server account changes */
- if (is_server_account)
- /* change in place: retrieve the parent account name */
- get_account_name_from_server_account (account_name);
-
/* account was removed. Do not emit an account removed signal
because it was already being done in the remove_account
method. Do not notify also the removal of the server
return;
}
+ /* ignore server account changes */
+ if (is_server_account)
+ /* change in place: retrieve the parent account name */
+ get_account_name_from_server_account (account_name);
+
/* is this account enabled? */
gboolean enabled = FALSE;
if (is_server_account)
account_name);
/* hmm, small race when this object is destroyed within
* 500ms of the last change, and there are multiple timeouts... */
- priv->timeout = g_timeout_add (500, (GSourceFunc)on_timeout_notify_changes,
+ priv->timeout = g_timeout_add (500, (GSourceFunc) on_timeout_notify_changes,
self);
- }
+ }
}
g_free (account_name);
}
g_signal_new ("account_inserted",
MODEST_TYPE_ACCOUNT_MGR,
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(ModestAccountMgrClass,account_inserted),
+ G_STRUCT_OFFSET(ModestAccountMgrClass, account_inserted),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
g_signal_new ("account_removed",
MODEST_TYPE_ACCOUNT_MGR,
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(ModestAccountMgrClass,account_removed),
+ G_STRUCT_OFFSET(ModestAccountMgrClass, account_removed),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
g_signal_new ("account_changed",
MODEST_TYPE_ACCOUNT_MGR,
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(ModestAccountMgrClass,account_changed),
+ G_STRUCT_OFFSET(ModestAccountMgrClass, account_changed),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ G_TYPE_NONE, 1, G_TYPE_STRING);
signals[ACCOUNT_BUSY_SIGNAL] =
g_signal_new ("account_busy_changed",
MODEST_TYPE_ACCOUNT_MGR,
G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(ModestAccountMgrClass,account_busy_changed),
+ G_STRUCT_OFFSET(ModestAccountMgrClass, account_busy_changed),
NULL, NULL,
modest_marshal_VOID__STRING_BOOLEAN,
G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ signals[DEFAULT_ACCOUNT_CHANGED_SIGNAL] =
+ g_signal_new ("default_account_changed",
+ MODEST_TYPE_ACCOUNT_MGR,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(ModestAccountMgrClass, default_account_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
modest_account_mgr_initialized = TRUE;
}
}
const gchar* account,
gboolean busy,
gpointer user_data);
+
+ void (* default_account_changed)(ModestAccountMgr *obj,
+ gpointer user_data);
};
/**
{
GConfClient *conf = NULL;
ModestConfPrivate *priv = MODEST_CONF_GET_PRIVATE(obj);
-/* GError *err = NULL; */
+ GError *err = NULL;
-
priv->gconf_client = NULL;
conf = gconf_client_get_default ();
g_printerr ("modest: could not get gconf client\n");
return;
}
-/* gconf_client_add_dir (conf,MODEST_CONF_NAMESPACE, */
-/* GCONF_CLIENT_PRELOAD_NONE, */
-/* &err); */
-/* if (err) { */
-/* g_printerr ("modest: error %d with gconf_client_add_dir: '%s'\n", */
-/* err->code, err->message); */
-/* g_object_unref (conf); */
-/* g_error_free (err); */
-/* return; */
-/* } */
-
-/* gconf_client_notify_add (conf, MODEST_CONF_NAMESPACE, */
-/* modest_conf_on_change, */
-/* obj, NULL, &err); */
-/* if (err) { */
-/* g_printerr ("modest: gconf_client_notify_add error %d: '%s'\n", */
-/* err->code, err->message); */
-/* g_object_unref (conf); */
-/* g_error_free (err); */
-/* return; */
-/* } */
+
priv->gconf_client = conf; /* all went well! */
}
TnyAccount *tny_account;
tny_account = TNY_ACCOUNT (tny_iterator_get_current (iter));
if (tny_account) {
- const gchar* parent_name =
- modest_tny_account_get_parent_modest_account_name_for_server_account (tny_account);
- if (parent_name && strcmp (parent_name, account_name) == 0) {
- found = TRUE;
- modest_tny_account_update_from_account (tny_account, acc_mgr, account_name, type);
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, tny_account);
+ TnyConnectionStatus conn_status = tny_account_get_connection_status (tny_account);
+
+ if (conn_status != TNY_CONNECTION_STATUS_RECONNECTING &&
+ conn_status != TNY_CONNECTION_STATUS_INIT) {
+ const gchar* parent_name;
+ parent_name = modest_tny_account_get_parent_modest_account_name_for_server_account (tny_account);
+ if (parent_name && strcmp (parent_name, account_name) == 0) {
+ found = TRUE;
+ modest_tny_account_update_from_account (tny_account, acc_mgr, account_name, type);
+ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, tny_account);
+ }
}
g_object_unref (tny_account);
}
{
ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
- g_debug ("DEBUG: modest: %s\n", __FUNCTION__);
+/* g_debug ("DEBUG: modest: %s\n", __FUNCTION__); */
- /* Ignore the change if it's a change in the last_updated value */
-// if (key && g_str_has_suffix ((const gchar *) key, MODEST_ACCOUNT_LAST_UPDATED))
-// return;
+/* /\* Ignore the change if it's a change in the last_updated value *\/ */
+/* if (key && g_str_has_suffix ((const gchar *) key, MODEST_ACCOUNT_LAST_UPDATED)) */
+/* return; */
if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_STORE))
g_warning ("%s: failed to update store account for %s", __FUNCTION__, account_name);
}
gchar *account_name = NULL;
- gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name,
- -1);
+ gtk_tree_model_get (model, &iter,
+ MODEST_ACCOUNT_VIEW_NAME_COLUMN,
+ &account_name, -1);
/* Set this previously-non-default account as the default: */
- if (modest_account_mgr_set_default_account (priv->account_mgr, account_name))
- {
+ if (modest_account_mgr_set_default_account (priv->account_mgr, account_name)) {
/* Explicitely set default column because we are ignoring gconf changes */
GtkTreeIter old_default_iter;
if (find_default_account (self, &old_default_iter)) {
* Track changes in the local account name (in the device it
* will be the device name)
*/
- priv->notification_id = modest_conf_listen_to_namespace (conf,
+ priv->notification_id = modest_conf_listen_to_namespace (conf,
MODEST_CONF_NAMESPACE);
priv->conf_key_signal = g_signal_connect (G_OBJECT(conf),
"key_changed",