Simon Busch <morp...@gravedo.de> writes: > On 03/12/11 at 12:40am, Neil Jerram wrote: >> * fsodatad/src/plugins/world/plugin.vala: Don't return a 3 digit >> prefix match while there are still countries we haven't checked yet >> that might have a full match. > > Some comments on this patch:
Thanks for taking a look. > - please use spaces for indentation only! Sure, I'll do that. > - why using debug(...) and not logger.debug(...)? I was just following the pre-existing usage in that file. All of the source files under fsodatad use debug(...). Given that, do you still want this changed? > Please send a new patch with correction of the issues mentioned above and I > will apply it. The attached has the tabs corrected, in case that's sufficient. By the way, in general do you prefer to receive patches as attachments or from git-send-email? > regards, > morphis Thanks, Neil
>From 41c73c918310d41babb1b2185430536d116b5837 Mon Sep 17 00:00:00 2001 From: Neil Jerram <n...@ossau.uklinux.net> Date: Sat, 12 Mar 2011 00:32:45 +0000 Subject: [PATCH] Fix provider code to country mapping * fsodatad/src/plugins/world/plugin.vala: Don't return a 3 digit prefix match while there are still countries we haven't checked yet that might have a full match. --- fsodatad/src/plugins/world/plugin.vala | 38 +++++++++++++++++++++----------- 1 files changed, 25 insertions(+), 13 deletions(-) diff --git a/fsodatad/src/plugins/world/plugin.vala b/fsodatad/src/plugins/world/plugin.vala index 4e2d11a..f885a1d 100644 --- a/fsodatad/src/plugins/world/plugin.vala +++ b/fsodatad/src/plugins/world/plugin.vala @@ -59,35 +59,47 @@ class World.Info : FreeSmartphone.Data.World, FsoFramework.AbstractObject public async string get_country_code_for_mcc_mnc( string mcc_mnc ) throws FreeSmartphone.Error, DBusError, IOError { + var mcc = "%c%c%c".printf( (int)mcc_mnc[0], (int)mcc_mnc[1], (int)mcc_mnc[2] ); + var prefixccode = ""; +#if DEBUG + debug( @"Looking for = $(mcc_mnc)" ); +#endif foreach ( var country in FsoData.MBPI.Database.instance().allCountries().values ) { +#if DEBUG + debug( @"Country = $(country.code)" ); +#endif foreach ( var provider in country.providers.values ) { +#if DEBUG + debug( @"Provider = $(provider.name)" ); +#endif foreach ( var code1 in provider.codes ) { +#if DEBUG + debug( @"Code = $(code1)" ); +#endif if ( code1 == mcc_mnc ) { - return country.code; - } - } #if DEBUG - debug( @"Exact match not found for $mcc_mnc; trying first three digits..." ); + debug( @"Full match with country code $(country.code)" ); #endif - var mcc = "%c%c%c".printf( (int)mcc_mnc[0], (int)mcc_mnc[1], (int)mcc_mnc[2] ); - - foreach ( var code2 in provider.codes ) - { - if ( code2.has_prefix( mcc ) ) - { return country.code; } - } + else if ( ( prefixccode == "" ) && code1.has_prefix( mcc ) ) + { #if DEBUG - debug( @"No provider with MCC $mcc found" ); + debug( @"Prefix match with country code $(country.code)" ); #endif + prefixccode = country.code; + } + } } } - return ""; +#if DEBUG + debug( @"No country/provider found with MCC $mcc" ); +#endif + return prefixccode; } public async GLib.HashTable<string,string> get_timezones_for_country_code( string country_code ) throws FreeSmartphone.Error, DBusError, IOError -- 1.7.1
_______________________________________________ Smartphones-userland mailing list Smartphones-userland@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland