account_name,
store_name,
transport_name, TRUE);
- modest_account_mgr_set_string (priv->account_mgr,
- account_name,
- MODEST_ACCOUNT_FULLNAME,
- get_fullname(self), FALSE);
- modest_account_mgr_set_string (priv->account_mgr,
- account_name,
- MODEST_ACCOUNT_EMAIL,
- get_email(self), FALSE);
+
+ modest_account_mgr_set_server_account_user_fullname (priv->account_mgr, account_name,
+ get_fullname (self));
+ modest_account_mgr_set_server_account_user_email (priv->account_mgr, account_name,
+ get_email (self));
/* Frees */
g_free (store_name);
/* 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_string (self->account_manager, account_name,
- MODEST_ACCOUNT_FULLNAME, user_name, FALSE /* not server account */);
+ 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_string (self->account_manager, account_name,
- MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */);
+ modest_account_mgr_set_server_account_user_email (self->account_manager, account_name, emailaddress);
/* Set the display name: */
- modest_account_mgr_set_string (self->account_manager, account_name,
- MODEST_ACCOUNT_DISPLAY_NAME, display_name, FALSE /* not server account */);
+ 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_string (self->account_manager, account_name,
- MODEST_ACCOUNT_RETRIEVE, retrieve, FALSE /* not server account */);
+ 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,
#include "maemo/modest-signature-editor-dialog.h"
#include "maemo/modest-maemo-utils.h"
#include "widgets/modest-ui-constants.h"
-
-#include <tny-camel-transport-account.h>
-#include <tny-camel-imap-store-account.h>
-#include <tny-camel-pop-store-account.h>
+#include <tny-account.h>
#include <tny-status.h>
#include <gconf/gconf-client.h>
}
static void
-show_error (GtkWidget *parent_widget, const gchar* text);
-
-static void
on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data);
static void
tmp = g_strndup (account_title_forbidden_chars, ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH);
msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
- show_error (GTK_WIDGET (self), msg);
+ hildon_banner_show_information(GTK_WIDGET (self), NULL, msg);
g_free (msg);
g_free (tmp);
tmp = g_strndup (user_name_forbidden_chars, USER_NAME_FORBIDDEN_CHARS_LENGTH);
msg = g_strdup_printf (_CS("ckdg_ib_illegal_characters_entered"), tmp);
- show_error (GTK_WIDGET (self), msg);
+ hildon_banner_show_information(GTK_WIDGET (self), NULL, msg);
g_free (msg);
g_free (tmp);
static void
on_entry_max (ModestValidatingEntry *self, gpointer user_data)
{
- /* ModestAccountSettingsDialog *dialog = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); */
- show_error (GTK_WIDGET (self), _CS("ckdg_ib_maximum_characters_reached"));
+ hildon_banner_show_information(GTK_WIDGET (self), NULL,
+ _CS("ckdg_ib_maximum_characters_reached"));
}
static GtkWidget*
modest_signature_editor_dialog_set_settings (
MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog),
use_signature, signature, account_title);
+
g_free (account_title);
account_title = NULL;
g_free (signature);
port > PORT_MAX) {
/* Warn the user via a dialog: */
- /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
gchar *message = g_strdup_printf (_CS("ckct_ib_set_a_value_within_range"),
min,
max);
if (!modest_text_utils_validate_email_address (email_address, NULL)) {
/* Warn the user via a dialog: */
- /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email"));
/* Return focus to the email address entry: */
if (!modest_text_utils_validate_domain_name (hostname)) {
/* Warn the user via a dialog: */
- /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_servername"));
/* Return focus to the email address entry: */
if (!modest_text_utils_validate_domain_name (hostname2)) {
/* Warn the user via a dialog: */
- /*show_error (GTK_WINDOW (self), _("mcen_ib_invalid_email"));*/
hildon_banner_show_information (self->entry_outgoingserver, NULL, _("mcen_ib_invalid_servername"));
/* Return focus to the email address entry: */
{
if(error == NULL || error->domain != modest_maemo_utils_get_supported_secure_authentication_error_quark() ||
error->code != MODEST_MAEMO_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
- {
- show_error (GTK_WIDGET (self), _("Could not discover supported secure authentication methods."));
- }
+ hildon_banner_show_information(GTK_WIDGET (self), NULL,
+ _("Could not discover supported secure authentication methods."));
if(error != NULL)
g_error_free(error);
if (saved) {
/* Do not show the account-saved dialog if we are just saving this
* temporarily, because from the user's point of view it will not
- * really be saved (saved + enabled) until later.
+ * really be saved (saved + enabled) until later
*/
- const gboolean enabled =
- modest_account_mgr_get_enabled (self->account_manager, self->account_name);
- if (enabled)
- show_error (NULL, _("mcen_ib_advsetup_settings_saved"));
+ if (modest_account_mgr_get_enabled (self->account_manager,
+ self->account_name)) {
+ gchar *incoming_account_name = NULL, *outgoing_account_name = NULL;
+
+ incoming_account_name =
+ modest_account_mgr_get_server_account_name (self->account_manager,
+ self->account_name,
+ TNY_ACCOUNT_TYPE_STORE);
+ outgoing_account_name =
+ modest_account_mgr_get_server_account_name (self->account_manager,
+ self->account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+
+ if (incoming_account_name) {
+ modest_account_mgr_notify_account_update (self->account_manager,
+ incoming_account_name);
+ g_free (incoming_account_name);
+ }
+ if (outgoing_account_name) {
+ modest_account_mgr_notify_account_update (self->account_manager,
+ outgoing_account_name);
+ g_free (outgoing_account_name);
+ }
+
+ hildon_banner_show_information(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
+ }
+ }
+ else {
+ hildon_banner_show_information (NULL, NULL, _("mail_ib_setting_failed"));
}
- else
- show_error (NULL, _("mail_ib_setting_failed"));
}
}
}
if (incoming_account)
modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), incoming_account->proto);
- gchar *retrieve = modest_account_mgr_get_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_RETRIEVE, FALSE /* not server account */);
+
+
+ gchar *retrieve = modest_account_mgr_get_retrieve_type (dialog->account_manager, account_name);
if (!retrieve) {
/* Default to something, though no default is specified in the UI spec: */
retrieve = g_strdup (MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY);
modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), retrieve);
g_free (retrieve);
- const gint limit_retrieve = modest_account_mgr_get_int (dialog->account_manager, account_name,
- MODEST_ACCOUNT_LIMIT_RETRIEVE, FALSE /* not server account */);
+ const gint limit_retrieve = modest_account_mgr_get_retrieve_limit (dialog->account_manager, account_name);
modest_limit_retrieve_combo_box_set_active_limit_retrieve (MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve), limit_retrieve);
- const gboolean leave_on_server = modest_account_mgr_get_bool (dialog->account_manager, account_name,
- MODEST_ACCOUNT_LEAVE_ON_SERVER, FALSE /* not server account */);
+ const gboolean leave_on_server = modest_account_mgr_get_leave_on_server (dialog->account_manager, account_name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages), leave_on_server);
/* Only show the leave-on-server checkbox for POP,
* If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
* TODO: Do we need to discover which of these (SSL, TLS, CRAM-MD5) is supported?
*/
- const ModestConnectionProtocol security = modest_server_account_get_security (
+ const ModestConnectionProtocol security = modest_account_mgr_get_server_account_security (
dialog->account_manager, incoming_account->account_name);
modest_serversecurity_combo_box_set_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security), security);
OR
- use encrypted passwords
*/
- const ModestAuthProtocol secure_auth = modest_server_account_get_secure_auth(
+ const ModestAuthProtocol secure_auth = modest_account_mgr_get_server_account_secure_auth(
dialog->account_manager, incoming_account->account_name);
dialog->protocol_authentication_incoming = secure_auth;
if (modest_protocol_info_auth_is_secure(secure_auth))
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
- TRUE);
+ TRUE);
}
else
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
- FALSE);
+ FALSE);
};
update_incoming_server_title (dialog, incoming_account->proto);
- const gint port_num = modest_account_mgr_get_int (dialog->account_manager, incoming_account->account_name,
- MODEST_ACCOUNT_PORT, TRUE /* server account */);
-
+ const gint port_num = modest_account_mgr_get_server_account_port (dialog->account_manager,
+ incoming_account->account_name);
if (port_num == 0) {
/* Show the appropriate port number: */
on_combo_incoming_security_changed (
outgoing_account->password ? outgoing_account->password : "");
/* Get the secure-auth setting: */
- const ModestAuthProtocol secure_auth = modest_server_account_get_secure_auth(
+ const ModestAuthProtocol secure_auth = modest_account_mgr_get_server_account_secure_auth(
dialog->account_manager, outgoing_account->account_name);
modest_secureauth_combo_box_set_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto);
/* Get the security setting: */
- const ModestConnectionProtocol security = modest_server_account_get_security (
+ const ModestConnectionProtocol security = modest_account_mgr_get_server_account_security (
dialog->account_manager, outgoing_account->account_name);
modest_serversecurity_combo_box_set_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
- const gint port_num = modest_account_mgr_get_int (dialog->account_manager, outgoing_account->account_name,
- MODEST_ACCOUNT_PORT, TRUE /* server account */);
+ const gint port_num = modest_account_mgr_get_server_account_port (dialog->account_manager,
+ outgoing_account->account_name);
if (port_num == 0) {
/* Show the appropriate port number: */
on_combo_outgoing_security_changed (
const gchar* account_name = dialog->account_name;
/* Set the account data from the widgets: */
- const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
- gboolean test = modest_account_mgr_set_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_FULLNAME, user_name, FALSE /* not server account */);
- if (!test)
- return FALSE;
-
+ 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);
+
const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
- test = modest_account_mgr_set_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_EMAIL, emailaddress, FALSE /* not server account */);
- if (!test)
- return FALSE;
+ modest_account_mgr_set_server_account_user_email (dialog->account_manager, account_name,
+ emailaddress);
/* Signature: */
if (dialog->signature_dialog) {
gboolean use_signature = FALSE;
- gchar *signature = modest_signature_editor_dialog_get_settings (
- MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog),
- &use_signature);
+ gchar *signature =
+ modest_signature_editor_dialog_get_settings (MODEST_SIGNATURE_EDITOR_DIALOG (dialog->signature_dialog),
+ &use_signature);
- modest_account_mgr_set_signature(dialog->account_manager, account_name,
- signature, use_signature);
- g_free (signature);
- }
+ modest_account_mgr_set_signature(dialog->account_manager, account_name,
+ signature, use_signature);
+ g_free (signature);
+ }
gchar *retrieve = modest_retrieve_combo_box_get_active_retrieve_conf (
MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));
- modest_account_mgr_set_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_RETRIEVE, retrieve, FALSE /* not server account */);
+ modest_account_mgr_set_retrieve_type (dialog->account_manager, account_name, (const gchar*) retrieve);
g_free (retrieve);
const gint limit_retrieve = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve));
- modest_account_mgr_set_int (dialog->account_manager, account_name,
- MODEST_ACCOUNT_LIMIT_RETRIEVE, limit_retrieve, FALSE /* not server account */);
+ modest_account_mgr_set_retrieve_limit (dialog->account_manager, account_name, limit_retrieve);
const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages));
- test = modest_account_mgr_set_bool (dialog->account_manager, account_name,
- MODEST_ACCOUNT_LEAVE_ON_SERVER, leave_on_server, FALSE /* not server account */);
- if (!test)
- return FALSE;
+ modest_account_mgr_set_leave_on_server (dialog->account_manager, account_name, leave_on_server);
/* Incoming: */
- gchar* incoming_account_name = modest_account_mgr_get_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_STORE_ACCOUNT, FALSE /* not server account */);
+ gchar* incoming_account_name =
+ modest_account_mgr_get_server_account_name (dialog->account_manager,
+ account_name,
+ TNY_ACCOUNT_TYPE_STORE);
g_assert (incoming_account_name);
const gchar* hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_incomingserver));
- test = modest_account_mgr_set_string (dialog->account_manager, incoming_account_name,
- MODEST_ACCOUNT_HOSTNAME, hostname, TRUE /* server account */);
- if (!test)
- return FALSE;
+ modest_account_mgr_set_server_account_hostname (dialog->account_manager, incoming_account_name, hostname);
const gchar* username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_username));
- modest_server_account_set_username (dialog->account_manager, incoming_account_name, username);
+ modest_account_mgr_set_server_account_username (dialog->account_manager, incoming_account_name, username);
const gchar* password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_password));
- modest_server_account_set_password (dialog->account_manager, incoming_account_name, password);
+ modest_account_mgr_set_server_account_password (dialog->account_manager, incoming_account_name,
+ password);
/* port: */
gint port_num = hildon_number_editor_get_value (
HILDON_NUMBER_EDITOR (dialog->entry_incoming_port));
- modest_account_mgr_set_int (dialog->account_manager, incoming_account_name,
- MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
+ modest_account_mgr_set_server_account_port (dialog->account_manager, incoming_account_name, port_num);
/* The UI spec says:
* If secure authentication is unchecked, allow sending username and password also as plain text.
const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
- modest_server_account_set_security (dialog->account_manager, incoming_account_name, protocol_security_incoming);
+ modest_account_mgr_set_server_account_security (dialog->account_manager, incoming_account_name, protocol_security_incoming);
- modest_server_account_set_secure_auth (dialog->account_manager, incoming_account_name, dialog->protocol_authentication_incoming);
+ modest_account_mgr_set_server_account_secure_auth (dialog->account_manager, incoming_account_name, dialog->protocol_authentication_incoming);
g_free (incoming_account_name);
/* Outgoing: */
- gchar* outgoing_account_name = modest_account_mgr_get_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_TRANSPORT_ACCOUNT, FALSE /* not server account */);
+ gchar* outgoing_account_name =
+ modest_account_mgr_get_server_account_name (dialog->account_manager,
+ account_name,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
g_assert (outgoing_account_name);
hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoingserver));
- test = modest_account_mgr_set_string (dialog->account_manager, outgoing_account_name,
- MODEST_ACCOUNT_HOSTNAME, hostname, TRUE /* server account */);
- if (!test)
- return FALSE;
+ modest_account_mgr_set_server_account_hostname (dialog->account_manager, outgoing_account_name, hostname);
username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
- modest_server_account_set_username (dialog->account_manager, outgoing_account_name,
+ modest_account_mgr_set_server_account_username (dialog->account_manager, outgoing_account_name,
username);
password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
- modest_server_account_set_password (dialog->account_manager, outgoing_account_name,
- password);
+ modest_account_mgr_set_server_account_password (dialog->account_manager, outgoing_account_name,
+ password);
const ModestConnectionProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
- modest_server_account_set_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
+ modest_account_mgr_set_server_account_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
const ModestAuthProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
- modest_server_account_set_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);
+ modest_account_mgr_set_server_account_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);
/* port: */
port_num = hildon_number_editor_get_value (
HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
- modest_account_mgr_set_int (dialog->account_manager, outgoing_account_name,
- MODEST_ACCOUNT_PORT, port_num, TRUE /* server account */);
-
+ modest_account_mgr_set_server_account_port (dialog->account_manager,
+ outgoing_account_name,
+ port_num);
g_free (outgoing_account_name);
if (!account_title)
return FALSE; /* Should be prevented already anyway. */
- if (strcmp(account_title, account_name) != 0) {
- /* Change the title: */
- const gboolean test = modest_account_mgr_set_string (dialog->account_manager, account_name,
- MODEST_ACCOUNT_DISPLAY_NAME, account_title, FALSE /* not server account */);
- if (!test) {
- g_free (account_title);
- return FALSE;
- }
- }
-
+/* if (strcmp (account_title, account_name) != 0) { */
+ modest_account_mgr_set_display_name (dialog->account_manager, account_name, account_title);
+/* } */
g_free (account_title);
account_title = NULL;
if (dialog->specific_window) {
return modest_connection_specific_smtp_window_save_server_accounts (
MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
- }
- else
+ } else {
return TRUE;
+ }
}
static gboolean entry_is_empty (GtkWidget *entry)
object_class->dispose = modest_account_settings_dialog_dispose;
object_class->finalize = modest_account_settings_dialog_finalize;
}
-
-static void
-show_error (GtkWidget *parent_widget, const gchar* text)
-{
- hildon_banner_show_information(parent_widget, NULL, text);
-
-#if 0
- GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_widget, text);
- /*
- GtkDialog *dialog = GTK_DIALOG (gtk_message_dialog_new (parent_window,
- (GtkDialogFlags)0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- text ));
- */
-
- gtk_dialog_run (dialog);
- gtk_widget_destroy (GTK_WIDGET (dialog));
-#endif
-}
} else {
/* Change an existing server account: */
- success = modest_account_mgr_set_string (priv->account_manager, server_account_name,
- MODEST_ACCOUNT_HOSTNAME, data->hostname, TRUE /* server account */);
+ modest_account_mgr_set_server_account_hostname (priv->account_manager, server_account_name,
+ data->hostname);
- modest_server_account_set_username (priv->account_manager, server_account_name,
+ modest_account_mgr_set_server_account_username (priv->account_manager, server_account_name,
data->username);
- modest_server_account_set_password (priv->account_manager, server_account_name,
+ modest_account_mgr_set_server_account_password (priv->account_manager, server_account_name,
data->password);
- modest_server_account_set_secure_auth (priv->account_manager, server_account_name,
+ modest_account_mgr_set_server_account_secure_auth (priv->account_manager, server_account_name,
data->secure_auth);
- modest_server_account_set_security (priv->account_manager, server_account_name,
+ modest_account_mgr_set_server_account_security (priv->account_manager, server_account_name,
data->security);
-
- modest_account_mgr_set_int (priv->account_manager, server_account_name,
- MODEST_ACCOUNT_PORT, data->port, TRUE /* server account */);
+
+ modest_account_mgr_set_server_account_port (priv->account_manager, server_account_name, data->port);
}
}
if (server_account_name) {
/* Get the server hostname and show it in the treemodel: */
- gchar *hostname = modest_account_mgr_get_string (priv->account_manager,
- server_account_name, MODEST_ACCOUNT_HOSTNAME, TRUE /* server account */);
+ gchar *hostname = modest_account_mgr_get_server_account_hostname (priv->account_manager,
+ server_account_name);
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
MODEL_COL_SERVER_NAME, hostname,
-1);
time_t last_updated;
gchar *last_updated_string;
/* Get last updated from configuration */
- last_updated = modest_account_mgr_get_int (modest_runtime_get_account_mgr (),
- tny_account_get_id (account),
- MODEST_ACCOUNT_LAST_UPDATED,
- TRUE);
+ last_updated = modest_account_mgr_get_last_updated (modest_runtime_get_account_mgr (),
+ tny_account_get_id (account));
+
if (last_updated > 0)
last_updated_string = modest_text_utils_get_display_date(last_updated);
else
return result;
}
-gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self,
- const gchar* name)
-{
- return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_DISPLAY_NAME, FALSE);
-}
-
-
-
gchar* modest_account_mgr_get_signature (ModestAccountMgr *self, const gchar* name,
gboolean* use_signature)
{
}
gchar*
-modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name)
+modest_account_mgr_get_server_account_username (ModestAccountMgr *self, const gchar* account_name)
{
return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_USERNAME,
TRUE /* server account */);
}
void
-modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name,
+modest_account_mgr_set_server_account_username (ModestAccountMgr *self, const gchar* account_name,
const gchar* username)
{
/* Note that this won't work properly as long as the gconf cache is broken
* in Maemo Bora: */
- gchar *existing_username = modest_server_account_get_username(self,
+ gchar *existing_username = modest_account_mgr_get_server_account_username(self,
account_name);
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
/* We don't know anything about new usernames: */
if (strcmp (existing_username, username) != 0)
- modest_server_account_set_username_has_succeeded (self,
- account_name, FALSE);
+ modest_account_mgr_get_server_account_username_has_succeeded (self, account_name);
g_free (existing_username);
}
gboolean
-modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name)
+modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name)
{
return modest_account_mgr_get_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
TRUE /* server account */);
}
void
-modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
- gboolean succeeded)
+modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
+ const gchar* account_name,
+ gboolean succeeded)
{
modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
succeeded, TRUE /* server account */);
}
void
-modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name,
+modest_account_mgr_set_server_account_password (ModestAccountMgr *self, const gchar* account_name,
const gchar* password)
{
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
gchar*
-modest_server_account_get_password (ModestAccountMgr *self, const gchar* account_name)
+modest_account_mgr_get_server_account_password (ModestAccountMgr *self, const gchar* account_name)
{
return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
TRUE /* server account */);
}
gboolean
-modest_server_account_get_has_password (ModestAccountMgr *self, const gchar* account_name)
+modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self, const gchar* account_name)
{
gboolean result = FALSE;
gchar *password = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
gchar*
-modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name)
+modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
+ const gchar* account_name)
{
- return modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_HOSTNAME,
- TRUE /* server account */);
+ return modest_account_mgr_get_string (self,
+ account_name,
+ MODEST_ACCOUNT_HOSTNAME,
+ TRUE /* server account */);
}
+void
+modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
+ const gchar *server_account_name,
+ const gchar *hostname)
+{
+ modest_account_mgr_set_string (self,
+ server_account_name,
+ MODEST_ACCOUNT_HOSTNAME,
+ hostname,
+ TRUE /* server account */);
+}
+
static ModestAuthProtocol
get_secure_auth_for_conf_string(const gchar* value)
}
ModestAuthProtocol
-modest_server_account_get_secure_auth (ModestAccountMgr *self,
+modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
const gchar* account_name)
{
ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
void
-modest_server_account_set_secure_auth (ModestAccountMgr *self,
+modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
const gchar* account_name, ModestAuthProtocol secure_auth)
{
/* Get the conf string for the enum value: */
}
ModestConnectionProtocol
-modest_server_account_get_security (ModestAccountMgr *self,
+modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
const gchar* account_name)
{
ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
}
void
-modest_server_account_set_security (ModestAccountMgr *self,
+modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
const gchar* account_name, ModestConnectionProtocol security)
{
/* Get the conf string for the enum value: */
g_slice_free (ModestAccountData, data);
}
-
-gchar*
-modest_account_mgr_get_default_account (ModestAccountMgr *self)
-{
- gchar *account;
- ModestConf *conf;
- GError *err = NULL;
-
- g_return_val_if_fail (self, NULL);
-
- conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
- account = modest_conf_get_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, &err);
-
- if (err) {
- g_printerr ("modest: failed to get '%s': %s\n",
- MODEST_CONF_DEFAULT_ACCOUNT, err->message);
- g_error_free (err);
- g_free (account);
- return NULL;
- }
-
- /* sanity check */
- if (account && !modest_account_mgr_account_exists (self, account, FALSE)) {
- g_printerr ("modest: default account does not exist\n");
- g_free (account);
- return NULL;
- }
-
- return account;
-}
-
-
-gboolean
-modest_account_mgr_set_default_account (ModestAccountMgr *self, const gchar* account)
-{
- ModestConf *conf;
-
- g_return_val_if_fail (self, FALSE);
- g_return_val_if_fail (account, FALSE);
- g_return_val_if_fail (modest_account_mgr_account_exists (self, account, FALSE),
- FALSE);
-
- conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
-
- return modest_conf_set_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, account, NULL);
-}
-
-gboolean
-modest_account_mgr_unset_default_account (ModestAccountMgr *self)
-{
- ModestConf *conf;
-
- g_return_val_if_fail (self, FALSE);
-
- conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
-
- return modest_conf_remove_key (conf, MODEST_CONF_DEFAULT_ACCOUNT, NULL /* err */);
-
-}
-
-gint on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
+gint
+on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
{
return g_utf8_collate((const gchar*)a, (const gchar*)b);
}
return account_name;
}
+
+void
+modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
+ const gchar *account_name,
+ gboolean leave_on_server)
+{
+ modest_account_mgr_set_bool (self,
+ account_name,
+ MODEST_ACCOUNT_LEAVE_ON_SERVER,
+ leave_on_server,
+ FALSE);
+}
+
+gboolean
+modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_bool (self,
+ account_name,
+ MODEST_ACCOUNT_LEAVE_ON_SERVER,
+ FALSE);
+}
+
+gint
+modest_account_mgr_get_last_updated (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (modest_runtime_get_account_mgr (),
+ account_name,
+ MODEST_ACCOUNT_LAST_UPDATED,
+ TRUE);
+}
+
+void
+modest_account_mgr_set_last_updated (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint time)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_LAST_UPDATED,
+ time,
+ TRUE);
+
+ /* TODO: notify about changes */
+}
+
+gint
+modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (self,
+ account_name,
+ MODEST_ACCOUNT_LIMIT_RETRIEVE,
+ FALSE);
+}
+
+void
+modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint limit_retrieve)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_LIMIT_RETRIEVE,
+ limit_retrieve,
+ FALSE /* not server account */);
+}
+
+gint
+modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
+ const gchar* account_name)
+{
+ return modest_account_mgr_get_int (self,
+ account_name,
+ MODEST_ACCOUNT_PORT,
+ TRUE);
+}
+
+void
+modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
+ const gchar *account_name,
+ gint port_num)
+{
+ modest_account_mgr_set_int (self,
+ account_name,
+ MODEST_ACCOUNT_PORT,
+ port_num, TRUE /* server account */);
+}
+
+gchar*
+modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
+ const gchar *account_name,
+ TnyAccountType account_type)
+{
+ return modest_account_mgr_get_string (self,
+ account_name,
+ (account_type == TNY_ACCOUNT_TYPE_STORE) ?
+ MODEST_ACCOUNT_STORE_ACCOUNT :
+ MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
+ FALSE);
+}
+
+gchar*
+modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
+ const gchar *account_name)
+{
+ return modest_account_mgr_get_string (self,
+ account_name,
+ MODEST_ACCOUNT_RETRIEVE,
+ FALSE /* not server account */);
+}
+
+void
+modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *retrieve_type)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_RETRIEVE,
+ retrieve_type,
+ FALSE /* not server account */);
+}
+
+
+void
+modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *fullname)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_FULLNAME,
+ fullname,
+ FALSE /* not server account */);
+}
+
+void
+modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *email)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_EMAIL,
+ email,
+ FALSE /* not server account */);
+}
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMIT
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
const gchar* name);
/**
- * modest_account_mgr_get_default_account:
- * @self: a ModestAccountMgr instance
- *
- * get the default account name, or NULL if none is found
- *
- * Returns: the default account name (as newly allocated string, which
- * must be g_free'd), or NULL
- */
-gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
-
-/**
- * modest_account_mgr_set_default_account:
- * @self: a ModestAccountMgr instance
- * @account: the name of an existing account
- *
- * set the default account name (which must be valid account)
- *
- * Returns: TRUE if succeeded, FALSE otherwise
- */
-gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
- const gchar* account);
-
-/**
- * modest_account_mgr_unset_default_account:
- * @self: a ModestAccountMgr instance
- * @account: the name of an account
- *
- * Unset the default account name, so that no account is the default.
- *
- * Returns: TRUE if succeeded, FALSE otherwise
- */
-gboolean modest_account_mgr_unset_default_account (ModestAccountMgr *self);
-
-/**
* modest_account_mgr_set_first_account_as_default:
* @self: a ModestAccountMgr instance
*
gboolean modest_account_mgr_get_enabled (ModestAccountMgr *self, const gchar* name);
/**
- * modest_account_mgr_get_display_name:
- * @self: a ModestAccountMgr instance
- * @name: the account name to check
- *
- * Return the human-readable account title for this account, or NULL.
- */
-gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self,
- const gchar* name);
-
-
-/**
* modest_account_mgr_set_signature
* @self: a ModestAccountMgr instance
* @name: the account name to check
* @new_value: New value that indicates if if this account should use connection-specific smtp server accounts.
* @result: TRUE if it succeeded, FALSE otherwise
*/
-gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self, const gchar* account_name,
- gboolean new_value);
+gboolean modest_account_mgr_set_use_connection_specific_smtp (ModestAccountMgr *self,
+ const gchar* account_name,
+ gboolean new_value);
/**
* modest_account_mgr_get_connection_specific_smtp
* Returns: a server account name to use for this connection, or NULL if none is specified.
*/
gchar* modest_account_mgr_get_connection_specific_smtp (ModestAccountMgr *self,
- const gchar* connection_name);
+ const gchar* connection_name);
/**
- * modest_server_account_get_username:
+ * modest_account_mgr_get_server_account_username:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
*
* Returns: The username.
*/
-gchar*
-modest_server_account_get_username (ModestAccountMgr *self, const gchar* account_name);
+gchar* modest_account_mgr_get_server_account_username (ModestAccountMgr *self,
+ const gchar* account_name);
/**
- * modest_server_account_set_username:
+ * modest_account_mgr_set_server_account_username:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
* @username: The new username.
*
* Sets the username this server account.
*/
-void
-modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name,
- const gchar* username);
+void modest_account_mgr_set_server_account_username (ModestAccountMgr *self,
+ const gchar* account_name,
+ const gchar* username);
/**
- * modest_server_account_get_username_has_succeeded:
+ * modest_account_mgr_get_server_account_username_has_succeeded:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
*
* Returns: TRUE if the username is known to be correct.
*/
-gboolean
-modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name);
+gboolean modest_account_mgr_get_server_account_username_has_succeeded (ModestAccountMgr *self,
+ const gchar* account_name);
/**
- * modest_server_account_set_username_has_succeeded:
+ * modest_account_mgr_set_server_account_username_has_succeeded:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
* @succeeded: Whether the username has succeeded
*
* Sets whether the username is known to be correct.
*/
-void
-modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
- gboolean succeeded);
+void modest_account_mgr_set_server_account_username_has_succeeded (ModestAccountMgr *self,
+ const gchar* account_name,
+ gboolean succeeded);
/**
- * modest_server_account_set_password:
+ * modest_account_mgr_set_server_account_password:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
* @password: The new password.
*
* Sets the password for this server account.
*/
-void
-modest_server_account_set_password (ModestAccountMgr *self, const gchar* account_name,
- const gchar* password);
+void modest_account_mgr_set_server_account_password (ModestAccountMgr *self,
+ const gchar* account_name,
+ const gchar* password);
/**
- * modest_server_account_get_password:
+ * modest_account_mgr_get_server_account_password:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
* Gets the password for this server account from the account settings.
*/
-gchar*
-modest_server_account_get_password (ModestAccountMgr *self, const gchar* account_name);
+gchar* modest_account_mgr_get_server_account_password (ModestAccountMgr *self,
+ const gchar* account_name);
/**
- * modest_server_account_get_has_password:
+ * modest_account_mgr_get_server_account_has_password:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
* Gets whether a password has been set for this server account in the account settings.
*/
-gboolean
-modest_server_account_get_has_password (ModestAccountMgr *self, const gchar* account_name);
+gboolean modest_account_mgr_get_server_account_has_password (ModestAccountMgr *self,
+ const gchar* account_name);
/**
- * modest_server_account_modest_server_account_get_hostnameget_username:
+ * modest_server_account_modest_account_mgr_get_server_account_hostname:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
*
* Returns: The hostname.
*/
-gchar*
-modest_server_account_get_hostname (ModestAccountMgr *self, const gchar* account_name);
+gchar* modest_account_mgr_get_server_account_hostname (ModestAccountMgr *self,
+ const gchar* account_name);
+/**
+ * modest_server_account_modest_account_mgr_set_server_account_hostname:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ * @hostname: The new hostname
+ *
+ * Sets the hostname this server account.
+ */
+void modest_account_mgr_set_server_account_hostname (ModestAccountMgr *self,
+ const gchar* account_name,
+ const gchar *hostname);
/**
- * modest_server_account_get_secure_auth:
+ * modest_account_mgr_get_server_account_secure_auth:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
*
*
* Returns: The secure authentication enum value.
*/
-ModestAuthProtocol
-modest_server_account_get_secure_auth (ModestAccountMgr *self, const gchar* account_name);
+ModestAuthProtocol modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
+ const gchar* account_name);
/**
* modest_server_account_data_get_secure_auth:
*
* Gets the secure authentication method for this server account.
*/
-void
-modest_server_account_set_secure_auth (ModestAccountMgr *self, const gchar* account_name,
- ModestAuthProtocol secure_auth);
+void modest_account_mgr_set_server_account_secure_auth (ModestAccountMgr *self,
+ const gchar* account_name,
+ ModestAuthProtocol secure_auth);
/**
* modest_server_account_data_get_security:
*
* Returns: The security enum value.
*/
-ModestConnectionProtocol
-modest_server_account_get_security (ModestAccountMgr *self, const gchar* account_name);
+ModestConnectionProtocol modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
+ const gchar* account_name);
/**
- * modest_server_account_set_security:
+ * modest_account_mgr_set_server_account_security:
* @self: a ModestAccountMgr instance
* @secure_auth: The security enum value.
*
* Gets the security method for this server account.
*/
-void
-modest_server_account_set_security (ModestAccountMgr *self, const gchar* account_name,
- ModestConnectionProtocol security);
+void modest_account_mgr_set_server_account_security (ModestAccountMgr *self,
+ const gchar* account_name,
+ ModestConnectionProtocol security);
-ModestServerAccountData*
-modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name);
+ModestServerAccountData* modest_account_mgr_get_server_account_data (ModestAccountMgr *self,
+ const gchar* name);
-void
-modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
- ModestServerAccountData* data);
+void modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
+ ModestServerAccountData* data);
/**
* modest_account_mgr_get_from_string
*
* Returns: the newly allocated name.
*/
-gchar*
-modest_account_mgr_get_unused_account_name (ModestAccountMgr *self, const gchar* starting_name,
- gboolean server_account);
+gchar* modest_account_mgr_get_unused_account_name (ModestAccountMgr *self,
+ const gchar* starting_name,
+ gboolean server_account);
/**
* modest_account_mgr_get_unused_account_display name
*
* Returns: the newly allocated name.
*/
-gchar*
-modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self, const gchar* starting_name);
+gchar* modest_account_mgr_get_unused_account_display_name (ModestAccountMgr *self,
+ const gchar* starting_name);
+
+/**
+ * modest_account_mgr_set_server_account_security:
+ * @self: a ModestAccountMgr instance
+ * @secure_auth: The security enum value.
+ *
+ * Gets the security method for this server account.
+ */
+void modest_account_mgr_set_leave_on_server (ModestAccountMgr *self,
+ const gchar* account_name,
+ gboolean leave_on_server);
+
+gboolean modest_account_mgr_get_leave_on_server (ModestAccountMgr *self,
+ const gchar* account_name);
+
+gint modest_account_mgr_get_last_updated (ModestAccountMgr *self,
+ const gchar* account_name);
+
+void modest_account_mgr_set_last_updated (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint time);
+
+gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name);
+
+void modest_account_mgr_set_retrieve_limit (ModestAccountMgr *self,
+ const gchar* account_name,
+ gint limit_retrieve);
+
+gint modest_account_mgr_get_server_account_port (ModestAccountMgr *self,
+ const gchar* account_name);
+
+void modest_account_mgr_set_server_account_port (ModestAccountMgr *self,
+ const gchar *account_name,
+ gint port_num);
+
+gchar* modest_account_mgr_get_server_account_name (ModestAccountMgr *self,
+ const gchar *account_name,
+ TnyAccountType account_type);
+
+gchar* modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
+ const gchar *account_name);
+
+void modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
+ 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_server_account_user_email (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *email);
G_END_DECLS
MODEST_TYPE_ACCOUNT_MGR, \
ModestAccountMgrPrivate))
+/**
+ * modest_account_mgr_set_bool:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @server_account: if TRUE, this is a server account
+ *
+ * set a config bool for an account
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ */
+gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key, gboolean val,
+ gboolean server_account);
+
+/**
+ * modest_account_mgr_get_bool:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to retrieve
+ * @server_account: if TRUE, this is a server account
+ *
+ * get a config boolean from an account
+ *
+ * Returns: an boolean with the value for the key, or FALSE in case of
+ * error (but of course FALSE does not necessarily imply an error)
+ */
+gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ gboolean server_account);
+
+
+/**
+ * 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
+ *
+ * get a config list of values of type @list_type of an account
+ *
+ * Returns: a newly allocated list of elements
+ */
+GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ ModestConfValueType list_type,
+ gboolean server_account);
+
+/**
+ * modest_account_mgr_set_list:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to set
+ * @val: the list with the values to set
+ * @list_type: the type of the members of the list
+ * @server_account: if TRUE, this is a server account
+ *
+ * * set a config list of values of type @list_type of an account
+ *
+ * returns TRUE if this succeeded, FALSE otherwise
+ */
+gboolean modest_account_mgr_set_list (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ GSList *val,
+ ModestConfValueType list_type,
+ gboolean server_account);
+
+/**
+ * modest_account_mgr_get_int:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to retrieve
+ * @server_account: if TRUE, this is a server account
+ *
+ * get a config int from an account
+ *
+ * Returns: an integer with the value for the key, or -1 in case of
+ * error (but of course -1 does not necessarily imply an error)
+ */
+gint modest_account_mgr_get_int (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ gboolean server_account);
+
+
+
+/**
+ * modest_account_mgr_set_int:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @server_account: if TRUE, this is a server account
+ *
+ * set a config int for an account
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ */
+gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key, gint val,
+ gboolean server_account);
+
+/**
+ * modest_account_mgr_get_string:
+ * @self: self a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to retrieve
+ * @server_account: if TRUE, this is a server account
+ *
+ * get a config string from an account
+ *
+ * Returns: a newly allocated string with the value for the key,
+ * or NULL in case of error.
+ */
+gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key,
+ gboolean server_account);
+
+
+/**
+ * modest_account_mgr_set_string:
+ * @self: a ModestAccountMgr instance
+ * @name: the name of the account
+ * @key: the key of the value to set
+ * @val: the value to set
+ * @server_account: if TRUE, this is a server account
+ *
+ * set a config string for an account.
+ *
+ * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
+ */
+gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
+ const gchar *name,
+ const gchar *key, const gchar* val,
+ gboolean server_account);
+
G_END_DECLS
#endif /* __MODEST_ACCOUNT_MGR_PRIV_H__ */
#include <string.h>
#include <modest-marshal.h>
+#include <modest-runtime.h>
#include <modest-account-mgr.h>
#include <modest-account-mgr-priv.h>
#include <modest-account-mgr-helpers.h>
static void modest_account_mgr_finalize (GObject * obj);
static void modest_account_mgr_base_init (gpointer g_class);
-static const gchar *
-_modest_account_mgr_get_account_keyname_cached (ModestAccountMgrPrivate *priv, const gchar* account_name,
- const gchar *name, gboolean is_server);
+static const gchar *_modest_account_mgr_get_account_keyname_cached (ModestAccountMgrPrivate *priv,
+ const gchar* account_name,
+ const gchar *name,
+ gboolean is_server);
+
+static gboolean modest_account_mgr_unset_default_account (ModestAccountMgr *self);
/* list my signals */
enum {
ACCOUNT_REMOVED_SIGNAL,
ACCOUNT_BUSY_SIGNAL,
DEFAULT_ACCOUNT_CHANGED_SIGNAL,
+ DISPLAY_NAME_CHANGED_SIGNAL,
LAST_SIGNAL
};
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = {0};
-/* is the account already in the queue? */
-static gboolean
-in_change_queue (GSList *change_queue, const gchar *account)
-{
- GSList *cursor = change_queue;
- while (cursor) {
- const gchar *acc = cursor->data;
- if (acc && strcmp (acc, account) == 0)
- return TRUE;
- cursor = g_slist_next (cursor);
- }
- return FALSE;
-}
-
-static GSList*
-add_to_change_queue (GSList *change_queue, const gchar *account_name)
-{
- g_return_val_if_fail (account_name, change_queue);
- return g_slist_prepend (change_queue, g_strdup (account_name));
-}
-
-
-/* we don't need to track specific accounts, as in our UI case
- * it's impossible to change two accounts within .5 seconds.
- * still, we might want to allow that later, and then this func
- * will come in handy */
-#if 0
-static GSList*
-remove_from_queue (GSList *change_queue, const gchar *account)
-{
- GSList *cursor = change_queue;
- while (cursor) {
- const gchar *acc = cursor->data;
- if (acc && strcmp (acc, account) == 0) {
- g_free (acc);
- return g_slist_delete_link (change_queue, cursor);
- }
- cursor = g_slist_next (cursor);
- }
- return change_queue;
-}
-#endif
-
-static gboolean
-on_timeout_notify_changes (gpointer data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
-
- GSList *cursor = priv->change_queue;
- while (cursor) {
- const gchar *account = cursor->data;
- if (account)
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
- account);
- cursor = g_slist_next (cursor);
- }
-
- /* free our queue */
- g_slist_foreach (priv->change_queue, (GFunc)g_free, NULL);
- g_slist_free (priv->change_queue);
- priv->change_queue = NULL;
- priv->timeout = 0; /* hmmm */
-
- return FALSE; /* don't call me again */
-}
-
-
-/* little hack to retrieve the account name from a server account name,
- * by relying on the convention for that. Note: this changes the
- * string in-place
- *
- * server accounts look like fooID_transport or fooID_store
- * FIXME: make the suffixes more explicit in the account setup
- */
-static void
-get_account_name_from_server_account (gchar *server_account_name)
-{
- static const gchar *t = "ID_transport";
- static const gchar *s = "ID_store";
- const guint len_t = strlen (t);
- const guint len_s = strlen (s);
-
- guint len_a = strlen (server_account_name);
-
- if (g_str_has_suffix (server_account_name, t))
- server_account_name [len_a - len_t] = '\0';
- else if (g_str_has_suffix (server_account_name, s))
- server_account_name [len_a - len_s] = '\0';
-}
-
-
-
-static void
-on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event,
- ModestConfNotificationId id, gpointer user_data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
-
- gboolean is_account_key;
- gboolean is_server_account;
- gchar* account_name = NULL;
-
- /* Notify that the default account has changed */
- if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- g_signal_emit (G_OBJECT(self), signals[DEFAULT_ACCOUNT_CHANGED_SIGNAL], 0);
- return;
- }
-
- is_account_key = FALSE;
- is_server_account = FALSE;
- account_name = _modest_account_mgr_account_from_key (key, &is_account_key,
- &is_server_account);
-
- /* if this is not an account-related key change, ignore */
- if (!account_name)
- return;
-
- /* 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
- account keys for the same reason */
- if ((is_account_key || is_server_account) &&
- event == MODEST_CONF_EVENT_KEY_UNSET) {
- g_free (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);
-
- /* is this account enabled? */
- gboolean enabled = FALSE;
- if (is_server_account)
- enabled = TRUE;
- else
- enabled = modest_account_mgr_get_enabled (self, account_name);
-
- /* Notify is server account was changed, default account was changed
- * or when enabled/disabled changes:
- */
- if (!is_server_account)
- if (enabled || g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) ||
- strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- if (!in_change_queue (priv->change_queue, account_name)) {
- priv->change_queue = add_to_change_queue (priv->change_queue,
- 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,
- self);
- }
- }
- g_free (account_name);
-}
-
-
GType
modest_account_mgr_get_type (void)
{
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(ModestAccountMgrClass, account_changed),
NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ modest_marshal_VOID__STRING_INT,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_INT);
signals[ACCOUNT_BUSY_SIGNAL] =
g_signal_new ("account_busy_changed",
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[DISPLAY_NAME_CHANGED_SIGNAL] =
+ g_signal_new ("display_name_changed",
+ MODEST_TYPE_ACCOUNT_MGR,
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(ModestAccountMgrClass, display_name_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
modest_account_mgr_initialized = TRUE;
}
}
priv->modest_conf = NULL;
priv->busy_accounts = NULL;
- priv->change_queue = NULL;
priv->timeout = 0;
priv->notification_id_accounts = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, g_free);
g_hash_table_destroy (priv->notification_id_accounts);
}
- if (priv->key_changed_handler_uid) {
- g_signal_handler_disconnect (priv->modest_conf,
- priv->key_changed_handler_uid);
- priv->key_changed_handler_uid = 0;
- }
-
if (priv->modest_conf) {
g_object_unref (G_OBJECT(priv->modest_conf));
priv->modest_conf = NULL;
g_object_ref (G_OBJECT(conf));
priv->modest_conf = conf;
- priv->key_changed_handler_uid =
- g_signal_connect (G_OBJECT (conf), "key_changed",
- G_CALLBACK (on_key_change),
- obj);
-
return MODEST_ACCOUNT_MGR (obj);
}
/* Make sure that leave-messages-on-server is enabled by default,
* as per the UI spec, though it is only meaningful for accounts using POP.
* (possibly this gconf key should be under the server account): */
- modest_account_mgr_set_bool (self, name,
- MODEST_ACCOUNT_LEAVE_ON_SERVER, TRUE, FALSE /* not server account */);
-
- modest_account_mgr_set_enabled (self, name, 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);
/* Notify the observers */
g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
gboolean
modest_account_mgr_add_server_account (ModestAccountMgr * self,
- const gchar * name, const gchar *hostname,
+ const gchar *name,
+ const gchar *hostname,
guint portnumber,
- const gchar * username, const gchar * password,
+ const gchar *username,
+ const gchar *password,
ModestTransportStoreProtocol proto,
ModestConnectionProtocol security,
ModestAuthProtocol auth)
goto cleanup;
/* Add the security settings: */
- modest_server_account_set_security (self, name, security);
+ modest_account_mgr_set_server_account_security (self, name, security);
cleanup:
if (!ok) {
*/
gboolean
modest_account_mgr_add_server_account_uri (ModestAccountMgr * self,
- const gchar *name, ModestTransportStoreProtocol proto,
+ const gchar *name,
+ ModestTransportStoreProtocol proto,
const gchar *uri)
{
ModestAccountMgrPrivate *priv;
gboolean add = TRUE;
if (only_enabled) {
if (unescaped_name &&
- !modest_account_mgr_get_enabled (self, unescaped_name)) {
+ !modest_account_mgr_get_bool (self, unescaped_name,
+ MODEST_ACCOUNT_ENABLED, FALSE))
add = FALSE;
- }
}
/* Ignore modest accounts whose server accounts don't exist:
}
}
- if (add)
+ if (add)
result = g_slist_append (result, unescaped_name);
else
g_free (unescaped_name);
}
-gchar *
-modest_account_mgr_get_password (ModestAccountMgr *self, const gchar *name,
- const gchar *key, gboolean server_account)
-{
- return modest_account_mgr_get_string (self, name, key, server_account);
-
-}
-
-
-
gint
modest_account_mgr_get_int (ModestAccountMgr *self, const gchar *name, const gchar *key,
gboolean server_account)
gboolean
-modest_account_mgr_set_string (ModestAccountMgr * self, const gchar * name,
- const gchar * key, const gchar * val, gboolean server_account)
+modest_account_mgr_set_string (ModestAccountMgr * self,
+ const gchar * name,
+ const gchar * key,
+ const gchar * val,
+ gboolean server_account)
{
ModestAccountMgrPrivate *priv;
return retval;
}
-
-gboolean
-modest_account_mgr_set_password (ModestAccountMgr * self, const gchar * name,
- const gchar * key, const gchar * val, gboolean server_account)
-{
- return modest_account_mgr_set_password (self, name, key, val, server_account);
-}
-
-
-
gboolean
modest_account_mgr_set_int (ModestAccountMgr * self, const gchar * name,
const gchar * key, int val, gboolean server_account)
}
gboolean
-modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self, const gchar *display_name)
+modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self,
+ const gchar *display_name)
{
GSList *account_names = NULL;
GSList *cursor = NULL;
return retval;
}
-
-#if 0
-static void
-f2 (gchar*key, gchar* val, gpointer user_data)
-{
- g_debug (">>%s:%s", key, val);
-}
-
-
-static void
-f1 (gchar*key, GHashTable* h, gpointer user_data)
-{
- g_debug (">%s", key);
- g_hash_table_foreach (h, (GHFunc)f2, NULL);
-}
-#endif
-
-
static const gchar *
-_modest_account_mgr_get_account_keyname_cached (ModestAccountMgrPrivate *priv, const gchar* account_name,
- const gchar *name, gboolean is_server)
+_modest_account_mgr_get_account_keyname_cached (ModestAccountMgrPrivate *priv,
+ const gchar* account_name,
+ const gchar *name,
+ gboolean is_server)
{
- //return _modest_account_mgr_get_account_keyname (account_name, name, is_server);
-
-
GHashTable *hash = is_server ? priv->server_account_key_hash : priv->account_key_hash;
GHashTable *account_hash;
gchar *key = NULL;
const gchar *search_name;
-
- //g_hash_table_foreach (hash, (GHFunc)f1, NULL);
if (!account_name)
return is_server ? MODEST_SERVER_ACCOUNT_NAMESPACE : MODEST_ACCOUNT_NAMESPACE;
return (g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name)
!= NULL);
}
+
+void
+modest_account_mgr_notify_account_update (ModestAccountMgr* self,
+ const gchar *server_account_name)
+{
+ ModestTransportStoreProtocol proto;
+ gchar *proto_name = NULL;
+
+ /* Get protocol */
+ proto_name = modest_account_mgr_get_string (self, server_account_name,
+ MODEST_ACCOUNT_PROTO, TRUE);
+ if (!proto_name) {
+ g_free (proto_name);
+ g_return_if_reached ();
+ }
+ proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+ g_free (proto_name);
+
+ /* Emit "update-account" */
+ g_signal_emit (G_OBJECT(self),
+ signals[ACCOUNT_CHANGED_SIGNAL], 0,
+ server_account_name,
+ (modest_protocol_info_protocol_is_store (proto)) ?
+ TNY_ACCOUNT_TYPE_STORE :
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+}
+
+
+gboolean
+modest_account_mgr_set_default_account (ModestAccountMgr *self, const gchar* account)
+{
+ ModestConf *conf;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (account, FALSE);
+ g_return_val_if_fail (modest_account_mgr_account_exists (self, account, FALSE),
+ FALSE);
+
+ conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
+
+ /* Change the default account and notify */
+ retval = modest_conf_set_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, account, NULL);
+ if (retval)
+ g_signal_emit (G_OBJECT(self), signals[DEFAULT_ACCOUNT_CHANGED_SIGNAL], 0);
+
+ return retval;
+}
+
+
+gchar*
+modest_account_mgr_get_default_account (ModestAccountMgr *self)
+{
+ gchar *account;
+ ModestConf *conf;
+ GError *err = NULL;
+
+ g_return_val_if_fail (self, NULL);
+
+ conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
+ account = modest_conf_get_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, &err);
+
+ if (err) {
+ g_printerr ("modest: failed to get '%s': %s\n",
+ MODEST_CONF_DEFAULT_ACCOUNT, err->message);
+ g_error_free (err);
+ g_free (account);
+ return NULL;
+ }
+ /* sanity check */
+ if (account && !modest_account_mgr_account_exists (self, account, FALSE)) {
+ g_printerr ("modest: default account does not exist\n");
+ g_free (account);
+ return NULL;
+ }
+
+ return account;
+}
+
+static gboolean
+modest_account_mgr_unset_default_account (ModestAccountMgr *self)
+{
+ ModestConf *conf;
+ gboolean retval;
+
+ g_return_val_if_fail (self, FALSE);
+
+ conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
+
+ retval = modest_conf_remove_key (conf, MODEST_CONF_DEFAULT_ACCOUNT, NULL /* err */);
+
+ if (retval)
+ g_signal_emit (G_OBJECT(self), signals[DEFAULT_ACCOUNT_CHANGED_SIGNAL], 0);
+
+ return retval;
+}
+
+
+gchar*
+modest_account_mgr_get_display_name (ModestAccountMgr *self,
+ const gchar* name)
+{
+ return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_DISPLAY_NAME, FALSE);
+}
+
+void
+modest_account_mgr_set_display_name (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *display_name)
+{
+ modest_account_mgr_set_string (self,
+ account_name,
+ MODEST_ACCOUNT_DISPLAY_NAME,
+ display_name,
+ FALSE /* not server account */);
+
+ /* Notify about the change in the display name */
+ g_signal_emit (self, signals[DISPLAY_NAME_CHANGED_SIGNAL], 0, account_name);
+}
void (* default_account_changed)(ModestAccountMgr *obj,
gpointer user_data);
+
+ void (* display_name_changed) (ModestAccountMgr *obj,
+ const gchar *account,
+ gpointer user_data);
};
/**
*
* Returns: TRUE if the account with name @name exists, FALSE otherwise (or in case of error)
*/
-gboolean modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self,
- const gchar *display_name);
-
-
-/**
- * modest_account_mgr_get_string:
- * @self: self a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to retrieve
- * @server_account: if TRUE, this is a server account
- *
- * get a config string from an account
- *
- * Returns: a newly allocated string with the value for the key,
- * or NULL in case of error.
- */
-gchar* modest_account_mgr_get_string (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- gboolean server_account);
-
-
-/**
- * modest_account_mgr_get_password:
- * @self: self a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to retrieve
- * @server_account: if TRUE, this is a server account
- *
- * get a password from an account
- *
- * Returns: a newly allocated string with the value for the key,
- * or NULL in case of error.
- */
-gchar* modest_account_mgr_get_password (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- gboolean server_account);
-
-/**
- * modest_account_mgr_get_int:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to retrieve
- * @server_account: if TRUE, this is a server account
- *
- * get a config int from an account
- *
- * Returns: an integer with the value for the key, or -1 in case of
- * error (but of course -1 does not necessarily imply an error)
- */
-gint modest_account_mgr_get_int (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- gboolean server_account);
-
-/**
- * modest_account_mgr_get_bool:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to retrieve
- * @server_account: if TRUE, this is a server account
- *
- * get a config boolean from an account
- *
- * Returns: an boolean with the value for the key, or FALSE in case of
- * error (but of course FALSE does not necessarily imply an error)
- */
-gboolean modest_account_mgr_get_bool (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- gboolean server_account);
-
-/**
- * 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
- *
- * get a config list of values of type @list_type of an account
- *
- * Returns: a newly allocated list of elements
- */
-GSList* modest_account_mgr_get_list (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- ModestConfValueType list_type,
- gboolean server_account);
-
-/**
- * modest_account_mgr_set_string:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to set
- * @val: the value to set
- * @server_account: if TRUE, this is a server account
- *
- * set a config string for an account.
- *
- * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
- */
-gboolean modest_account_mgr_set_string (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key, const gchar* val,
- gboolean server_account);
-
-
-/**
- * modest_account_mgr_set_password:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to set
- * @val: the value to set
- * @server_account: if TRUE, this is a server account
- *
- * set a password for an account.
- *
- * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
-* @err gives details in case of error
- */
-gboolean modest_account_mgr_set_password (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key, const gchar* val,
- gboolean server_account);
-
-/**
- * modest_account_mgr_set_int:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to set
- * @val: the value to set
- * @server_account: if TRUE, this is a server account
- *
- * set a config int for an account
- *
- * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
- */
-gboolean modest_account_mgr_set_int (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key, gint val,
- gboolean server_account);
-
-/**
- * modest_account_mgr_set_bool:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to set
- * @val: the value to set
- * @server_account: if TRUE, this is a server account
- *
- * set a config bool for an account
- *
- * Returns: TRUE if setting the value succeeded, or FALSE in case of error.
- */
-gboolean modest_account_mgr_set_bool (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key, gboolean val,
- gboolean server_account);
-
-/**
- * modest_account_mgr_set_list:
- * @self: a ModestAccountMgr instance
- * @name: the name of the account
- * @key: the key of the value to set
- * @val: the list with the values to set
- * @list_type: the type of the members of the list
- * @server_account: if TRUE, this is a server account
- *
- * * set a config list of values of type @list_type of an account
- *
- * returns TRUE if this succeeded, FALSE otherwise
- */
-gboolean modest_account_mgr_set_list (ModestAccountMgr *self,
- const gchar *name,
- const gchar *key,
- GSList *val,
- ModestConfValueType list_type,
- gboolean server_account);
+gboolean modest_account_mgr_account_with_display_name_exists (ModestAccountMgr *self,
+ const gchar *display_name);
/**
* modest_account_mgr_unset:
* Returns: If the account is currently busy or not
*
*/
-gboolean
-modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name);
+gboolean modest_account_mgr_account_is_busy (ModestAccountMgr* self,
+ const gchar* account_name);
+
+
+void modest_account_mgr_notify_account_update (ModestAccountMgr* self,
+ const gchar *server_account_name);
+
+/**
+ * modest_account_mgr_set_default_account:
+ * @self: a ModestAccountMgr instance
+ * @account: the name of an existing account
+ *
+ * set the default account name (which must be valid account)
+ *
+ * Returns: TRUE if succeeded, FALSE otherwise
+ */
+gboolean modest_account_mgr_set_default_account (ModestAccountMgr *self,
+ const gchar* account);
+
+/**
+ * modest_account_mgr_get_default_account:
+ * @self: a ModestAccountMgr instance
+ *
+ * get the default account name, or NULL if none is found
+ *
+ * Returns: the default account name (as newly allocated string, which
+ * must be g_free'd), or NULL
+ */
+gchar* modest_account_mgr_get_default_account (ModestAccountMgr *self);
+
+/**
+ * modest_account_mgr_get_display_name:
+ * @self: a ModestAccountMgr instance
+ * @name: the account name to check
+ *
+ * Return the human-readable account title for this account, or NULL.
+ */
+gchar* modest_account_mgr_get_display_name (ModestAccountMgr *self,
+ const gchar* name);
+
+void modest_account_mgr_set_display_name (ModestAccountMgr *self,
+ const gchar *account_name,
+ const gchar *display_name);
G_END_DECLS
#include <camel/camel-stream-mem.h>
#include <glib/gi18n.h>
#include "modest-platform.h"
+#include "modest-account-mgr-helpers.h"
#include <modest-tny-account.h>
#include <modest-tny-send-queue.h>
#include <modest-runtime.h>
{
/* This is a GDK lock because we are an idle callback and
- * modest_account_mgr_set_int can contain Gtk+ code */
+ * modest_account_mgr_set_last_updated can issue Gtk+ code */
gdk_threads_enter (); /* CHECKED - please recheck */
the time when this idle was called, it's just an
approximation and it won't be very different */
- modest_account_mgr_set_int (modest_runtime_get_account_mgr (),
- (gchar *) data,
- MODEST_ACCOUNT_LAST_UPDATED,
- time(NULL),
- TRUE);
+ modest_account_mgr_set_last_updated (modest_runtime_get_account_mgr (),
+ (gchar *) data,
+ time (NULL));
gdk_threads_leave (); /* CHECKED - please recheck */
/* Get per-account retrieval type */
mgr = modest_runtime_get_account_mgr ();
- info->retrieve_type = modest_account_mgr_get_string (mgr, account_name,
- MODEST_ACCOUNT_RETRIEVE, FALSE);
+ info->retrieve_type = modest_account_mgr_get_retrieve_type (mgr, account_name);
/* Get per-account message amount retrieval limit */
- info->retrieve_limit = modest_account_mgr_get_int (mgr, account_name,
- MODEST_ACCOUNT_LIMIT_RETRIEVE, FALSE);
+ info->retrieve_limit = modest_account_mgr_get_retrieve_limit (mgr, account_name);
if (info->retrieve_limit == 0)
info->retrieve_limit = G_MAXINT;
}
}
-
-static gboolean
-update_tny_account_for_account (ModestTnyAccountStore *self, ModestAccountMgr *acc_mgr,
- const gchar *account_name, TnyAccountType type)
+static void
+on_account_changed (ModestAccountMgr *acc_mgr,
+ const gchar *account_name,
+ TnyAccountType account_type,
+ gpointer user_data)
{
+ ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
ModestTnyAccountStorePrivate *priv;
TnyList* account_list;
gboolean found = FALSE;
TnyIterator *iter = NULL;
- g_return_val_if_fail (self, FALSE);
- g_return_val_if_fail (account_name, FALSE);
- g_return_val_if_fail (type == TNY_ACCOUNT_TYPE_STORE ||
- type == TNY_ACCOUNT_TYPE_TRANSPORT,
- FALSE);
-
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
- account_list = (type == TNY_ACCOUNT_TYPE_STORE ? priv->store_accounts : priv->transport_accounts);
+ account_list = (account_type == TNY_ACCOUNT_TYPE_STORE ?
+ priv->store_accounts :
+ priv->transport_accounts);
iter = tny_list_create_iterator (account_list);
while (!tny_iterator_is_done (iter) && !found) {
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) {
+ if (!strcmp (tny_account_get_id (tny_account), account_name)) {
found = TRUE;
- modest_tny_account_update_from_account (tny_account, acc_mgr, account_name, type);
+ modest_tny_account_update_from_account (tny_account);
g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, tny_account);
}
}
if (iter)
g_object_unref (iter);
-
- return found;
-}
-
-
-static void
-on_account_changed (ModestAccountMgr *acc_mgr,
- const gchar *account_name,
- gpointer user_data)
-{
- ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
-
-/* 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; */
-
- 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);
- if (!update_tny_account_for_account (self, acc_mgr, account_name, TNY_ACCOUNT_TYPE_TRANSPORT))
- g_warning ("%s: failed to update transport account for %s", __FUNCTION__, account_name);
}
static void
/* If the password is not already there, try ModestConf */
if (!already_asked) {
- pwd = modest_server_account_get_password (priv->account_mgr,
- server_account_name);
+ pwd = modest_account_mgr_get_server_account_password (priv->account_mgr,
+ server_account_name);
g_hash_table_insert (priv->password_hash, g_strdup (server_account_name), g_strdup (pwd));
}
* then show a banner and the account settings dialog so it can be corrected:
*/
const gboolean settings_have_password =
- modest_server_account_get_has_password (priv->account_mgr, server_account_name);
+ modest_account_mgr_get_server_account_has_password (priv->account_mgr, server_account_name);
printf ("DEBUG: modest: %s: settings_have_password=%d\n", __FUNCTION__, settings_have_password);
if (settings_have_password) {
/* The password must be wrong, so show the account settings dialog so it can be corrected: */
* but we need to tell tinymail about the username too: */
tny_account_set_user (account, username);
- /* Do not save the password in gconf,
- * because the UI spec says "The password will never be saved in the account": */
- /*
- if (remember) {
- printf ("%s: Storing username=%s, password=%s\n",
- __FUNCTION__, username, pwd);
- modest_server_account_set_username (priv->account_mgr, server_account_name,
- username);
- modest_server_account_set_password (priv->account_mgr, server_account_name,
- pwd);
- }
- */
+ /* Do not save the password in gconf, because
+ * the UI spec says "The password will never
+ * be saved in the account": */
/* We need to dup the string even knowing that
it's already a dup of the contents of an
return special_folder;
}
-static void
-on_connection_status_changed (TnyAccount *account, TnyConnectionStatus status, gpointer user_data)
-{
- printf ("DEBUG: %s: status=%d\n", __FUNCTION__, status);
-
- if (status == TNY_CONNECTION_STATUS_DISCONNECTED) {
- /* A tinymail network operation failed, and tinymail then noticed that
- * the account is offline, because our TnyDevice is offline,
- * because libconic says we are offline.
- * So ask the user to go online again.
- *
- * Note that this signal will not be emitted if the account was offline
- * when the network operation was first attempted. For those cases,
- * the application must do its own explicit checks.
- *
- * We make sure that this UI is shown in the main thread, to avoid races,
- * because tinymail does not guarantee that this signal handler will be called
- * in the main thread.
- */
- /* TODO: Commented out, because this causes hangs, probably related to
- * our use of mainloops:
- * modest_platform_connect_and_wait (NULL);
- */
- } else if (status == TNY_CONNECTION_STATUS_CONNECTED_BROKEN) {
- printf ("DEBUG: %s: Connection broken. Forcing TnyDevice offline.\n",
- __FUNCTION__);
-
- /* Something went wrong during some network operation.
- * Stop trying to use the network now,
- * by forcing accounts into offline mode:
- *
- * When libconic reconnects, it will set the device back online again,
- * regardless of it being forced offline before.
- */
- /* TODO: Find out when this is falsely being emitted. */
- printf (" DEBUG: %s: Not forcing offline because tinymail is sometimes reporting false connection breaks.\n",
- __FUNCTION__);
- /*
- TnyDevice *device = modest_runtime_get_device ();
- tny_device_force_offline (device);
- */
- }
-}
-
-
-
/**
* create_tny_account:
* @account_mgr: a valid account mgr instance
/* This must be set quite early, or other set() functions will fail. */
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session);
- /* Handle connection requests:
- * This (badly-named) signal will be called when we try to use an offline account. */
- g_signal_connect (G_OBJECT (tny_account), "connection-status-changed",
- G_CALLBACK (on_connection_status_changed), NULL);
-
/* Proto */
const gchar* proto_name =
modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
}
gboolean
-modest_tny_account_update_from_account (TnyAccount *tny_account, ModestAccountMgr *account_mgr,
- const gchar *account_name, TnyAccountType type)
+modest_tny_account_update_from_account (TnyAccount *tny_account)
{
ModestAccountData *account_data = NULL;
ModestServerAccountData *server_data = NULL;
- TnyConnectionStatus conn_status;
-
+ TnyConnectionStatus conn_status;
+ ModestAccountMgr *account_mgr;
+ const gchar *account_name;
+ TnyAccountType type;
+
g_return_val_if_fail (tny_account, FALSE);
- g_return_val_if_fail (account_mgr, FALSE);
- g_return_val_if_fail (account_name, FALSE);
- g_return_val_if_fail (type == TNY_ACCOUNT_TYPE_STORE || type == TNY_ACCOUNT_TYPE_TRANSPORT,
- FALSE);
+ account_mgr = modest_runtime_get_account_mgr ();
+ account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (tny_account);
+ type = tny_account_get_account_type (tny_account);
account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
if (!account_data) {
g_printerr ("modest: %s: cannot get account data for account %s\n",
/**
* modest_tny_account_update_from_account:
* @tny_account: a valid tny_account
- * @account_mgr: a valid account mgr instance
- * @account_name: the modest account name for which to create a corresponding tny account of the given type.
- * @type: the type of account to create (TNY_ACCOUNT_TYPE_STORE or TNY_ACCOUNT_TYPE_TRANSPORT)
*
* update a tnyaccount corresponding to the server_accounts (store or transport) for this account.
*
* Returns: a TRUE or FALSE in case of error.
*/
gboolean
-modest_tny_account_update_from_account (TnyAccount *tny_account, ModestAccountMgr *account_mgr,
- const gchar *account_name, TnyAccountType type);
+modest_tny_account_update_from_account (TnyAccount *tny_account);
/**
TnyAccount *account = NULL;
ModestWindowMgr *mgr = NULL;
gchar *signature = NULL;
+ gboolean use_signature;
/* If there was any error. The mail operation could be NULL,
this means that we already have the message downloaded and
from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
rf_helper->account_name);
- if (modest_account_mgr_get_bool (modest_runtime_get_account_mgr(),
- rf_helper->account_name,
- MODEST_ACCOUNT_USE_SIGNATURE, FALSE)) {
- signature = modest_account_mgr_get_string (modest_runtime_get_account_mgr (),
- rf_helper->account_name,
- MODEST_ACCOUNT_SIGNATURE, FALSE);
- }
+ signature = modest_account_mgr_get_signature (modest_runtime_get_account_mgr(),
+ rf_helper->account_name,
+ &use_signature);
/* Create reply mail */
switch (rf_helper->action) {
gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(main_window));
- gchar *server_name = modest_server_account_get_hostname (
+ gchar *server_name = modest_account_mgr_get_server_account_hostname (
modest_runtime_get_account_mgr(), server_account_name);
if (!server_name) {/* This happened once, though I don't know why. murrayc. */
g_warning("%s: Could not get server name for server account '%s'", __FUNCTION__, server_account_name);
server_name = NULL;
/* username: */
- gchar *initial_username = modest_server_account_get_username (
+ gchar *initial_username = modest_account_mgr_get_server_account_username (
modest_runtime_get_account_mgr(), server_account_name);
GtkWidget *entry_username = gtk_entry_new ();
/* Dim this if a connection has ever succeeded with this username,
* as per the UI spec: */
const gboolean username_known =
- modest_server_account_get_username_has_succeeded(
+ modest_account_mgr_get_server_account_username_has_succeeded(
modest_runtime_get_account_mgr(), server_account_name);
gtk_widget_set_sensitive (entry_username, !username_known);
if (username) {
*username = g_strdup (gtk_entry_get_text (GTK_ENTRY(entry_username)));
- modest_server_account_set_username (
+ modest_account_mgr_set_server_account_username (
modest_runtime_get_account_mgr(), server_account_name,
*username);
static void on_default_account_changed (ModestAccountMgr *mgr,
gpointer user_data);
+static void on_display_name_changed (ModestAccountMgr *self,
+ const gchar *account,
+ gpointer user_data);
+
typedef enum {
MODEST_ACCOUNT_VIEW_NAME_COLUMN,
MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN,
"default_account_changed",
G_CALLBACK(on_default_account_changed),
self);
+ priv->sig_handlers =
+ modest_signal_mgr_connect (priv->sig_handlers,
+ G_OBJECT(priv->account_mgr),
+ "display_name_changed",
+ G_CALLBACK(on_display_name_changed),
+ self);
}
g_free (default_account_name);
gtk_widget_queue_draw (GTK_WIDGET (user_data));
}
+
+static void
+on_display_name_changed (ModestAccountMgr *mgr,
+ const gchar *account,
+ gpointer user_data)
+{
+ /* Update the view */
+ update_account_view (mgr, MODEST_ACCOUNT_VIEW (user_data));
+}
GtkTreeIter *iter,
ModestFolderView *self);
+static void on_display_name_changed (ModestAccountMgr *self,
+ const gchar *account,
+ gpointer user_data);
+
enum {
FOLDER_SELECTION_CHANGED_SIGNAL,
FOLDER_DISPLAY_NAME_CHANGED_SIGNAL,
gulong account_removed_signal;
gulong account_changed_signal;
gulong conf_key_signal;
+ gulong display_name_changed_signal;
/* not unref this object, its a singlenton */
ModestEmailClipboard *clipboard;
}
static void
-text_cell_data (GtkTreeViewColumn *column, GtkCellRenderer *renderer,
- GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
+text_cell_data (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer data)
{
ModestFolderViewPrivate *priv;
GObject *rendobj;
type = modest_tny_folder_get_local_or_mmc_folder_type (TNY_FOLDER (instance));
if (type != TNY_FOLDER_TYPE_UNKNOWN) {
g_free (fname);
- fname = g_strdup(modest_local_folder_info_get_type_display_name (type));
+ fname = g_strdup (modest_local_folder_info_get_type_display_name (type));
}
}
} else if (TNY_IS_ACCOUNT (instance)) {
/* If it's a server account */
- if (modest_tny_account_is_virtual_local_folders (
- TNY_ACCOUNT (instance))) {
+ if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (instance))) {
item_name = g_strdup (priv->local_account_name);
item_weight = 800;
- } else if (modest_tny_account_is_memory_card_account (
- TNY_ACCOUNT (instance))) {
+ } else if (modest_tny_account_is_memory_card_account (TNY_ACCOUNT (instance))) {
/* fname is only correct when the items are first
* added to the model, not when the account is
* changed later, so get the name from the account
"key-press-event",
G_CALLBACK (on_key_pressed), NULL);
+ priv->display_name_changed_signal =
+ g_signal_connect (modest_runtime_get_account_mgr (),
+ "display_name_changed",
+ G_CALLBACK (on_display_name_changed),
+ obj);
+
/*
* Track changes in the local account name (in the device it
* will be the device name)
}
+static void
+on_display_name_changed (ModestAccountMgr *mgr,
+ const gchar *account,
+ gpointer user_data)
+{
+ ModestFolderView *self;
+
+ self = MODEST_FOLDER_VIEW (user_data);
+
+ /* Force a redraw */
+#if GTK_CHECK_VERSION(2, 8, 0)
+ GtkTreeViewColumn * tree_column;
+
+ tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW (self),
+ TNY_GTK_FOLDER_STORE_TREE_MODEL_NAME_COLUMN);
+ gtk_tree_view_column_queue_resize (tree_column);
+#else
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+#endif
+}
ModestPairList *msg_format_list;
GtkWidget *msg_format;
- gboolean changed;
ModestGlobalSettingsState initial_state;
};
priv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (self);
priv->notebook = gtk_notebook_new ();
- priv->changed = FALSE;
/* Add the buttons: */
gtk_dialog_add_button (GTK_DIALOG (self), _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK);