Fixes a stack overflow caused by the recent commit that was pre-creating the send...
[modest] / src / modest-main.c
index f84edf3..62d2e69 100644 (file)
 #include "modest-platform.h"
 #include "modest-ui-actions.h"
 
+static gboolean show_ui = FALSE;
+static GOptionEntry option_entries [] =
+{
+       { "show-ui", 's', 0, G_OPTION_ARG_NONE, &show_ui, "Show UI immediately, so no wait for DBUS activation", NULL },
+       { NULL }
+};
+
 typedef struct {
        gulong queue_handler;
        gulong window_list_handler;
@@ -116,12 +123,22 @@ main (int argc, char *argv[])
        gboolean show_ui_without_top_application_method = FALSE;
        int retval  = 0;
        MainSignalHandlers *handlers;
+       ModestTnyAccountStore *acc_store;
 
-       if (argc >= 2) {
-               if (strcmp (argv[1], "showui") == 0)
-                       show_ui_without_top_application_method = TRUE;
+       GError *error;
+       GOptionContext *context;
+
+       context = g_option_context_new ("- Modest email client");
+       g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);
+       g_option_context_add_group (context, gtk_get_option_group (TRUE));
+       if (!g_option_context_parse (context, &argc, &argv, &error)) {
+               g_print ("option parsing failed: %s\n", error->message);
+               exit (1);
        }
 
+
+       show_ui_without_top_application_method = show_ui;
+
        if (!show_ui_without_top_application_method) {
                g_print ("modest: use 'modest showui' to start from cmdline  with UI\n");
        }
@@ -150,6 +167,11 @@ main (int argc, char *argv[])
                goto cleanup;
        }
 
+
+       /* Create the account store & launch send queues */
+       acc_store = modest_runtime_get_account_store ();
+       modest_tny_account_store_start_send_queues (acc_store);
+
        handlers = g_malloc0 (sizeof (MainSignalHandlers));
        /* Connect to the "queue-emtpy" signal */
        handlers->queue_handler =
@@ -167,7 +189,7 @@ main (int argc, char *argv[])
 
        /* Connect to the "password-requested" signal */
        handlers->get_password_handler =
-               g_signal_connect (modest_runtime_get_account_store (),
+               g_signal_connect (acc_store,
                                  "password_requested",
                                  G_CALLBACK (modest_ui_actions_on_password_requested),
                                  NULL);