- if (priv->pw_invalid==PW_NOT_INVALID) {
- retval = modest_account_mgr_get_string (priv->account_mgr,
- key,
- MODEST_ACCOUNT_PASSWORD,
- TRUE,
- NULL);
- } else {
- retval = priv->get_pass_func(account, prompt, cancel);
- if (!*cancel) {
- priv->pw_invalid=PW_NOT_INVALID;
- modest_account_mgr_set_string(priv->account_mgr,
- key,
- MODEST_ACCOUNT_PASSWORD,
- retval, TRUE,
- NULL);
- }
- }
- return retval;
+ /* is it in the conf? */
+ pwd = modest_account_mgr_get_string (priv->account_mgr,
+ key, MODEST_ACCOUNT_PASSWORD,
+ TRUE, NULL);
+ if (!pwd || strlen(pwd) == 0) {
+ /* we don't have it yet. we emit a signal to get the password somewhere */
+ const gchar* name = tny_account_iface_get_name (account);
+ *cancel = TRUE;
+ pwd = NULL;
+ g_signal_emit (G_OBJECT(self), signals[PASSWORD_REQUESTED_SIGNAL], 0,
+ name, &pwd, cancel);
+ if (!*cancel) /* remember the password */
+ modest_account_mgr_set_string (priv->account_mgr,
+ key, MODEST_ACCOUNT_PASSWORD,
+ pwd, TRUE, NULL);
+ } else
+ *cancel = FALSE;
+
+ return pwd;