From: Murray Cumming Date: Thu, 5 Apr 2007 17:58:43 +0000 (+0000) Subject: 2007-04-05 Murray Cumming X-Git-Tag: git_migration_finished~3936 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=e7aa48ed52565f434a99141e9478980d23fa3a3a 2007-04-05 Murray Cumming * docs/reference/modest-design.sgml: Corrected spelling mistake. * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): Create the 2 server accounts and then create the account, using the names of the 2 server accounts. This seems to be how this should be used. If it is, then I will update the AccountMgr documentation to make that clearer. * src/modest-account-mgr.h: Corrected the modest_account_mgr_search_server_account() documentation. pmo-trunk-r1516 --- diff --git a/ChangeLog2 b/ChangeLog2 index 182b86d..85f3e78 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,5 +1,14 @@ 2007-04-05 Murray Cumming + * docs/reference/modest-design.sgml: Corrected spelling mistake. + * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): + Create the 2 server accounts and then create the account, using the names of the 2 server accounts. + This seems to be how this should be used. If it is, then I will update the AccountMgr documentation + to make that clearer. + * src/modest-account-mgr.h: Corrected the modest_account_mgr_search_server_account() documentation. + +2007-04-05 Murray Cumming + * src/maemo/modest-account-view-window.c: (modest_account_view_window_init), (modest_account_view_window_new): diff --git a/docs/reference/modest-design.sgml b/docs/reference/modest-design.sgml index ac7dff5..370656e 100644 --- a/docs/reference/modest-design.sgml +++ b/docs/reference/modest-design.sgml @@ -127,7 +127,7 @@ used by other accounts as well. - The reason two keep accounts and server accounts separately, is a bit of + The reason to keep accounts and server accounts separately, is a bit of flexibility. In mobile use-cases, quite often it's desirable to use a network-specific smtp-server. The chosen structure makes it easy to iterate over all smtp-servers and find the right one. @@ -172,4 +172,4 @@ recipient (RCPT TO:) is on the same network. - \ No newline at end of file + diff --git a/src/maemo/easysetup/modest-easysetup-wizard.c b/src/maemo/easysetup/modest-easysetup-wizard.c index 581fb45..e29dad5 100644 --- a/src/maemo/easysetup/modest-easysetup-wizard.c +++ b/src/maemo/easysetup/modest-easysetup-wizard.c @@ -1179,7 +1179,7 @@ create_account (ModestEasysetupWizardDialog *self) * but let's check again just in case: */ if (modest_account_mgr_account_exists (self->account_manager, account_name, FALSE)) - return FALSE; + return FALSE; /* username and password (for both incoming and outgoing): */ const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username)); @@ -1238,8 +1238,13 @@ create_account (ModestEasysetupWizardDialog *self) } + /* 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 = g_strconcat (account_name, "_store", NULL); gboolean created = modest_account_mgr_add_server_account (self->account_manager, - account_name, + store_name, servername_incoming, username, password, protocol_incoming, @@ -1313,8 +1318,10 @@ create_account (ModestEasysetupWizardDialog *self) } + /* Add a (outgoing) server account to be used by the account: */ + gchar *transport_name = g_strconcat (account_name, "_transport", NULL); /* What is this good for? */ created = modest_account_mgr_add_server_account (self->account_manager, - account_name, + transport_name, servername_outgoing, username, password, protocol_outgoing, @@ -1327,7 +1334,21 @@ create_account (ModestEasysetupWizardDialog *self) /* TODO: Provide a Logical ID for the text: */ show_error (GTK_WINDOW (self), _("An error occurred while creating the outgoing account.")); return FALSE; - } + } + + + /* Create the account, which will contain the two "server accounts": */ + created = modest_account_mgr_add_account (self->account_manager, account_name, + store_name, /* The name of our POP/IMAP server account. */ + transport_name /* The name of our SMTP server account. */); + g_free (store_name); + g_free (transport_name); + + if (!created) { + /* TODO: Provide a Logical ID for the text: */ + show_error (GTK_WINDOW (self), _("An error occurred while creating the account.")); + return FALSE; + } return FALSE; } diff --git a/src/modest-account-mgr.h b/src/modest-account-mgr.h index 22901fb..1e2e27b 100644 --- a/src/modest-account-mgr.h +++ b/src/modest-account-mgr.h @@ -178,14 +178,13 @@ GSList* modest_account_mgr_account_names (ModestAccountMgr *self); /** - * modest_account_mgr_server_account_names: + * modest_account_mgr_search_server_account: * @self: a ModestAccountMgr instance * @account_name: get only server accounts for @account_name, or NULL for any - * @type: get only server accounts from protocol type @type, or MODEST_PROTO_TYPE_ANY - * @proto: get only server account with protocol @proto, or NULL for any - * @only_enabled: get only enabled server accounts if TRUE + * @type: get only server accounts from protocol type @type, or MODEST_PROTOCOL_TYPE_UNKNOWN + * @proto: get only server account with protocol @proto, or MODEST_PROTOCOL_UNKNOWN for any * - * list all the server account names + * List all the server account names, optionally narrowing the result down to one account. * * Returns: a newly allocated list of server account names, or NULL in case of * error or if there are no server accounts. The caller must free the returned GSList diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 80be1c3..460c7b0 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -206,6 +206,15 @@ void modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win) { GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr()); + +#if 0 + GSList *account_names = modest_account_mgr_search_server_accounts ( + modest_runtime_get_account_mgr(), + NULL /* account_name, any */, + MODEST_PROTOCOL_TYPE_UNKNOWN /* type */, + MODEST_PROTOCOL_UNKNOWN /* proto */); +#endif + gboolean accounts_exist = account_names != NULL; g_slist_free (account_names); @@ -215,7 +224,7 @@ modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win) #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */ /* To test, while modest_account_mgr_account_names() is broken: accounts_exist = TRUE; */ if (!accounts_exist) { - printf ("debug: modest_account_mgr_account_names() returned NULL."); + printf ("debug: modest_account_mgr_account_names() returned NULL.\n"); /* If there are no accounts yet, just show the easy-setup wizard, as per the UI spec: */ ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new (); gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));