{ "/_Edit", NULL, NULL, 0, "<Branch>", NULL },
{ "/Edit/_Undo", "<CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_UNDO },
{ "/Edit/_Redo", "<shift><CTRL>Z", NULL, 0, "<StockItem>", GTK_STOCK_REDO },
- { "/File/sep1", NULL, NULL, 0, "<Separator>", NULL },
+ { "/Edit/sep1", NULL, NULL, 0, "<Separator>", NULL },
{ "/Edit/Cut", "<control>X", NULL, 0, "<StockItem>", GTK_STOCK_CUT },
{ "/Edit/Copy", "<CTRL>C", NULL, 0, "<StockItem>", GTK_STOCK_COPY },
{ "/Edit/Paste", NULL, NULL, 0, "<StockItem>", GTK_STOCK_PASTE},
- { "/Edit/sep1", NULL, NULL, 0, "<Separator>", NULL },
+ { "/Edit/sep2", NULL, NULL, 0, "<Separator>", NULL },
{ "/Edit/Delete", "<CTRL>Q", NULL, 0, "<Item>" ,NULL},
{ "/Edit/Select all", "<CTRL>A", NULL, 0, "<Item>" ,NULL},
{ "/Edit/Deelect all", "<Shift><CTRL>A", NULL, 0, "<Item>" ,NULL},
return retval;
}
+
+gboolean
+modest_account_mgr_unset (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ gboolean server_account,
+ GError **err)
+{
+ ModestAccountMgrPrivate *priv;
+
+ gchar *keyname;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (name, FALSE);
+ g_return_val_if_fail (key, FALSE);
+
+ keyname = get_account_keyname (name, key, server_account);
+
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ retval = modest_conf_remove_key (priv->modest_conf, keyname, err);
+
+ g_free (keyname);
+ return retval;
+}
+
/* must be freed by caller */
static gchar *
get_account_keyname (const gchar * accname, const gchar * name, gboolean server_account)
* @server_account: if TRUE, this is a server account
* @err: a GError ptr, or NULL to ignore.
*
- * set a config string for an account
+ * set a config string for an account.
*
* Returns: TRUE if setting the value succeeded, or FALSE in case of error.
* @err gives details in case of error
GError **err);
+/**
+ * modest_account_mgr_get_list:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to get
+ * @list_type: the type of the members of the list
+ * @server_account: if TRUE, this is a server account
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * get a config list of values of type @list_type of an account
+ *
+ * Returns: a newly allocated list of elements
+ * @err gives details in case of error
+ */
GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
const gchar *name,
const gchar *key,
ModestConfValueType list_type,
gboolean server_account,
GError **err);
+
+/**
+ * modest_account_mgr_unset:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to unset
+ * @server_account: if TRUE, this is a server account
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * unsets the config value of an account and all their children keys
+ *
+ * Returns: TRUE if unsetting the value succeeded, or FALSE in case of error.
+ * @err gives details in case of error
+ */
+gboolean modest_account_mgr_unset (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ gboolean server_account,
+ GError **err);
+
G_END_DECLS
#endif /* __MODEST_ACCOUNT_MGR_H__ */
gboolean modest_conf_get_bool (ModestConf* self, const gchar* key, GError **err);
+/**
+ * modest_conf_get_list:
+ * @self: a ModestConf instance
+ * @key: the key of the value to retrieve
+ * @list_type: the type of the elements of the list
+ * @err: a GError ptr, or NULL to ignore.
+ *
+ * get a list of values from the configuration system
+ *
+ * Returns: a list with the values for the key, or NULL in case of error
+ * @err gives details in case of error
+ */
+GSList * modest_conf_get_list (ModestConf* self, const gchar* key,
+ ModestConfValueType list_type, GError **err);
/**
* modest_conf_set_string:
VOID:STRING,INT,INT
VOID:STRING,BOOL
VOID:STRING,STRING,BOOL
-VOID:STRING,POINTER,POINTER
+VOID:STRING,POINTER,POINTER,POINTER
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(ModestTnyAccountStoreClass, password_requested),
NULL, NULL,
- modest_marshal_VOID__STRING_POINTER_POINTER,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);
+ modest_marshal_VOID__STRING_POINTER_POINTER_POINTER,
+ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
signals[ACCOUNT_UPDATE_SIGNAL] =
g_signal_new ("account_update",
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
/* is it in the hash? if it's already there, it must be wrong... */
- pwd = g_hash_table_lookup (priv->password_hash, key);
- already_asked = (pwd != NULL);
+ already_asked = g_hash_table_lookup_extended (priv->password_hash,
+ key, NULL, (gpointer *) &pwd);
/* if the password is not already there, try ModestConf */
if (!already_asked) {
/* we don't have it yet. we emit a signal to get the password somewhere */
const gchar* name = tny_account_get_name (account);
+ gboolean remember;
pwd = NULL;
gdk_threads_enter ();
g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
- name, &pwd, cancel);
-
- if (!*cancel) {/* TODO: if remember the password */
- modest_account_mgr_set_string (priv->account_mgr,
- key, MODEST_ACCOUNT_PASSWORD,
- pwd, TRUE, NULL);
+ name, &pwd, cancel, &remember);
+
+ if (!*cancel) {
+ if (remember)
+ modest_account_mgr_set_string (priv->account_mgr,
+ key, MODEST_ACCOUNT_PASSWORD,
+ pwd,
+ TRUE, NULL);
/* We need to dup the string even knowing that
it's already a dup of the contents of an
- entry, because it if it's wrong then camel
+ entry, because it if it's wrong, then camel
will free it */
g_hash_table_insert (priv->password_hash, g_strdup (key), g_strdup(pwd));
} else {
ModestTnyAccountStore *self;
ModestTnyAccountStorePrivate *priv;
const TnyAccountStore *account_store;
+ gchar *pwd;
+ const gchar *key;
account_store = TNY_ACCOUNT_STORE(get_account_store_for_account (account));
self = MODEST_TNY_ACCOUNT_STORE (account_store);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+ key = tny_account_get_id (account);
+
+ /* Do not remove the key, this will allow us to detect that we
+ have already asked for it at least once */
+ pwd = g_hash_table_lookup (priv->password_hash, key);
+ if (pwd) {
+ memset (pwd, 0, strlen (pwd));
+ g_hash_table_insert (priv->password_hash, g_strdup (key), NULL);
+ }
+
+ /* Remove from configuration system */
+ modest_account_mgr_unset (priv->account_mgr,
+ key, MODEST_ACCOUNT_PASSWORD,
+ TRUE, NULL);
}
static void on_online_toggle_toggled (GtkToggleButton *toggle, ModestWidgetFactory *factory);
static void on_password_requested (ModestTnyAccountStore *account_store, const gchar* account_name,
- gchar **password, gboolean *cancel, ModestWidgetFactory *self);
+ gchar **password, gboolean *cancel, gboolean *remember, ModestWidgetFactory *self);
static void on_item_not_found (ModestHeaderView* header_view, ModestItemType type,
ModestWidgetFactory *self);
GTK_BUTTONS_OK,
_("The %s you selected cannot be found"),
item);
+ gdk_threads_enter ();
gtk_dialog_run (GTK_DIALOG(dialog));
+ gdk_threads_leave ();
} else {
dialog = gtk_dialog_new_with_buttons (_("Connection requested"),
g_free (txt);
gtk_window_set_default_size (GTK_WINDOW(dialog), 300, 300);
+ gdk_threads_enter ();
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
tny_device_force_online (device);
+ gdk_threads_leave ();
}
gtk_widget_destroy (dialog);
}
static void
on_password_requested (ModestTnyAccountStore *account_store, const gchar* account_name,
- gchar **password, gboolean *cancel, ModestWidgetFactory *self)
+ gchar **password, gboolean *cancel, gboolean *remember, ModestWidgetFactory *self)
{
gchar *txt;
GtkWidget *dialog, *entry, *remember_pass_check;
*password = NULL;
*cancel = TRUE;
}
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (remember_pass_check)))
+ *remember = TRUE;
+ else
+ *remember = FALSE;
+
gtk_widget_destroy (dialog);
}