* handle the save-settings in all cases, when quiting via menu
[modest] / src / modest-main.c
index 6b35614..988c5c2 100644 (file)
@@ -31,6 +31,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <tny-list.h>
 
 #include <tny-account-store-iface.h>
 #include <tny-list-iface.h>
@@ -42,9 +43,6 @@
 #include "modest-tny-transport-actions.h"
 #include "modest-tny-account-store.h"
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /*HAVE_CONFIG_H*/
 
 #ifdef MODEST_ENABLE_HILDON /* Hildon includes */
 #include <libosso.h>
@@ -72,7 +70,6 @@ main (int argc, char *argv[])
 {
        GOptionContext   *context        = NULL;
        ModestConf       *modest_conf    = NULL;
-       ModestUI         *modest_ui      = NULL;
 
        GError *err = NULL;
        int retval  = MODEST_ERR_NONE;
@@ -120,7 +117,10 @@ main (int argc, char *argv[])
        }
 
        if (debug)
-               g_log_set_always_fatal (G_LOG_LEVEL_WARNING);
+               g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING);
+       
+       if (!getenv("DISPLAY"))
+               batch = TRUE; 
        
        if (!batch) {
                gtk_init (&argc, &argv);
@@ -142,10 +142,13 @@ start_ui (ModestConf *conf, const gchar* mailto, const gchar *cc, const gchar *b
          const gchar* subject, const gchar *body)
 {
 
-       GtkWidget *win;
        ModestUI *modest_ui;
-       gint ok, retval = 0;
+       gint retval = 0;
 
+       #ifndef OLD_UI_STUFF
+       GtkWidget *win;
+       #endif
+       
        modest_ui = MODEST_UI(modest_ui_new (conf));
        if (!modest_ui) {
                g_printerr ("modest: failed to initialize ui, exiting\n");
@@ -219,11 +222,8 @@ send_mail (ModestConf *conf, const gchar* mailto, const gchar *cc, const gchar *
 
        TnyListIface *accounts = NULL;
        TnyIteratorIface *iter = NULL;
-
-       TnyTransportAccountIface *account = NULL;
-       
+       TnyTransportAccountIface *account = NULL;       
        int retval;
-       int i = 0;
        
        acc_mgr   = modest_account_mgr_new (conf);
        acc_store = modest_tny_account_store_new (acc_mgr);     
@@ -236,7 +236,7 @@ send_mail (ModestConf *conf, const gchar* mailto, const gchar *cc, const gchar *
        iter = tny_list_iface_create_iterator(accounts);
        tny_iterator_iface_first (iter);
        if (tny_iterator_iface_is_done (iter)) {
-               g_printerr("modest: no transport accounts defined");
+               g_printerr("modest: no transport accounts defined\n");
                retval = MODEST_ERR_SEND;
                goto cleanup;
        }