-
- char line[MAX_LINE_LEN];
- guint previous_mcc = 0;
- gchar *territory, *fallback = NULL;
- gchar *current_locale;
-
- /* Get the territory specified for the current locale */
- territory = nl_langinfo (_NL_ADDRESS_COUNTRY_NAME);
-
- /* Tricky stuff, the translations of the OSSO countries does
- not always correspond to the country names in locale
- databases. Add all these cases here. sergio */
- if (!strcmp (territory, "United Kingdom"))
- fallback = g_strdup ("UK");
-
- current_locale = setlocale (LC_ALL ,NULL);
-
- FILE *file = modest_maemo_open_mcc_mapping_file ();
- if (!file) {
- g_warning("Could not open mcc_mapping file");
- return;
- }
-
- while (fgets (line, MAX_LINE_LEN, file) != NULL) {
-
- int mcc;
- char *country = NULL;
- const gchar *name_translated, *english_translation;
-
- mcc = parse_mcc_mapping_line (line, &country);
- if (!country || mcc == 0) {
- g_warning ("%s: error parsing line: '%s'", __FUNCTION__, line);
- continue;
- }
-
- if (mcc == previous_mcc) {
- /* g_warning ("already seen: %s", line); */
- continue;
- }
- previous_mcc = mcc;
-
- if (!priv->locale_mcc) {
- english_translation = dgettext ("osso-countries", country);
- if (!strcmp (english_translation, territory) ||
- (fallback && !strcmp (english_translation, fallback)))
- priv->locale_mcc = mcc;
- }
- name_translated = dgettext ("osso-countries", country);
-
- /* Add the row to the model: */
- GtkTreeIter iter;
- gtk_list_store_append (liststore, &iter);
- gtk_list_store_set(liststore, &iter, MODEL_COL_MCC, mcc, MODEL_COL_NAME, name_translated, -1);
- }
- fclose (file);
-
- /* Sort the items: */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore),
- MODEL_COL_NAME, GTK_SORT_ASCENDING);
-
- g_free (fallback);