From: Sergio Villar Senin Date: Wed, 21 Oct 2009 07:42:52 +0000 (+0200) Subject: Fixes NB#133900, some countries are missing in the country list X-Git-Tag: 3.1.6~1 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=e3277ea07a5543dcc250f8e60dadb6c51cc3bfb1 Fixes NB#133900, some countries are missing in the country list --- diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index 4e18836..1125cde 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -139,26 +139,21 @@ on_modest_conf_update_interval_changed (ModestConf* self, static gboolean check_required_files (void) { - FILE *mcc_file = modest_utils_open_mcc_mapping_file (FALSE, NULL); + FILE *mcc_file = modest_utils_open_mcc_mapping_file (); + if (!mcc_file) { g_printerr ("modest: check for mcc file (for LANG) failed\n"); return FALSE; - } else - fclose (mcc_file); - - mcc_file = modest_utils_open_mcc_mapping_file (TRUE, NULL); - if (!mcc_file) { - g_printerr ("modest: check for mcc file (for LC_MESSAGES) failed\n"); - return FALSE; - } else + } else { fclose (mcc_file); - + } + if (access(MODEST_PROVIDER_DATA_FILE, R_OK) != 0 && access(MODEST_FALLBACK_PROVIDER_DATA_FILE, R_OK) != 0) { g_printerr ("modest: cannot find providers data\n"); return FALSE; } - + return TRUE; } diff --git a/src/maemo/modest-platform.c b/src/maemo/modest-platform.c index b54f5f4..1b54395 100644 --- a/src/maemo/modest-platform.c +++ b/src/maemo/modest-platform.c @@ -103,20 +103,14 @@ on_modest_conf_update_interval_changed (ModestConf* self, static gboolean check_required_files (void) { - FILE *mcc_file = modest_utils_open_mcc_mapping_file (FALSE,NULL); - if (!mcc_file) { - g_printerr ("modest: check for mcc file failed\n"); - return FALSE; - } else - fclose (mcc_file); + FILE *mcc_file = modest_utils_open_mcc_mapping_file (); - - mcc_file = modest_utils_open_mcc_mapping_file (TRUE, NULL); if (!mcc_file) { - g_printerr ("modest: check for mcc file (for LC_MESSAGES) failed\n"); + g_printerr ("modest: check for mcc file failed\n"); return FALSE; - } else + } else { fclose (mcc_file); + } if (access(MODEST_PROVIDER_DATA_FILE, R_OK) != 0 && access(MODEST_FALLBACK_PROVIDER_DATA_FILE, R_OK) != 0) { diff --git a/src/mcc_mapping b/src/mcc_mapping index 3ecfa82..ff0862d 100644 --- a/src/mcc_mapping +++ b/src/mcc_mapping @@ -1,230 +1,231 @@ -412 qtn_clk_country_afghanistan -276 qtn_clk_country_albania -603 qtn_clk_country_algeria -544 qtn_clk_country_american_samoa -213 qtn_clk_country_andorra -631 qtn_clk_country_angola -365 qtn_clk_country_anguilla -344 qtn_clk_country_antigua_and_barbuda -722 qtn_clk_country_argentina -283 qtn_clk_country_armenia -363 qtn_clk_country_aruba -505 qtn_clk_country_australia -232 qtn_clk_country_austria -400 qtn_clk_country_azerbaijani_republic -364 qtn_clk_country_bahamas -426 qtn_clk_country_bahrain -470 qtn_clk_country_bangladesh -342 qtn_clk_country_barbados -257 qtn_clk_country_belarus -206 qtn_clk_country_belgium -702 qtn_clk_country_belize -616 qtn_clk_country_benin -350 qtn_clk_country_bermuda -402 qtn_clk_country_bhutan -736 qtn_clk_country_bolivia -218 qtn_clk_country_bosnia_and_herzegovina -652 qtn_clk_country_botswana -724 qtn_clk_country_brazil -348 qtn_clk_country_british_virgin_islands -528 qtn_clk_country_brunei_darussalam -284 qtn_clk_country_bulgaria -613 qtn_clk_country_burkina_faso -642 qtn_clk_country_burundi -456 qtn_clk_country_cambodia -624 qtn_clk_country_cameroon -302 qtn_clk_country_canada -625 qtn_clk_country_cape_verde -346 qtn_clk_country_cayman_islands -623 qtn_clk_country_central_african_republic -622 qtn_clk_country_chad -730 qtn_clk_country_chile -461 qtn_clk_country_china -460 qtn_clk_country_china -732 qtn_clk_country_colombia -654 qtn_clk_country_comoros -629 qtn_clk_country_republic_of_the_congo -548 qtn_clk_country_cook_islands -712 qtn_clk_country_costa_rica -612 qtn_clk_country_cote_dlvoire -219 qtn_clk_country_croatia -368 qtn_clk_country_cuba -280 qtn_clk_country_cyprus -230 qtn_clk_country_czech_republic -630 qtn_clk_country_democratic_republic_of_the_congo -238 qtn_clk_country_denmark -638 qtn_clk_country_djibouti -366 qtn_clk_country_dominica -370 qtn_clk_country_dominican_republic -514 qtn_clk_country_east_timor -740 qtn_clk_country_ecuador -602 qtn_clk_country_egypt -706 qtn_clk_country_el_salvador -627 qtn_clk_country_equatorial_guinea -657 qtn_clk_country_eritrea -248 qtn_clk_country_estonia -636 qtn_clk_country_ethiopia -288 qtn_clk_country_faroe_islands -542 qtn_clk_country_fiji -244 qtn_clk_country_finland -208 qtn_clk_country_france -742 qtn_clk_country_french_guiana -547 qtn_clk_country_french_polynesia -628 qtn_clk_country_gobonese_republic -607 qtn_clk_country_gambia -282 qtn_clk_country_georgia -262 qtn_clk_country_germany -620 qtn_clk_country_ghana -266 qtn_clk_country_gibraltar -202 qtn_clk_country_greece -290 qtn_clk_country_greenland -352 qtn_clk_country_grenada -340 qtn_clk_country_guadeloupe -535 qtn_clk_country_guam -704 qtn_clk_country_guatemala -611 qtn_clk_country_guinea -632 qtn_clk_country_guinea_bissaus -738 qtn_clk_country_guyana -372 qtn_clk_country_haiti -708 qtn_clk_country_honduras -454 qtn_clk_country_hong_kong -216 qtn_clk_country_hungary -274 qtn_clk_country_iceland -404 qtn_clk_country_india -510 qtn_clk_country_indonesia -432 qtn_clk_country_iran -418 qtn_clk_country_iraq -272 qtn_clk_country_republic_of_ireland -425 qtn_clk_country_israel -222 qtn_clk_country_italy -338 qtn_clk_country_jamaica -441 qtn_clk_country_japan -440 qtn_clk_country_japan -416 qtn_clk_country_jordan -401 qtn_clk_country_kazakhstan -639 qtn_clk_country_kenya -545 qtn_clk_country_kiribati -467 qtn_clk_country_korea_north -450 qtn_clk_country_country_south_korea -419 qtn_clk_country_kuwait -437 qtn_clk_country_kyrgyz_republic -457 qtn_clk_country_laos -247 qtn_clk_country_latvia -415 qtn_clk_country_lebanon -651 qtn_clk_country_lesotho -618 qtn_clk_country_liberia -606 qtn_clk_country_libya -295 qtn_clk_country_liechtenstein -246 qtn_clk_country_lithuania -270 qtn_clk_country_luxembourg -455 qtn_clk_country_macao -294 qtn_clk_country_the_former_yugoslav_republic_of_macedonia -646 qtn_clk_country_madagascar -650 qtn_clk_country_malawi -502 qtn_clk_country_malaysia -472 qtn_clk_country_maldives -610 qtn_clk_country_mali -278 qtn_clk_country_malta -551 qtn_clk_country_marshall_islands -340 qtn_clk_country_martinique -609 qtn_clk_country_mauritania -617 qtn_clk_country_mauritius -334 qtn_clk_country_mexico -550 qtn_clk_country_micronesia -259 qtn_clk_country_republic_of_moldova -212 qtn_clk_country_monaco -428 qtn_clk_country_mongolia -354 qtn_clk_country_montserrat -604 qtn_clk_country_morocco -643 qtn_clk_country_mozambique -414 qtn_clk_country_myanmar -649 qtn_clk_country_namibia -536 qtn_clk_country_nauru -429 qtn_clk_country_nepal -204 qtn_clk_country_netherlands -362 qtn_clk_country_netherlands_antilles -546 qtn_clk_country_new_caledonia -530 qtn_clk_country_new_zealand -710 qtn_clk_country_nicaraqua -614 qtn_clk_country_niger -621 qtn_clk_country_nigeria -534 qtn_clk_country_northern_mariana_islands -242 qtn_clk_country_norway -422 qtn_clk_country_oman -410 qtn_clk_country_pakistan -552 qtn_clk_country_palau -714 qtn_clk_country_panama -537 qtn_clk_country_papua_new_guinea -744 qtn_clk_country_paraquay -716 qtn_clk_country_peru -515 qtn_clk_country_philippines -260 qtn_clk_country_poland -268 qtn_clk_country_portugal -330 qtn_clk_country_puerto_rico -427 qtn_clk_country_qatar -647 qtn_clk_country_reunion -226 qtn_clk_country_romania -250 qtn_clk_country_russian_federation -635 qtn_clk_country_rwandese_republic -356 qtn_clk_country_saint_kitts_and_nevis -358 qtn_clk_country_saint_lucia -308 qtn_clk_country_saint_pierre_and_miquelon -360 qtn_clk_country_saint_vincent_and_grenadines -549 qtn_clk_country_samoa -292 qtn_clk_country_san_marino -626 qtn_clk_country_sao_tome_and_principe -420 qtn_clk_country_saudi_arabia -608 qtn_clk_country_senegal -220 qtn_clk_country_serbia_and_montenegro -633 qtn_clk_country_seychelles -619 qtn_clk_country_sierra_leone -525 qtn_clk_country_singapore -231 qtn_clk_country_slovakia -293 qtn_clk_country_slovenia -540 qtn_clk_country_solomon_islands -637 qtn_clk_country_somalia -655 qtn_clk_country_south_africa -214 qtn_clk_country_spain -413 qtn_clk_country_sri_lanka -634 qtn_clk_country_sudan -746 qtn_clk_country_suriname -653 qtn_clk_country_swaziland -240 qtn_clk_country_sweden -228 qtn_clk_country_switzerland -417 qtn_clk_country_syrian_arab_republic -466 qtn_clk_country_taiwan -436 qtn_clk_country_tajikistan -640 qtn_clk_country_united_republic_of_tanzania -520 qtn_clk_country_thailand -615 qtn_clk_country_togolese_republic -539 qtn_clk_country_tonga -374 qtn_clk_country_trinidad_and_tobago -605 qtn_clk_country_tunisia -286 qtn_clk_country_turkey -438 qtn_clk_country_turkmenistan -376 qtn_clk_country_turks_and_caicos_islands -641 qtn_clk_country_uganda -255 qtn_clk_country_ukraine -424 qtn_clk_country_united_arab_emirates -430 qtn_clk_country_united_arab_emirates_abu_dhabi -431 qtn_clk_country_united_arab_emirates_dubai -235 qtn_clk_country_united_kingdom_of_great_britain_and_northern_ireland -234 qtn_clk_country_united_kingdom_of_great_britain_and_northern_ireland -310 qtn_clk_country_united_states_of_america -316 qtn_clk_country_united_states_of_america -311 qtn_clk_country_united_states_of_america -312 qtn_clk_country_united_states_of_america -313 qtn_clk_country_united_states_of_america -314 qtn_clk_country_united_states_of_america -315 qtn_clk_country_united_states_of_america -332 qtn_clk_country_unites_states_virgin_islands -748 qtn_clk_country_uruguay -434 qtn_clk_country_uzbekistan -541 qtn_clk_country_vanuatu -225 qtn_clk_country_the_vatican -734 qtn_clk_country_venezuela -452 qtn_clk_country_viet_nam -543 qtn_clk_country_wallis_and_futuna -421 qtn_clk_country_yemen -645 qtn_clk_country_zambia -648 qtn_clk_country_zimbabwe +412 qtn_clk_country_afghanistan +276 qtn_clk_country_albania +603 qtn_clk_country_algeria +544 qtn_clk_country_samoa +213 qtn_clk_country_andorra +631 qtn_clk_country_angola +365 qtn_clk_country_anguilla +344 qtn_clk_country_antigua_barbuda +722 qtn_clk_country_argentina +283 qtn_clk_country_armenia +363 qtn_clk_country_aruba +505 qtn_clk_country_australia +232 qtn_clk_country_austria +400 qtn_clk_country_azerbaijan +364 qtn_clk_country_bahamas +426 qtn_clk_country_bahrain +470 qtn_clk_country_bangladesh +342 qtn_clk_country_barbados +257 qtn_clk_country_belarus +206 qtn_clk_country_belgium +702 qtn_clk_country_belize +616 qtn_clk_country_benin +350 qtn_clk_country_bermuda +402 qtn_clk_country_bhutan +736 qtn_clk_country_bolivia +218 qtn_clk_country_bosnia_herz +652 qtn_clk_country_botswana +724 qtn_clk_country_brazil +348 qtn_clk_country_uk +528 qtn_clk_country_brunei +284 qtn_clk_country_bulgaria +613 qtn_clk_country_burkina_faso +642 qtn_clk_country_burundi +456 qtn_clk_country_cambodia +624 qtn_clk_country_cameroon +302 qtn_clk_country_canada +625 qtn_clk_country_cap_verde +346 qtn_clk_country_cayman_islands +623 qtn_clk_country_car +622 qtn_clk_country_chad +730 qtn_clk_country_chile +460 qtn_clk_country_china +732 qtn_clk_country_colombia +654 qtn_clk_country_comoros +629 qtn_clk_country_r_congo +548 qtn_clk_country_cook_islands +712 qtn_clk_country_costa_rica +612 qtn_clk_country_cotedlvoire +219 qtn_clk_country_croatia +368 qtn_clk_country_cuba +280 qtn_clk_country_cyprus +230 qtn_clk_country_czech_reb +630 qtn_clk_country_r_congo +238 qtn_clk_country_denmark +638 qtn_clk_country_djibouti +366 qtn_clk_country_dominica +370 qtn_clk_country_dominican_reb +514 qtn_clk_country_east_timor +740 qtn_clk_country_ecuador +602 qtn_clk_country_egypt +706 qtn_clk_country_el_salvador +627 qtn_clk_country_equatorial_guinea +657 qtn_clk_country_eritrea +248 qtn_clk_country_estonia +636 qtn_clk_country_ethiopia +288 qtn_clk_country_faroe_islands +542 qtn_clk_country_fiji +244 qtn_clk_country_finland +208 qtn_clk_country_france +742 qtn_clk_country_french_guiana +547 qtn_clk_country_french_polynesia +628 qtn_clk_country_gabon +607 qtn_clk_country_gambia +282 qtn_clk_country_georgia +262 qtn_clk_country_germany +620 qtn_clk_country_ghana +266 qtn_clk_country_gibraltar +202 qtn_clk_country_greece +290 qtn_clk_country_greenland +352 qtn_clk_country_grenada +340 qtn_clk_country_guadeloupe +535 qtn_clk_country_guam +704 qtn_clk_country_guatemala +611 qtn_clk_country_guinea +632 qtn_clk_country_guinea_bissau +738 qtn_clk_country_guyana +372 qtn_clk_country_haiti +708 qtn_clk_country_honduras +454 qtn_clk_country_hong_kong +216 qtn_clk_country_hungary +274 qtn_clk_country_iceland +404 qtn_clk_country_india +405 qtn_clk_country_india +510 qtn_clk_country_indonesia +432 qtn_clk_country_iran +418 qtn_clk_country_iraq +272 qtn_clk_country_ireland +425 qtn_clk_country_israel +222 qtn_clk_country_italy +338 qtn_clk_country_jamaica +441 qtn_clk_country_japan +440 qtn_clk_country_japan +416 qtn_clk_country_jordan +401 qtn_clk_country_kazakhstan +639 qtn_clk_country_kenya +545 qtn_clk_country_kiribati +467 qtn_clk_country_north_korea +450 qtn_clk_country_south_korea +419 qtn_clk_country_kuwait +437 qtn_clk_country_kyrgyzstan +457 qtn_clk_country_laos +247 qtn_clk_country_latvia +415 qtn_clk_country_lebanon +651 qtn_clk_country_lesotho +618 qtn_clk_country_liberia +606 qtn_clk_country_libya +295 qtn_clk_country_liechtenstein +246 qtn_clk_country_lithuania +270 qtn_clk_country_luxembourg +455 qtn_clk_region_macau +294 qtn_clk_country_macedonia +646 qtn_clk_country_madagascar +650 qtn_clk_country_malawi +502 qtn_clk_country_malaysia +472 qtn_clk_country_maldives +610 qtn_clk_country_mali +278 qtn_clk_country_malta +551 qtn_clk_country_marshall_islands +340 qtn_clk_country_martinique +609 qtn_clk_country_mauritania +617 qtn_clk_country_mauritius +334 qtn_clk_country_mexico +550 qtn_clk_country_micronesia +259 qtn_clk_country_moldova +212 qtn_clk_country_monaco +428 qtn_clk_country_mongolia +354 qtn_clk_country_montserrat +604 qtn_clk_country_morocco +643 qtn_clk_country_mozambique +414 qtn_clk_country_myanmar +649 qtn_clk_country_namibia +536 qtn_clk_country_nauru +429 qtn_clk_country_nepal +204 qtn_clk_country_netherlands +362 qtn_clk_country_netherlands +546 qtn_clk_country_new_caledonia +530 qtn_clk_country_new_zealand +710 qtn_clk_country_nicaragua +614 qtn_clk_country_niger +621 qtn_clk_country_nigeria +534 qtn_clk_country_n_mariana_i +242 qtn_clk_country_norway +422 qtn_clk_country_oman +410 qtn_clk_country_pakistan +552 qtn_clk_country_palau +714 qtn_clk_country_panama +537 qtn_clk_country_papua_new_g +744 qtn_clk_country_paraguay +716 qtn_clk_country_peru +515 qtn_clk_country_philippines +260 qtn_clk_country_poland +268 qtn_clk_country_portugal +330 qtn_clk_country_puerto_rico +427 qtn_clk_country_qatar +647 qtn_clk_country_reunion +226 qtn_clk_country_romania +250 qtn_clk_country_russia +635 qtn_clk_country_rwanda +356 qtn_clk_country_st_kitts_nevis +358 qtn_clk_country_st_lucia +308 qtn_clk_country_st_pierre_miquelon +360 qtn_clk_country_st_vincent_granadines +549 qtn_clk_country_usa +292 qtn_clk_country_san_marino +626 qtn_clk_country_sao_tome_principe +420 qtn_clk_country_saudi_arab +608 qtn_clk_country_senegal +220 qtn_clk_country_serbia +220 qtn_clk_country_montenegro +633 qtn_clk_country_seychelles +619 qtn_clk_country_sierra_leone +525 qtn_clk_country_singapore +231 qtn_clk_country_slovakia +293 qtn_clk_country_slovenia +540 qtn_clk_country_solomon_is +637 qtn_clk_country_somalia +655 qtn_clk_country_south_africa +214 qtn_clk_country_spain +413 qtn_clk_country_sri_lanka +634 qtn_clk_country_sudan +746 qtn_clk_country_suriname +653 qtn_clk_country_swaziland +240 qtn_clk_country_sweden +228 qtn_clk_country_switzerland +417 qtn_clk_country_syria +466 qtn_clk_country_taiwan +436 qtn_clk_country_tajikistan +640 qtn_clk_country_tanzania +520 qtn_clk_country_thailand +615 qtn_clk_country_togo +539 qtn_clk_country_tonga +374 qtn_clk_country_trinid_tobago +605 qtn_clk_country_tunisia +286 qtn_clk_country_turkey +438 qtn_clk_country_turkmenistan +376 qtn_clk_country_turks_caicos +641 qtn_clk_country_uganda +255 qtn_clk_country_ukraine +424 qtn_clk_country_arab_emirates +430 qtn_clk_country_arab_emirates +431 qtn_clk_country_arab_emirates +235 qtn_clk_country_uk +234 qtn_clk_country_uk +310 qtn_clk_country_usa +316 qtn_clk_country_usa +311 qtn_clk_country_usa +312 qtn_clk_country_usa +313 qtn_clk_country_usa +314 qtn_clk_country_usa +315 qtn_clk_country_usa +332 qtn_clk_country_usa +748 qtn_clk_country_uruguay +434 qtn_clk_country_uzbekistan +541 qtn_clk_country_vanuatu +225 qtn_clk_country_vatican +734 qtn_clk_country_venezuela +452 qtn_clk_country_vietnam +543 qtn_clk_country_wallis_futuna +421 qtn_clk_country_yemen +645 qtn_clk_country_zambia +648 qtn_clk_country_zimbabwe diff --git a/src/mcc_mapping.en_GB b/src/mcc_mapping.en_GB deleted file mode 100644 index 491e504..0000000 --- a/src/mcc_mapping.en_GB +++ /dev/null @@ -1,107 +0,0 @@ -276 Albania -213 Andorra -722 Argentina -363 Aruba -505 Australia -232 Austria -400 Azerbaijan -426 Bahrain -470 Bangladesh -257 Belarus -206 Belgium -736 Bolivia -218 Bosnia and Herzegovina -652 Botswana -724 Brazil -528 Brunei Darussalam -284 Bulgaria -456 Cambodia -302 Canada -730 Chile -460 China -732 Colombia -219 Croatia -280 Cyprus -230 Czech Republic -238 Denmark -370 Dominican Republic -740 Ecuador -602 Egypt -706 El Salvador -248 Estonia -244 Finland -208 France -282 Georgia -262 Germany -620 Ghana -266 Gibraltar -202 Greece -340 Guadeloupe -704 Guatemala -708 Honduras -454 Hong Kong, China -216 Hungary -274 Iceland -404 India -510 Indonesia -272 Ireland -425 Israel -222 Italy -338 Jamaica -440 Japan -416 Jordan -401 Kazakhstan -639 Kenya -419 Kuwait -247 Latvia -415 Lebanon -295 Liechtenstein -246 Lithuania -270 Luxembourg -455 Macao, China -294 Macedonia -502 Malaysia -472 Maldives -278 Malta -340 Martinique -334 Mexico -259 Moldova -212 Monaco -428 Mongolia -220 Montenegro -604 Morocco -204 Netherlands -530 New Zealand -621 Nigeria -242 Norway -422 Oman -410 Pakistan -714 Panama -744 Paraguay -716 Peru -515 Philippines -260 Poland -268 Portugal -427 Qatar -226 Romania -250 Russian Federation -420 Saudi Arabia -220 Serbia -525 Singapore -231 Slovakia -293 Slovenia -655 South Africa -214 Spain -413 Sri Lanka -240 Sweden -228 Switzerland -417 Syria -466 Taiwan -520 Thailand -374 Trinidad and Tobago -286 Turkey -255 Ukraine -234 United Kingdom -748 Uruguay -310 USA -734 Venezuela diff --git a/src/modest-utils.c b/src/modest-utils.c index 358228c..1f09385 100644 --- a/src/modest-utils.c +++ b/src/modest-utils.c @@ -833,60 +833,27 @@ modest_utils_on_entry_invalid_character (ModestValidatingEntry *self, } FILE* -modest_utils_open_mcc_mapping_file (gboolean from_lc_messages, gboolean *translated) +modest_utils_open_mcc_mapping_file (void) { FILE* result = NULL; const gchar* path; - const gchar *env_list; - gchar **parts, **node; - if (from_lc_messages) { - env_list = setlocale (LC_MESSAGES, NULL); + if (access (MODEST_OPERATOR_WIZARD_MCC_MAPPING, R_OK) == 0) { + path = MODEST_OPERATOR_WIZARD_MCC_MAPPING; + } else if (access (MODEST_MCC_MAPPING, R_OK) == 0) { + path = MODEST_MCC_MAPPING; } else { - env_list = getenv ("LANG"); - } - parts = g_strsplit (env_list, ":", 0); - gchar *path1 = NULL; - const gchar* path2 = MODEST_MCC_MAPPING; - - if (translated) - *translated = TRUE; - - path = NULL; - for (node = parts; path == NULL && node != NULL && *node != NULL && **node != '\0'; node++) { - path1 = g_strdup_printf ("%s.%s", MODEST_OPERATOR_WIZARD_MCC_MAPPING, *node); - if (access (path1, R_OK) == 0) { - path = path1; - break; - } else { - g_free (path1); - path1 = NULL; - } - } - g_strfreev (parts); - - if (path == NULL) { - if (access (MODEST_OPERATOR_WIZARD_MCC_MAPPING, R_OK) == 0) { - path = MODEST_OPERATOR_WIZARD_MCC_MAPPING; - if (translated) - *translated = FALSE; - } 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); - goto end; - } + g_warning ("%s: neither '%s' nor '%s' is a readable mapping file", + __FUNCTION__, MODEST_OPERATOR_WIZARD_MCC_MAPPING, MODEST_MCC_MAPPING); + return NULL; } result = fopen (path, "r"); if (!result) { g_warning ("%s: error opening mapping file '%s': %s", __FUNCTION__, path, strerror(errno)); - goto end; } - end: - g_free (path1); + return result; } @@ -942,8 +909,9 @@ parse_mcc_mapping_line (const char* line, char** country) *country = g_utf8_find_next_char (tab, NULL); /* Replace by end of string. We need to use strlen, because - g_utf8_strrchr expects bytes and not UTF8 characters */ - final = g_utf8_strrchr (tab, strlen (tab) + 1, '\n'); + g_utf8_strrchr expects bytes and not UTF8 characters. File + lines end with \r\n */ + final = g_utf8_strrchr (tab, strlen (tab) + 1, '\r'); if (G_LIKELY (final)) *final = '\0'; else @@ -978,7 +946,6 @@ modest_utils_create_country_model (void) void modest_utils_fill_country_model (GtkTreeModel *model, gint *locale_mcc) { - gboolean translated; char line[MCC_FILE_MAX_LINE_LEN]; guint previous_mcc = 0; gchar *territory; @@ -986,7 +953,7 @@ modest_utils_fill_country_model (GtkTreeModel *model, gint *locale_mcc) FILE *file; /* First we need to know our current region */ - file = modest_utils_open_mcc_mapping_file (FALSE, &translated); + file = modest_utils_open_mcc_mapping_file (); if (!file) { g_warning ("Could not open mcc_mapping file"); return; @@ -1012,25 +979,14 @@ modest_utils_fill_country_model (GtkTreeModel *model, gint *locale_mcc) previous_mcc = mcc; if (!(*locale_mcc)) { - if (translated) { - if (!g_utf8_collate (country, territory)) - *locale_mcc = mcc; - } else { - gchar *translation = dgettext ("osso-countries", country); - if (!g_utf8_collate (translation, territory)) - *locale_mcc = mcc; - } + gchar *translation = dgettext ("osso-countries", country); + if (!g_utf8_collate (translation, territory)) + *locale_mcc = mcc; } } - fclose (file); /* Now we fill the model */ - file = modest_utils_open_mcc_mapping_file (TRUE, &translated); - if (!file) { - g_warning ("Could not open mcc_mapping file"); - return; - } - + rewind (file); country_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); while (fgets (line, MCC_FILE_MAX_LINE_LEN, file) != NULL) { @@ -1056,12 +1012,16 @@ modest_utils_fill_country_model (GtkTreeModel *model, gint *locale_mcc) name_translated = dgettext ("osso-countries", country); - /* Add the row to the model: */ - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set(GTK_LIST_STORE (model), &iter, - MODEST_UTILS_COUNTRY_MODEL_COLUMN_MCC, mcc, - MODEST_UTILS_COUNTRY_MODEL_COLUMN_NAME, name_translated, - -1); + /* Add the row to the model if we have translation for it */ + if (g_utf8_collate (country, name_translated)) { + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set(GTK_LIST_STORE (model), &iter, + MODEST_UTILS_COUNTRY_MODEL_COLUMN_MCC, mcc, + MODEST_UTILS_COUNTRY_MODEL_COLUMN_NAME, name_translated, + -1); + } else { + g_debug ("%s no translation for %s", __FUNCTION__, country); + } } diff --git a/src/modest-utils.h b/src/modest-utils.h index ffc1ae2..669d778 100644 --- a/src/modest-utils.h +++ b/src/modest-utils.h @@ -202,12 +202,11 @@ void modest_utils_on_entry_invalid_character (ModestValidatingEntry *self, * modest_utils_open_mcc_mapping_file: * @translated: a #gboolean pointer * - * open the mcc mapping file, or %NULL if it fails. It also - * sets @translated to %TRUE if the file is translated + * open the mcc mapping file, or %NULL if it fails * * Returns: file ptr or %NULL in case of error */ -FILE* modest_utils_open_mcc_mapping_file (gboolean from_lc_messages, gboolean *translated); +FILE* modest_utils_open_mcc_mapping_file (void); typedef enum { MODEST_UTILS_COUNTRY_MODEL_COLUMN_NAME = 0,