2007-04-05 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 11:32:45 +0000 (11:32 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Thu, 5 Apr 2007 11:32:45 +0000 (11:32 +0000)
* src/maemo/easysetup/modest-easysetup-wizard.c:
        (set_default_custom_servernames): Avoid a dereference of a destroyed widget.
        (create_account): Do a sanity check, showing that modest_account_mgr_account_names()
        returns NULL after modest_account_mgr_add_server_account() returned TRUE,
        which seems wrong.

        * src/maemo/modest-main-window-ui.h: Specify the callback for the Accounts menu item.
        * src/modest-ui-actions.c: (modest_ui_actions_on_accounts): Open the wizard if no
        accounts exist yet, as in the UI spec.

        * src/modest-account-mgr.h: Add TODO comment about a possible memory leak.

pmo-trunk-r1512

ChangeLog2
src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-main-window-ui.h
src/modest-account-mgr.h
src/modest-ui-actions.c

index 476539c..e384129 100644 (file)
@@ -1,5 +1,19 @@
 2007-04-05  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/maemo/easysetup/modest-easysetup-wizard.c:
+       (set_default_custom_servernames): Avoid a dereference of a destroyed widget.
+       (create_account): Do a sanity check, showing that modest_account_mgr_account_names() 
+       returns NULL after modest_account_mgr_add_server_account() returned TRUE, 
+       which seems wrong.
+       
+       * src/maemo/modest-main-window-ui.h: Specify the callback for the Accounts menu item.
+       * src/modest-ui-actions.c: (modest_ui_actions_on_accounts): Open the wizard if no 
+       accounts exist yet, as in the UI spec.
+       
+       * src/modest-account-mgr.h: Add TODO comment about a possible memory leak.
+
+2007-04-05  Murray Cumming  <murrayc@murrayc.com>
+
        * src/maemo/Makefile.am:
        * src/maemo/modest-connection-specific-smtp-edit-window.c:
        * src/maemo/modest-connection-specific-smtp-edit-window.h: 
index bdcfc96..581fb45 100644 (file)
@@ -961,6 +961,9 @@ util_increment_name (const gchar* text)
        
 static void set_default_custom_servernames (ModestEasysetupWizardDialog *account_wizard)
 {
+       if (!account_wizard->entry_incomingserver)
+               return;
+               
        /* Set a default domain for the server, based on the email address,
         * if no server name was already specified.
         */
@@ -1251,6 +1254,16 @@ create_account (ModestEasysetupWizardDialog *self)
                return FALSE;   
        }
        
+       /* Sanity check: */
+       /* There must be at least one account now: */
+       GSList *account_names = modest_account_mgr_account_names (self->account_manager);
+       if(account_names != NULL)
+       {
+               g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
+       }
+       g_slist_free (account_names);
+       
+       
        /* Outgoing server: */
        gchar* servername_outgoing = NULL;
        ModestProtocol protocol_outgoing = MODEST_PROTOCOL_STORE_POP;
index ae297a4..cb0611c 100644 (file)
@@ -87,7 +87,7 @@ static const GtkActionEntry modest_action_entries [] = {
        
        /* Tools */
        { "ToolsSettings",        NULL,      N_("Settings..."),               NULL, NULL,  NULL },
-       { "ToolsAccounts",        NULL,      N_("Accounts..."),                NULL, NULL,  NULL },
+       { "ToolsAccounts",        NULL,      N_("Accounts..."),                NULL, NULL,  G_CALLBACK (modest_ui_actions_on_accounts) },
        { "ToolsSMTPServers",     NULL,      N_("SMTP servers..."),                NULL, NULL,  NULL },
        { "ToolsSendReceive", NULL, N_("Send & receive") }, /* submenu */
        { "ToolsSendReceiveAll",    NULL,      N_("All"),          NULL, NULL,  NULL },
index 6e6bff4..22901fb 100644 (file)
@@ -168,7 +168,11 @@ gboolean        modest_account_mgr_remove_account         (ModestAccountMgr *sel
  * list all account names
  *
  * Returns: a newly allocated list of account names, or NULL in case of error or
- * if there are no accounts. The caller must free the returned GSList
+ * if there are no accounts. The caller must free the returned GSList.
+ *
+ * TODO: I believe that the caller must free the strings in the GSList items too, 
+ * because this is implemented via gconf_client_all_dirs() which also requires a deep free, 
+ * though that's not documented. murrayc.
  */
 GSList*                modest_account_mgr_account_names    (ModestAccountMgr *self);
 
index 29440a7..5e4e07d 100644 (file)
@@ -205,14 +205,30 @@ modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
 void
 modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 {
+       GSList *account_names = modest_account_mgr_account_names (modest_runtime_get_account_mgr());
+       const gboolean accounts_exist = account_names != NULL;
+       g_slist_free (account_names);
+       
        /* This is currently only implemented for Maemo,
         * because it requires a providers preset file which is not publically available.
         */
 #ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
-       GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
-       gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
-       gtk_dialog_run (account_win);
-       gtk_widget_destroy (GTK_WIDGET(account_win));
+       if (!accounts_exist) {
+               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));
+               gtk_dialog_run (GTK_DIALOG (wizard));
+               gtk_widget_destroy (GTK_WIDGET (wizard));
+       }
+       else
+       {
+               /* Show the list of accounts: */
+               GtkDialog *account_win = GTK_DIALOG(modest_account_view_window_new ());
+               gtk_window_set_transient_for (GTK_WINDOW (account_win), GTK_WINDOW(win));
+               gtk_dialog_run (account_win);
+               gtk_widget_destroy (GTK_WIDGET(account_win));
+       }
 #else
    GtkWidget *dialog, *label;
    
@@ -241,20 +257,6 @@ modest_ui_actions_on_accounts (GtkAction *action, ModestWindow *win)
 }
 
 void
-modest_ui_actions_on_new_account (GtkAction *action, ModestWindow *win)
-{
-       /* This is currently only implemented for Maemo,
-        * because it requires a providers preset file which is not publically available.
-        */
-#ifdef MODEST_PLATFORM_MAEMO /* Defined in config.h */
-       ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
-       gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (win));
-       gtk_dialog_run (GTK_DIALOG (wizard));
-       gtk_widget_destroy (GTK_WIDGET (wizard));
-#endif /* MODEST_PLATFORM_MAEMO */
-}
-
-void
 modest_ui_actions_on_new_msg (GtkAction *action, ModestWindow *win)
 {
        ModestWindow *msg_win;