* call osso_abook_init before doing anything with the addressbook.
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 26 Jun 2007 08:03:16 +0000 (08:03 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Tue, 26 Jun 2007 08:03:16 +0000 (08:03 +0000)
  this fixes NB#57415

pmo-trunk-r2417

src/gnome/modest-platform.c
src/maemo/modest-platform.c
src/modest-init.c
src/modest-init.h
src/modest-main.c

index c92d1da..0143b45 100644 (file)
@@ -37,7 +37,7 @@
 #include "gnome/modest-gnome-global-settings-dialog.h"
 
 gboolean
-modest_platform_init (void)
+modest_platform_init (int argc, char *argv[])
 {      
        return TRUE; /* nothing to do */
 }
index 1ee57ed..0584656 100644 (file)
@@ -38,6 +38,7 @@
 #include <modest-hildon-includes.h>
 #include <osso-helplib.h>
 #include <dbus_api/modest-dbus-callbacks.h>
+#include <libosso-abook/osso-abook.h>
 #include <maemo/modest-osso-autosave-callbacks.h>
 #include <libosso.h>
 #include <alarmd/alarm_event.h> /* For alarm_event_add(), etc. */
@@ -48,6 +49,7 @@
 #include <gtk/gtkmain.h>
 #include <string.h>
 
+
 #define HILDON_OSSO_URI_ACTION "uri-action"
 #define URI_ACTION_COPY "copy:"
 
@@ -65,10 +67,11 @@ on_modest_conf_update_interval_changed (ModestConf* self, const gchar *key,
 }
 
 gboolean
-modest_platform_init (void)
+modest_platform_init (int argc, char *argv[])
 {
        osso_hw_state_t hw_state = { 0 };
        DBusConnection *con;    
+
        osso_context =
                osso_initialize(PACKAGE,PACKAGE_VERSION,
                                FALSE, NULL);   
@@ -78,11 +81,11 @@ modest_platform_init (void)
        }
 
        if ((con = osso_get_dbus_connection (osso_context)) == NULL) {
-               g_printerr ("Could not get dbus connection\n");
+               g_printerr ("modest: could not get dbus connection\n");
                return FALSE;
 
        }
-
+       
        /* Add a D-Bus handler to be used when the main osso-rpc 
         * D-Bus handler has not handled something.
         * We use this for D-Bus methods that need to use more complex types 
@@ -93,7 +96,7 @@ modest_platform_init (void)
                                         NULL,
                                         NULL)) {
 
-               g_printerr ("Could not add D-Bus filter\n");
+               g_printerr ("modest: Could not add D-Bus filter\n");
                return FALSE;
        }
 
@@ -104,8 +107,8 @@ modest_platform_init (void)
                                MODEST_DBUS_IFACE,
                                modest_dbus_req_handler, NULL /* user_data */);
        if (result != OSSO_OK) {
-                       g_print("Error setting D-BUS callback (%d)\n", result);
-                       return OSSO_ERROR;
+                       g_printerr ("modest: Error setting D-BUS callback (%d)\n", result);
+                       return FALSE;
        }
 
        /* Add handler for Exit D-BUS messages.
@@ -127,7 +130,8 @@ modest_platform_init (void)
        result = osso_application_set_autosave_cb (osso_context, 
                modest_on_osso_application_autosave, NULL /* user_data */);
        if (result != OSSO_OK) {
-               g_warning ("osso_application_set_autosave_cb() failed.");       
+               g_printerr ("modest: osso_application_set_autosave_cb() failed.\n");
+               return FALSE;
        }
        
 
@@ -142,7 +146,13 @@ modest_platform_init (void)
        /* Get the initial update interval from gconf: */
        on_modest_conf_update_interval_changed(conf, MODEST_CONF_UPDATE_INTERVAL,
                MODEST_CONF_EVENT_KEY_CHANGED, NULL);
-       
+
+       /* initialize the addressbook */
+       if (!osso_abook_init (&argc, &argv, osso_context)) {
+               g_printerr ("modest: failed to initialized addressbook\n");
+               return FALSE;
+       }
+               
        return TRUE;
 }
 
index 8f81f3d..2217eb1 100644 (file)
@@ -172,7 +172,7 @@ modest_init_get_default_header_view_column_ids (TnyFolderType folder_type, Modes
 }
 
 gboolean
-modest_init_init_core (void)
+modest_init_init_core (int argc, char *argv[])
 {
        gboolean reset;
        static gboolean invoked = FALSE;
@@ -187,6 +187,13 @@ modest_init_init_core (void)
        init_i18n();
        init_debug_g_type();
        init_debug_logging();
+
+       if (!gnome_vfs_initialized()) {
+               if (!gnome_vfs_init ()) {
+                       g_printerr ("modest: failed to init gnome-vfs\n");
+                       return FALSE;
+               }
+       }
        
        if (!modest_runtime_init()) {
                modest_init_uninit ();
@@ -194,11 +201,12 @@ modest_init_init_core (void)
                return FALSE;
        }
 
-
+       
        /* do an initial guess for the device name */
        init_device_name (modest_runtime_get_conf());
 
-       if (!modest_platform_init()) {
+       
+       if (!modest_platform_init(argc, argv)) {
                modest_init_uninit ();
                g_printerr ("modest: failed to run platform-specific initialization\n");
                return FALSE;
@@ -245,10 +253,11 @@ modest_init_init_ui (gint argc, gchar** argv)
        init_stock_icons ();
 
        /* Init notification system */
-       #ifdef MODEST_HAVE_HILDON_NOTIFY
+#ifdef MODEST_HAVE_HILDON_NOTIFY
        notify_init ("Basics");
-       #endif
+#endif
 
+       
        return TRUE;
 }
 
@@ -258,7 +267,10 @@ modest_init_uninit (void)
 {
        if (!modest_runtime_uninit())
                g_printerr ("modest: failed to uninit runtime\n");
-               
+
+       if (gnome_vfs_initialized())
+               gnome_vfs_shutdown ();
+       
        return TRUE;
 }
 
index 493202e..c0eede7 100644 (file)
@@ -39,6 +39,8 @@ G_BEGIN_DECLS
 
 /**
  * modest_init_init_core:
+ * @argc:
+ * @argv:
  *
  * initialize the modest runtime system (which sets up the
  * environment, instantiates singletons and so on)
@@ -47,7 +49,7 @@ G_BEGIN_DECLS
  *  
  * TRUE if this succeeded, FALSE otherwise.
  */
-gboolean modest_init_init_core (void);
+gboolean modest_init_init_core (int argc, char *argv[]);
 
 
 /**
index e0dc501..0682b88 100644 (file)
@@ -133,10 +133,9 @@ main (int argc, char *argv[])
        }
        g_option_context_free (context);
        
-       if (!modest_init_init_core ()) {
+       if (!modest_init_init_core (argc, argv)) {
                g_printerr ("modest: cannot init modest core\n");
                return MODEST_ERR_INIT;
-               
        }
        
        account_or_default = check_account (account);