* src/maemo/modest-connection-specific-smtp-edit-window.c:
[modest] / src / maemo / easysetup / modest-easysetup-country-combo-box.c
index a3213a9..ba1a908 100644 (file)
@@ -159,36 +159,32 @@ static int
 parse_mcc_mapping_line (const char* line,  char** country)
 {
        int i, j;
-       char mcc[4];  /* the mcc code, always 3 bytes*/
+       char mcc[3];  /* the mcc code, always 3 bytes*/
        static char my_country[128];
-       
-       /* Initialize output parameters: */
-       *country = NULL;
 
-       g_return_val_if_fail (line && strlen(line) > 20, 0);
+       if (!line) {
+               *country = NULL;
+               return 0;
+       }
        
        for (i = 3, j = 0; i < 128; ++i) {
                char kar = line[i];
-               if (kar < '_' ) { /* optimization */
-                       if (kar == '\n' || kar == '\r')
-                               break;
-                       else if (kar == ' ' || kar == '\t')
-                               continue;
-                       else  /* error */
-                               return 0;
-               } else {
+               if (kar == '\0')
+                       break;
+               else if (kar < '_')
+                       continue;
+               else 
                        my_country [j++] = kar;
-               }
        }
        my_country[j] = '\0';
 
        mcc[0] = line[0];
        mcc[1] = line[1];
        mcc[2] = line[2];
-       mcc[3] = '\0';
        
        *country = my_country;
-       return effective_mcc (atoi(mcc));
+
+       return effective_mcc ((int) strtol ((const char*)mcc, NULL, 10));
 }
 
 /** Note that the mcc_mapping file is installed 
@@ -260,7 +256,6 @@ easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
        
        /* Setup the combo box: */
        GtkComboBox *combobox = GTK_COMBO_BOX (self);
-       gtk_combo_box_set_model (combobox, priv->model);
        
        /* Country column:
         * The ID model column in not shown in the view. */
@@ -276,6 +271,8 @@ easysetup_country_combo_box_init (EasysetupCountryComboBox *self)
        
        /* Fill the model with rows: */
        load_from_file (self);
+       /* Set this _after_ loading from file, it makes loading faster */
+       gtk_combo_box_set_model (combobox, priv->model);
 }
 
 EasysetupCountryComboBox*