modest-account-mgr-priv.h \
modest-account-mgr.c \
modest-account-mgr.h \
+ modest-account-settings.c \
+ modest-account-settings.h \
modest-address-book.h \
modest-cache-mgr.c \
modest-cache-mgr.h \
modest-signal-mgr.h \
modest-singletons.c \
modest-singletons.h \
+ modest-server-account-settings.c \
+ modest-server-account-settings.h \
modest-text-utils.c \
modest-text-utils.h \
modest-tny-account-store.c \
modest-ui-dimming-manager.h \
modest-ui-dimming-rules.c \
modest-ui-dimming-rules.h \
+ modest-utils.c \
+ modest-utils.h \
modest-widget-memory-priv.h \
modest-widget-memory.c \
modest-widget-memory.h
account_name,
get_fullname (self),
get_email (self),
- MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY,
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
store_name,
transport_name, TRUE);
modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
const gchar *msg)
{
+ gint response;
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (parent_window,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK_CANCEL,
+ msg);
+
+ response = gtk_dialog_run (GTK_DIALOG(dialog));
+ gtk_widget_destroy (dialog);
+
/* TODO implement confirmation dialog */
- return GTK_RESPONSE_CANCEL;
+ return response;
}
void
modest_platform_run_information_dialog (GtkWindow *parent_window,
const gchar *message)
{
- /* TODO: implement a information dialog */
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (parent_window,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
}
gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account)
g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
}
+GtkWidget *
+modest_platform_get_account_settings_dialog (ModestAccountSettings *settings)
+{
+ GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "NOT IMPLEMENTED");
+ return dialog;
+}
+
+GtkWidget *
+modest_platform_get_account_settings_wizard ()
+{
+ GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "NOT IMPLEMENTED");
+ return dialog;
+}
return NULL; /* Failed. */
}
+
+void
+easysetup_provider_combo_box_set_others_provider (EasysetupProviderComboBox *combobox)
+{
+ GtkTreeModel *model;
+ GtkTreeIter others_iter;
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
+
+ gtk_tree_model_get_iter_first (model, &others_iter);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &others_iter);
+}
#include "widgets/modest-ui-constants.h"
#include "maemo/modest-account-settings-dialog.h"
#include "maemo/modest-maemo-utils.h"
+#include "modest-utils.h"
#include <gconf/gconf-client.h>
#include <string.h> /* For strlen(). */
#include "maemo/modest-hildon-includes.h"
/* Check if the user changes a field to show a confirmation dialog */
gboolean dirty;
+
+ /* If we have a pending load of settings or not. */
+ gboolean pending_load_settings;
};
+static void save_to_settings (ModestEasysetupWizardDialog *self);
+
+
static gboolean
on_delete_event (GtkWidget *widget,
GdkEvent *event,
if (self->specific_window)
gtk_widget_destroy (self->specific_window);
+
+ if (self->settings)
+ g_object_unref (self->settings);
- g_free (self->saved_account_name);
-
G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->finalize (object);
}
static void
show_error (GtkWidget *parent_widget, const gchar* text);
-static gboolean
-create_account (ModestEasysetupWizardDialog *self, gboolean enabled);
-
static void
create_subsequent_easysetup_pages (ModestEasysetupWizardDialog *self);
account_wizard->combo_incoming_security));
const int port_num = get_serverport_incoming(protocol, protocol_security_incoming);
GList *list_auth_methods =
- modest_maemo_utils_get_supported_secure_authentication_methods (
- protocol,
- hostname, port_num, username, GTK_WINDOW (account_wizard), &error);
+ modest_utils_get_supported_secure_authentication_methods (protocol, hostname, port_num,
+ username, GTK_WINDOW (account_wizard), &error);
if (list_auth_methods) {
/* TODO: Select the correct method */
GList* list = NULL;
return list;
}
- 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)
+ if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
+ error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
{
show_error (GTK_WIDGET(account_wizard), _("Could not discover supported secure authentication methods."));
}
show_advanced_edit(gpointer user_data)
{
ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
-
- if (!(self->saved_account_name))
- return FALSE;
+ ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
+ gint response;
/* Show the Account Settings window: */
ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
- modest_account_settings_dialog_set_account_name (dialog, self->saved_account_name);
+ if (priv->pending_load_settings) {
+ save_to_settings (self);
+ priv->pending_load_settings = FALSE;
+ }
+ modest_account_settings_dialog_set_account (dialog, self->settings);
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
- gtk_dialog_run (GTK_DIALOG (dialog));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
{
ModestEasysetupWizardDialog * self = MODEST_EASYSETUP_WIZARD_DIALOG (user_data);
- /* Save the new account, so we can edit it with ModestAccountSettingsDialog,
- * without recoding it to use non-gconf information.
- * This account will be deleted if Finish is never actually clicked. */
-
- gboolean saved = TRUE;
- if (!(self->saved_account_name)) {
- saved = create_account (self, FALSE);
- }
-
- if (!saved)
- return;
-
- if (!(self->saved_account_name))
- return;
-
/* Show the Account Settings window: */
show_advanced_edit(self);
}
gpointer user_data)
{
ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (wizard_dialog);
- if (response_id == GTK_RESPONSE_CANCEL) {
- /* Remove any temporarily-saved account that will not actually be needed: */
- if (self->saved_account_name) {
- modest_account_mgr_remove_account (self->account_manager,
- self->saved_account_name);
- }
- }
invoke_enable_buttons_vfunc (self);
}
* specified in the UI specification. */
const gint dialog_response = gtk_dialog_run (dialog);
- self->combo_account_country = NULL;
gtk_widget_destroy (GTK_WIDGET (dialog));
if (dialog_response != GTK_RESPONSE_OK) {
/* The server fields did not have been manually changed yet */
priv->server_changes = 0;
+ priv->pending_load_settings = TRUE;
/* Get the account manager object,
* so we can check for existing accounts,
hildon_help_dialog_help_enable (GTK_DIALOG(self), "applications_email_wizardwelcome",
modest_maemo_utils_get_osso_context());
+
+ self->settings = modest_account_settings_new ();
}
ModestEasysetupWizardDialog*
on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *next_page)
{
ModestEasysetupWizardDialog *account_wizard = MODEST_EASYSETUP_WIZARD_DIALOG (dialog);
+ ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (account_wizard);
+
+ /* if are browsing pages previous to the last one, then we have pending settings in
+ * this wizard */
+ if (next_page != NULL)
+ priv->pending_load_settings = TRUE;
/* Do extra validation that couldn't be done for every key press,
* either because it was too slow,
/* Check if the server supports secure authentication */
const ModestConnectionProtocol security_incoming =
modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (
- account_wizard->combo_incoming_security));
+ MODEST_SERVERSECURITY_COMBO_BOX (account_wizard->combo_incoming_security));
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (account_wizard->checkbox_incoming_auth))
&& !modest_protocol_info_is_secure(security_incoming))
*/
if(!next_page) /* This is NULL when this is a click on Finish. */
{
- if (account_wizard->saved_account_name) {
- /* Just enable the already-saved account (temporarily created when
- * editing advanced settings): */
- modest_account_mgr_set_enabled (account_wizard->account_manager,
- account_wizard->saved_account_name, TRUE);
- } else {
- create_account (account_wizard, TRUE /* enabled */);
+ if (priv->pending_load_settings) {
+ save_to_settings (account_wizard);
}
+ modest_account_mgr_add_account_from_settings (account_wizard->account_manager, account_wizard->settings);
}
show_error (GtkWidget *parent_widget, const gchar* text)
{
//TODO: Apparently this doesn't show anything in Maemo Bora:
- hildon_banner_show_information(parent_widget, NULL, text);
-
-#if 0
- GtkDialog *dialog = GTK_DIALOG (hildon_note_new_information (parent_window, 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
+ hildon_banner_show_information(parent_widget, NULL, text);
}
-/** Attempt to create the account from the information that the user has entered.
- * @result: TRUE if the account was successfully created.
+
+/**
+ * save_to_settings:
+ * @self: a #ModestEasysetupWizardDialog
+ *
+ * takes information from all the wizard and stores it in settings
*/
-static gboolean
-create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
+static void
+save_to_settings (ModestEasysetupWizardDialog *self)
{
ModestEasysetupWizardDialogPrivate *priv = WIZARD_DIALOG_GET_PRIVATE (self);
guint special_port;
- gchar* display_name = get_entered_account_title (self);
+ gchar *provider_id;
+ gchar* display_name;
+ const gchar *username, *password;
+ gchar *store_hostname, *transport_hostname;
+ guint store_port, transport_port;
+ ModestTransportStoreProtocol store_protocol, transport_protocol;
+ ModestConnectionProtocol store_security, transport_security;
+ ModestAuthProtocol store_auth_protocol, transport_auth_protocol;
+ ModestServerAccountSettings *store_settings, *transport_settings;
+ const gchar *fullname, *email_address;
- /* Some checks: */
- if (!display_name)
- return FALSE;
-
- /* We should have checked for this already,
- * and changed that name accordingly,
- * but let's check again just in case:
- */
- if (modest_account_mgr_account_with_display_name_exists (self->account_manager, display_name)) {
- g_free (display_name);
- return FALSE;
- }
-
- /* Increment the non-user visible name if necessary,
- * based on the display name: */
- gchar *account_name_start = g_strdup_printf ("%sID", display_name);
- gchar* account_name = modest_account_mgr_get_unused_account_name (self->account_manager,
- account_name_start, FALSE /* not a server account */);
- g_free (account_name_start);
+ /* Get details from the specified presets: */
+ provider_id = easysetup_provider_combo_box_get_active_provider_id (
+ EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider));
/* username and password (for both incoming and outgoing): */
- const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
- const gchar* password = gtk_entry_get_text (GTK_ENTRY (self->entry_user_password));
+ username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username));
+ password = gtk_entry_get_text (GTK_ENTRY (self->entry_user_password));
+
/* Incoming server: */
/* Note: We need something as default for the ModestTransportStoreProtocol* values,
* or modest_account_mgr_add_server_account will fail. */
- gchar* servername_incoming = NULL;
- guint serverport_incoming = 0;
- ModestTransportStoreProtocol protocol_incoming = MODEST_PROTOCOL_STORE_POP;
- ModestConnectionProtocol protocol_security_incoming = MODEST_PROTOCOL_CONNECTION_NORMAL;
- ModestAuthProtocol protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_NONE;
+ store_port = 0;
+ store_protocol = MODEST_PROTOCOL_STORE_POP;
+ store_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ store_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
- /* Get details from the specified presets: */
- gchar* provider_id = easysetup_provider_combo_box_get_active_provider_id (
- EASYSETUP_PROVIDER_COMBO_BOX (self->combo_account_serviceprovider));
if (provider_id) {
+ ModestPresetsServerType store_provider_server_type;
+ ModestPresetsSecurity store_provider_security;
/* Use presets: */
- servername_incoming = modest_presets_get_server (priv->presets, provider_id,
- TRUE /* incoming */);
+ store_hostname = modest_presets_get_server (priv->presets, provider_id,
+ TRUE /* store */);
- ModestPresetsServerType servertype_incoming = modest_presets_get_info_server_type (priv->presets,
- provider_id,
- TRUE /* incoming */);
- ModestPresetsSecurity security_incoming = modest_presets_get_info_server_security (priv->presets,
- provider_id,
- TRUE /* incoming */);
+ store_provider_server_type = modest_presets_get_info_server_type (priv->presets,
+ provider_id,
+ TRUE /* store */);
+ store_provider_security = modest_presets_get_info_server_security (priv->presets,
+ provider_id,
+ TRUE /* store */);
-
/* We don't check for SMTP here as that is impossible for an incoming server. */
- if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_IMAP) {
- protocol_incoming = MODEST_PROTOCOL_STORE_IMAP;
- } else if (servertype_incoming == MODEST_PRESETS_SERVER_TYPE_POP) {
- protocol_incoming = MODEST_PROTOCOL_STORE_POP;
- }
- serverport_incoming = get_serverport_incoming(servertype_incoming, security_incoming);
+ if (store_provider_server_type == MODEST_PRESETS_SERVER_TYPE_IMAP)
+ store_protocol = MODEST_PROTOCOL_STORE_IMAP;
+ else if (store_provider_server_type == MODEST_PRESETS_SERVER_TYPE_POP)
+ store_protocol = MODEST_PROTOCOL_STORE_POP;
+ else /* fallback */
+ store_protocol = MODEST_PROTOCOL_STORE_POP;
+
+ /* we check if there is a *special* port */
+ special_port = modest_presets_get_port (priv->presets, provider_id, TRUE /* incoming */);
+ if (special_port != 0)
+ store_port = special_port;
+ else
+ store_port = get_serverport_incoming(store_provider_server_type, store_provider_security);
- if (security_incoming & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
- protocol_security_incoming = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
+ if (store_provider_security & MODEST_PRESETS_SECURITY_SECURE_INCOMING)
+ store_security = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
- if (security_incoming & MODEST_PRESETS_SECURITY_APOP)
- protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD; /* TODO: Is this what we want? */
- }
- else {
+ if (store_provider_security & MODEST_PRESETS_SECURITY_APOP)
+ store_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD; /* TODO: Is this what we want? */
+ } else {
/* Use custom pages because no preset was specified: */
- servername_incoming = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver) ));
-
- protocol_incoming = easysetup_servertype_combo_box_get_active_servertype (
- EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
-
- protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
+ store_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_incomingserver) ));
+ store_protocol = easysetup_servertype_combo_box_get_active_servertype (
+ EASYSETUP_SERVERTYPE_COMBO_BOX (self->combo_incoming_servertype));
+ store_security = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security));
- /* The UI spec says:
+ /* The UI spec says:
* If secure authentication is unchecked, allow sending username and password also as plain text.
- * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
- */
-
+ * If secure authentication is checked, require one of the secure methods during
+ * connection: SSL, TLS, CRAM-MD5 etc. */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth)) &&
- !modest_protocol_info_is_secure(protocol_security_incoming)) {
- protocol_authentication_incoming = check_first_supported_auth_method (self);
- }
- else {
- protocol_authentication_incoming = MODEST_PROTOCOL_AUTH_PASSWORD;
+ !modest_protocol_info_is_secure(store_security)) {
+ store_auth_protocol = check_first_supported_auth_method (self);
+ } else {
+ store_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD;
}
}
-
- /* First we add the 2 server accounts, and then we add the account that uses them.
- * If we don't do it in this order then we will experience a crash. */
-
- /* Add a (incoming) server account, to be used by the account: */
- gchar *store_name_start = g_strconcat (account_name, "_store", NULL);
- gchar *store_name = modest_account_mgr_get_unused_account_name (self->account_manager,
- store_name_start, TRUE /* server account */);
- g_free (store_name_start);
-
- /* we check if there is a *special* port */
- special_port = modest_presets_get_port (priv->presets, provider_id,
- TRUE /* incoming */);
- if (special_port != 0)
- serverport_incoming = special_port;
-
- gboolean created = modest_account_mgr_add_server_account (self->account_manager,
- store_name,
- servername_incoming,
- serverport_incoming,
- username, password,
- protocol_incoming,
- protocol_security_incoming,
- protocol_authentication_incoming);
-
- g_free (servername_incoming);
-
- if (!created) {
- /* TODO: Provide a Logical ID for the text: */
- show_error (GTK_WIDGET (self), _("An error occurred while creating the incoming account."));
- g_free (display_name);
- return FALSE;
- }
+
+ /* now we store the store account settings */
+ store_settings = modest_account_settings_get_store_settings (self->settings);
+ modest_server_account_settings_set_hostname (store_settings, store_hostname);
+ modest_server_account_settings_set_username (store_settings, username);
+ modest_server_account_settings_set_password (store_settings, password);
+ modest_server_account_settings_set_protocol (store_settings, store_protocol);
+ modest_server_account_settings_set_security (store_settings, store_security);
+ modest_server_account_settings_set_auth_protocol (store_settings, store_auth_protocol);
+ if (store_port != 0)
+ modest_server_account_settings_set_port (store_settings, store_port);
+
+ g_object_unref (store_settings);
+ g_free (store_hostname);
/* Outgoing server: */
- gchar* servername_outgoing = NULL;
- ModestTransportStoreProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP;
- ModestConnectionProtocol protocol_security_outgoing = MODEST_PROTOCOL_CONNECTION_NORMAL;
- ModestAuthProtocol protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
- guint serverport_outgoing = 0;
+ transport_hostname = NULL;
+ transport_protocol = MODEST_PROTOCOL_STORE_POP;
+ transport_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ transport_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ transport_port = 0;
if (provider_id) {
+ ModestPresetsServerType transport_provider_server_type;
+ ModestPresetsSecurity transport_provider_security;
+
/* Use presets: */
- servername_outgoing = modest_presets_get_server (priv->presets, provider_id,
- FALSE /* incoming */);
+ transport_hostname = modest_presets_get_server (priv->presets, provider_id,
+ FALSE /* transport */);
- ModestPresetsServerType servertype_outgoing = modest_presets_get_info_server_type (priv->presets,
- provider_id,
- FALSE /* incoming */);
-
+ transport_provider_server_type = modest_presets_get_info_server_type (priv->presets,
+ provider_id,
+ FALSE /* transport */);
+ transport_provider_security = modest_presets_get_info_server_security (priv->presets,
+ provider_id,
+ FALSE /* transport */);
+
/* Note: We need something as default, or modest_account_mgr_add_server_account will fail. */
- protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SENDMAIL;
- if (servertype_outgoing == MODEST_PRESETS_SERVER_TYPE_SMTP)
- protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP;
-
- ModestPresetsSecurity security_outgoing =
- modest_presets_get_info_server_security (priv->presets, provider_id,
- FALSE /* incoming */);
+ transport_protocol = MODEST_PROTOCOL_TRANSPORT_SENDMAIL;
+ if (transport_provider_server_type == MODEST_PRESETS_SERVER_TYPE_SMTP)
+ transport_protocol = MODEST_PROTOCOL_TRANSPORT_SMTP;
- protocol_security_outgoing = MODEST_PROTOCOL_CONNECTION_NORMAL;
- if (security_outgoing & MODEST_PRESETS_SECURITY_SECURE_SMTP) {
+ transport_security = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ if (transport_provider_security & MODEST_PRESETS_SECURITY_SECURE_SMTP) {
/* printf("DEBUG: %s: using secure SMTP\n", __FUNCTION__); */
- protocol_security_outgoing = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
- serverport_outgoing = 465;
- protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_PASSWORD;
+ transport_security = MODEST_PROTOCOL_CONNECTION_SSL; /* TODO: Is this what we want? */
+ /* we check if there is a *special* port */
+ special_port = modest_presets_get_port (priv->presets, provider_id,
+ FALSE /* transport */);
+ if (special_port != 0)
+ transport_port = special_port;
+ else
+ transport_port = 465;
+ transport_auth_protocol = MODEST_PROTOCOL_AUTH_PASSWORD;
} else {
/* printf("DEBUG: %s: using non-secure SMTP\n", __FUNCTION__); */
- protocol_authentication_outgoing = MODEST_PROTOCOL_AUTH_NONE;
+ transport_auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
}
} else {
/* Use custom pages because no preset was specified: */
- servername_outgoing = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver) ));
-
- protocol_outgoing = MODEST_PROTOCOL_TRANSPORT_SMTP; /* It's always SMTP for outgoing. */
-
- protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
-
- protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
+ transport_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (self->entry_outgoingserver) ));
+ transport_protocol = MODEST_PROTOCOL_TRANSPORT_SMTP; /* It's always SMTP for outgoing. */
+ transport_security = modest_serversecurity_combo_box_get_active_serversecurity (
+ MODEST_SERVERSECURITY_COMBO_BOX (self->combo_outgoing_security));
+ transport_auth_protocol = modest_secureauth_combo_box_get_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (self->combo_outgoing_auth));
}
- /* Add a (outgoing) server account to be used by the account: */
- gchar *transport_name_start = g_strconcat (account_name, "_transport", NULL);
- gchar *transport_name = modest_account_mgr_get_unused_account_name (self->account_manager,
- transport_name_start, TRUE /* server account */);
- g_free (transport_name_start);
-
- /* we check if there is a *special* port */
- special_port = modest_presets_get_port (priv->presets, provider_id,
- FALSE /* incoming */);
- if (special_port != 0)
- serverport_outgoing = special_port;
-
- created = modest_account_mgr_add_server_account (self->account_manager,
- transport_name,
- servername_outgoing,
- serverport_outgoing,
- username, password,
- protocol_outgoing,
- protocol_security_outgoing,
- protocol_authentication_outgoing);
-
- g_free (servername_outgoing);
-
- if (!created) {
- /* TODO: Provide a Logical ID for the text: */
- show_error (GTK_WIDGET (self), _("An error occurred while creating the outgoing account."));
- g_free (display_name);
- return FALSE;
- }
+ /* now we transport the transport account settings */
+ transport_settings = modest_account_settings_get_transport_settings (self->settings);
+ modest_server_account_settings_set_hostname (transport_settings, transport_hostname);
+ modest_server_account_settings_set_username (transport_settings, username);
+ modest_server_account_settings_set_password (transport_settings, password);
+ modest_server_account_settings_set_protocol (transport_settings, transport_protocol);
+ modest_server_account_settings_set_security (transport_settings, transport_security);
+ modest_server_account_settings_set_auth_protocol (transport_settings, transport_auth_protocol);
+ if (transport_port != 0)
+ modest_server_account_settings_set_port (transport_settings, transport_port);
+
+ g_object_unref (transport_settings);
+ g_free (transport_hostname);
+
+ fullname = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
+ email_address = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
+ modest_account_settings_set_fullname (self->settings, fullname);
+ modest_account_settings_set_email_address (self->settings, email_address);
+ /* we don't set retrieve type to preserve advanced settings if any. By default account settings
+ are set to headers only */
- const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
- const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
- const gchar *retrieve = MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
-
- /* Create the account, which will contain the two "server accounts": */
- created = modest_account_mgr_add_account (self->account_manager,
- account_name,
- display_name,
- user_fullname,
- emailaddress,
- retrieve,
- store_name,
- transport_name,
- enabled);
- g_free (store_name);
- g_free (transport_name);
-
- if (!created) {
- /* TODO: Provide a Logical ID for the text: */
- show_error (GTK_WIDGET (self), _("An error occurred while creating the account."));
- g_free (display_name);
- return FALSE;
- }
-
- /* Sanity check: */
- /* There must be at least one account now: */
- /* Note, when this fails is is caused by a Maemo gconf bug that has been
- * fixed in versions after 3.1. */
- if(!modest_account_mgr_has_accounts (self->account_manager, FALSE))
- g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
-
/* Save the connection-specific SMTP server accounts. */
- modest_account_mgr_set_use_connection_specific_smtp(self->account_manager, account_name,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->checkbox_outgoing_smtp_specific)));
- gboolean result = TRUE;
- if (self->specific_window)
- result = modest_connection_specific_smtp_window_save_server_accounts (
- MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window));
+ modest_account_settings_set_use_connection_specific_smtp
+ (self->settings,
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->checkbox_outgoing_smtp_specific)));
-
- g_free (self->saved_account_name);
- self->saved_account_name = g_strdup (account_name);
-
- g_free (account_name);
+ display_name = get_entered_account_title (self);
+ modest_account_settings_set_display_name (self->settings, display_name);
g_free (display_name);
-
- return result;
+
+ if (self->specific_window)
+ modest_connection_specific_smtp_window_save_server_accounts (
+ MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (self->specific_window));
}
+
/* Used by derived widgets to query existing accounts,
* and to create new accounts: */
ModestAccountMgr *account_manager;
+ ModestAccountSettings *settings;
- /* Whether we saved the account before we were finished,
- * to allow editing via the Advanced Settings dialog.
- * We might need to delete the account if Finish is never clicked. */
- gchar* saved_account_name;
-
/* notebook pages: */
GtkWidget *page_welcome;
#include "modest-protocol-info.h"
#include "maemo/modest-connection-specific-smtp-window.h"
#include "maemo/modest-signature-editor-dialog.h"
+#include <modest-utils.h>
#include "maemo/modest-maemo-utils.h"
#include "widgets/modest-ui-constants.h"
#include <tny-account.h>
static gboolean
save_configuration (ModestAccountSettingsDialog *dialog);
+static const gchar * null_means_empty (const gchar * str);
+
+static const gchar *
+null_means_empty (const gchar * str)
+{
+ return str ? str : "";
+}
+
+
static void
modest_account_settings_dialog_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
if (self->signature_dialog)
gtk_widget_destroy (self->signature_dialog);
+
+ if (self->settings) {
+ g_object_unref (self->settings);
+ self->settings = NULL;
+ }
G_OBJECT_CLASS (modest_account_settings_dialog_parent_class)->finalize (object);
}
if (!(self->signature_dialog)) {
self->signature_dialog = GTK_WIDGET (modest_signature_editor_dialog_new ());
- gboolean use_signature = FALSE;
- gchar *signature = modest_account_mgr_get_signature(self->account_manager, self->account_name,
- &use_signature);
+ gboolean use_signature = modest_account_settings_get_use_signature (self->settings);
+ const gchar *signature = modest_account_settings_get_signature(self->settings);
gchar* account_title = get_entered_account_title (self);
modest_signature_editor_dialog_set_settings (
MODEST_SIGNATURE_EDITOR_DIALOG (self->signature_dialog),
g_free (account_title);
account_title = NULL;
- g_free (signature);
signature = NULL;
}
GError *error = NULL;
GList *list_auth_methods =
- modest_maemo_utils_get_supported_secure_authentication_methods (self->incoming_protocol,
+ modest_utils_get_supported_secure_authentication_methods (self->incoming_protocol,
hostname, port_num, username, GTK_WINDOW (self), &error);
if (list_auth_methods) {
/* Use the first supported method.
if (list_auth_methods == NULL ||
!modest_protocol_info_auth_is_secure(self->protocol_authentication_incoming))
{
- 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)
+ if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() ||
+ error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED)
hildon_banner_show_information(GTK_WIDGET (self), NULL,
_("Could not discover supported secure authentication methods."));
* temporarily, because from the user's point of view it will not
* really be saved (saved + enabled) until later
*/
- 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) {
+ if (modest_account_settings_get_account_name (self->settings) != NULL) {
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
+ const gchar *store_account_name;
+ const gchar *transport_account_name;
+
+
+ store_settings = modest_account_settings_get_store_settings (self->settings);
+ transport_settings = modest_account_settings_get_store_settings (self->settings);
+ store_account_name = modest_server_account_settings_get_account_name (store_settings);
+ transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
+
+ if (store_account_name) {
modest_account_mgr_notify_account_update (self->account_manager,
- incoming_account_name);
- g_free (incoming_account_name);
+ store_account_name);
}
- if (outgoing_account_name) {
+ if (transport_account_name) {
modest_account_mgr_notify_account_update (self->account_manager,
- outgoing_account_name);
- g_free (outgoing_account_name);
+ transport_account_name);
}
+ g_object_unref (store_settings);
+ g_object_unref (transport_settings);
hildon_banner_show_information(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
}
/* Create the notebook to be used by the GtkDialog base class:
* Each page of the notebook will be a page of the wizard: */
self->notebook = GTK_NOTEBOOK (gtk_notebook_new());
+ self->settings = modest_account_settings_new ();
/* Get the account manager object,
* so we can check for existing accounts,
/** Update the UI with the stored account details, so they can be edited.
* @account_name: Name of the account, which should contain incoming and outgoing server accounts.
*/
-void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialog *dialog, const gchar* account_name)
+void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings)
{
- if (!account_name)
- return;
+ ModestServerAccountSettings *incoming_account;
+ ModestServerAccountSettings *outgoing_account;
+ const gchar *account_name;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ incoming_account = modest_account_settings_get_store_settings (settings);
+ outgoing_account = modest_account_settings_get_transport_settings (settings);
+
+ account_name = modest_account_settings_get_account_name (settings);
/* Save the account name so we can refer to it later: */
if (dialog->account_name)
g_free (dialog->account_name);
dialog->account_name = g_strdup (account_name);
-
-
- /* Get the account data for this account name: */
- ModestAccountData *account_data = modest_account_mgr_get_account_data (dialog->account_manager,
- account_name);
- if (!account_data) {
- g_printerr ("modest: failed to get account data for %s\n", account_name);
- return;
- }
+
+ if (dialog->settings)
+ g_object_unref (dialog->settings);
+ dialog->settings = g_object_ref (settings);
/* Save the account title so we can refer to it if the user changes it: */
if (dialog->original_account_title)
g_free (dialog->original_account_title);
- dialog->original_account_title = g_strdup (account_data->display_name);
+ dialog->original_account_title = g_strdup (modest_account_settings_get_display_name (settings));
-
- if (!(account_data->store_account)) {
- g_printerr ("modest: account has no stores: %s\n", account_name);
- return;
- }
-
/* Show the account data in the widgets: */
/* Note that we never show the non-display name in the UI.
* (Though the display name defaults to the non-display name at the start.) */
gtk_entry_set_text( GTK_ENTRY (dialog->entry_account_title),
- account_data->display_name ? account_data->display_name : "");
-
+ null_means_empty (modest_account_settings_get_display_name (settings)));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_name),
- account_data->fullname ? account_data->fullname : "");
+ null_means_empty (modest_account_settings_get_fullname (settings)));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email),
- account_data->email ? account_data->email : "");
-
- ModestServerAccountData *incoming_account = account_data->store_account;
-
- if (incoming_account)
- modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), incoming_account->proto);
-
-
- 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_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);
+ null_means_empty (modest_account_settings_get_email_address (settings)));
+ modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve),
+ modest_server_account_settings_get_protocol (incoming_account));
+ modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve),
+ modest_account_settings_get_retrieve_type (settings));
+ modest_limit_retrieve_combo_box_set_active_limit_retrieve (
+ MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve),
+ modest_account_settings_get_retrieve_limit (settings));
- 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);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages),
+ modest_account_settings_get_leave_messages_on_server (settings));
/* Only show the leave-on-server checkbox for POP,
* as per the UI spec: */
- if (incoming_account->proto != MODEST_PROTOCOL_STORE_POP) {
+ if (modest_server_account_settings_get_protocol (incoming_account) != MODEST_PROTOCOL_STORE_POP) {
gtk_widget_hide (dialog->caption_leave_messages);
} else {
gtk_widget_show (dialog->caption_leave_messages);
}
- update_incoming_server_security_choices (dialog, incoming_account->proto);
+ update_incoming_server_security_choices (dialog, modest_server_account_settings_get_protocol (incoming_account));
if (incoming_account) {
+ const gchar *username;
+ const gchar *password;
+ const gchar *hostname;
/* Remember this for later: */
- dialog->incoming_protocol = incoming_account->proto;
+ dialog->incoming_protocol = modest_server_account_settings_get_protocol (incoming_account);;
+ hostname = modest_server_account_settings_get_hostname (incoming_account);
+ username = modest_server_account_settings_get_username (incoming_account);
+ password = modest_server_account_settings_get_password (incoming_account);
gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_username),
- incoming_account->username ? incoming_account->username : "");
+ null_means_empty (username));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_password),
- incoming_account->password ? incoming_account->password : "");
+ null_means_empty (password));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_incomingserver),
- incoming_account->hostname ? incoming_account->hostname : "");
+ null_means_empty (hostname));
/* The UI spec says:
* If secure authentication is unchecked, allow sending username and password also as plain text.
* 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_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);
+ MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security),
+ modest_server_account_settings_get_security (incoming_account));
/* Check if we have
- a secure protocol
OR
- use encrypted passwords
*/
- 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;
+ const ModestAuthProtocol secure_auth = modest_server_account_settings_get_auth_protocol (incoming_account);
+ dialog->protocol_authentication_incoming = (secure_auth != MODEST_PROTOCOL_AUTH_NONE)?
+ secure_auth:MODEST_PROTOCOL_AUTH_PASSWORD;
if (modest_protocol_info_auth_is_secure(secure_auth))
{
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth),
FALSE);
};
- update_incoming_server_title (dialog, incoming_account->proto);
+ update_incoming_server_title (dialog, dialog->incoming_protocol);
- const gint port_num = modest_account_mgr_get_server_account_port (dialog->account_manager,
- incoming_account->account_name);
+ const gint port_num = modest_server_account_settings_get_port (incoming_account);
if (port_num == 0) {
/* Show the appropriate port number: */
on_combo_incoming_security_changed (
hildon_number_editor_set_value (
HILDON_NUMBER_EDITOR (dialog->entry_incoming_port), port_num);
}
+ g_object_unref (incoming_account);
}
- ModestServerAccountData *outgoing_account = account_data->transport_account;
+ outgoing_account = modest_account_settings_get_transport_settings (settings);
if (outgoing_account) {
+ const gchar *hostname;
+ const gchar *username;
+ const gchar *password;
+
/* Remember this for later: */
- dialog->outgoing_protocol = outgoing_account->proto;
-
+ dialog->outgoing_protocol =
+ modest_server_account_settings_get_protocol (outgoing_account);
+
+ hostname = modest_server_account_settings_get_hostname (outgoing_account);
+ username = modest_server_account_settings_get_username (outgoing_account);
+ password = modest_server_account_settings_get_password (outgoing_account);
gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoingserver),
- outgoing_account->hostname ? outgoing_account->hostname : "");
+ null_means_empty (hostname));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_username),
- outgoing_account->username ? outgoing_account->username : "");
+ null_means_empty (username));
gtk_entry_set_text( GTK_ENTRY (dialog->entry_outgoing_password),
- outgoing_account->password ? outgoing_account->password : "");
+ null_means_empty (password));
/* Get the secure-auth setting: */
- const ModestAuthProtocol secure_auth = modest_account_mgr_get_server_account_secure_auth(
- dialog->account_manager, outgoing_account->account_name);
+ const ModestAuthProtocol secure_auth = modest_server_account_settings_get_auth_protocol (outgoing_account);
modest_secureauth_combo_box_set_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth), secure_auth);
on_combo_outgoing_auth_changed (GTK_COMBO_BOX (dialog->combo_outgoing_auth), dialog);
modest_serversecurity_combo_box_fill (
- MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), outgoing_account->proto);
+ MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security),
+ dialog->outgoing_protocol);
/* Get the security setting: */
- const ModestConnectionProtocol security = modest_account_mgr_get_server_account_security (
- dialog->account_manager, outgoing_account->account_name);
+ const ModestConnectionProtocol security = modest_server_account_settings_get_security (outgoing_account);
modest_serversecurity_combo_box_set_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security), security);
- const gint port_num = modest_account_mgr_get_server_account_port (dialog->account_manager,
- outgoing_account->account_name);
+ const gint port_num = modest_server_account_settings_get_port (outgoing_account);
if (port_num == 0) {
/* Show the appropriate port number: */
on_combo_outgoing_security_changed (
}
const gboolean has_specific =
- modest_account_mgr_get_use_connection_specific_smtp (
- dialog->account_manager, account_name);
+ modest_account_settings_get_use_connection_specific_smtp (settings);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dialog->checkbox_outgoing_smtp_specific),
has_specific);
+ g_object_unref (outgoing_account);
}
/* Set window title according to account: */
* the protocol used? */
const gchar* proto_str = modest_protocol_info_get_transport_store_protocol_name (dialog->incoming_protocol);
gchar *proto_name = g_utf8_strup(proto_str, -1);
- gchar *account_title = modest_account_mgr_get_display_name(dialog->account_manager, account_name);
+ const gchar *account_title = modest_account_settings_get_display_name(settings);
gchar *title = g_strdup_printf(_("mcen_ti_account_settings"), proto_name, account_title);
g_free (proto_name);
- g_free (account_title);
gtk_window_set_title (GTK_WINDOW (dialog), title);
g_free (title);
/* account_data->is_enabled, */
/*account_data->is_default, */
- /* account_data->store_account->proto */
-
- modest_account_mgr_free_account_data (dialog->account_manager, account_data);
-
/* Unset the modified flag so we can detect changes later: */
dialog->modified = FALSE;
}
static gboolean
save_configuration (ModestAccountSettingsDialog *dialog)
{
- g_assert (dialog->account_name);
-
const gchar* account_name = dialog->account_name;
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
/* Set the account data from the widgets: */
const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
- modest_account_mgr_set_user_fullname (dialog->account_manager,
- account_name,
- user_fullname);
+ modest_account_settings_set_fullname (dialog->settings, user_fullname);
const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
- modest_account_mgr_set_user_email (dialog->account_manager, account_name,
- emailaddress);
+ modest_account_settings_set_email_address (dialog->settings, emailaddress);
/* Signature: */
if (dialog->signature_dialog) {
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_settings_set_use_signature (dialog->settings, use_signature);
+ modest_account_settings_set_signature (dialog->settings, signature);
}
- gchar *retrieve = modest_retrieve_combo_box_get_active_retrieve_conf (
+ ModestAccountRetrieveType retrieve_type = modest_retrieve_combo_box_get_active_retrieve_conf (
MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve));
- modest_account_mgr_set_retrieve_type (dialog->account_manager, account_name, (const gchar*) retrieve);
- g_free (retrieve);
+ modest_account_settings_set_retrieve_type (dialog->settings, retrieve_type);
- const gint limit_retrieve = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
+ gint retrieve_limit = modest_limit_retrieve_combo_box_get_active_limit_retrieve (
MODEST_LIMIT_RETRIEVE_COMBO_BOX (dialog->combo_limit_retrieve));
- modest_account_mgr_set_retrieve_limit (dialog->account_manager, account_name, limit_retrieve);
+ modest_account_settings_set_retrieve_limit (dialog->settings, retrieve_limit);
const gboolean leave_on_server = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->checkbox_leave_messages));
- modest_account_mgr_set_leave_on_server (dialog->account_manager, account_name, leave_on_server);
+ modest_account_settings_set_leave_messages_on_server (dialog->settings, leave_on_server);
+
+ store_settings = modest_account_settings_get_store_settings (dialog->settings);
- /* Incoming: */
- 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));
- modest_account_mgr_set_server_account_hostname (dialog->account_manager, incoming_account_name, hostname);
+ modest_server_account_settings_set_hostname (store_settings, hostname);
const gchar* username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_username));
- modest_account_mgr_set_server_account_username (dialog->account_manager, incoming_account_name, username);
+ modest_server_account_settings_set_username (store_settings, username);
const gchar* password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_password));
- modest_account_mgr_set_server_account_password (dialog->account_manager, incoming_account_name,
- password);
+ modest_server_account_settings_set_password (store_settings, password);
/* port: */
gint port_num = hildon_number_editor_get_value (
HILDON_NUMBER_EDITOR (dialog->entry_incoming_port));
- modest_account_mgr_set_server_account_port (dialog->account_manager, incoming_account_name, port_num);
+ modest_server_account_settings_set_port (store_settings, port_num);
/* The UI spec says:
* If secure authentication is unchecked, allow sending username and password also as plain text.
- * If secure authentication is checked, require one of the secure methods during connection: SSL, TLS, CRAM-MD5 etc.
+ * If secure authentication is checked, require one of the secure
+ * methods during connection: SSL, TLS, CRAM-MD5 etc.
*/
const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security));
- modest_account_mgr_set_server_account_security (dialog->account_manager, incoming_account_name, protocol_security_incoming);
-
- modest_account_mgr_set_server_account_secure_auth (dialog->account_manager, incoming_account_name, dialog->protocol_authentication_incoming);
-
-
- g_free (incoming_account_name);
+ modest_server_account_settings_set_security (store_settings, protocol_security_incoming);
+ modest_server_account_settings_set_auth_protocol (store_settings, dialog->protocol_authentication_incoming);
+
+ g_object_unref (store_settings);
/* Outgoing: */
- 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);
+ transport_settings = modest_account_settings_get_transport_settings (dialog->settings);
hostname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoingserver));
- modest_account_mgr_set_server_account_hostname (dialog->account_manager, outgoing_account_name, hostname);
+ modest_server_account_settings_set_hostname (transport_settings, hostname);
username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
- modest_account_mgr_set_server_account_username (dialog->account_manager, outgoing_account_name,
- username);
+ modest_server_account_settings_set_username (transport_settings, username);
password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
- modest_account_mgr_set_server_account_password (dialog->account_manager, outgoing_account_name,
- password);
+ modest_server_account_settings_set_password (transport_settings, password);
const ModestConnectionProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
- modest_account_mgr_set_server_account_security (dialog->account_manager, outgoing_account_name, protocol_security_outgoing);
+ modest_server_account_settings_set_security (transport_settings, protocol_security_outgoing);
const ModestAuthProtocol protocol_authentication_outgoing = modest_secureauth_combo_box_get_active_secureauth (
MODEST_SECUREAUTH_COMBO_BOX (dialog->combo_outgoing_auth));
- modest_account_mgr_set_server_account_secure_auth (dialog->account_manager, outgoing_account_name, protocol_authentication_outgoing);
+ modest_server_account_settings_set_auth_protocol (transport_settings, protocol_authentication_outgoing);
/* port: */
port_num = hildon_number_editor_get_value (
HILDON_NUMBER_EDITOR (dialog->entry_outgoing_port));
- modest_account_mgr_set_server_account_port (dialog->account_manager,
- outgoing_account_name,
- port_num);
- g_free (outgoing_account_name);
+ modest_server_account_settings_set_port (transport_settings, port_num);
+ g_object_unref (transport_settings);
/* Set the changed account title last, to simplify the previous code: */
return FALSE; /* Should be prevented already anyway. */
/* if (strcmp (account_title, account_name) != 0) { */
- modest_account_mgr_set_display_name (dialog->account_manager, account_name, account_title);
+ modest_account_settings_set_display_name (dialog->settings, account_title);
/* } */
g_free (account_title);
account_title = NULL;
/* Save connection-specific SMTP server accounts: */
- modest_account_mgr_set_use_connection_specific_smtp(dialog->account_manager, account_name,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
+ modest_account_settings_set_use_connection_specific_smtp
+ (dialog->settings,
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbox_outgoing_smtp_specific)));
+
+ /* this configuration is not persistent, we should not save */
+ if (account_name != NULL)
+ modest_account_mgr_save_account_settings (dialog->account_manager, dialog->settings);
+
if (dialog->specific_window) {
return modest_connection_specific_smtp_window_save_server_accounts (
MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (dialog->specific_window));
} else {
return TRUE;
}
+
}
static gboolean entry_is_empty (GtkWidget *entry)
/* Used by derived widgets to query existing accounts,
* and to create new accounts: */
ModestAccountMgr *account_manager;
+ ModestAccountSettings *settings;
gboolean modified;
gchar * account_name; /* This may not change. It is not user visible. */
ModestAccountSettingsDialog* modest_account_settings_dialog_new (void);
-void modest_account_settings_dialog_set_account_name (ModestAccountSettingsDialog *dialog, const gchar* account_name);
+void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *dialog, ModestAccountSettings *settings);
void modest_account_settings_dialog_switch_to_user_info (ModestAccountSettingsDialog *dialog);
#include "modest-tny-platform-factory.h"
#include "maemo/easysetup/modest-easysetup-wizard.h"
#include "maemo/modest-account-settings-dialog.h"
-#include <maemo/modest-maemo-utils.h>
+#include <modest-utils.h>
#include "widgets/modest-ui-constants.h"
/* 'private'/'protected' functions */
if (store_conn_status == TNY_CONNECTION_STATUS_CONNECTED ||
transport_conn_status == TNY_CONNECTION_STATUS_CONNECTED) {
- GtkWidget *note = NULL;
gint response;
- note = hildon_note_new_confirmation (GTK_WINDOW (self),
- _("emev_nc_disconnect_account"));
- response = gtk_dialog_run (GTK_DIALOG(note));
-
- gtk_widget_destroy (note);
+ response = modest_platform_run_confirmation_dialog (GTK_WINDOW (self),
+ _("emev_nc_disconnect_account"));
if (response == GTK_RESPONSE_OK) {
/* FIXME: We should only cancel those of this account */
modest_mail_operation_queue_cancel_all (queue);
account_title);
}
- GtkDialog *dialog = GTK_DIALOG (hildon_note_new_confirmation (GTK_WINDOW (self),
- txt));
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
+ response = modest_platform_run_confirmation_dialog (GTK_WINDOW (self), txt);
g_free (txt);
txt = NULL;
-
- response = gtk_dialog_run (dialog);
- gtk_widget_destroy (GTK_WIDGET (dialog));
- while (gtk_events_pending ())
- gtk_main_iteration ();
if (response == GTK_RESPONSE_OK) {
/* Remove account. If it succeeds then it also removes
/* Show the Account Settings window: */
ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+ ModestAccountSettings *settings;
+
+ settings = modest_account_mgr_load_account_settings (modest_runtime_get_account_mgr (), account_name);
- modest_account_settings_dialog_set_account_name (dialog, account_name);
+ modest_account_settings_dialog_set_account (dialog, settings);
+ g_object_unref (settings);
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
/* When the dialog is closed, reconnect */
G_CALLBACK (on_account_settings_dialog_response),
self);
- modest_maemo_show_dialog_and_forget (GTK_WINDOW (self), GTK_DIALOG (dialog));
+ modest_utils_show_dialog_and_forget (GTK_WINDOW (self), GTK_DIALOG (dialog));
}
g_free (account_name);
#include "widgets/modest-serversecurity-combo-box.h"
#include "widgets/modest-secureauth-combo-box.h"
#include "widgets/modest-validating-entry.h"
-#include <modest-account-mgr-helpers.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
/* Don't close the dialog if a range error occured */
- if(priv->range_error_occured)
+ if(response_id == GTK_RESPONSE_OK && priv->range_error_occured)
{
priv->range_error_occured = FALSE;
g_signal_stop_emission_by_name (dialog, "response");
void
modest_connection_specific_smtp_edit_window_set_connection (
ModestConnectionSpecificSmtpEditWindow *window, const gchar* iap_id, const gchar* iap_name,
- const ModestServerAccountData *data)
+ ModestServerAccountSettings *server_settings)
{
ModestConnectionSpecificSmtpEditWindowPrivate *priv =
CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
gtk_window_set_title (GTK_WINDOW (window), title);
g_free (title);
- if (data)
+ if (server_settings)
{
- gtk_entry_set_text (GTK_ENTRY (priv->entry_outgoingserver), data->hostname);
- gtk_entry_set_text (GTK_ENTRY (priv->entry_user_username), data->username);
- gtk_entry_set_text (GTK_ENTRY (priv->entry_user_password), data->password);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_outgoingserver),
+ modest_server_account_settings_get_hostname (server_settings));
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_user_username),
+ modest_server_account_settings_get_username (server_settings));
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_user_password),
+ modest_server_account_settings_get_password (server_settings));
modest_serversecurity_combo_box_set_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security), data->security);
+ MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security),
+ modest_server_account_settings_get_security (server_settings));
modest_secureauth_combo_box_set_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth), data->secure_auth);
+ MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth),
+ modest_server_account_settings_get_auth_protocol (server_settings));
/* port: */
hildon_number_editor_set_value (
- HILDON_NUMBER_EDITOR (priv->entry_port), data->port);
+ HILDON_NUMBER_EDITOR (priv->entry_port),
+ modest_server_account_settings_get_port (server_settings));
/* This will cause changed signals so we set dirty back to FALSE */
}
}
-/*
- * The result must be freed with modest_account_mgr_free_server_account_data(). */
-ModestServerAccountData*
-modest_connection_specific_smtp_edit_window_get_settings (
- ModestConnectionSpecificSmtpEditWindow *window,
- ModestAccountMgr *account_manager)
+ModestServerAccountSettings*
+modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecificSmtpEditWindow *window)
{
ModestConnectionSpecificSmtpEditWindowPrivate *priv = NULL;
- ModestServerAccountData *result = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
const gchar *outgoing_server = NULL;
priv = CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
return NULL;
}
- /* Use g_slice_new0(), because that's what modest_account_mgr_free_server_account_data()
- * expects us to use. */
- result = g_slice_new0 (ModestServerAccountData);
+ server_settings = modest_server_account_settings_new ();
- result->hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)));
- result->username = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)));
- result->password = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
+ modest_server_account_settings_set_hostname (server_settings,
+ gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)));
+ modest_server_account_settings_set_username (server_settings,
+ gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)));
+ modest_server_account_settings_set_password (server_settings,
+ gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
- result->security = modest_serversecurity_combo_box_get_active_serversecurity (
- MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security));
+ modest_server_account_settings_set_security (server_settings,
+ modest_serversecurity_combo_box_get_active_serversecurity (
+ MODEST_SERVERSECURITY_COMBO_BOX (priv->combo_outgoing_security)));
+ modest_server_account_settings_set_auth_protocol (server_settings,
+ modest_secureauth_combo_box_get_active_secureauth (
+ MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth)));
- result->secure_auth = modest_secureauth_combo_box_get_active_secureauth (
- MODEST_SECUREAUTH_COMBO_BOX (priv->combo_outgoing_auth));
-
/* port: */
- result->port = hildon_number_editor_get_value (
- HILDON_NUMBER_EDITOR (priv->entry_port));
+ modest_server_account_settings_set_port (server_settings,
+ hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->entry_port)));
- return result;
+ return server_settings;
}
gboolean modest_connection_specific_smtp_edit_window_is_dirty(
#ifndef __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
#define __MODEST_MAEMO_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW
-#include <modest-account-mgr.h>
-#include <modest-account-mgr-helpers.h> /* For ModestServerAccountData */
#include <gtk/gtkdialog.h>
#include <gtk/gtktreeview.h>
+#include <modest-server-account-settings.h>
G_BEGIN_DECLS
void modest_connection_specific_smtp_edit_window_set_connection (
ModestConnectionSpecificSmtpEditWindow *window, const gchar* iap_id, const gchar* iap_name,
- const ModestServerAccountData *data);
+ ModestServerAccountSettings *server_settings);
-ModestServerAccountData* modest_connection_specific_smtp_edit_window_get_settings (
- ModestConnectionSpecificSmtpEditWindow *window,
- ModestAccountMgr *account_manager);
+ModestServerAccountSettings* modest_connection_specific_smtp_edit_window_get_settings (
+ ModestConnectionSpecificSmtpEditWindow *window);
gboolean modest_connection_specific_smtp_edit_window_is_dirty(
ModestConnectionSpecificSmtpEditWindow *window);
MODEL_COL_ID = 1, /* libconic IAP ID: a string */
MODEL_COL_SERVER_ACCOUNT_NAME = 2, /* a string */
MODEL_COL_SERVER_NAME = 3, /* a string */
- MODEL_COL_SERVER_ACCOUNT_DATA = 4 /* a gpointer */
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS = 4 /* a gpointer */
};
GtkTreeIter iter;
gboolean valid = gtk_tree_model_get_iter_first (priv->model, &iter);
while (valid) {
- ModestServerAccountData *data = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
gtk_tree_model_get (priv->model, &iter,
- MODEL_COL_SERVER_ACCOUNT_DATA, &data,
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, &server_settings,
-1);
- if (data)
- modest_account_mgr_free_server_account_data (priv->account_manager, data);
+ if (server_settings)
+ g_object_unref (server_settings);
/* Get next row: */
valid = gtk_tree_model_iter_next (priv->model, &iter);
{
ModestConnectionSpecificSmtpWindow *self = MODEST_CONNECTION_SPECIFIC_SMTP_WINDOW (user_data);
ModestConnectionSpecificSmtpWindowPrivate *priv = CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
+ ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
gchar *id = NULL;
gchar *connection_name = NULL;
gchar *server_account_name = NULL;
- ModestServerAccountData *data = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
GtkTreeIter iter;
GtkTreeModel *model = 0;
MODEL_COL_ID, &id,
MODEL_COL_NAME, &connection_name,
MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name,
- MODEL_COL_SERVER_ACCOUNT_DATA, &data,
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, &server_settings,
-1);
/* printf("DEBUG: %s: BEFORE: connection-specific server_account_name=%s\n", __FUNCTION__, server_account_name); */
* If not then we should check for it. */
/* Get existing server account data if a server account is already specified: */
- gboolean data_was_retrieved = FALSE;
- if (server_account_name && !data) {
- data = modest_account_mgr_get_server_account_data (priv->account_manager,
- server_account_name);
- if (data)
- data_was_retrieved = TRUE;
+ gboolean settings_were_retrieved = FALSE;
+ if (server_account_name && !server_settings) {
+ server_settings = modest_account_mgr_load_server_settings(mgr, server_account_name);
+ if (server_settings)
+ settings_were_retrieved = TRUE;
}
GtkWidget * window = GTK_WIDGET (modest_connection_specific_smtp_edit_window_new ());
modest_connection_specific_smtp_edit_window_set_connection (
- MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window), id, connection_name, data);
+ MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window), id, connection_name, server_settings);
/* Delete data, unless it was data from the rowmodel: */
- if (data_was_retrieved) {
- modest_account_mgr_free_server_account_data (priv->account_manager, data);
- data = NULL;
+ if (settings_were_retrieved) {
+ g_object_unref (server_settings);
+ server_settings = NULL;
}
gtk_window_set_transient_for (GTK_WINDOW (self), GTK_WINDOW (window));
gtk_widget_hide (window);
dialog_finished = TRUE;
/* Delete any previous data for this row: */
- if (data)
+ if (server_settings)
{
- modest_account_mgr_free_server_account_data (priv->account_manager, data);
- data = NULL;
+ g_object_unref (server_settings);
+ server_settings = NULL;
}
/* Get the new account data and save it in the row for later:
* We free this in finalize(),
* and save it to our configuration in
* modest_connection_specific_smtp_window_save_server_accounts(). */
- data = modest_connection_specific_smtp_edit_window_get_settings (
- MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window),
- priv->account_manager);
+ server_settings = modest_connection_specific_smtp_edit_window_get_settings (
+ MODEST_CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW (window));
- if (data) {
+ if (server_settings) {
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
- MODEL_COL_SERVER_ACCOUNT_DATA, data,
- MODEL_COL_SERVER_NAME, data->hostname,
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, server_settings,
+ MODEL_COL_SERVER_NAME, modest_server_account_settings_get_hostname (server_settings),
-1);
} else {
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
- MODEL_COL_SERVER_ACCOUNT_DATA, NULL,
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, NULL,
MODEL_COL_SERVER_NAME, NULL,
MODEL_COL_SERVER_ACCOUNT_NAME, NULL,
-1);
gboolean
modest_connection_specific_smtp_window_save_server_accounts (ModestConnectionSpecificSmtpWindow *self)
{
+ ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
ModestConnectionSpecificSmtpWindowPrivate *priv =
CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
gchar *connection_name = NULL;
gchar *server_account_name = NULL;
gchar *server_name = NULL;
- ModestServerAccountData *data = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
gtk_tree_model_get (priv->model, &iter,
MODEL_COL_ID, &id,
MODEL_COL_NAME, &connection_name,
MODEL_COL_SERVER_NAME, &server_name,
MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name,
- MODEL_COL_SERVER_ACCOUNT_DATA, &data,
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, &server_settings,
-1);
gboolean success = TRUE;
- if (id && data) { /* The presence of data suggests that there is something to save. */
+ if (id && server_settings) { /* The presence of data suggests that there is something to save. */
if (!server_account_name) {
/* Add a new server account, building a (non-human-visible) name: */
gchar *name_start = g_strdup_printf("specific_%s", connection_name);
g_assert (server_account_name);
g_free (name_start);
- success = modest_account_mgr_add_server_account (priv->account_manager,
- server_account_name,
- data->hostname, 0,
- data->username, data->password,
- MODEST_PROTOCOL_TRANSPORT_SMTP,
- data->security,
- data->secure_auth);
+ modest_server_account_settings_set_account_name (server_settings, server_account_name);
+ success = modest_account_mgr_save_server_settings (mgr, server_settings);
if (success) {
TnyAccount *account = TNY_ACCOUNT (modest_tny_account_store_new_connection_specific_transport_account
(modest_runtime_get_account_store (),
if (account)
g_object_unref (account);
}
-
+
/* associate the specific server account with this connection for this account: */
success = success && modest_account_mgr_set_connection_specific_smtp (
priv->account_manager, connection_name, server_account_name);
-
+
/* Save the new name in the treemodel, so it can be edited again later: */
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
MODEL_COL_SERVER_ACCOUNT_NAME, server_account_name, -1);
} else {
- /* Change an existing server account: */
- modest_account_mgr_set_server_account_hostname (priv->account_manager, server_account_name,
- data->hostname);
-
- modest_account_mgr_set_server_account_username (priv->account_manager, server_account_name,
- data->username);
-
- modest_account_mgr_set_server_account_password (priv->account_manager, server_account_name,
- data->password);
-
- modest_account_mgr_set_server_account_secure_auth (priv->account_manager, server_account_name,
- data->secure_auth);
-
- modest_account_mgr_set_server_account_security (priv->account_manager, server_account_name,
- data->security);
-
- modest_account_mgr_set_server_account_port (priv->account_manager, server_account_name, data->port);
+ modest_account_mgr_save_server_settings (mgr, server_settings);
}
} else if (connection_name && server_name &&
!strcmp (server_name, _("mcen_ia_optionalsmtp_notdefined"))) {
while (valid) {
gchar *server_account_name = NULL;
- ModestServerAccountData *data = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
gtk_tree_model_get (priv->model, &iter,
MODEL_COL_SERVER_ACCOUNT_NAME, &server_account_name,
- MODEL_COL_SERVER_ACCOUNT_DATA, &data,
- -1);
- if (data && data->hostname && (data->hostname[0] != '\0')) {
+ MODEL_COL_SERVER_ACCOUNT_SETTINGS, &server_settings,
+ -1);
+ if (server_settings && modest_server_account_settings_get_hostname (server_settings)
+ && (modest_server_account_settings_get_hostname (server_settings) [0] != '\0')) {
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
- MODEL_COL_SERVER_NAME, data->hostname,
+ MODEL_COL_SERVER_NAME, modest_server_account_settings_get_hostname (server_settings),
-1);
} else if (server_account_name) {
__osso_context = osso_context;
}
-
-GQuark
-modest_maemo_utils_get_supported_secure_authentication_error_quark (void)
-{
- return g_quark_from_static_string("modest-maemo-utils-get-supported-secure-authentication-error-quark");
-}
-
-GtkWidget*
-modest_maemo_utils_menubar_to_menu (GtkUIManager *ui_manager)
-{
- GtkWidget *main_menu;
- GtkWidget *menubar;
- GList *children, *iter;
-
- g_return_val_if_fail (ui_manager, NULL);
-
- /* Create new main menu */
- main_menu = gtk_menu_new();
-
- /* Get the menubar from the UI manager */
- menubar = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
-
- iter = children = gtk_container_get_children (GTK_CONTAINER (menubar));
- while (iter) {
- GtkWidget *menu;
-
- menu = GTK_WIDGET (iter->data);
- gtk_widget_reparent(menu, main_menu);
-
- iter = g_list_next (iter);
- }
- g_list_free (children);
- return main_menu;
-}
-
-
static void
update_device_name_from_msg (DBusMessage *message)
{
get_device_name_from_dbus ();
}
-gboolean
-modest_maemo_utils_folder_writable (const gchar *filename)
-{
- g_return_val_if_fail (filename, FALSE);
-
- if (!filename)
- return FALSE;
-
- if (g_strncasecmp (filename, "obex", 4) != 0) {
- GnomeVFSFileInfo folder_info;
- gchar *folder;
- folder = g_path_get_dirname (filename);
- gnome_vfs_get_file_info (folder, &folder_info,
- GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
- g_free (folder);
- if (!((folder_info.permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) ||
- (folder_info.permissions & GNOME_VFS_PERM_USER_WRITE))) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-gboolean
-modest_maemo_utils_file_exists (const gchar *filename)
-{
- GnomeVFSURI *uri = NULL;
- gboolean result = FALSE;
-
- uri = gnome_vfs_uri_new (filename);
- if (uri) {
- result = gnome_vfs_uri_exists (uri);
- gnome_vfs_uri_unref (uri);
- }
- return result;
-}
-
-TnyFsStream *
-modest_maemo_utils_create_temp_stream (const gchar *orig_name, const gchar *hash_base, gchar **path)
-{
- gint fd;
- gchar *filepath = NULL;
- gchar *tmpdir;
- guint hash_number;
-
- /* hmmm... maybe we need a modest_text_utils_validate_file_name? */
- g_return_val_if_fail (orig_name || strlen(orig_name) == 0, NULL);
- if (strlen(orig_name) > 200) {
- g_warning ("%s: filename too long ('%s')",
- __FUNCTION__, orig_name);
- return NULL;
- }
-
- if (g_strstr_len (orig_name, strlen(orig_name), "/") != NULL) {
- g_warning ("%s: filename contains '/' character(s) (%s)",
- __FUNCTION__, orig_name);
- return NULL;
- }
-
- /* make a random subdir under /tmp or /var/tmp */
- if (hash_base != NULL) {
- hash_number = g_str_hash (hash_base);
- } else {
- hash_number = (guint) random ();
- }
- tmpdir = g_strdup_printf ("%s/%u", g_get_tmp_dir (), hash_number);
- if ((g_access (tmpdir, R_OK) == -1) && (g_mkdir (tmpdir, 0755) == -1)) {
- g_warning ("%s: failed to create dir '%s': %s",
- __FUNCTION__, tmpdir, g_strerror(errno));
- g_free (tmpdir);
- return NULL;
- }
-
- filepath = g_strconcat (tmpdir, "/", orig_name, NULL);
- /* don't overwrite if it already exists, even if it is writable */
- if (modest_maemo_utils_file_exists (filepath)) {
- if (path!=NULL) {
- *path = filepath;
- } else {
- g_free (filepath);
- }
- g_free (tmpdir);
- return NULL;
- } else {
- /* try to write the file there */
- fd = g_open (filepath, O_CREAT|O_WRONLY|O_TRUNC, 0644);
- if (fd == -1) {
- g_warning ("%s: failed to create '%s': %s",
- __FUNCTION__, filepath, g_strerror(errno));
- g_free (filepath);
- g_free (tmpdir);
- return NULL;
- }
- }
-
- g_free (tmpdir);
-
- if (path)
- *path = filepath;
-
- return TNY_FS_STREAM (tny_fs_stream_new (fd));
-}
-
-typedef struct
-{
- gboolean cancel;
- GList *result;
- GtkWidget* dialog;
- GtkWidget* progress;
- GError* error;
-} ModestGetSupportedAuthInfo;
-
-static void on_camel_account_get_supported_secure_authentication_status (
- GObject *self, TnyStatus *status, gpointer user_data)
-{
- /*ModestGetSupportedAuthInfo* info = (ModestGetSupportedAuthInfo*) user_data;*/
-}
-
-static gboolean
-on_idle_secure_auth_finished (gpointer user_data)
-{
- ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
- /* Operation has finished, close the dialog. Control continues after
- * gtk_dialog_run in modest_maemo_utils_get_supported_secure_authentication_methods() */
-
- /* This is a GDK lock because we are an idle callback and
- * the code below is or does Gtk+ code */
-
- gdk_threads_enter(); /* CHECKED */
- gtk_dialog_response (GTK_DIALOG (info->dialog), GTK_RESPONSE_ACCEPT);
- gdk_threads_leave(); /* CHECKED */
-
- return FALSE;
-}
-
-static void
-on_camel_account_get_supported_secure_authentication (
- TnyCamelAccount *self, gboolean cancelled,
- TnyList *auth_types, GError *err,
- gpointer user_data)
-{
- ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
- g_return_if_fail (info);
-
-
- /* Free everything if the actual action was canceled */
- if (info->cancel)
- {
- /* The operation was canceled and the ownership of the info given to us
- * so that we could still check the cancel flag. */
- g_slice_free (ModestGetSupportedAuthInfo, info);
- info = NULL;
- }
- else
- {
- if (err)
- {
- if (info->error) {
- g_error_free (info->error);
- info->error = NULL;
- }
-
- info->error = g_error_copy (err);
- }
-
- if (!auth_types) {
- g_warning ("DEBUG: %s: auth_types is NULL.\n", __FUNCTION__);
- }
- else if (tny_list_get_length(auth_types) == 0) {
- g_warning ("DEBUG: %s: auth_types is an empty TnyList.\n", __FUNCTION__);
- } else
- {
- ModestPairList* pairs = modest_protocol_info_get_auth_protocol_pair_list ();
-
- /* Get the enum value for the strings: */
- GList *result = NULL;
- TnyIterator* iter = tny_list_create_iterator(auth_types);
- while (!tny_iterator_is_done(iter)) {
- TnyPair *pair = TNY_PAIR(tny_iterator_get_current(iter));
- const gchar *auth_name = NULL;
- if (pair) {
- auth_name = tny_pair_get_name(pair);
- g_object_unref (pair);
- pair = NULL;
- }
-
- printf("DEBUG: %s: auth_name=%s\n", __FUNCTION__, auth_name);
-
- ModestAuthProtocol proto = modest_protocol_info_get_auth_protocol (auth_name);
- if(proto != MODEST_PROTOCOL_AUTH_NONE)
- result = g_list_prepend(result, GINT_TO_POINTER(proto));
-
- tny_iterator_next(iter);
- }
- g_object_unref (iter);
-
- modest_pair_list_free (pairs);
-
- info->result = result;
- }
-
- printf("DEBUG: finished\n");
-
- /* Close the dialog in a main thread */
- g_idle_add(on_idle_secure_auth_finished, info);
- }
-}
-
-static void
-on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data)
-{
- if(response == GTK_RESPONSE_REJECT || response == GTK_RESPONSE_DELETE_EVENT)
- {
- ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
- g_return_if_fail(info);
- /* This gives the ownership of the info to the worker thread. */
- info->result = NULL;
- info->cancel = TRUE;
- }
-}
-
-GList*
-modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
- const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error)
-{
- g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
-
- /* We need a connection to get the capabilities; */
- if (!modest_platform_connect_and_wait (GTK_WINDOW (parent_window), NULL))
- return NULL;
-
- /*
- result = g_list_append (result, GINT_TO_POINTER (MODEST_PROTOCOL_AUTH_CRAMMD5));
- */
-
- /* Create a TnyCamelAccount so we can use
- * tny_camel_account_get_supported_secure_authentication(): */
- TnyAccount * tny_account = NULL;
- switch (proto) {
- case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
- case MODEST_PROTOCOL_TRANSPORT_SMTP:
- tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
- case MODEST_PROTOCOL_STORE_POP:
- tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_IMAP:
- tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
- case MODEST_PROTOCOL_STORE_MAILDIR:
- case MODEST_PROTOCOL_STORE_MBOX:
- tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
- default:
- tny_account = NULL;
- }
-
-
- if (!tny_account) {
- g_printerr ("%s could not create tny account.", __FUNCTION__);
- return NULL;
- }
-
- /* Set proto, so that the prepare_func() vfunc will work when we call
- * set_session(): */
- /* TODO: Why isn't this done in account_new()? */
- tny_account_set_proto (tny_account,
- modest_protocol_info_get_transport_store_protocol_name(proto));
-
- tny_account_set_hostname (tny_account, hostname);
- /* Required for POP, at least */
- tny_account_set_user (tny_account, username);
-
- if(port > 0)
- tny_account_set_port (tny_account, port);
-
- /* Set the session for the account, so we can use it: */
- ModestTnyAccountStore *account_store = modest_runtime_get_account_store ();
- TnySessionCamel *session =
- modest_tny_account_store_get_session (TNY_ACCOUNT_STORE (account_store));
- g_return_val_if_fail (session, NULL);
- tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
-
-
- /* Ask camel to ask the server, asynchronously: */
- ModestGetSupportedAuthInfo *info = g_slice_new (ModestGetSupportedAuthInfo);
- info->result = NULL;
- info->cancel = FALSE;
- info->error = NULL;
- info->progress = gtk_progress_bar_new();
- /* TODO: Need logical_ID for the title: */
- info->dialog = gtk_dialog_new_with_buttons(_("Authentication"),
- parent_window, GTK_DIALOG_MODAL,
- _("mcen_bd_dialog_cancel"),
- GTK_RESPONSE_REJECT,
- NULL);
- //gtk_window_set_default_size(GTK_WINDOW(info->dialog), 300, 100);
-
- g_signal_connect(G_OBJECT(info->dialog), "response", G_CALLBACK(on_secure_auth_cancel), info);
-
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox),
- gtk_label_new("Checking for supported authentication types..."));
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox), info->progress);
- gtk_widget_show_all(info->dialog);
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(info->progress));
-
- printf ("DEBUG: %s: STARTING.\n", __FUNCTION__);
- tny_camel_account_get_supported_secure_authentication (
- TNY_CAMEL_ACCOUNT (tny_account),
- on_camel_account_get_supported_secure_authentication,
- on_camel_account_get_supported_secure_authentication_status,
- info);
-
- gtk_dialog_run (GTK_DIALOG (info->dialog));
-
- gtk_widget_destroy(info->dialog);
-
- GList *result = info->result;
- if (!info->cancel)
- {
- if (info->error) {
- gchar * debug_url_string = tny_account_get_url_string (tny_account);
- g_warning ("DEBUG: %s:\n error: %s\n account url: %s", __FUNCTION__, info->error->message,
- debug_url_string);
- g_free (debug_url_string);
-
- g_propagate_error(error, info->error);
- info->error = NULL;
- }
-
- g_slice_free (ModestGetSupportedAuthInfo, info);
- info = NULL;
- }
- else
- {
- // Tell the caller that the operation was canceled so it can
- // make a difference
- g_set_error(error,
- modest_maemo_utils_get_supported_secure_authentication_error_quark(),
- MODEST_MAEMO_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED,
- "User has canceled query");
- }
-
- return result;
-}
-
void
modest_maemo_utils_setup_images_filechooser (GtkFileChooser *chooser)
{
}
-#if 0
-static void
-on_hide (GtkDialog *dialog, gpointer user_data)
-{
- /* Just destroy the dialog: */
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-#endif
-
-#if 0 /* Not used now. */
-/* user_data for the idle callback: */
-typedef struct
-{
- GtkWindow *parent_window;
- gchar *message;
-} ModestIdleNoteInfo;
-
-static gboolean
-on_idle_show_information(gpointer user_data)
-{
- ModestIdleNoteInfo *info = (ModestIdleNoteInfo*)user_data;
-
- modest_maemo_show_information_note_and_forget (info->parent_window, info->message);
-
- g_free (info->message);
- g_slice_free (ModestIdleNoteInfo, info);
-
- return FALSE; /* Don't call this again. */
-}
-
-void
-modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window,
- const gchar* message)
-{
- ModestIdleNoteInfo *info = g_slice_new (ModestIdleNoteInfo);
- info->parent_window = parent_window;
- info->message = g_strdup (message);
-
- g_idle_add (on_idle_show_information, info);
-}
-#endif
-
-void
-modest_maemo_show_dialog_and_forget (GtkWindow *parent_window,
- GtkDialog *dialog)
-{
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window);
-
- /* Destroy the dialog when it is closed: */
- g_signal_connect_swapped (dialog,
- "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
-
- gtk_widget_show (GTK_WIDGET (dialog));
-}
-
-
-
void
modest_maemo_set_thumbable_scrollbar (GtkScrolledWindow *win,
gboolean thumbable)
#endif /* MODEST_HAVE_HILDON1_WIDGETS */
}
-void
-modest_maemo_toggle_action_set_active_block_notify (GtkToggleAction *action, gboolean value)
-{
- GSList *proxies = NULL;
-
- g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
-
- for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
- proxies != NULL; proxies = g_slist_next (proxies)) {
- GtkWidget *widget = (GtkWidget *) proxies->data;
- gtk_action_block_activate_from (GTK_ACTION (action), widget);
- }
-
- gtk_toggle_action_set_active (action, value);
-
- for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
- proxies != NULL; proxies = g_slist_next (proxies)) {
- GtkWidget *widget = (GtkWidget *) proxies->data;
- gtk_action_unblock_activate_from (GTK_ACTION (action), widget);
- }
-
-}
-
-
FILE*
modest_maemo_open_mcc_mapping_file (void)
{
#define MODEST_MAEMO_UTILS_MYDOCS_FOLDER "MyDocs"
#define MODEST_MAEMO_UTILS_DEFAULT_IMAGE_FOLDER ".images"
-typedef enum {
- MODEST_MAEMO_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED
-} ModestMaemoUtilsGetSupportedSecureAuthenticationError;
-
-GQuark modest_maemo_utils_get_supported_secure_authentication_error_quark (void);
-
-/**
- * modest_maemo_utils_menubar_to_menu:
- * @ui_manager: a ui manager, with the menubar at "/MenuBar"
- *
- * convert a menubar description (in a GtkUIManager) in to a menu
- *
- * Returns: a new menu, or NULL in case of error
- */
-GtkWidget* modest_maemo_utils_menubar_to_menu (GtkUIManager *ui_manager);
-
/**
* modest_maemo_utils_get_device_name
*/
void modest_maemo_utils_get_device_name (void);
-/**
- * modest_maemo_utils_folder_writable:
- * @filename: a string
- *
- * Checks if @filename is in a writable folder
- *
- * Returns: %TRUE if @filename is writable, %FALSE otherwise
- */
-gboolean modest_maemo_utils_folder_writable (const gchar *filename);
-
-/**
- * modest_maemo_utils_file_exists:
- * @filename: a string
- *
- * Checks if @filename exists
- *
- * Returns: %TRUE if @filename currently exists, %FALSE otherwise
- */
-gboolean modest_maemo_utils_file_exists (const gchar *filename);
-
-/**
- * modest_maemo_utils_create_temp_stream:
- * @orig_name: a string with the original name of the extension, or %NULL
- * @hash_base: if %NULL, subdir will be random. If not, it will be a hash
- * of this.
- * @path: a string with the created file path.
- *
- * Creates a temporary fs stream, in a random subdir of /tmp or /var/tmp.
- *
- * Returns: a #TnyFsStream, or %NULL if operation failed. Note that it is
- * possible that the file already exists but it is not writable. In that case,
- * the function would return NULL and @path would contain its path.
- */
-TnyFsStream *modest_maemo_utils_create_temp_stream (const gchar *orig_name, const gchar *hash_base, gchar **path);
-
-/**
- * modest_maemo_utils_get_supported_secure_authentication_methods:
- * @proto: the protocol
- * @hostname: hostname of the mail server to check
- * @port: mail server port
- * @username: username of the account to check for
- * @parent_window: a GtkWindow that can be used a parent for progress indication
- *
- * Get a list of supported authentication methods of the server
- *
- * Returns: GList* of the method names. This list needs to be freed using g_list_free.
- *
- */
-
-GList* modest_maemo_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
- const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error);
/**
* modest_maemo_utils_setup_images_filechooser:
*/
osso_context_t *modest_maemo_utils_get_osso_context (void);
-
-
-/** modest_maemo_show_information_note_in_main_context_and_forget:
- * @parent_window: The window for which the note should be transient.
- * @message: The text to show.
- *
- * This calls modest_maemo_show_information_note_and_forget() in an idle handler.
- * This should be used when you are not sure that you are in the main context,
- * because you should try to use GTK+ UI code only in the main context.
- */
-void modest_maemo_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, const gchar* message);
-
-/** modest_maemo_show_dialog_and_forget:
- * @parent_window: The window for which the note should be transient.
- * @message: The dialog to show.
- *
- * Show the dialog and destroy it when it is closed, without
- * blocking. Use this when you don't want to use gtk_dialog_run(), which might lead
- * to hangs.
- */
-void modest_maemo_show_dialog_and_forget (GtkWindow *parent_window, GtkDialog *dialog);
-
-
/**
* modest_maemo_open_mcc_mapping_file:
*
/**
- * modest_maemo_toggle_action_set_active_block_notify:
- * @action: a #GtkToggleAction
- * @value: a #gboolean
- *
- * updates the toggle action active status, but blocking the notification of the changes.
- */
-void modest_maemo_toggle_action_set_active_block_notify (GtkToggleAction *action, gboolean value);
-
-
-/**
* modest_maemo_get_osso_context:
*
* retrieve the osso context for this application
#include "modest-tny-account.h"
#include "modest-tny-folder.h"
#include "modest-conf.h"
+#include <modest-utils.h>
#include <modest-maemo-utils.h>
#include "modest-tny-platform-factory.h"
#include "modest-tny-msg.h"
}
static gint
-compare_display_names (ModestAccountData *a,
- ModestAccountData *b)
+compare_display_names (ModestAccountSettings *a,
+ ModestAccountSettings *b)
{
- return strcmp (a->display_name, b->display_name);
+ return strcmp (modest_account_settings_get_display_name (a),
+ modest_account_settings_get_display_name (b));
}
static void
accounts = NULL;
while (iter) {
- ModestAccountData *account_data =
- modest_account_mgr_get_account_data (mgr, (gchar*) iter->data);
- accounts = g_slist_prepend (accounts, account_data);
+ ModestAccountSettings *settings =
+ modest_account_mgr_load_account_settings (mgr, (gchar*) iter->data);
+ accounts = g_slist_prepend (accounts, settings);
iter = iter->next;
}
radio_group = NULL;
for (i = 0; i < num_accounts; i++) {
gchar *display_name = NULL;
- ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i);
+ const gchar *account_name;
+ ModestAccountSettings *settings = (ModestAccountSettings *) g_slist_nth_data (accounts, i);
- if (!account_data) {
+ if (!settings) {
g_warning ("%s: BUG: account_data == NULL", __FUNCTION__);
continue;
}
+ account_name = modest_account_settings_get_account_name (settings);
- if (default_account && account_data->account_name &&
- !(strcmp (default_account, account_data->account_name) == 0)) {
+ if (default_account && account_name &&
+ !(strcmp (default_account, account_name) == 0)) {
display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"),
- account_data->display_name);
+ modest_account_settings_get_display_name (settings));
} else {
display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_mailbox_n"),
- account_data->display_name);
+ modest_account_settings_get_display_name (settings));
}
/* Create action and add it to the action group. The
action name must be the account name, this way we
could know in the handlers the account to show */
- if (account_data && account_data->account_name) {
+ if (settings && account_name) {
gchar* item_name, *refresh_action_name;
guint8 merge_id = 0;
GtkAction *view_account_action, *refresh_account_action;
- view_account_action = GTK_ACTION (gtk_radio_action_new (account_data->account_name,
+ view_account_action = GTK_ACTION (gtk_radio_action_new (account_name,
display_name, NULL, NULL, 0));
gtk_action_group_add_action (priv->view_additions_group, view_account_action);
gtk_radio_action_set_group (GTK_RADIO_ACTION (view_account_action), radio_group);
radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (view_account_action));
if (active_account_name) {
- if (active_account_name && account_data->account_name &&
- (strcmp (active_account_name, account_data->account_name) == 0)) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_account_action), TRUE);
+ if (active_account_name && account_name &&
+ (strcmp (active_account_name, account_name) == 0)) {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_account_action), TRUE);
}
}
changes in a single execution because we're
downcasting the guint to a guint8 in order to use a
GByteArray. It should be enough. */
- item_name = g_strconcat (account_data->account_name, "Menu", NULL);
+ item_name = g_strconcat (account_name, "Menu", NULL);
merge_id = (guint8) gtk_ui_manager_new_merge_id (parent_priv->ui_manager);
priv->merge_ids = g_byte_array_append (priv->merge_ids, &merge_id, 1);
gtk_ui_manager_add_ui (parent_priv->ui_manager,
merge_id,
"/MenuBar/ViewMenu/ViewMenuAdditions",
item_name,
- account_data->account_name,
+ account_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
self);
/* Create the items for the Tools->Send&Receive submenu */
- refresh_action_name = g_strconcat ("SendReceive", account_data->account_name, NULL);
+ refresh_action_name = g_strconcat ("SendReceive", account_name, NULL);
refresh_account_action = gtk_action_new ((const gchar*) refresh_action_name,
display_name, NULL, NULL);
gtk_action_group_add_action (priv->view_additions_group, refresh_account_action);
g_signal_connect_data (G_OBJECT (refresh_account_action),
"activate",
G_CALLBACK (on_refresh_account_action_activated),
- g_strdup (account_data->account_name),
+ g_strdup (account_name),
(GClosureNotify) g_free,
0);
if (priv->accounts_popup) {
GtkWidget *label = gtk_label_new(NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- if (default_account && (strcmp(account_data->account_name, default_account) == 0))
+ if (default_account && (strcmp(account_name, default_account) == 0))
{
gchar *escaped = g_markup_printf_escaped ("<b>%s</b>", display_name);
gtk_label_set_markup (GTK_LABEL (label), escaped);
g_signal_connect_data (G_OBJECT (item),
"activate",
G_CALLBACK (on_send_receive_csm_activated),
- g_strdup (account_data->account_name),
+ g_strdup (account_name),
(GClosureNotify) g_free,
0);
}
* group being inserted. This makes the default account appear in bold.
* I agree it is a rather ugly way, but I don't see another possibility. armin. */
for (i = 0; i < num_accounts; i++) {
- ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i);
+ ModestAccountSettings *settings = (ModestAccountSettings *) g_slist_nth_data (accounts, i);
+ const gchar *account_name;
- if(account_data->account_name && default_account &&
- strcmp (account_data->account_name, default_account) == 0) {
- gchar *item_name = g_strconcat (account_data->account_name, "Menu", NULL);
+ account_name = modest_account_settings_get_account_name (settings);
+
+ if(account_name && default_account &&
+ strcmp (account_name, default_account) == 0) {
+ gchar *item_name = g_strconcat (account_name, "Menu", NULL);
gchar *path = g_strconcat ("/MenuBar/ViewMenu/ViewMenuAdditions/", item_name, NULL);
GtkWidget *item = gtk_ui_manager_get_widget (parent_priv->ui_manager, path);
g_free (bold_name);
}
}
-
+
path = g_strconcat("/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsMenuAdditions/", item_name, NULL);
item = gtk_ui_manager_get_widget (parent_priv->ui_manager, path);
g_free (path);
g_free(item_name);
}
- modest_account_mgr_free_account_data (mgr, account_data);
+ g_object_unref (settings);
}
if (priv->accounts_popup) {
gtk_ui_manager_get_accel_group (parent_priv->ui_manager));
/* Menubar. Update the state of some toggles */
- parent_priv->menubar = modest_maemo_utils_menubar_to_menu (parent_priv->ui_manager);
+ parent_priv->menubar = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/MenuBar");
conf = modest_runtime_get_conf ();
action = gtk_ui_manager_get_action (parent_priv->ui_manager,
"/MenuBar/ViewMenu/ViewShowToolbarMainMenu/ViewShowToolbarNormalScreenMenu");
action_name = "/MenuBar/ViewMenu/ViewShowToolbarMainMenu/ViewShowToolbarNormalScreenMenu";
action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
show_toolbar);
}
{
ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
GtkAction *action;
+ ModestAccountMgr *mgr;
+ ModestAccountSettings *settings;
+ ModestServerAccountSettings *store_settings = NULL;
/* Get account data */
- ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
- ModestAccountData *acc_data = modest_account_mgr_get_account_data (mgr, acc_name);
+ mgr = modest_runtime_get_account_mgr ();
+ settings = modest_account_mgr_load_account_settings (mgr, acc_name);
+ if (settings)
+ store_settings = modest_account_settings_get_store_settings (settings);
/* Set the new visible & active account */
- if (acc_data && acc_data->store_account) {
- modest_folder_view_set_account_id_of_visible_server_account (priv->folder_view,
- acc_data->store_account->account_name);
- modest_window_set_active_account (MODEST_WINDOW (self), acc_data->account_name);
- action = gtk_action_group_get_action (priv->view_additions_group, acc_data->account_name);
+ if (settings && (modest_server_account_settings_get_account_name (store_settings)!= NULL)) {
+ const gchar *account_name;
+
+ account_name = modest_account_settings_get_account_name (settings);
+
+ modest_folder_view_set_account_id_of_visible_server_account
+ (priv->folder_view,
+ modest_server_account_settings_get_account_name (store_settings));
+ modest_window_set_active_account (MODEST_WINDOW (self), account_name);
+ action = gtk_action_group_get_action (priv->view_additions_group, account_name);
if (action != NULL) {
if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
- modest_maemo_toggle_action_set_active_block_notify (
+ modest_utils_toggle_action_set_active_block_notify (
GTK_TOGGLE_ACTION (action),
TRUE);
}
/* Free */
- if (acc_data)
- modest_account_mgr_free_account_data (mgr, acc_data);
+ if (settings) {
+ g_object_unref (store_settings);
+ g_object_unref (settings);
+ }
}
/* Make sure that at least one account is "viewed": */
#else
#include <libgnomevfs/gnome-vfs-mime.h>
#endif
+#include <modest-utils.h>
#include "modest-maemo-utils.h"
conf = modest_runtime_get_conf ();
action = gtk_ui_manager_get_action (parent_priv->ui_manager,
"/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR, NULL));
action = gtk_ui_manager_get_action (parent_priv->ui_manager,
"/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarFullScreenMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
modest_conf_get_bool (conf, MODEST_CONF_EDIT_WINDOW_SHOW_TOOLBAR_FULLSCREEN, NULL));
/* set initial state of cc and bcc */
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewCcFieldMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_CC, NULL));
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewBccFieldMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
modest_conf_get_bool(modest_runtime_get_conf(), MODEST_CONF_SHOW_BCC, NULL));
/* Dim at start clipboard actions */
if (wp_text_buffer_is_rich_text (WP_TEXT_BUFFER (priv->text_buffer))) {
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/FileFormatMenu/FileFormatFormattedTextMenu");
if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), TRUE);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), TRUE);
} else {
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/FileFormatMenu/FileFormatPlainTextMenu");
if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), TRUE);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), TRUE);
}
wp_text_buffer_get_attributes (WP_TEXT_BUFFER (priv->text_buffer), buffer_format, FALSE);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ActionsBold");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bold);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bold);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ActionsItalics");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->italic);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->italic);
/* action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/BulletedListMenu"); */
-/* modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bullet); */
+/* modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), buffer_format->bullet); */
g_signal_handlers_block_by_func (G_OBJECT (priv->font_color_button),
G_CALLBACK (modest_msg_edit_window_color_button_change),
action_name = "/MenuBar/ViewMenu/ShowToolbarMenu/ViewShowToolbarNormalScreenMenu";
action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
show_toolbar);
}
wp_text_buffer_enable_rich_text (WP_TEXT_BUFFER (priv->text_buffer), FALSE);
} else {
GtkToggleAction *action = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/FormatMenu/FileFormatMenu/FileFormatFormattedTextMenu"));
- modest_maemo_toggle_action_set_active_block_notify (action, TRUE);
+ modest_utils_toggle_action_set_active_block_notify (action, TRUE);
}
}
break;
#include <tny-vfs-stream.h>
#include "modest-marshal.h"
#include "modest-platform.h"
+#include <modest-utils.h>
#include <modest-maemo-utils.h>
#include <modest-tny-msg.h>
#include <modest-msg-view-window.h>
/* update the toggle buttons status */
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ToolsMenu/ToolsFindInMessageMenu");
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
}
action_name = "/MenuBar/ViewMenu/ViewShowToolbarMenu/ViewShowToolbarNormalScreenMenu";
action = gtk_ui_manager_get_action (parent_priv->ui_manager, action_name);
- modest_maemo_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
+ modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action),
show_toolbar);
}
const gchar *att_filename = tny_mime_part_get_filename (mime_part);
const gchar *content_type;
TnyFsStream *temp_stream = NULL;
- temp_stream = modest_maemo_utils_create_temp_stream (att_filename, attachment_uid,
- &filepath);
+ temp_stream = modest_utils_create_temp_stream (att_filename, attachment_uid,
+ &filepath);
if (temp_stream != NULL) {
content_type = tny_mime_part_get_content_type (mime_part);
for (iter = files; (iter != NULL) && (replaced_files < 2); iter = g_list_next(iter)) {
SaveMimePartPair *pair = iter->data;
- if (modest_maemo_utils_file_exists (pair->filename)) {
- replaced_files++;
+ if (modest_utils_file_exists (pair->filename)) {
+ replaced_files++;
}
}
if (replaced_files) {
if (gtk_dialog_run (GTK_DIALOG (save_dialog)) == GTK_RESPONSE_OK) {
gchar *chooser_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (save_dialog));
- if (!modest_maemo_utils_folder_writable (chooser_uri)) {
+ if (!modest_utils_folder_writable (chooser_uri)) {
hildon_banner_show_information
(NULL, NULL, dgettext("hildon-fm", "sfil_ib_readonly_location"));
} else {
#include "modest-tny-account.h"
#include <string.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <modest-account-settings-dialog.h>
+#include <maemo/easysetup/modest-easysetup-wizard.h>
#ifdef MODEST_HAVE_ABOOK
#include <libosso-abook/osso-abook.h>
return;
}
+
+GtkWidget *
+modest_platform_get_account_settings_dialog (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
+
+ modest_account_settings_dialog_set_account (dialog, settings);
+ return GTK_WIDGET (dialog);
+}
+
+GtkWidget *
+modest_platform_get_account_settings_wizard ()
+{
+ ModestEasysetupWizardDialog *dialog = modest_easysetup_wizard_dialog_new ();
+
+ return GTK_WIDGET (dialog);
+}
<ui>
- <menubar name="MenuBar">
+ <popup name="MenuBar">
<menu name="EmailMenu" action="Email">
<menu name="EmailNewMainMenu" action="EmailNew">
<menuitem name="CloseWindowMenu" action="CloseWindow"/>
<menuitem name="CloseAllWindowsMenu" action="CloseAllWindows"/>
</menu>
- </menubar>
+ </popup>
<toolbar name="ToolBar">
<toolitem action="ToolbarMessageNew"/>
#include <modest-runtime.h>
#include <string.h>
+static const gchar * null_means_empty (const gchar * str);
+
+static const gchar *
+null_means_empty (const gchar * str)
+{
+ return str ? str : "";
+}
+
gboolean
modest_account_mgr_set_enabled (ModestAccountMgr *self, const gchar* name,
gboolean enabled)
gboolean result = modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_USE_SIGNATURE,
use_signature, FALSE);
result = result && modest_account_mgr_set_string (self, name, MODEST_ACCOUNT_SIGNATURE,
- signature, FALSE);
+ null_means_empty (signature), FALSE);
return result;
}
return modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SIGNATURE, FALSE);
}
-
ModestTransportStoreProtocol modest_account_mgr_get_store_protocol (ModestAccountMgr *self, const gchar* name)
{
- ModestTransportStoreProtocol result = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default */
-
- gchar *server_account_name = modest_account_mgr_get_string (self, name,
- MODEST_ACCOUNT_STORE_ACCOUNT,
- FALSE);
- if (server_account_name) {
- ModestServerAccountData* server_data =
- modest_account_mgr_get_server_account_data (self, server_account_name);
- result = server_data->proto;
-
- modest_account_mgr_free_server_account_data (self, server_data);
-
- g_free (server_account_name);
- }
-
- return result;
+ ModestTransportStoreProtocol result = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default */
+
+ gchar *server_account_name = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_STORE_ACCOUNT,
+ FALSE);
+ if (server_account_name) {
+ ModestServerAccountSettings* server_settings =
+ modest_account_mgr_load_server_settings (self, server_account_name);
+ result = modest_server_account_settings_get_protocol (server_settings);
+
+ g_object_unref (server_settings);
+
+ g_free (server_account_name);
+ }
+
+ return result;
}
+
gboolean modest_account_mgr_set_connection_specific_smtp (ModestAccountMgr *self,
const gchar* connection_name, const gchar* server_account_name)
{
/* We don't know anything about new usernames: */
if (strcmp (existing_username, username) != 0)
- modest_account_mgr_get_server_account_username_has_succeeded (self, account_name);
+ modest_account_mgr_set_server_account_username_has_succeeded (self, account_name,
+ TRUE);
g_free (existing_username);
}
}
-static ModestAuthProtocol
-get_secure_auth_for_conf_string(const gchar* value)
-{
- ModestAuthProtocol result = MODEST_PROTOCOL_AUTH_NONE;
- if (value) {
- if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE) == 0)
- result = MODEST_PROTOCOL_AUTH_NONE;
- else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD) == 0)
- result = MODEST_PROTOCOL_AUTH_PASSWORD;
- else if (strcmp(value, MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5) == 0)
- result = MODEST_PROTOCOL_AUTH_CRAMMD5;
- }
-
- return result;
-}
ModestAuthProtocol
modest_account_mgr_get_server_account_secure_auth (ModestAccountMgr *self,
gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH,
TRUE /* server account */);
if (value) {
- result = get_secure_auth_for_conf_string (value);
+ result = modest_protocol_info_get_auth_protocol (value);
g_free (value);
}
{
/* Get the conf string for the enum value: */
const gchar* str_value = NULL;
- if (secure_auth == MODEST_PROTOCOL_AUTH_NONE)
- str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_NONE;
- else if (secure_auth == MODEST_PROTOCOL_AUTH_PASSWORD)
- str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_PASSWORD;
- else if (secure_auth == MODEST_PROTOCOL_AUTH_CRAMMD5)
- str_value = MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5;
+
+ str_value = modest_protocol_info_get_auth_protocol_name (secure_auth);
/* Set it in the configuration: */
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_AUTH_MECH, str_value, TRUE);
}
-static ModestConnectionProtocol
-get_security_for_conf_string(const gchar* value)
-{
- ModestConnectionProtocol result = MODEST_PROTOCOL_CONNECTION_NORMAL;
- if (value) {
- if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NONE) == 0)
- result = MODEST_PROTOCOL_CONNECTION_NORMAL;
- else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_NORMAL) == 0) {
- /* The UI has "Normal (TLS)": */
- result = MODEST_PROTOCOL_CONNECTION_TLS;
- } else if (strcmp(value, MODEST_ACCOUNT_SECURITY_VALUE_SSL) == 0)
- result = MODEST_PROTOCOL_CONNECTION_SSL;
- }
-
- return result;
-}
-
ModestConnectionProtocol
modest_account_mgr_get_server_account_security (ModestAccountMgr *self,
const gchar* account_name)
gchar* value = modest_account_mgr_get_string (self, account_name, MODEST_ACCOUNT_SECURITY,
TRUE /* server account */);
if (value) {
- result = get_security_for_conf_string (value);
+ result = modest_protocol_info_get_connection_protocol (value);
g_free (value);
}
{
/* Get the conf string for the enum value: */
const gchar* str_value = NULL;
- if (security == MODEST_PROTOCOL_CONNECTION_NORMAL)
- str_value = MODEST_ACCOUNT_SECURITY_VALUE_NONE;
- else if (security == MODEST_PROTOCOL_CONNECTION_TLS) {
- /* The UI has "Normal (TLS)": */
- str_value = MODEST_ACCOUNT_SECURITY_VALUE_NORMAL;
- } else if (security == MODEST_PROTOCOL_CONNECTION_SSL)
- str_value = MODEST_ACCOUNT_SECURITY_VALUE_SSL;
+ str_value = modest_protocol_info_get_connection_protocol_name (security);
/* Set it in the configuration: */
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY, str_value, TRUE);
}
-ModestServerAccountData*
-modest_account_mgr_get_server_account_data (ModestAccountMgr *self, const gchar* name)
+ModestServerAccountSettings*
+modest_account_mgr_load_server_settings (ModestAccountMgr *self, const gchar* name)
{
- ModestServerAccountData *data;
- gchar *proto;
+ ModestServerAccountSettings *settings;
+ gchar *string;
- g_return_val_if_fail (modest_account_mgr_account_exists (self, name, TRUE), NULL);
- data = g_slice_new0 (ModestServerAccountData);
-
- data->account_name = g_strdup (name);
- data->hostname = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_HOSTNAME,TRUE);
- data->username = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_USERNAME,TRUE);
- proto = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
- data->proto = modest_protocol_info_get_transport_store_protocol (proto);
- g_free (proto);
-
- data->port = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE);
-
- gchar *secure_auth_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
- data->secure_auth = get_secure_auth_for_conf_string(secure_auth_str);
- g_free (secure_auth_str);
-
- gchar *security_str = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SECURITY, TRUE);
- data->security = get_security_for_conf_string(security_str);
- g_free (security_str);
-
- data->last_updated = modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_LAST_UPDATED,TRUE);
-
- data->password = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PASSWORD, TRUE);
-
- return data;
-}
+ g_return_val_if_fail (modest_account_mgr_account_exists (self, name, TRUE), NULL);
+ settings = modest_server_account_settings_new ();
+ modest_server_account_settings_set_account_name (settings, name);
-void
-modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
- ModestServerAccountData* data)
-{
- g_return_if_fail (self);
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_HOSTNAME,TRUE);
+ modest_server_account_settings_set_hostname (settings, string);
+ g_free (string);
- if (!data)
- return; /* not an error */
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_USERNAME,TRUE);
+ modest_server_account_settings_set_username (settings, string);
+ g_free (string);
- g_free (data->account_name);
- data->account_name = NULL;
-
- g_free (data->hostname);
- data->hostname = NULL;
+ string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_PROTO, TRUE);
+ modest_server_account_settings_set_protocol (settings,
+ modest_protocol_info_get_transport_store_protocol (string));
+ g_free (string);
+
+ modest_server_account_settings_set_port (settings,
+ modest_account_mgr_get_int (self, name, MODEST_ACCOUNT_PORT, TRUE));
+
+ string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
+ modest_server_account_settings_set_auth_protocol (settings,
+ modest_protocol_info_get_auth_protocol(string));
+ g_free (string);
+
+ string = modest_account_mgr_get_string (self, name, MODEST_ACCOUNT_SECURITY, TRUE);
+ modest_server_account_settings_set_security (settings,
+ modest_protocol_info_get_connection_protocol(string));
+ g_free (string);
+
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_PASSWORD, TRUE);
+ modest_server_account_settings_set_password (settings, string);
+ g_free (string);
- g_free (data->username);
- data->username = NULL;
+ return settings;
+}
- g_free (data->password);
- data->password = NULL;
+gboolean
+modest_account_mgr_save_server_settings (ModestAccountMgr *self,
+ ModestServerAccountSettings *settings)
+{
+ gboolean has_errors = FALSE;
+ const gchar *account_name;
+ const gchar *protocol;
+ const gchar *uri;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), FALSE);
+ account_name = modest_server_account_settings_get_account_name (settings);
+
+ /* if we don't have a valid account name we cannot save */
+ g_return_val_if_fail (account_name, FALSE);
+
+ protocol = modest_protocol_info_get_transport_store_protocol_name (
+ modest_server_account_settings_get_protocol (settings));
+ uri = modest_server_account_settings_get_uri (settings);
+ if (!uri) {
+ const gchar *hostname = null_means_empty (modest_server_account_settings_get_hostname (settings));
+ const gchar *username = null_means_empty (modest_server_account_settings_get_username (settings));
+ const gchar *password = null_means_empty (modest_server_account_settings_get_password (settings));
+ gint port = modest_server_account_settings_get_port (settings);
+ const gchar *auth_protocol = modest_protocol_info_get_auth_protocol_name (
+ modest_server_account_settings_get_auth_protocol (settings));
+ const gchar *security = modest_protocol_info_get_connection_protocol_name (
+ modest_server_account_settings_get_security (settings));
+
+ has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_HOSTNAME,
+ hostname, TRUE);
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
+ username, TRUE));
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
+ password, TRUE));
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
+ protocol, TRUE));
+ has_errors || (has_errors = !modest_account_mgr_set_int (self, account_name, MODEST_ACCOUNT_PORT,
+ port, TRUE));
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name,
+ MODEST_ACCOUNT_AUTH_MECH,
+ auth_protocol, TRUE));
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_SECURITY,
+ security,
+ TRUE));
+ } else {
+ const gchar *uri = modest_server_account_settings_get_uri (settings);
+ has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_URI,
+ uri, TRUE);
+ has_errors || (has_errors = !modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PROTO,
+ protocol, TRUE));
+ }
+
+ return !has_errors;
- g_slice_free (ModestServerAccountData, data);
}
-/** You must use modest_account_mgr_free_account_data() on the result.
- */
-ModestAccountData *
-modest_account_mgr_get_account_data (ModestAccountMgr *self,
- const gchar* name)
+
+ModestAccountSettings *
+modest_account_mgr_load_account_settings (ModestAccountMgr *self,
+ const gchar* name)
{
- ModestAccountData *data;
+ ModestAccountSettings *settings;
+ gchar *string;
gchar *server_account;
gchar *default_account;
+ gboolean use_signature = FALSE;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (name, NULL);
return NULL;
}
- data = g_slice_new0 (ModestAccountData);
-
- data->account_name = g_strdup (name);
+ settings = modest_account_settings_new ();
- data->display_name = modest_account_mgr_get_string (self, name,
- MODEST_ACCOUNT_DISPLAY_NAME,
- FALSE);
- data->fullname = modest_account_mgr_get_string (self, name,
- MODEST_ACCOUNT_FULLNAME,
- FALSE);
- data->email = modest_account_mgr_get_string (self, name,
- MODEST_ACCOUNT_EMAIL,
- FALSE);
- data->is_enabled = modest_account_mgr_get_enabled (self, name);
+ modest_account_settings_set_account_name (settings, name);
+
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_DISPLAY_NAME,
+ FALSE);
+ modest_account_settings_set_display_name (settings, string);
+ g_free (string);
+
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_FULLNAME,
+ FALSE);
+ modest_account_settings_set_fullname (settings, string);
+ g_free (string);
+
+ string = modest_account_mgr_get_string (self, name,
+ MODEST_ACCOUNT_EMAIL,
+ FALSE);
+ modest_account_settings_set_email_address (settings, string);
+ g_free (string);
+
+ modest_account_settings_set_enabled (settings, modest_account_mgr_get_enabled (self, name));
+ modest_account_settings_set_retrieve_type (settings, modest_account_mgr_get_retrieve_type (self, name));
default_account = modest_account_mgr_get_default_account (self);
- data->is_default = (default_account && strcmp (default_account, name) == 0);
+ modest_account_settings_set_is_default (settings,
+ (default_account && strcmp (default_account, name) == 0));
g_free (default_account);
+ string = modest_account_mgr_get_signature (self, name, &use_signature);
+ modest_account_settings_set_use_signature (settings, use_signature);
+ modest_account_settings_set_signature (settings, string);
+ g_free (string);
+
+ modest_account_settings_set_leave_messages_on_server
+ (settings, modest_account_mgr_get_leave_on_server (self, name));
+ modest_account_settings_set_use_connection_specific_smtp
+ (settings, modest_account_mgr_get_use_connection_specific_smtp (self, name));
+
/* store */
server_account = modest_account_mgr_get_string (self, name,
MODEST_ACCOUNT_STORE_ACCOUNT,
FALSE);
if (server_account) {
- data->store_account =
- modest_account_mgr_get_server_account_data (self, server_account);
+ ModestServerAccountSettings *store_settings;
+ store_settings = modest_account_mgr_load_server_settings (self, server_account);
+ modest_account_settings_set_store_settings (settings,
+ store_settings);
+ g_object_unref (store_settings);
g_free (server_account);
}
MODEST_ACCOUNT_TRANSPORT_ACCOUNT,
FALSE);
if (server_account) {
- data->transport_account =
- modest_account_mgr_get_server_account_data (self, server_account);
+ ModestServerAccountSettings *transport_settings;
+ transport_settings = modest_account_mgr_load_server_settings (self, server_account);
+ modest_account_settings_set_transport_settings (settings, transport_settings);
+ g_object_unref (transport_settings);
g_free (server_account);
}
- return data;
+ return settings;
}
-
void
-modest_account_mgr_free_account_data (ModestAccountMgr *self, ModestAccountData *data)
-{
- g_return_if_fail (self);
-
- if (!data) /* not an error */
- return;
-
- g_free (data->account_name);
- g_free (data->display_name);
- g_free (data->fullname);
- g_free (data->email);
+modest_account_mgr_save_account_settings (ModestAccountMgr *mgr,
+ ModestAccountSettings *settings)
+{
+ g_return_if_fail (MODEST_IS_ACCOUNT_MGR (mgr));
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ const gchar *account_name;
+ const gchar *store_account_name;
+ const gchar *transport_account_name;
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
+
+ account_name = modest_account_settings_get_account_name (settings);
+ g_return_if_fail (account_name != NULL);
+
+ modest_account_mgr_set_display_name (mgr, account_name,
+ modest_account_settings_get_display_name (settings));
+ modest_account_mgr_set_user_fullname (mgr, account_name,
+ modest_account_settings_get_fullname (settings));
+ modest_account_mgr_set_user_email (mgr, account_name,
+ modest_account_settings_get_email_address (settings));
+ modest_account_mgr_set_retrieve_type (mgr, account_name,
+ modest_account_settings_get_retrieve_type (settings));
+ modest_account_mgr_set_retrieve_limit (mgr, account_name,
+ modest_account_settings_get_retrieve_limit (settings));
+ modest_account_mgr_set_leave_on_server (mgr, account_name,
+ modest_account_settings_get_leave_messages_on_server (settings));
+ modest_account_mgr_set_signature (mgr, account_name,
+ modest_account_settings_get_signature (settings),
+ modest_account_settings_get_use_signature (settings));
+ modest_account_mgr_set_use_connection_specific_smtp
+ (mgr, account_name,
+ modest_account_settings_get_use_connection_specific_smtp (settings));
+
+ store_settings = modest_account_settings_get_store_settings (settings);
+ store_account_name = modest_server_account_settings_get_account_name (store_settings);
+ if (store_settings != NULL) {
+ modest_account_mgr_save_server_settings (mgr, store_settings);
+ }
+ modest_account_mgr_set_string (mgr, account_name, MODEST_ACCOUNT_STORE_ACCOUNT, store_account_name, FALSE);
+ g_object_unref (store_settings);
- modest_account_mgr_free_server_account_data (self, data->store_account);
- modest_account_mgr_free_server_account_data (self, data->transport_account);
-
- g_slice_free (ModestAccountData, data);
+ transport_settings = modest_account_settings_get_transport_settings (settings);
+ transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
+ if (transport_settings != NULL) {
+ modest_account_mgr_save_server_settings (mgr, transport_settings);
+ }
+ modest_account_mgr_set_string (mgr, account_name, MODEST_ACCOUNT_TRANSPORT_ACCOUNT, transport_account_name, FALSE);
+ g_object_unref (transport_settings);
+ modest_account_mgr_set_enabled (mgr, account_name, TRUE);
}
+
gint
on_accounts_list_sort_by_title(gconstpointer a, gconstpointer b)
{
FALSE);
}
-gchar*
+static const gchar *
+get_retrieve_type_name (ModestAccountRetrieveType retrieve_type)
+{
+ switch(retrieve_type) {
+ case MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
+ break;
+ case MODEST_ACCOUNT_RETRIEVE_MESSAGES:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES;
+ break;
+ case MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES_AND_ATTACHMENTS;
+ break;
+ default:
+ return MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
+ };
+}
+
+static ModestAccountRetrieveType
+get_retrieve_type (const gchar *name)
+{
+ if (!name || name[0] == 0)
+ return MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ if (strcmp (name, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES) == 0) {
+ return MODEST_ACCOUNT_RETRIEVE_MESSAGES;
+ } else if (strcmp (name, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES_AND_ATTACHMENTS) == 0) {
+ return MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS;
+ } else {
+ /* we fall back to headers only */
+ return MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ }
+}
+
+ModestAccountRetrieveType
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 */);
+ gchar *string;
+ ModestAccountRetrieveType result;
+
+ string = modest_account_mgr_get_string (self,
+ account_name,
+ MODEST_ACCOUNT_RETRIEVE,
+ FALSE /* not server account */);
+ result = get_retrieve_type (string);
+ g_free (string);
+
+ return result;
}
void
modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
const gchar *account_name,
- const gchar *retrieve_type)
+ ModestAccountRetrieveType retrieve_type)
{
modest_account_mgr_set_string (self,
account_name,
MODEST_ACCOUNT_RETRIEVE,
- retrieve_type,
+ get_retrieve_type_name (retrieve_type),
FALSE /* not server account */);
}
#include <tny-account.h>
#include <tny-store-account.h>
#include <tny-transport-account.h>
+#include <modest-server-account-settings.h>
G_BEGIN_DECLS
-typedef struct {
- gchar *account_name;
- gchar *hostname;
- gchar *username;
- gchar *uri; /*< Only for mbox and maildir accounts. */
- ModestTransportStoreProtocol proto; /*< The store or transport. Not ORed. */
- gchar *password;
- time_t last_updated;
- gint port; /* Or 0, if the default should be used. */
- ModestAuthProtocol secure_auth;
- ModestConnectionProtocol security;
-} ModestServerAccountData;
-
-typedef struct {
- gchar *account_name;
- gchar *display_name;
- gchar *fullname;
- gchar *email;
- gboolean is_enabled;
- gboolean is_default;
- ModestServerAccountData *transport_account;
- ModestServerAccountData *store_account;
-} ModestAccountData;
-
-
-
/**
- * modest_account_mgr_get_account_data:
+ * modest_account_mgr_load_account_settings:
* @self: a ModestAccountMgr instance
* @name: the name of the account
*
* get information about an account
*
- * Returns: a ModestAccountData structure with information about the account.
- * the data should not be changed, and be freed with modest_account_mgr_free_account_data
- * The function does a sanity check, an if it's not returning NULL,
- * it is a valid account
+ * Returns: a ModestAccountSettings instance with information about the account,
+ * or NULL if the account is not valid or does not exist.
*/
-ModestAccountData *modest_account_mgr_get_account_data (ModestAccountMgr *self,
- const gchar* name);
+ModestAccountSettings *modest_account_mgr_load_account_settings (ModestAccountMgr *self,
+ const gchar* name);
+
+void modest_account_mgr_save_account_settings (ModestAccountMgr *self,
+ ModestAccountSettings *settings);
/**
* modest_account_mgr_set_first_account_as_default:
gchar*
modest_account_mgr_get_first_account_name (ModestAccountMgr *self);
-/**
- * modest_account_mgr_free_account_data:
- * @self: a ModestAccountMgr instance
- * @data: a ModestAccountData instance
- *
- * free the account data structure
- */
-void modest_account_mgr_free_account_data (ModestAccountMgr *self,
- ModestAccountData *data);
/**
* modest_account_mgr_set_enabled
const gchar* account_name,
ModestConnectionProtocol security);
-ModestServerAccountData* modest_account_mgr_get_server_account_data (ModestAccountMgr *self,
- const gchar* name);
+gboolean modest_account_mgr_save_server_settings (ModestAccountMgr *self,
+ ModestServerAccountSettings *settings);
-void modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
- ModestServerAccountData* data);
+ModestServerAccountSettings *modest_account_mgr_load_server_settings (ModestAccountMgr *self,
+ const gchar *account_name);
/**
* modest_account_mgr_get_from_string
const gchar *account_name,
TnyAccountType account_type);
-gchar* modest_account_mgr_get_retrieve_type (ModestAccountMgr *self,
- const gchar *account_name);
+ModestAccountRetrieveType 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);
+ ModestAccountRetrieveType retrieve_type);
void modest_account_mgr_set_user_fullname (ModestAccountMgr *self,
const gchar *account_name,
return str ? str : "";
}
+gboolean
+modest_account_mgr_add_account_from_settings (ModestAccountMgr *self,
+ ModestAccountSettings *settings)
+{
+ ModestAccountMgrPrivate *priv;
+ const gchar* display_name;
+ gchar *account_name_start, *account_name;
+ gchar *store_name_start, *store_name;
+ gchar *transport_name_start, *transport_name;
+ gchar *default_account;
+ ModestServerAccountSettings *store_settings, *transport_settings;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR (self), FALSE);
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), FALSE);
+
+ priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ display_name = modest_account_settings_get_display_name (settings);
+
+ /* We should have checked for this already, and changed that name accordingly,
+ * but let's check again just in case */
+ if (!display_name ||
+ modest_account_mgr_account_with_display_name_exists (self, display_name)) {
+ return FALSE;
+ }
+
+ /* Increment the non-user visible name if necessary,
+ * based on the display name: */
+ account_name_start = g_strdup_printf ("%sID", display_name);
+ account_name = modest_account_mgr_get_unused_account_name (self,
+ account_name_start, FALSE /* not a server account */);
+ g_free (account_name_start);
+
+ /* Add a (incoming) server account, to be used by the account: */
+ store_name_start = g_strconcat (account_name, "_store", NULL);
+ store_name = modest_account_mgr_get_unused_account_name (self,
+ store_name_start, TRUE /* server account */);
+ g_free (store_name_start);
+
+ /* Add a (outgoing) server account to be used by the account: */
+ transport_name_start = g_strconcat (account_name, "_transport", NULL);
+ transport_name = modest_account_mgr_get_unused_account_name (self,
+ transport_name_start, TRUE /* server account */);
+ g_free (transport_name_start);
+
+ modest_account_settings_set_account_name (settings, account_name);
+ store_settings = modest_account_settings_get_store_settings (settings);
+ modest_server_account_settings_set_account_name (store_settings, store_name);
+ transport_settings = modest_account_settings_get_transport_settings (settings);
+ modest_server_account_settings_set_account_name (transport_settings, transport_name);
+ g_object_unref (store_settings);
+ g_object_unref (transport_settings);
+
+ /* Create the account, which will contain the two "server accounts": */
+ modest_account_mgr_save_account_settings (self, settings);
+ g_free (store_name);
+ g_free (transport_name);
+
+ /* Sanity check: */
+ /* There must be at least one account now: */
+ /* Note, when this fails is is caused by a Maemo gconf bug that has been
+ * fixed in versions after 3.1. */
+ if(!modest_account_mgr_has_accounts (self, FALSE))
+ g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
+
+ /* Notify the observers */
+ g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, account_name);
+
+ /* if no default account has been defined yet, do so now */
+ default_account = modest_account_mgr_get_default_account (self);
+ if (!default_account) {
+ modest_account_mgr_set_default_account (self, account_name);
+ modest_account_settings_set_is_default (settings, TRUE);
+ }
+ g_free (default_account);
+ g_free (account_name);
+
+ /* (re)set the automatic account update */
+ modest_platform_set_update_interval
+ (modest_conf_get_int (priv->modest_conf, MODEST_CONF_UPDATE_INTERVAL, NULL));
+
+ return TRUE;
+}
+
gboolean
modest_account_mgr_add_account (ModestAccountMgr *self,
const gchar *display_name,
const gchar *user_fullname,
const gchar *user_email,
- const gchar *retrieve_type,
+ ModestAccountRetrieveType retrieve_type,
const gchar *store_account,
const gchar *transport_account,
gboolean enabled)
modest_account_mgr_set_string (self, name,
MODEST_ACCOUNT_EMAIL,
user_email, FALSE);
- modest_account_mgr_set_string (self, name,
- MODEST_ACCOUNT_RETRIEVE,
- retrieve_type, FALSE);
+ modest_account_mgr_set_retrieve_type (self, name,
+ retrieve_type);
/* Notify the observers */
g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
/* Look at each non-server account to check their display names; */
while (cursor) {
- const gchar * account_name = (gchar*)cursor->data;
+ const gchar *account_name = (gchar*)cursor->data;
+ const gchar *cursor_display_name;
- ModestAccountData *account_data = modest_account_mgr_get_account_data (self, account_name);
- if (!account_data) {
+ ModestAccountSettings *settings = modest_account_mgr_load_account_settings (self, account_name);
+ if (!settings) {
g_printerr ("modest: failed to get account data for %s\n", account_name);
continue;
}
- if(account_data->display_name && (strcmp (account_data->display_name, display_name) == 0)) {
+ cursor_display_name = modest_account_settings_get_display_name (settings);
+ if(cursor_display_name && (strcmp (cursor_display_name, display_name) == 0)) {
found = TRUE;
+ g_object_unref (settings);
break;
}
- modest_account_mgr_free_account_data (self, account_data);
+ g_object_unref (settings);
cursor = cursor->next;
}
modest_account_mgr_free_account_names (account_names);
#include <modest-conf.h>
#include <modest-defs.h>
#include <modest-protocol-info.h>
+#include <modest-account-settings.h>
G_BEGIN_DECLS
/**
+ * modest_account_mgr_add_account_from_settings:
+ * @self: a #ModestAccountMgr instance
+ * @self: a #ModestSettings
+ *
+ * Create a new account from a @settings instance.
+ *
+ * Returns: TRUE if the creation succeeded, FALSE otherwise,
+ */
+gboolean modest_account_mgr_add_account_from_settings (ModestAccountMgr *self,
+ ModestAccountSettings *settings);
+
+/**
* modest_account_mgr_add_account:
* @self: a ModestAccountMgr instance
* @name: name (id) of the account, which is a valid UTF8 string that does not contain '/'
const gchar *display_name,
const gchar *user_fullname,
const gchar *user_email,
- const gchar *retrieve_type,
+ ModestAccountRetrieveType retrieve_type,
const gchar* store_name,
const gchar* transport_name,
gboolean enabled);
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <modest-account-settings.h>
+
+/* 'private'/'protected' functions */
+static void modest_account_settings_class_init (ModestAccountSettingsClass *klass);
+static void modest_account_settings_finalize (GObject *obj);
+static void modest_account_settings_instance_init (ModestAccountSettings *obj);
+
+typedef struct _ModestAccountSettingsPrivate ModestAccountSettingsPrivate;
+struct _ModestAccountSettingsPrivate {
+ gchar *fullname;
+ gchar *email_address;
+ ModestAccountRetrieveType retrieve_type;
+ gint retrieve_limit;
+ gchar *display_name;
+ gchar *account_name;
+ ModestServerAccountSettings *store_settings;
+ ModestServerAccountSettings *transport_settings;
+ gboolean enabled;
+ gboolean is_default;
+ gboolean leave_messages_on_server;
+ gboolean use_signature;
+ gchar *signature;
+ gboolean use_connection_specific_smtp;
+};
+
+#define MODEST_ACCOUNT_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_ACCOUNT_SETTINGS, \
+ ModestAccountSettingsPrivate))
+
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+GType
+modest_account_settings_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestAccountSettingsClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_account_settings_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestAccountSettings),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) modest_account_settings_instance_init,
+ NULL
+ };
+
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestAccountSettings",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_account_settings_class_init (ModestAccountSettingsClass *klass)
+{
+ GObjectClass *gobject_class;
+ gobject_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_account_settings_finalize;
+
+ g_type_class_add_private (gobject_class,
+ sizeof(ModestAccountSettingsPrivate));
+}
+
+static void
+modest_account_settings_instance_init (ModestAccountSettings *obj)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (obj);
+
+ priv->fullname = NULL;
+ priv->email_address = NULL;
+ priv->retrieve_type = MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ priv->retrieve_limit = 0;
+ priv->display_name = NULL;
+ priv->account_name = NULL;
+ priv->store_settings = NULL;
+ priv->transport_settings = NULL;
+ priv->enabled = TRUE;
+ priv->is_default = FALSE;
+ priv->leave_messages_on_server = TRUE;
+ priv->use_signature = FALSE;
+ priv->signature = FALSE;
+ priv->use_connection_specific_smtp = FALSE;
+}
+
+static void
+modest_account_settings_finalize (GObject *obj)
+{
+ ModestAccountSettings *settings = MODEST_ACCOUNT_SETTINGS (obj);
+ ModestAccountSettingsPrivate *priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->fullname);
+ priv->fullname = NULL;
+ g_free (priv->email_address);
+ priv->email_address = NULL;
+ g_free (priv->display_name);
+ priv->display_name = NULL;
+ g_free (priv->account_name);
+ priv->account_name = NULL;
+ g_free (priv->signature);
+ priv->signature = FALSE;
+ if (priv->store_settings) {
+ g_object_unref (priv->store_settings);
+ priv->store_settings = NULL;
+ }
+ if (priv->transport_settings) {
+ g_object_unref (priv->transport_settings);
+ priv->transport_settings = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+ModestAccountSettings*
+modest_account_settings_new (void)
+{
+ return g_object_new (MODEST_TYPE_ACCOUNT_SETTINGS, NULL);
+}
+
+const gchar*
+modest_account_settings_get_fullname (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->fullname;
+}
+
+void
+modest_account_settings_set_fullname (ModestAccountSettings *settings,
+ const gchar *fullname)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->fullname);
+ priv->fullname = g_strdup (fullname);
+}
+
+const gchar*
+modest_account_settings_get_email_address (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->email_address;
+}
+
+void
+modest_account_settings_set_email_address (ModestAccountSettings *settings,
+ const gchar *email_address)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->email_address);
+ priv->email_address = g_strdup (email_address);
+}
+
+const gchar*
+modest_account_settings_get_display_name (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->display_name;
+}
+
+void
+modest_account_settings_set_display_name (ModestAccountSettings *settings,
+ const gchar *display_name)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->display_name);
+ priv->display_name = g_strdup (display_name);
+}
+
+const gchar*
+modest_account_settings_get_account_name (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->account_name;
+}
+
+void
+modest_account_settings_set_account_name (ModestAccountSettings *settings,
+ const gchar *account_name)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ /* be careful. This method should only be used internally in #ModestAccountMgr and
+ * #ModestAccountSettings. */
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->account_name);
+ priv->account_name = g_strdup (account_name);
+}
+
+ModestAccountRetrieveType
+modest_account_settings_get_retrieve_type (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->retrieve_type;
+}
+
+void
+modest_account_settings_set_retrieve_type (ModestAccountSettings *settings,
+ ModestAccountRetrieveType retrieve_type)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->retrieve_type = retrieve_type;
+}
+
+gint
+modest_account_settings_get_retrieve_limit (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->retrieve_limit;
+}
+
+void
+modest_account_settings_set_retrieve_limit (ModestAccountSettings *settings,
+ gint retrieve_limit)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->retrieve_limit = retrieve_limit;
+}
+
+gboolean
+modest_account_settings_get_enabled (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->enabled;
+}
+
+void
+modest_account_settings_set_enabled (ModestAccountSettings *settings,
+ gboolean enabled)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->enabled = enabled;
+}
+
+gboolean
+modest_account_settings_get_is_default (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->is_default;
+}
+
+void
+modest_account_settings_set_is_default (ModestAccountSettings *settings,
+ gboolean is_default)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->is_default = is_default;
+}
+
+ModestServerAccountSettings *
+modest_account_settings_get_store_settings (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ if (!priv->store_settings)
+ priv->store_settings = modest_server_account_settings_new ();
+ return g_object_ref (priv->store_settings);
+}
+
+void
+modest_account_settings_set_store_settings (ModestAccountSettings *settings,
+ ModestServerAccountSettings *store_settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+
+ if (priv->store_settings) {
+ g_object_unref (priv->store_settings);
+ priv->store_settings = NULL;
+ }
+
+ if (MODEST_IS_SERVER_ACCOUNT_SETTINGS (store_settings))
+ priv->store_settings = g_object_ref (store_settings);
+}
+
+ModestServerAccountSettings *
+modest_account_settings_get_transport_settings (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ if (!priv->transport_settings)
+ priv->transport_settings = modest_server_account_settings_new ();
+ return g_object_ref (priv->transport_settings);
+}
+
+void
+modest_account_settings_set_transport_settings (ModestAccountSettings *settings,
+ ModestServerAccountSettings *transport_settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+
+ if (priv->transport_settings) {
+ g_object_unref (priv->transport_settings);
+ priv->transport_settings = NULL;
+ }
+
+ if (MODEST_IS_SERVER_ACCOUNT_SETTINGS (transport_settings))
+ priv->transport_settings = g_object_ref (transport_settings);
+}
+
+gboolean
+modest_account_settings_get_use_signature (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->use_signature;
+}
+
+void
+modest_account_settings_set_use_signature (ModestAccountSettings *settings,
+ gboolean use_signature)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->use_signature = use_signature;
+}
+
+const gchar*
+modest_account_settings_get_signature (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->signature;
+}
+
+void
+modest_account_settings_set_signature (ModestAccountSettings *settings,
+ const gchar *signature)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->signature);
+ priv->signature = g_strdup (signature);
+}
+
+gboolean
+modest_account_settings_get_leave_messages_on_server (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->leave_messages_on_server;
+}
+
+void
+modest_account_settings_set_leave_messages_on_server (ModestAccountSettings *settings,
+ gboolean leave_messages_on_server)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->leave_messages_on_server = leave_messages_on_server;
+}
+
+gboolean
+modest_account_settings_get_use_connection_specific_smtp (ModestAccountSettings *settings)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->use_connection_specific_smtp;
+}
+
+void
+modest_account_settings_set_use_connection_specific_smtp (ModestAccountSettings *settings,
+ gboolean use_connection_specific_smtp)
+{
+ ModestAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->use_connection_specific_smtp = use_connection_specific_smtp;
+}
+
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/* modest-account-settings.h */
+
+#ifndef __MODEST_ACCOUNT_SETTINGS_H__
+#define __MODEST_ACCOUNT_SETTINGS_H__
+
+#include <glib-object.h>
+#include <modest-defs.h>
+#include <modest-server-account-settings.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_ACCOUNT_SETTINGS (modest_account_settings_get_type())
+#define MODEST_ACCOUNT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNT_SETTINGS,ModestAccountSettings))
+#define MODEST_ACCOUNT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNT_SETTINGS,ModestAccountSettingsClass))
+#define MODEST_IS_ACCOUNT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNT_SETTINGS))
+#define MODEST_IS_ACCOUNT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNT_SETTINGS))
+#define MODEST_ACCOUNT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNT_SETTINGS,ModestAccountSettingsClass))
+
+typedef struct _ModestAccountSettings ModestAccountSettings;
+typedef struct _ModestAccountSettingsClass ModestAccountSettingsClass;
+
+struct _ModestAccountSettings {
+ GObject parent;
+};
+
+struct _ModestAccountSettingsClass {
+ GObjectClass parent_class;
+};
+
+typedef enum {
+ MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY = 0,
+ MODEST_ACCOUNT_RETRIEVE_MESSAGES,
+ MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS
+} ModestAccountRetrieveType;
+
+
+/**
+ * modest_account_settings_get_type:
+ *
+ * Returns: GType of the account store
+ */
+GType modest_account_settings_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_account_settings_new:
+ *
+ * creates a new instance of #ModestAccountSettings
+ *
+ * Returns: a #ModestAccountSettings
+ */
+ModestAccountSettings* modest_account_settings_new (void);
+
+/**
+ * modest_account_settings_get_fullname:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the user full name.
+ *
+ * Returns: a string
+ */
+const gchar* modest_account_settings_get_fullname (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_fullname:
+ * @settings: a #ModestAccountSettings
+ * @hostname: a string.
+ *
+ * set @fullname as the user full name .
+ */
+void modest_account_settings_set_fullname (ModestAccountSettings *settings,
+ const gchar *fullname);
+/**
+ * modest_account_settings_get_email_address:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the user email address.
+ *
+ * Returns: a string
+ */
+const gchar* modest_account_settings_get_email_address (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_email_address:
+ * @settings: a #ModestAccountSettings
+ * @hostname: a string.
+ *
+ * set @email_address of the account.
+ */
+void modest_account_settings_set_email_address (ModestAccountSettings *settings,
+ const gchar *email_address);
+/**
+ * modest_account_settings_get_retrieve_type:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the account retrieve type.
+ *
+ * Returns: a #ModestAccountRetrieveType
+ */
+ModestAccountRetrieveType modest_account_settings_get_retrieve_type (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_retrieve_type:
+ * @settings: a #ModestAccountSettings
+ * @retrieve_type: a #ModestAccountRetrieveType.
+ *
+ * set @retrieve_type of the account.
+ */
+void modest_account_settings_set_retrieve_type (ModestAccountSettings *settings,
+ ModestAccountRetrieveType retrieve_type);
+
+/**
+ * modest_account_settings_get_retrieve_limit:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the account retrieve limit. 0 is no limit.
+ *
+ * Returns: a #gint
+ */
+gint modest_account_settings_get_retrieve_limit (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_retrieve_limit:
+ * @settings: a #ModestAccountSettings
+ * @retrieve_limit: a #gint.
+ *
+ * set @retrieve_limit of the account. 0 is no limit.
+ */
+void modest_account_settings_set_retrieve_limit (ModestAccountSettings *settings,
+ gint retrieve_limit);
+
+/**
+ * modest_account_settings_get_display_name:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the visible name of the account.
+ *
+ * Returns: a string
+ */
+const gchar* modest_account_settings_get_display_name (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_display_name:
+ * @settings: a #ModestAccountSettings
+ * @hostname: a string.
+ *
+ * set @display_name as the name of the account visible to the users in UI.
+ */
+void modest_account_settings_set_display_name (ModestAccountSettings *settings,
+ const gchar *display_name);
+
+/**
+ * modest_account_settings_get_account_name:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the #ModestAccountMgr account name for these settings, or
+ * %NULL if it's not in the manager.
+ *
+ * Returns: a string, or %NULL
+ */
+const gchar *modest_account_settings_get_account_name (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_account_name:
+ * @settings: a #ModestAccountSettings
+ * @account_name: a string
+ *
+ * sets the account name that will be used to store the account settings. This should
+ * only be called from #ModestAccountMgr and #ModestAccountSettings.
+ */
+void modest_account_settings_set_account_name (ModestAccountSettings *settings,
+ const gchar *account_name);
+
+/**
+ * modest_account_settings_get_enabled:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains whether the account is enabled or not.
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_settings_get_enabled (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_enabled:
+ * @settings: a #ModestAccountSettings
+ * @enabled: a #gboolean
+ *
+ * set if @settings account is enabled or not.
+ */
+void modest_account_settings_set_enabled (ModestAccountSettings *settings, gboolean enabled);
+
+
+/**
+ * modest_account_settings_get_is_default:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains whether the account is the default account or not.
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_settings_get_is_default (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_is_default:
+ * @settings: a #ModestAccountSettings
+ * @is_default: a #gboolean
+ *
+ * set if @settings account is the default account or not.
+ */
+void modest_account_settings_set_is_default (ModestAccountSettings *settings, gboolean is_default);
+
+/**
+ * modest_account_settings_get_store_settings:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains a ref'ed instance of the store account server settings
+ *
+ * Returns: a ref'd #ModestServerAccountSettings. You should unreference it on finishing usage.
+ */
+ModestServerAccountSettings *modest_account_settings_get_store_settings (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_store_settings:
+ * @settings: a #ModestAccountSettings
+ *
+ * sets @store_settings as the settings of the store account of @settings account.
+ * @settings will keep an internal reference to it.
+ */
+void modest_account_settings_set_store_settings (ModestAccountSettings *settings,
+ ModestServerAccountSettings *store_settings);
+
+/**
+ * modest_account_settings_get_transport_settings:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains a ref'ed instance of the transport account server settings
+ *
+ * Returns: a ref'd #ModestServerAccountSettings. You should unreference it on finishing usage.
+ */
+ModestServerAccountSettings *modest_account_settings_get_transport_settings (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_transport_settings:
+ * @settings: a #ModestAccountSettings
+ *
+ * sets @transport_settings as the settings of the transport account of @settings account.
+ * @settings will keep an internal reference to it.
+ */
+void modest_account_settings_set_transport_settings (ModestAccountSettings *settings,
+ ModestServerAccountSettings *transport_settings);
+
+/**
+ * modest_account_settings_get_use_signature:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains whether the mails from this account use signature or not.
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_settings_get_use_signature (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_use_signature:
+ * @settings: a #ModestAccountSettings
+ * @use_signature: a #gboolean
+ *
+ * set if @settings mails use signature or not
+ */
+void modest_account_settings_set_use_signature (ModestAccountSettings *settings, gboolean use_signature);
+
+/**
+ * modest_account_settings_get_signature:
+ * @settings: a #ModestAccountSettings
+ *
+ * get the signature.
+ *
+ * Returns: a string
+ */
+const gchar* modest_account_settings_get_signature (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_signature:
+ * @settings: a #ModestAccountSettings
+ * @hostname: a string.
+ *
+ * set @signature for the account .
+ */
+void modest_account_settings_set_signature (ModestAccountSettings *settings,
+ const gchar *signature);
+/**
+ * modest_account_settings_get_leave_messages_on_server:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains whether messages should be left on server or not
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_settings_get_leave_messages_on_server (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_leave_messages_on_server:
+ * @settings: a #ModestAccountSettings
+ * @leave_messages_on_server: a #gboolean
+ *
+ * set if we leave the messages on server or not.
+ */
+void modest_account_settings_set_leave_messages_on_server (ModestAccountSettings *settings,
+ gboolean leave_messages_on_server);
+
+
+/**
+ * modest_account_settings_get_use_connection_specific_smtp:
+ * @settings: a #ModestAccountSettings
+ *
+ * obtains if we should try the connection specific smtp servers
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_settings_get_use_connection_specific_smtp (ModestAccountSettings *settings);
+
+/**
+ * modest_account_settings_set_use_connection_specific_smtp:
+ * @settings: a #ModestAccountSettings
+ * @use_connection_specific_smtp: a #gboolean
+ *
+ * if set, mails sent from this account first try the connection specific smtp servers
+ * before the transport account.
+ */
+void modest_account_settings_set_use_connection_specific_smtp (ModestAccountSettings *settings,
+ gboolean use_connection_specific_smtp);
+
+G_END_DECLS
+
+#endif /* __MODEST_ACCOUNT_SETTINGS_H__ */
GPtrArray *new_headers_array = NULL;
gint max_size, retrieve_limit, i;
ModestAccountMgr *mgr;
- gchar *retrieve_type = NULL;
+ ModestAccountRetrieveType retrieve_type;
TnyList *new_headers = NULL;
gboolean headers_only;
TnyTransportAccount *transport_account;
/* Get per-account retrieval type */
retrieve_type = modest_account_mgr_get_retrieve_type (mgr, info->account_name);
- headers_only = !g_ascii_strcasecmp (retrieve_type, MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY);
- g_free (retrieve_type);
+ headers_only = (retrieve_type == MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY);
/* Order by date */
g_ptr_array_sort (new_headers_array, (GCompareFunc) compare_headers_by_date);
ModestConnectedPerformer callback,
gpointer user_data);
+/**
+ * modest_platform_get_account_settings_dialog:
+ * @settings: a #ModestAccountSettings
+ *
+ * creates a dialog for editing @settings
+ *
+ * Returns: the newly created dialog.
+ */
+GtkWidget *modest_platform_get_account_settings_dialog (ModestAccountSettings *settings);
+
+/**
+ * modest_platform_get_account_settings_wizard:
+ * @settings: a #ModestAccountSettings
+ *
+ * creates a dialog for editing @settings
+ *
+ * Returns: the newly created dialog.
+ */
+GtkWidget *modest_platform_get_account_settings_wizard ();
+
G_END_DECLS
#endif /* __MODEST_PLATFORM_UTILS_H__ */
FALSE);
}
+ModestConnectionProtocol
+modest_protocol_info_get_connection_protocol (const gchar* name)
+{
+ g_return_val_if_fail (name, MODEST_PROTOCOL_CONNECTION_NORMAL);
+
+ return get_protocol_by_name(ConnectionProtocolMap,
+ G_N_ELEMENTS(ConnectionProtocolMap),
+ name,
+ MODEST_PROTOCOL_CONNECTION_NORMAL,
+ FALSE);
+}
+
/* get either the name or the display_name for the protocol */
static const gchar*
ModestAuthProtocol modest_protocol_info_get_auth_protocol (const gchar* name);
/**
+ * modest_protocol_info_get_connection_protocol:
+ * @name: The name of the #ModestConnectionProtocol
+ *
+ * Returns the ID of the protocol with the given name
+ *
+ * Returns: The ID of the protocol or MODEST_CONNECTION_PROTOCOL_NORMAL
+ */
+ModestConnectionProtocol modest_protocol_info_get_connection_protocol (const gchar* name);
+
+/**
* modest_protocol_info_get_transport_store_protocol_name:
* @proto: the protocol you are looking for
*
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <modest-server-account-settings.h>
+
+/* 'private'/'protected' functions */
+static void modest_server_account_settings_class_init (ModestServerAccountSettingsClass *klass);
+static void modest_server_account_settings_finalize (GObject *obj);
+static void modest_server_account_settings_instance_init (ModestServerAccountSettings *obj);
+
+typedef struct _ModestServerAccountSettingsPrivate ModestServerAccountSettingsPrivate;
+struct _ModestServerAccountSettingsPrivate {
+ gchar *hostname;
+ guint port;
+ ModestTransportStoreProtocol protocol;
+ gchar *username;
+ gchar *password;
+ ModestConnectionProtocol security;
+ ModestAuthProtocol auth_protocol;
+ gchar *account_name;
+ gchar *uri;
+};
+
+#define MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ MODEST_TYPE_SERVER_ACCOUNT_SETTINGS, \
+ ModestServerAccountSettingsPrivate))
+
+/* globals */
+static GObjectClass *parent_class = NULL;
+
+GType
+modest_server_account_settings_get_type (void)
+{
+ static GType my_type = 0;
+
+ if (!my_type) {
+ static const GTypeInfo my_info = {
+ sizeof(ModestServerAccountSettingsClass),
+ NULL, /* base init */
+ NULL, /* base finalize */
+ (GClassInitFunc) modest_server_account_settings_class_init,
+ NULL, /* class finalize */
+ NULL, /* class data */
+ sizeof(ModestServerAccountSettings),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) modest_server_account_settings_instance_init,
+ NULL
+ };
+
+ my_type = g_type_register_static (G_TYPE_OBJECT,
+ "ModestServerAccountSettings",
+ &my_info, 0);
+ }
+ return my_type;
+}
+
+static void
+modest_server_account_settings_class_init (ModestServerAccountSettingsClass *klass)
+{
+ GObjectClass *gobject_class;
+ gobject_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+ gobject_class->finalize = modest_server_account_settings_finalize;
+
+ g_type_class_add_private (gobject_class,
+ sizeof(ModestServerAccountSettingsPrivate));
+}
+
+static void
+modest_server_account_settings_instance_init (ModestServerAccountSettings *obj)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (obj);
+
+ priv->hostname = NULL;
+ priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ priv->port = 0;
+ priv->username = NULL;
+ priv->password = NULL;
+ priv->security = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ priv->auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ priv->account_name = NULL;
+ priv->uri = NULL;
+}
+
+static void
+modest_server_account_settings_finalize (GObject *obj)
+{
+ ModestServerAccountSettings *settings = MODEST_SERVER_ACCOUNT_SETTINGS (obj);
+ ModestServerAccountSettingsPrivate *priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->hostname);
+ priv->hostname = NULL;
+ g_free (priv->username);
+ priv->username = NULL;
+ g_free (priv->password);
+ priv->password = NULL;
+ priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+ priv->port = 0;
+ priv->security = MODEST_PROTOCOL_CONNECTION_NORMAL;
+ priv->auth_protocol = MODEST_PROTOCOL_AUTH_NONE;
+ g_free (priv->account_name);
+ priv->account_name = NULL;
+ g_free (priv->uri);
+ priv->uri = NULL;
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+ModestServerAccountSettings*
+modest_server_account_settings_new (void)
+{
+ return g_object_new (MODEST_TYPE_SERVER_ACCOUNT_SETTINGS, NULL);
+}
+
+const gchar*
+modest_server_account_settings_get_hostname (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->hostname;
+}
+
+void
+modest_server_account_settings_set_hostname (ModestServerAccountSettings *settings,
+ const gchar *hostname)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->hostname);
+ priv->hostname = g_strdup (hostname);
+}
+
+const gchar*
+modest_server_account_settings_get_uri (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->uri;
+}
+
+void
+modest_server_account_settings_set_uri (ModestServerAccountSettings *settings,
+ const gchar *uri)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->uri);
+ priv->uri = g_strdup (uri);
+
+ /* we set the protocol to a NULL equivalent value. We should use uri in case
+ * protocol has this value. */
+ priv->protocol = MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+}
+
+const gchar*
+modest_server_account_settings_get_username (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->username;
+}
+
+void
+modest_server_account_settings_set_username (ModestServerAccountSettings *settings,
+ const gchar *username)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->username);
+ priv->username = g_strdup (username);
+}
+
+const gchar*
+modest_server_account_settings_get_password (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->password;
+}
+
+void
+modest_server_account_settings_set_password (ModestServerAccountSettings *settings,
+ const gchar *password)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->password);
+ priv->password = g_strdup (password);
+}
+
+const gchar*
+modest_server_account_settings_get_account_name (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), NULL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->account_name;
+}
+
+void
+modest_server_account_settings_set_account_name (ModestServerAccountSettings *settings,
+ const gchar *account_name)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ /* be careful. This method should only be used internally in #ModestAccountMgr and
+ * #ModestAccountSettings. */
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ g_free (priv->account_name);
+ priv->account_name = g_strdup (account_name);
+}
+
+ModestTransportStoreProtocol
+modest_server_account_settings_get_protocol (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->protocol;
+}
+
+void
+modest_server_account_settings_set_protocol (ModestServerAccountSettings *settings,
+ ModestTransportStoreProtocol protocol)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->protocol = protocol;
+
+ /* we also set the uri to NULL, as setting a protocol implies disabling uri setting type */
+ g_free (priv->uri);
+ priv->uri = NULL;
+}
+
+guint
+modest_server_account_settings_get_port (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), 0);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->port;
+}
+
+void
+modest_server_account_settings_set_port (ModestServerAccountSettings *settings,
+ guint port)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->port = port;
+}
+
+ModestConnectionProtocol
+modest_server_account_settings_get_security (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_CONNECTION_NORMAL);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->security;
+}
+
+void
+modest_server_account_settings_set_security (ModestServerAccountSettings *settings,
+ ModestConnectionProtocol security)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->security = security;
+}
+
+ModestAuthProtocol
+modest_server_account_settings_get_auth_protocol (ModestServerAccountSettings *settings)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings), MODEST_PROTOCOL_AUTH_NONE);
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ return priv->auth_protocol;
+}
+
+void
+modest_server_account_settings_set_auth_protocol (ModestServerAccountSettings *settings,
+ ModestAuthProtocol auth_protocol)
+{
+ ModestServerAccountSettingsPrivate *priv;
+
+ g_return_if_fail (MODEST_IS_SERVER_ACCOUNT_SETTINGS (settings));
+
+ priv = MODEST_SERVER_ACCOUNT_SETTINGS_GET_PRIVATE (settings);
+ priv->auth_protocol = auth_protocol;
+}
+
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/* modest-server-account-settings.h */
+
+#ifndef __MODEST_SERVER_ACCOUNT_SETTINGS_H__
+#define __MODEST_SERVER_ACCOUNT_SETTINGS_H__
+
+#include <glib-object.h>
+#include <modest-defs.h>
+#include <modest-protocol-info.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_SERVER_ACCOUNT_SETTINGS (modest_server_account_settings_get_type())
+#define MODEST_SERVER_ACCOUNT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_SERVER_ACCOUNT_SETTINGS,ModestServerAccountSettings))
+#define MODEST_SERVER_ACCOUNT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_SERVER_ACCOUNT_SETTINGS,ModestServerAccountSettingsClass))
+#define MODEST_IS_SERVER_ACCOUNT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_SERVER_ACCOUNT_SETTINGS))
+#define MODEST_IS_SERVER_ACCOUNT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_SERVER_ACCOUNT_SETTINGS))
+#define MODEST_SERVER_ACCOUNT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_SERVER_ACCOUNT_SETTINGS,ModestServerAccountSettingsClass))
+
+typedef struct _ModestServerAccountSettings ModestServerAccountSettings;
+typedef struct _ModestServerAccountSettingsClass ModestServerAccountSettingsClass;
+
+struct _ModestServerAccountSettings {
+ GObject parent;
+};
+
+struct _ModestServerAccountSettingsClass {
+ GObjectClass parent_class;
+};
+
+
+/**
+ * modest_server_account_settings_get_type:
+ *
+ * Returns: GType of the account store
+ */
+GType modest_server_account_settings_get_type (void) G_GNUC_CONST;
+
+/**
+ * modest_server_account_settings_new:
+ *
+ * creates a new instance of #ModestServerAccountSettings
+ *
+ * Returns: a #ModestServerAccountSettings
+ */
+ModestServerAccountSettings* modest_server_account_settings_new (void);
+
+/**
+ * modest_server_account_settings_get_hostname:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the server hostname.
+ *
+ * Returns: a string
+ */
+const gchar* modest_server_account_settings_get_hostname (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_hostname:
+ * @settings: a #ModestServerAccountSettings
+ * @hostname: a string.
+ *
+ * set @hostname as the server hostname.
+ */
+void modest_server_account_settings_set_hostname (ModestServerAccountSettings *settings,
+ const gchar *hostname);
+
+/**
+ * modest_server_account_settings_get_protocol:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the server protocol.
+ *
+ * Returns: a #ModestTransportStoreProtocol
+ */
+ModestTransportStoreProtocol modest_server_account_settings_get_protocol (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_protocol:
+ * @settings: a #ModestServerAccountSettings
+ * @protocol: a #ModestTransportStoreProtocol.
+ *
+ * set @server_type.
+ */
+void modest_server_account_settings_set_protocol (ModestServerAccountSettings *settings,
+ ModestTransportStoreProtocol protocol);
+
+
+/**
+ * modest_server_account_settings_get_uri:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the uri, if any. If this is set, then all the other fields are invalid. It's only valid if protocol is %NULL.
+ *
+ * Returns: a string
+ */
+const gchar *modest_server_account_settings_get_uri (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_uri:
+ * @settings: a #ModestServerAccountSettings
+ * @uri: a string
+ *
+ * set @uri. When you set an @uri, then the protocol is set to %NULL. This is used for setting maildir or mbox
+ * accounts.
+ */
+void modest_server_account_settings_set_uri (ModestServerAccountSettings *settings,
+ const gchar *uri);
+
+/**
+ * modest_server_account_settings_get_port:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the server port.
+ *
+ * Returns: a #guint
+ */
+guint modest_server_account_settings_get_port (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_port:
+ * @settings: a #ModestServerAccountSettings
+ * @port: a #guint.
+ *
+ * set @port.
+ */
+void modest_server_account_settings_set_port (ModestServerAccountSettings *settings,
+ guint port);
+
+/**
+ * modest_server_account_settings_get_username:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the username.
+ *
+ * Returns: a string
+ */
+const gchar *modest_server_account_settings_get_username (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_username:
+ * @settings: a #ModestServerAccountSettings
+ * @username: a string
+ *
+ * set @username.
+ */
+void modest_server_account_settings_set_username (ModestServerAccountSettings *settings,
+ const gchar *username);
+
+/**
+ * modest_server_account_settings_get_password:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the password.
+ *
+ * Returns: a string
+ */
+const gchar *modest_server_account_settings_get_password (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_password:
+ * @settings: a #ModestServerAccountSettings
+ * @password: a string
+ *
+ * set @password.
+ */
+void modest_server_account_settings_set_password (ModestServerAccountSettings *settings,
+ const gchar *password);
+
+
+/**
+ * modest_server_account_settings_get_security:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the secure connection type, if any.
+ *
+ * Returns: a #ModestConnectionProtocol
+ */
+ModestConnectionProtocol modest_server_account_settings_get_security (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_security:
+ * @settings: a #ModestServerAccountSettings
+ * @security: a #ModestConnectionProtocol
+ *
+ * set the current security connection protocol to @security.
+ */
+void modest_server_account_settings_set_security (ModestServerAccountSettings *settings,
+ ModestConnectionProtocol security);
+
+
+/**
+ * modest_server_account_settings_get_auth_protocol:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the authentication protocol
+ *
+ * Returns: a #ModestAuthProtocol
+ */
+ModestAuthProtocol modest_server_account_settings_get_auth_protocol (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_auth_protocol:
+ * @settings: a #ModestServerAccountSettings
+ * @auth_protocol: a #ModestAuthProtocol
+ *
+ * set the current authentication protocol to @auth_protocol.
+ */
+void modest_server_account_settings_set_auth_protocol (ModestServerAccountSettings *settings,
+ ModestAuthProtocol auth_protocol);
+
+/**
+ * modest_server_account_settings_get_account_name:
+ * @settings: a #ModestServerAccountSettings
+ *
+ * get the #ModestAccountMgr account name for these settings, or
+ * %NULL if it's not in the manager.
+ *
+ * Returns: a string, or %NULL
+ */
+const gchar *modest_server_account_settings_get_account_name (ModestServerAccountSettings *settings);
+
+/**
+ * modest_server_account_settings_set_account_name:
+ * @settings: a #ModestServerAccountSettings
+ * @account_name: a string
+ *
+ * sets the account name that will be used to store the account settings. This should
+ * only be called from #ModestAccountMgr and #ModestAccountSettings.
+ */
+void modest_server_account_settings_set_account_name (ModestServerAccountSettings *settings,
+ const gchar *account_name);
+
+
+G_END_DECLS
+
+#endif /* __MODEST_SERVER_ACCOUNT_SETTINGS_H__ */
gboolean created_dialog = FALSE;
if (!found || !dialog) {
+ ModestAccountSettings *settings;
dialog = modest_account_settings_dialog_new ();
- modest_account_settings_dialog_set_account_name (dialog, modest_account_name);
+ settings = modest_account_mgr_load_account_settings (priv->account_mgr, modest_account_name);
+ modest_account_settings_dialog_set_account (dialog, settings);
+ g_object_unref (settings);
modest_account_settings_dialog_switch_to_user_info (dialog);
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog));
}
tny_iterator_next (iter);
}
-
+
cleanup:
if (folders)
g_object_unref (folders);
/**
* create_tny_account:
- * @account_mgr: a valid account mgr instance
* @session: A valid TnySessionCamel instance.
* @account_data: the server account for which to create a corresponding tny account
*
* Returns: a new TnyAccount or NULL in case of error.
*/
static TnyAccount*
-create_tny_account (ModestAccountMgr *account_mgr,
- TnySessionCamel *session,
- ModestServerAccountData *account_data)
+create_tny_account (TnySessionCamel *session,
+ ModestServerAccountSettings *server_settings)
{
TnyAccount *tny_account = NULL;
+ ModestTransportStoreProtocol protocol;
const gchar* proto_name;
- g_return_val_if_fail (account_mgr, NULL);
g_return_val_if_fail (session, NULL);
- g_return_val_if_fail (account_data, NULL);
- g_return_val_if_fail (account_data->proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN,
- NULL);
+ g_return_val_if_fail (server_settings, NULL);
+ protocol = modest_server_account_settings_get_protocol (server_settings);
+ g_return_val_if_fail (protocol != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
- switch (account_data->proto) {
+ switch (protocol) {
case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
case MODEST_PROTOCOL_TRANSPORT_SMTP:
tny_account = TNY_ACCOUNT (modest_transport_account_decorator_new ()); break;
if (!tny_account) {
g_printerr ("modest: %s: could not create tny account for '%s'\n",
- __FUNCTION__, account_data->account_name);
+ __FUNCTION__, modest_server_account_settings_get_account_name (server_settings));
return NULL;
}
- tny_account_set_id (tny_account, account_data->account_name);
+ tny_account_set_id (tny_account, modest_server_account_settings_get_account_name (server_settings));
/* This must be set quite early, or other set() functions will fail. */
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session);
/* Proto */
- proto_name = modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
+ proto_name = modest_protocol_info_get_transport_store_protocol_name(protocol);
tny_account_set_proto (tny_account, proto_name);
return tny_account;
* Returns: a new TnyAccount or NULL in case of error.
*/
static gboolean
-update_tny_account (TnyAccount *tny_account, ModestAccountMgr *account_mgr,
- ModestServerAccountData *account_data)
+update_tny_account (TnyAccount *tny_account,
+ ModestServerAccountSettings *server_settings)
{
- g_return_val_if_fail (account_mgr, FALSE);
- g_return_val_if_fail (account_data, FALSE);
- g_return_val_if_fail (account_data->account_name, FALSE);
+ const gchar *account_name;
+ const gchar *uri;
+ g_return_val_if_fail (server_settings, FALSE);
+ account_name = modest_server_account_settings_get_account_name (server_settings);
+ g_return_val_if_fail (account_name, FALSE);
g_return_val_if_fail (tny_account, FALSE);
- tny_account_set_id (tny_account, account_data->account_name);
+ tny_account_set_id (tny_account, account_name);
/* mbox and maildir accounts use a URI instead of the rest:
* Note that this is not where we create the special local folders account.
* We do that in modest_tny_account_new_for_local_folders() instead. */
- if (account_data->uri)
- tny_account_set_url_string (TNY_ACCOUNT(tny_account), account_data->uri);
+ uri = modest_server_account_settings_get_uri (server_settings);
+ if (uri)
+ tny_account_set_url_string (TNY_ACCOUNT(tny_account), uri);
else {
/* Set camel-specific options: */
/* Enable secure connection settings: */
const gchar* option_security = NULL;
const gchar* auth_mech_name = NULL;
-
-
- switch (account_data->security) {
+ ModestTransportStoreProtocol protocol;
+ ModestConnectionProtocol security;
+ ModestAuthProtocol auth_protocol;
+ const gchar *username;
+ const gchar *hostname;
+ guint port;
+
+ protocol = modest_server_account_settings_get_protocol (server_settings);
+ security = modest_server_account_settings_get_security (server_settings);
+ auth_protocol = modest_server_account_settings_get_auth_protocol (server_settings);
+
+ switch (security) {
case MODEST_PROTOCOL_CONNECTION_NORMAL:
option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER;
break;
option_security);
/* Secure authentication: */
- switch (account_data->secure_auth) {
+ switch (auth_protocol) {
case MODEST_PROTOCOL_AUTH_NONE:
/* IMAP and POP need at least a password,
* which camel uses if we specify NULL.
* This setting should never happen anyway. */
- if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP ||
- account_data->proto == MODEST_PROTOCOL_STORE_POP)
+ if (protocol == MODEST_PROTOCOL_STORE_IMAP ||
+ protocol == MODEST_PROTOCOL_STORE_POP)
auth_mech_name = NULL;
- else if (account_data->proto == MODEST_PROTOCOL_TRANSPORT_SMTP)
+ else if (protocol == MODEST_PROTOCOL_TRANSPORT_SMTP)
auth_mech_name = MODEST_ACCOUNT_AUTH_ANONYMOUS;
else
auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN;
/* Camel use a password for IMAP or POP if we specify NULL,
* For IMAP, at least it will report an error if we use "Password", "Login" or "Plain".
* (POP is know to report an error for Login too. Probably Password and Plain too.) */
- if (account_data->proto == MODEST_PROTOCOL_STORE_IMAP)
+ if (protocol == MODEST_PROTOCOL_STORE_IMAP)
auth_mech_name = NULL;
- else if (account_data->proto == MODEST_PROTOCOL_STORE_POP)
+ else if (protocol == MODEST_PROTOCOL_STORE_POP)
auth_mech_name = NULL;
else
auth_mech_name = MODEST_ACCOUNT_AUTH_PASSWORD;
default:
g_warning ("%s: Unhandled secure authentication setting %d for "
- "account_name=%s (%s)", __FUNCTION__, account_data->secure_auth,
- account_data->account_name, account_data->hostname);
+ "account_name=%s (%s)", __FUNCTION__, auth_protocol,
+ account_name, modest_server_account_settings_get_hostname (server_settings));
break;
}
if(auth_mech_name)
tny_account_set_secure_auth_mech (tny_account, auth_mech_name);
- if (modest_protocol_info_protocol_is_store(account_data->proto) &&
- (account_data->proto == MODEST_PROTOCOL_STORE_IMAP) ) {
+ if (modest_protocol_info_protocol_is_store(protocol) &&
+ (protocol == MODEST_PROTOCOL_STORE_IMAP) ) {
/* Other connection options, needed for IMAP. */
tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account),
MODEST_ACCOUNT_OPTION_USE_LSUB);
MODEST_ACCOUNT_OPTION_CHECK_ALL);
}
- if (account_data->username && strlen(account_data->username) > 0)
- tny_account_set_user (tny_account, account_data->username);
- if (account_data->hostname)
- tny_account_set_hostname (tny_account, account_data->hostname);
+ username = modest_server_account_settings_get_username (server_settings);
+ if (username && strlen (username) > 0)
+ tny_account_set_user (tny_account, username);
+ hostname = modest_server_account_settings_get_hostname (server_settings);
+ if (hostname)
+ tny_account_set_hostname (tny_account, hostname);
/* Set the port: */
- if (account_data->port)
- tny_account_set_port (tny_account, account_data->port);
+ port = modest_server_account_settings_get_port (server_settings);
+ if (port)
+ tny_account_set_port (tny_account, port);
}
MODEST_DEBUG_BLOCK (
TnyGetPassFunc get_pass_func,
TnyForgetPassFunc forget_pass_func)
{
- ModestServerAccountData *account_data;
+ ModestServerAccountSettings *server_settings;
TnyAccount *tny_account;
g_return_val_if_fail (session, NULL);
g_return_val_if_fail (server_account_name, NULL);
- account_data = modest_account_mgr_get_server_account_data (account_mgr,
- server_account_name);
- if (!account_data)
+
+ server_settings = modest_account_mgr_load_server_settings (account_mgr, server_account_name);
+ if (!server_settings)
return NULL;
tny_account = TNY_ACCOUNT (tny_camel_transport_account_new ());
if (tny_account) {
const gchar* proto_name = NULL;
- tny_account_set_id (tny_account, account_data->account_name);
+ tny_account_set_id (tny_account, server_account_name);
tny_camel_account_set_session (TNY_CAMEL_ACCOUNT (tny_account), session);
- proto_name = modest_protocol_info_get_transport_store_protocol_name(account_data->proto);
+ proto_name = modest_protocol_info_get_transport_store_protocol_name
+ (modest_server_account_settings_get_protocol (server_settings));
tny_account_set_proto (tny_account, proto_name);
modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, server_account_name);
}
if (!tny_account)
g_warning ("%s: failed to create tny_account", __FUNCTION__);
- else if (!update_tny_account (tny_account, account_mgr, account_data))
+ else if (!update_tny_account (tny_account, server_settings))
g_warning ("%s: failed to initialize tny_account", __FUNCTION__);
else {
tny_account_set_forget_pass_func (tny_account,
get_pass_func ? get_pass_func: get_pass_dummy);
}
- modest_account_mgr_free_server_account_data (account_mgr, account_data);
+ g_object_unref (server_settings);
return tny_account;
}
gboolean
modest_tny_account_update_from_account (TnyAccount *tny_account)
{
- ModestAccountData *account_data = NULL;
- ModestServerAccountData *server_data = NULL;
+ ModestAccountSettings *settings = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
TnyConnectionStatus conn_status;
ModestAccountMgr *account_mgr;
const gchar *account_name;
TnyAccountType type;
+ const gchar *display_name;
g_return_val_if_fail (tny_account, 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) {
+ settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
+ if (!settings) {
g_printerr ("modest: %s: cannot get account data for account %s\n",
__FUNCTION__, account_name);
return FALSE;
}
- if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
- server_data = account_data->store_account;
- else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
- server_data = account_data->transport_account;
- if (!server_data) {
+ display_name = modest_account_settings_get_display_name (settings);
+
+ if (type == TNY_ACCOUNT_TYPE_STORE)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else if (type == TNY_ACCOUNT_TYPE_TRANSPORT)
+ server_settings = modest_account_settings_get_transport_settings (settings);
+
+ if (modest_server_account_settings_get_account_name (server_settings) == NULL) {
g_printerr ("modest: no %s account defined for '%s'\n",
type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
- account_data->display_name);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ display_name);
+ g_object_unref (server_settings);
+ g_object_unref (settings);
return FALSE;
}
- update_tny_account (tny_account, account_mgr, server_data);
+ update_tny_account (tny_account, server_settings);
/* This name is what shows up in the folder view -- so for some POP/IMAP/... server
* account, we set its name to the account of which it is part. */
-
- if (account_data->display_name)
- tny_account_set_name (tny_account, account_data->display_name);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ if (display_name)
+ tny_account_set_name (tny_account, display_name);
+
+ g_object_unref (server_settings);
+ g_object_unref (settings);
/* If the account was online, reconnect to apply the changes */
conn_status = tny_account_get_connection_status (tny_account);
TnyForgetPassFunc forget_pass_func)
{
TnyAccount *tny_account = NULL;
- ModestAccountData *account_data = NULL;
- ModestServerAccountData *server_data = NULL;
+ ModestAccountSettings *settings = NULL;
+ ModestServerAccountSettings *server_settings = NULL;
+ const gchar *display_name;
g_return_val_if_fail (account_mgr, NULL);
g_return_val_if_fail (account_name, NULL);
g_return_val_if_fail (type == TNY_ACCOUNT_TYPE_STORE || type == TNY_ACCOUNT_TYPE_TRANSPORT,
NULL);
- account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
- if (!account_data) {
+ settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
+ if (!settings) {
g_printerr ("modest: %s: cannot get account data for account %s\n",
__FUNCTION__, account_name);
return NULL;
}
+ display_name = modest_account_settings_get_display_name (settings);
+
+ if (type == TNY_ACCOUNT_TYPE_STORE)
+ server_settings = modest_account_settings_get_store_settings (settings);
+ else if (type == TNY_ACCOUNT_TYPE_TRANSPORT)
+ server_settings = modest_account_settings_get_transport_settings (settings);
- if (type == TNY_ACCOUNT_TYPE_STORE && account_data->store_account)
- server_data = account_data->store_account;
- else if (type == TNY_ACCOUNT_TYPE_TRANSPORT && account_data->transport_account)
- server_data = account_data->transport_account;
- if (!server_data) {
+ if (modest_server_account_settings_get_account_name (server_settings) == NULL) {
g_printerr ("modest: no %s account defined for '%s'\n",
type == TNY_ACCOUNT_TYPE_STORE ? "store" : "transport",
- account_data->display_name);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ display_name);
+ g_object_unref (server_settings);
+ g_object_unref (settings);
return NULL;
}
- tny_account = create_tny_account (account_mgr,session, server_data);
+ tny_account = create_tny_account (session, server_settings);
if (!tny_account) {
g_printerr ("modest: failed to create tny account for %s (%s)\n",
- account_data->account_name, server_data->account_name);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ account_name,
+ modest_server_account_settings_get_account_name (server_settings));
+ g_object_unref (server_settings);
+ g_object_unref (settings);
return NULL;
} else
- update_tny_account (tny_account, account_mgr, server_data);
+ update_tny_account (tny_account, server_settings);
/* This name is what shows up in the folder view -- so for some POP/IMAP/... server
* account, we set its name to the account of which it is part. */
- if (account_data->display_name)
- tny_account_set_name (tny_account, account_data->display_name);
+ if (display_name)
+ tny_account_set_name (tny_account, display_name);
tny_account_set_forget_pass_func (tny_account,
forget_pass_func ? forget_pass_func : forget_pass_dummy);
modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account,
account_name);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ g_object_unref (server_settings);
+ g_object_unref (settings);
return tny_account;
}
#ifdef MODEST_PLATFORM_MAEMO
#include "maemo/modest-osso-state-saving.h"
-#include "maemo/modest-maemo-utils.h"
#include "maemo/modest-hildon-includes.h"
#include "maemo/modest-connection-specific-smtp-window.h"
#endif /* MODEST_PLATFORM_MAEMO */
+#include <modest-utils.h>
#include "widgets/modest-ui-constants.h"
#include <widgets/modest-main-window.h>
modest_ui_actions_run_account_setup_wizard (ModestWindow *win)
{
gboolean result = FALSE;
-#ifdef MODEST_PLATFORM_MAEMO
GtkWindow *dialog, *wizard;
gint dialog_response;
/* Show the easy-setup wizard: */
dialog = modest_window_mgr_get_modal (modest_runtime_get_window_mgr());
- if (dialog && MODEST_IS_EASYSETUP_WIZARD_DIALOG(dialog)) {
+ if (dialog) {
/* old wizard is active already;
*/
gtk_window_present (GTK_WINDOW(dialog));
/* there is no such wizard yet */
- wizard = GTK_WINDOW (modest_easysetup_wizard_dialog_new ());
+ wizard = GTK_WINDOW (modest_platform_get_account_settings_wizard ());
modest_window_mgr_set_modal (modest_runtime_get_window_mgr(), wizard);
/* always present a main window in the background
/* Check whether an account was created: */
result = modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
}
-#endif
return result;
}
ModestWindow *win)
{
/* This is currently only implemented for Maemo */
-#ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) {
if (!modest_ui_actions_run_account_setup_wizard (win))
g_debug ("%s: wizard was already running", __FUNCTION__);
/* The accounts dialog must be modal */
modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), account_win);
- modest_maemo_show_dialog_and_forget (GTK_WINDOW (win), GTK_DIALOG (account_win));
+ modest_utils_show_dialog_and_forget (GTK_WINDOW (win), GTK_DIALOG (account_win));
}
-#else
- GtkWidget *dialog, *label;
-
- /* Create the widgets */
-
- dialog = gtk_dialog_new_with_buttons ("Message",
- GTK_WINDOW(win),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_OK,
- GTK_RESPONSE_NONE,
- NULL);
- label = gtk_label_new ("Hello World!");
-
- /* Ensure that the dialog box is destroyed when the user responds. */
-
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
-
- /* Add the label, and show everything we've added to the dialog. */
-
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
- label);
- gtk_widget_show_all (dialog);
-#endif /* MODEST_PLATFORM_MAEMO */
}
#ifdef MODEST_PLATFORM_MAEMO
} else {
const gchar *active_account_name = NULL;
ModestAccountMgr *mgr = NULL;
- ModestAccountData *acc_data = NULL;
+ ModestAccountSettings *settings = NULL;
+ ModestServerAccountSettings *store_settings = NULL;
modest_folder_view_set_style (MODEST_FOLDER_VIEW (*tree_view),
MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
active_account_name = modest_window_get_active_account (MODEST_WINDOW (win));
mgr = modest_runtime_get_account_mgr ();
- acc_data = modest_account_mgr_get_account_data (mgr, active_account_name);
+ settings = modest_account_mgr_load_account_settings (mgr, active_account_name);
+
+ if (settings) {
+ const gchar *store_account_name;
+ store_settings = modest_account_settings_get_store_settings (settings);
+ store_account_name = modest_server_account_settings_get_account_name (store_settings);
- /* Set the new visible & active account */
- if (acc_data && acc_data->store_account) {
modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (*tree_view),
- acc_data->store_account->account_name);
- modest_account_mgr_free_account_data (mgr, acc_data);
+ store_account_name);
+ g_object_unref (store_settings);
+ g_object_unref (settings);
}
}
--- /dev/null
+/* Copyright (c) 2007, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <errno.h>
+#include <string.h> /* for strlen */
+#include <modest-runtime.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <tny-fs-stream.h>
+#include <tny-camel-account.h>
+#include <tny-status.h>
+#include <tny-camel-transport-account.h>
+#include <tny-camel-imap-store-account.h>
+#include <tny-camel-pop-store-account.h>
+
+#include <modest-defs.h>
+#include "modest-utils.h"
+#include "modest-platform.h"
+
+GQuark
+modest_utils_get_supported_secure_authentication_error_quark (void)
+{
+ return g_quark_from_static_string("modest-utils-get-supported-secure-authentication-error-quark");
+}
+
+gboolean
+modest_utils_folder_writable (const gchar *filename)
+{
+ g_return_val_if_fail (filename, FALSE);
+
+ if (!filename)
+ return FALSE;
+
+ if (g_strncasecmp (filename, "obex", 4) != 0) {
+ GnomeVFSFileInfo folder_info;
+ gchar *folder;
+ folder = g_path_get_dirname (filename);
+ gnome_vfs_get_file_info (folder, &folder_info,
+ GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
+ g_free (folder);
+ if (!((folder_info.permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) ||
+ (folder_info.permissions & GNOME_VFS_PERM_USER_WRITE))) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+gboolean
+modest_utils_file_exists (const gchar *filename)
+{
+ GnomeVFSURI *uri = NULL;
+ gboolean result = FALSE;
+
+ uri = gnome_vfs_uri_new (filename);
+ if (uri) {
+ result = gnome_vfs_uri_exists (uri);
+ gnome_vfs_uri_unref (uri);
+ }
+ return result;
+}
+
+TnyFsStream *
+modest_utils_create_temp_stream (const gchar *orig_name, const gchar *hash_base, gchar **path)
+{
+ gint fd;
+ gchar *filepath = NULL;
+ gchar *tmpdir;
+ guint hash_number;
+
+ /* hmmm... maybe we need a modest_text_utils_validate_file_name? */
+ g_return_val_if_fail (orig_name || strlen(orig_name) == 0, NULL);
+ if (strlen(orig_name) > 200) {
+ g_warning ("%s: filename too long ('%s')",
+ __FUNCTION__, orig_name);
+ return NULL;
+ }
+
+ if (g_strstr_len (orig_name, strlen(orig_name), "/") != NULL) {
+ g_warning ("%s: filename contains '/' character(s) (%s)",
+ __FUNCTION__, orig_name);
+ return NULL;
+ }
+
+ /* make a random subdir under /tmp or /var/tmp */
+ if (hash_base != NULL) {
+ hash_number = g_str_hash (hash_base);
+ } else {
+ hash_number = (guint) random ();
+ }
+ tmpdir = g_strdup_printf ("%s/%u", g_get_tmp_dir (), hash_number);
+ if ((g_access (tmpdir, R_OK) == -1) && (g_mkdir (tmpdir, 0755) == -1)) {
+ g_warning ("%s: failed to create dir '%s': %s",
+ __FUNCTION__, tmpdir, g_strerror(errno));
+ g_free (tmpdir);
+ return NULL;
+ }
+
+ filepath = g_strconcat (tmpdir, "/", orig_name, NULL);
+ /* don't overwrite if it already exists, even if it is writable */
+ if (modest_utils_file_exists (filepath)) {
+ if (path!=NULL) {
+ *path = filepath;
+ } else {
+ g_free (filepath);
+ }
+ g_free (tmpdir);
+ return NULL;
+ } else {
+ /* try to write the file there */
+ fd = g_open (filepath, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ if (fd == -1) {
+ g_warning ("%s: failed to create '%s': %s",
+ __FUNCTION__, filepath, g_strerror(errno));
+ g_free (filepath);
+ g_free (tmpdir);
+ return NULL;
+ }
+ }
+
+ g_free (tmpdir);
+
+ if (path)
+ *path = filepath;
+
+ return TNY_FS_STREAM (tny_fs_stream_new (fd));
+}
+
+typedef struct
+{
+ gboolean cancel;
+ GList *result;
+ GtkWidget* dialog;
+ GtkWidget* progress;
+ GError* error;
+} ModestGetSupportedAuthInfo;
+
+static void on_camel_account_get_supported_secure_authentication_status (
+ GObject *self, TnyStatus *status, gpointer user_data)
+{
+ /*ModestGetSupportedAuthInfo* info = (ModestGetSupportedAuthInfo*) user_data;*/
+}
+
+static gboolean
+on_idle_secure_auth_finished (gpointer user_data)
+{
+ ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
+ /* Operation has finished, close the dialog. Control continues after
+ * gtk_dialog_run in modest_utils_get_supported_secure_authentication_methods() */
+
+ /* This is a GDK lock because we are an idle callback and
+ * the code below is or does Gtk+ code */
+
+ gdk_threads_enter(); /* CHECKED */
+ gtk_dialog_response (GTK_DIALOG (info->dialog), GTK_RESPONSE_ACCEPT);
+ gdk_threads_leave(); /* CHECKED */
+
+ return FALSE;
+}
+
+static void
+on_camel_account_get_supported_secure_authentication (
+ TnyCamelAccount *self, gboolean cancelled,
+ TnyList *auth_types, GError *err,
+ gpointer user_data)
+{
+ ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
+ g_return_if_fail (info);
+
+
+ /* Free everything if the actual action was canceled */
+ if (info->cancel)
+ {
+ /* The operation was canceled and the ownership of the info given to us
+ * so that we could still check the cancel flag. */
+ g_slice_free (ModestGetSupportedAuthInfo, info);
+ info = NULL;
+ }
+ else
+ {
+ if (err)
+ {
+ if (info->error) {
+ g_error_free (info->error);
+ info->error = NULL;
+ }
+
+ info->error = g_error_copy (err);
+ }
+
+ if (!auth_types) {
+ g_warning ("DEBUG: %s: auth_types is NULL.\n", __FUNCTION__);
+ }
+ else if (tny_list_get_length(auth_types) == 0) {
+ g_warning ("DEBUG: %s: auth_types is an empty TnyList.\n", __FUNCTION__);
+ } else
+ {
+ ModestPairList* pairs = modest_protocol_info_get_auth_protocol_pair_list ();
+
+ /* Get the enum value for the strings: */
+ GList *result = NULL;
+ TnyIterator* iter = tny_list_create_iterator(auth_types);
+ while (!tny_iterator_is_done(iter)) {
+ TnyPair *pair = TNY_PAIR(tny_iterator_get_current(iter));
+ const gchar *auth_name = NULL;
+ if (pair) {
+ auth_name = tny_pair_get_name(pair);
+ g_object_unref (pair);
+ pair = NULL;
+ }
+
+ printf("DEBUG: %s: auth_name=%s\n", __FUNCTION__, auth_name);
+
+ ModestAuthProtocol proto = modest_protocol_info_get_auth_protocol (auth_name);
+ if(proto != MODEST_PROTOCOL_AUTH_NONE)
+ result = g_list_prepend(result, GINT_TO_POINTER(proto));
+
+ tny_iterator_next(iter);
+ }
+ g_object_unref (iter);
+
+ modest_pair_list_free (pairs);
+
+ info->result = result;
+ }
+
+ printf("DEBUG: finished\n");
+
+ /* Close the dialog in a main thread */
+ g_idle_add(on_idle_secure_auth_finished, info);
+ }
+}
+
+static void
+on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data)
+{
+ if(response == GTK_RESPONSE_REJECT || response == GTK_RESPONSE_DELETE_EVENT)
+ {
+ ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data;
+ g_return_if_fail(info);
+ /* This gives the ownership of the info to the worker thread. */
+ info->result = NULL;
+ info->cancel = TRUE;
+ }
+}
+
+GList*
+modest_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
+ const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error)
+{
+ g_return_val_if_fail (proto != MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN, NULL);
+
+ /* We need a connection to get the capabilities; */
+ if (!modest_platform_connect_and_wait (GTK_WINDOW (parent_window), NULL))
+ return NULL;
+
+ /*
+ result = g_list_append (result, GINT_TO_POINTER (MODEST_PROTOCOL_AUTH_CRAMMD5));
+ */
+
+ /* Create a TnyCamelAccount so we can use
+ * tny_camel_account_get_supported_secure_authentication(): */
+ TnyAccount * tny_account = NULL;
+ switch (proto) {
+ case MODEST_PROTOCOL_TRANSPORT_SENDMAIL:
+ case MODEST_PROTOCOL_TRANSPORT_SMTP:
+ tny_account = TNY_ACCOUNT(tny_camel_transport_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_POP:
+ tny_account = TNY_ACCOUNT(tny_camel_pop_store_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_IMAP:
+ tny_account = TNY_ACCOUNT(tny_camel_imap_store_account_new ()); break;
+ case MODEST_PROTOCOL_STORE_MAILDIR:
+ case MODEST_PROTOCOL_STORE_MBOX:
+ tny_account = TNY_ACCOUNT(tny_camel_store_account_new()); break;
+ default:
+ tny_account = NULL;
+ }
+
+
+ if (!tny_account) {
+ g_printerr ("%s could not create tny account.", __FUNCTION__);
+ return NULL;
+ }
+
+ /* Set proto, so that the prepare_func() vfunc will work when we call
+ * set_session(): */
+ /* TODO: Why isn't this done in account_new()? */
+ tny_account_set_proto (tny_account,
+ modest_protocol_info_get_transport_store_protocol_name(proto));
+
+ tny_account_set_hostname (tny_account, hostname);
+ /* Required for POP, at least */
+ tny_account_set_user (tny_account, username);
+
+ if(port > 0)
+ tny_account_set_port (tny_account, port);
+
+ /* Set the session for the account, so we can use it: */
+ ModestTnyAccountStore *account_store = modest_runtime_get_account_store ();
+ TnySessionCamel *session =
+ modest_tny_account_store_get_session (TNY_ACCOUNT_STORE (account_store));
+ g_return_val_if_fail (session, NULL);
+ tny_camel_account_set_session (TNY_CAMEL_ACCOUNT(tny_account), session);
+
+
+ /* Ask camel to ask the server, asynchronously: */
+ ModestGetSupportedAuthInfo *info = g_slice_new (ModestGetSupportedAuthInfo);
+ info->result = NULL;
+ info->cancel = FALSE;
+ info->error = NULL;
+ info->progress = gtk_progress_bar_new();
+ /* TODO: Need logical_ID for the title: */
+ info->dialog = gtk_dialog_new_with_buttons(_("Authentication"),
+ parent_window, GTK_DIALOG_MODAL,
+ _("mcen_bd_dialog_cancel"),
+ GTK_RESPONSE_REJECT,
+ NULL);
+ //gtk_window_set_default_size(GTK_WINDOW(info->dialog), 300, 100);
+
+ g_signal_connect(G_OBJECT(info->dialog), "response", G_CALLBACK(on_secure_auth_cancel), info);
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox),
+ gtk_label_new("Checking for supported authentication types..."));
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(info->dialog)->vbox), info->progress);
+ gtk_widget_show_all(info->dialog);
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR(info->progress));
+
+ printf ("DEBUG: %s: STARTING.\n", __FUNCTION__);
+ tny_camel_account_get_supported_secure_authentication (
+ TNY_CAMEL_ACCOUNT (tny_account),
+ on_camel_account_get_supported_secure_authentication,
+ on_camel_account_get_supported_secure_authentication_status,
+ info);
+
+ gtk_dialog_run (GTK_DIALOG (info->dialog));
+
+ gtk_widget_destroy(info->dialog);
+
+ GList *result = info->result;
+ if (!info->cancel)
+ {
+ if (info->error) {
+ gchar * debug_url_string = tny_account_get_url_string (tny_account);
+ g_warning ("DEBUG: %s:\n error: %s\n account url: %s", __FUNCTION__, info->error->message,
+ debug_url_string);
+ g_free (debug_url_string);
+
+ g_propagate_error(error, info->error);
+ info->error = NULL;
+ }
+
+ g_slice_free (ModestGetSupportedAuthInfo, info);
+ info = NULL;
+ }
+ else
+ {
+ // Tell the caller that the operation was canceled so it can
+ // make a difference
+ g_set_error(error,
+ modest_utils_get_supported_secure_authentication_error_quark(),
+ MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED,
+ "User has canceled query");
+ }
+
+ return result;
+}
+
+void
+modest_utils_show_dialog_and_forget (GtkWindow *parent_window,
+ GtkDialog *dialog)
+{
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window);
+
+ /* Destroy the dialog when it is closed: */
+ g_signal_connect_swapped (dialog,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+
+ gtk_widget_show (GTK_WIDGET (dialog));
+}
+
+void
+modest_utils_toggle_action_set_active_block_notify (GtkToggleAction *action, gboolean value)
+{
+ GSList *proxies = NULL;
+
+ g_return_if_fail (GTK_IS_TOGGLE_ACTION (action));
+
+ for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
+ proxies != NULL; proxies = g_slist_next (proxies)) {
+ GtkWidget *widget = (GtkWidget *) proxies->data;
+ gtk_action_block_activate_from (GTK_ACTION (action), widget);
+ }
+
+ gtk_toggle_action_set_active (action, value);
+
+ for (proxies = gtk_action_get_proxies (GTK_ACTION (action));
+ proxies != NULL; proxies = g_slist_next (proxies)) {
+ GtkWidget *widget = (GtkWidget *) proxies->data;
+ gtk_action_unblock_activate_from (GTK_ACTION (action), widget);
+ }
+
+}
+
--- /dev/null
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * 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
+ * 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,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef __MODEST_UTILS_H__
+#define __MODEST_UTILS_H__
+
+#include <gtk/gtk.h>
+#include <stdio.h> /* for FILE* */
+#include <modest-protocol-info.h>
+#include <tny-fs-stream.h>
+
+typedef enum {
+ MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED
+} ModestUtilsGetSupportedSecureAuthenticationError;
+
+GQuark modest_utils_get_supported_secure_authentication_error_quark (void);
+
+
+/**
+ * modest_utils_folder_writable:
+ * @filename: a string
+ *
+ * Checks if @filename is in a writable folder
+ *
+ * Returns: %TRUE if @filename is writable, %FALSE otherwise
+ */
+gboolean modest_utils_folder_writable (const gchar *filename);
+
+/**
+ * modest_utils_file_exists:
+ * @filename: a string
+ *
+ * Checks if @filename exists
+ *
+ * Returns: %TRUE if @filename currently exists, %FALSE otherwise
+ */
+gboolean modest_utils_file_exists (const gchar *filename);
+
+/**
+ * modest_utils_create_temp_stream:
+ * @orig_name: a string with the original name of the extension, or %NULL
+ * @hash_base: if %NULL, subdir will be random. If not, it will be a hash
+ * of this.
+ * @path: a string with the created file path.
+ *
+ * Creates a temporary fs stream, in a random subdir of /tmp or /var/tmp.
+ *
+ * Returns: a #TnyFsStream, or %NULL if operation failed. Note that it is
+ * possible that the file already exists but it is not writable. In that case,
+ * the function would return NULL and @path would contain its path.
+ */
+TnyFsStream *modest_utils_create_temp_stream (const gchar *orig_name, const gchar *hash_base, gchar **path);
+
+/**
+ * modest_utils_get_supported_secure_authentication_methods:
+ * @proto: the protocol
+ * @hostname: hostname of the mail server to check
+ * @port: mail server port
+ * @username: username of the account to check for
+ * @parent_window: a GtkWindow that can be used a parent for progress indication
+ *
+ * Get a list of supported authentication methods of the server
+ *
+ * Returns: GList* of the method names. This list needs to be freed using g_list_free.
+ *
+ */
+
+GList* modest_utils_get_supported_secure_authentication_methods (ModestTransportStoreProtocol proto,
+ const gchar* hostname, gint port, const gchar* username, GtkWindow *parent_window, GError** error);
+
+/** modest_show_information_note_in_main_context_and_forget:
+ * @parent_window: The window for which the note should be transient.
+ * @message: The text to show.
+ *
+ * This calls modest_maemo_show_information_note_and_forget() in an idle handler.
+ * This should be used when you are not sure that you are in the main context,
+ * because you should try to use GTK+ UI code only in the main context.
+ */
+void modest_utils_show_information_note_in_main_context_and_forget (GtkWindow *parent_window, const gchar* message);
+
+/** modest_show_dialog_and_forget:
+ * @parent_window: The window for which the note should be transient.
+ * @message: The dialog to show.
+ *
+ * Show the dialog and destroy it when it is closed, without
+ * blocking. Use this when you don't want to use gtk_dialog_run(), which might lead
+ * to hangs.
+ */
+void modest_utils_show_dialog_and_forget (GtkWindow *parent_window, GtkDialog *dialog);
+
+/**
+ * modest_toggle_action_set_active_block_notify:
+ * @action: a #GtkToggleAction
+ * @value: a #gboolean
+ *
+ * updates the toggle action active status, but blocking the notification of the changes.
+ */
+void modest_utils_toggle_action_set_active_block_notify (GtkToggleAction *action, gboolean value);
+
+#endif /*__MODEST_MAEMO_UTILS_H__*/
mgr = modest_runtime_get_account_mgr ();
default_acc = modest_account_mgr_get_default_account (mgr);
if (default_acc) {
- ModestAccountData *acc_data;
+ ModestAccountSettings *settings;
+ ModestServerAccountSettings *store_settings;
const gchar *server_acc_id;
- acc_data = modest_account_mgr_get_account_data (mgr, (const gchar*) default_acc);
- server_acc_id = (const gchar *) acc_data->store_account->account_name;
+ settings = modest_account_mgr_load_account_settings (mgr, (const gchar*) default_acc);
+ store_settings = modest_account_settings_get_store_settings (settings);
+ server_acc_id = modest_server_account_settings_get_account_name (store_settings);
modest_folder_view_set_account_id_of_visible_server_account (folder_view, server_acc_id);
-
+ g_object_unref (store_settings);
+ g_object_unref (settings);
g_free (default_acc);
}
return TRUE;
#include <gtk/gtktreeselection.h>
#include <gtk/gtkliststore.h>
#include <string.h> /* For strcmp(). */
+#include <modest-account-mgr-helpers.h>
/* 'private'/'protected' functions */
static void modest_account_view_class_init (ModestAccountViewClass *klass);
/* Get the string for the last updated time. Result must NOT be g_freed */
static const gchar*
-get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountData *account_data)
+get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountSettings *settings)
{
/* FIXME: let's assume that 'last update' applies to the store account... */
- const gchar* last_updated_string;
- time_t last_updated = account_data->store_account->last_updated;
- if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name)) {
+ const gchar *last_updated_string;
+ const gchar *store_account_name;
+ const gchar *account_name;
+ time_t last_updated;
+ ModestServerAccountSettings *server_settings;
+
+ server_settings = modest_account_settings_get_store_settings (settings);
+ store_account_name = modest_server_account_settings_get_account_name (server_settings);
+ last_updated = modest_account_mgr_get_last_updated (account_mgr, store_account_name);
+ g_object_unref (server_settings);
+ account_name = modest_account_settings_get_account_name (settings);
+ if (!modest_account_mgr_account_is_busy(account_mgr, account_name)) {
if (last_updated > 0)
last_updated_string = modest_text_utils_get_display_date(last_updated);
else
while (cursor) {
gchar *account_name;
- ModestAccountData *account_data;
+ ModestAccountSettings *settings;
+ ModestServerAccountSettings *store_settings;
account_name = (gchar*)cursor->data;
- account_data = modest_account_mgr_get_account_data (account_mgr, account_name);
- if (!account_data) {
+ settings = modest_account_mgr_load_account_settings (account_mgr, account_name);
+ if (!settings) {
g_printerr ("modest: failed to get account data for %s\n", account_name);
continue;
}
+ store_settings = modest_account_settings_get_store_settings (settings);
/* don't display accounts without stores */
- if (account_data->store_account) {
+ if (modest_server_account_settings_get_account_name (store_settings) != NULL) {
GtkTreeIter iter;
/* don't free */
- const gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
+ const gchar *last_updated_string = get_last_updated_string(account_mgr, settings);
- if (account_data->is_enabled) {
+ if (modest_account_settings_get_enabled (settings)) {
const gchar *proto_name;
- proto_name = modest_protocol_info_get_transport_store_protocol_name (account_data->store_account->proto);
+ proto_name = modest_protocol_info_get_transport_store_protocol_name
+ (modest_server_account_settings_get_protocol (store_settings));
gtk_list_store_insert_with_values (
model, &iter, 0,
MODEST_ACCOUNT_VIEW_NAME_COLUMN, account_name,
- MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, account_data->display_name,
- MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, account_data->is_enabled,
- MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, account_data->is_default,
+ MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN,
+ modest_account_settings_get_display_name (settings),
+ MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN,
+ modest_account_settings_get_enabled (settings),
+ MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN,
+ modest_account_settings_get_is_default (settings),
MODEST_ACCOUNT_VIEW_PROTO_COLUMN, proto_name,
MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
-1);
}
}
-
- modest_account_mgr_free_account_data (account_mgr, account_data);
+
+ g_object_unref (store_settings);
+ g_object_unref (settings);
cursor = cursor->next;
}
&cur_name, -1);
if (g_str_equal(cur_name, account_name)) {
- ModestAccountData* account_data =
- modest_account_mgr_get_account_data (account_mgr, account_name);
- if (!account_data) {
+ ModestAccountSettings* settings =
+ modest_account_mgr_load_account_settings (account_mgr, account_name);
+ if (!settings) {
g_free (cur_name);
return;
}
- const gchar* last_updated_string = get_last_updated_string(account_mgr, account_data);
+ const gchar* last_updated_string = get_last_updated_string(account_mgr, settings);
gtk_list_store_set(model, &iter,
MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
-1);
- modest_account_mgr_free_account_data (account_mgr, account_data);
+ g_object_unref (settings);
found = TRUE;
}
g_free (cur_name);
model = gtk_tree_view_get_model(header_view);
+ if (!model)
+ return FALSE;
+
sel = gtk_tree_view_get_selection(header_view);
if(!gtk_tree_selection_count_selected_rows(sel))
if (gtk_tree_model_get_iter_first(model, &tree_iter)) {
#include "modest-retrieve-combo-box.h"
#include "modest-defs.h" /* For the conf names. */
+#include "modest-account-settings.h"
#include <gtk/gtkliststore.h>
#include <gtk/gtkcelllayout.h>
#include <gtk/gtkcellrenderertext.h>
enum MODEL_COLS {
MODEL_COL_NAME = 0, /* a string */
- MODEL_COL_CONF_NAME = 1 /* a string */
+ MODEL_COL_RETRIEVE_TYPE = 1 /* a gint (a ModestAccountRetrieveType) */
};
void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestTransportStoreProtocol protocol);
* with a string for the name, and an ID for the retrieve.
* This must match our MODEL_COLS enum constants.
*/
- priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING));
+ priv->model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT));
/* Setup the combo box: */
GtkComboBox *combobox = GTK_COMBO_BOX (self);
GtkTreeIter iter;
gtk_list_store_append (liststore, &iter);
gtk_list_store_set (liststore, &iter,
- MODEL_COL_CONF_NAME, MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY,
+ MODEL_COL_RETRIEVE_TYPE, MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY,
MODEL_COL_NAME, _("mcen_fi_advsetup_retrievetype_headers"), -1);
/* We disable messages retrieval finally */
/* if (protocol == MODEST_PROTOCOL_STORE_IMAP) { */
/* gtk_list_store_append (liststore, &iter); */
/* gtk_list_store_set (liststore, &iter, */
-/* MODEL_COL_CONF_NAME, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES, */
+/* MODEL_COL_RETRIEVE_TYPE, MODEST_ACCOUNT_RETRIEVE_MESSAGES, */
/* MODEL_COL_NAME, _("mcen_fi_advsetup_retrievetype_messages"), -1); */
/* } */
gtk_list_store_append (liststore, &iter);
gtk_list_store_set (liststore, &iter,
- MODEL_COL_CONF_NAME, MODEST_ACCOUNT_RETRIEVE_VALUE_MESSAGES_AND_ATTACHMENTS,
+ MODEL_COL_RETRIEVE_TYPE, MODEST_ACCOUNT_RETRIEVE_MESSAGES_AND_ATTACHMENTS,
MODEL_COL_NAME, _("mcen_fi_advsetup_retrievetype_messages_attachments"), -1);
}
* Returns the selected retrieve.
* or NULL if no retrieve was selected. The result must be freed with g_free().
*/
-gchar*
+ModestAccountRetrieveType
modest_retrieve_combo_box_get_active_retrieve_conf (ModestRetrieveComboBox *combobox)
{
GtkTreeIter active;
if (found) {
ModestRetrieveComboBoxPrivate *priv = RETRIEVE_COMBO_BOX_GET_PRIVATE (combobox);
- gchar *retrieve = NULL;
- gtk_tree_model_get (priv->model, &active, MODEL_COL_CONF_NAME, &retrieve, -1);
- return retrieve;
+ ModestAccountRetrieveType retrieve_type = MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY;
+ gtk_tree_model_get (priv->model, &active, MODEL_COL_RETRIEVE_TYPE, &retrieve_type, -1);
+ return retrieve_type;
}
- return NULL; /* Failed. */
+ return MODEST_ACCOUNT_RETRIEVE_HEADERS_ONLY; /* Failed. */
}
/* This allows us to pass more than one piece of data to the signal handler,
typedef struct
{
ModestRetrieveComboBox* self;
- const gchar* conf_name;
+ ModestAccountRetrieveType retrieve_type;
gboolean found;
} ForEachData;
gboolean result = FALSE;
/* Select the item if it has the matching name: */
- gchar * conf_name = 0;
- gtk_tree_model_get (model, iter, MODEL_COL_CONF_NAME, &conf_name, -1);
- if(conf_name && state->conf_name && (strcmp(conf_name, state->conf_name) == 0)) {
+ ModestAccountRetrieveType retrieve_type;
+ gtk_tree_model_get (model, iter, MODEL_COL_RETRIEVE_TYPE, &retrieve_type, -1);
+ if (retrieve_type == state->retrieve_type) {
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (state->self), iter);
state->found = TRUE;
result = TRUE; /* Stop walking the tree. */
}
- g_free (conf_name);
return result; /* Whether we keep walking the tree. */
}
* or FALSE if no retrieve was selected.
*/
gboolean
-modest_retrieve_combo_box_set_active_retrieve_conf (ModestRetrieveComboBox *combobox, const gchar* retrieve)
+modest_retrieve_combo_box_set_active_retrieve_conf (ModestRetrieveComboBox *combobox,
+ ModestAccountRetrieveType retrieve_type)
{
ModestRetrieveComboBoxPrivate *priv = RETRIEVE_COMBO_BOX_GET_PRIVATE (combobox);
/* Create a state instance so we can send two items of data to the signal handler: */
ForEachData *state = g_new0 (ForEachData, 1);
state->self = combobox;
- state->conf_name = retrieve;
+ state->retrieve_type = retrieve_type;
state->found = FALSE;
/* Look at each item, and select the one with the correct ID: */
#include <gtk/gtkcombobox.h>
#include "modest-protocol-info.h"
+#include <modest-account-settings.h>
G_BEGIN_DECLS
void modest_retrieve_combo_box_fill (ModestRetrieveComboBox *combobox, ModestTransportStoreProtocol protocol);
-gchar* modest_retrieve_combo_box_get_active_retrieve_conf (ModestRetrieveComboBox *combobox);
+ModestAccountRetrieveType modest_retrieve_combo_box_get_active_retrieve_conf (ModestRetrieveComboBox *combobox);
-gboolean modest_retrieve_combo_box_set_active_retrieve_conf (ModestRetrieveComboBox *combobox, const gchar* retrieve);
+gboolean modest_retrieve_combo_box_set_active_retrieve_conf (ModestRetrieveComboBox *combobox,
+ ModestAccountRetrieveType retrieve_type);
G_END_DECLS