- gboolean translated;
- char line[MAX_LINE_LEN];
- guint previous_mcc = 0;
- gchar *territory;
-
- FILE *file = modest_maemo_open_mcc_mapping_file (&translated);
- if (!file) {
- g_warning("Could not open mcc_mapping file");
- return;
- }
-
- /* Get the territory specified for the current locale */
- territory = nl_langinfo (_NL_ADDRESS_COUNTRY_NAME);
-
- while (fgets (line, MAX_LINE_LEN, file) != NULL) {
-
- int mcc;
- char *country = NULL;
- const gchar *name_translated;
-
- 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) {
- if (translated) {
- if (!g_utf8_collate (country, territory))
- priv->locale_mcc = mcc;
- g_debug ("'%s' || '%s' || %d", territory, country, mcc);
- } else {
- gchar *translation = dgettext ("osso-countries", country);
- if (!g_utf8_collate (translation, territory))
- priv->locale_mcc = mcc;
- g_debug ("'%s' || '%s' || %d", territory, translation, 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);
-
- /* Fallback to Finland */
- if (!priv->locale_mcc)
- priv->locale_mcc = 244;
-
- /* Sort the items: */
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (liststore),
- MODEL_COL_NAME, GTK_SORT_ASCENDING);