* check different places for the mcc_mapping file; this
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sat, 10 Nov 2007 13:30:52 +0000 (13:30 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sat, 10 Nov 2007 13:30:52 +0000 (13:30 +0000)
  enables modest to run on chinook

pmo-trunk-r3689

src/maemo/modest-maemo-utils.c
src/modest-defs.h

index 40da89c..656202d 100644 (file)
@@ -47,6 +47,7 @@
 #include <tny-camel-pop-store-account.h>
 #include "modest-hildon-includes.h"
 
+#include <modest-defs.h>
 #include "modest-maemo-utils.h"
 #include "modest-platform.h"
 
@@ -422,7 +423,8 @@ on_camel_account_get_supported_secure_authentication (
        }
 }
 
-static void on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data)
+static void
+on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data)
 {
        if(response == GTK_RESPONSE_REJECT || response == GTK_RESPONSE_DELETE_EVENT)
        {
@@ -684,24 +686,31 @@ modest_maemo_toggle_action_set_active_block_notify (GtkToggleAction *action, gbo
 }
 
 
-
 FILE*
 modest_maemo_open_mcc_mapping_file (void)
 {
        FILE* result;
        
-       /* Load the file one line at a time: */
-#ifdef MODEST_HILDON_VERSION_0
-       const gchar* filepath = PROVIDER_DATA_DIR "/mcc_mapping";
-#else
-       const gchar* filepath = "/usr/share/operator-wizard/mcc_mapping";
-#endif /*MODEST_HILDON_VERSION_0*/
+       const gchar* path;
+       const gchar* path1 = MODEST_OPERATOR_WIZARD_PROVIDER_DATA_DIR;
+       const gchar* path2 = MODEST_PROVIDER_DATA_DIR;
        
-       result = fopen (filepath, "r"); 
-       if (!result) 
-               g_printerr ("modest: failed to open mcc mapping file");
+       if (access(path1, R_OK) == 0) 
+               path = path1;
+       else if (access(path2, R_OK) == 0)
+               path = path2;
+       else {
+               g_warning ("%s: neither '%s' nor '%s' is a readable mapping file",
+                          __FUNCTION__, path1, path2);
+               return NULL;
+       }
        
+       result = fopen (path, "r");
+       if (!result) {
+               g_warning ("%s: error opening mapping file '%s': %s",
+                          __FUNCTION__, path, strerror(errno));
+               return NULL;
+       }
        return result;
 }
 
-
index 8652da4..d43983b 100644 (file)
@@ -31,6 +31,7 @@
 #ifndef __MODEST_DEFS_H__
 #define __MODEST_DEFS_H__
 
+#include <config.h>
 #include <glib/gi18n.h>
 
 /* Some interesting directories. NOTE, they should be prefixed
@@ -60,6 +61,7 @@
 
 #define MODEST_MMC_ACCOUNT_ID             "mcc"
 
+/* FIXME: get these from the environment */
 /* Without the trailing / because gnome-vfs reports mounted 
  * volume URIs without the trailing, and we want to match them: */
 #define MODEST_MCC1_VOLUMEPATH   "/media/mmc1" 
 /* configuration key definitions for modest */
 #define MODEST_CONF_NAMESPACE          "/apps/modest"
 
+/* the mapping files, there are two possibilities; used in modest_maemo_open_mcc_mapping_file */
+#define MODEST_PROVIDER_DATA_DIR                 PREFIX "/share/modest/provider-data/mcc_mapping"
+#define MODEST_OPERATOR_WIZARD_PROVIDER_DATA_DIR "/usr/share/operator-wizard/mcc_mapping"
+
+
 /* configuration key definitions for modest */
 #define MODEST_ACCOUNT_NAMESPACE         MODEST_CONF_NAMESPACE "/accounts"
 #define MODEST_CONF_DEFAULT_ACCOUNT      MODEST_CONF_NAMESPACE "/default_account"