]> sjero.net Git - linphone/commitdiff
add access to country code from iso name
authorJehan Monnier <jehan.monnier@linphone.org>
Fri, 31 Aug 2012 16:17:27 +0000 (18:17 +0200)
committerJehan Monnier <jehan.monnier@linphone.org>
Fri, 31 Aug 2012 16:17:27 +0000 (18:17 +0200)
coreapi/linphonecore_utils.h
coreapi/proxy.c

index bd41ec2b9e9b1b9dd1440a39c3e98f5a9930bbc6..9643856832fae7d3c4fce6ff24e0db0e527a748c 100644 (file)
@@ -86,7 +86,15 @@ typedef bool_t (*LinphoneCoreIterateHook)(void *data);
 void linphone_core_add_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data);
 
 void linphone_core_remove_iterate_hook(LinphoneCore *lc, LinphoneCoreIterateHook hook, void *hook_data);
-
+/**
+ * @ingroup misc
+ *Function to get  call country code from  ISO 3166-1 alpha-2 code, ex: FR returns 33
+ *@param iso country code alpha2
+ *@return call country code or -1 if not found
+ */
+int linphone_dial_plan_lookup_ccc_from_iso(const char* iso); 
+       
+       
 #ifdef __cplusplus
 }
 #endif
index bb01f14ee1ade10c993646db026160d6ba467da6..47fe08bdda30401886af9412814a843af33c198e 100644 (file)
@@ -375,21 +375,33 @@ bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg
  */
 typedef struct dial_plan{
        const char *country;
+       const char* iso_country_code; /* ISO 3166-1 alpha-2 code, ex: FR for France*/
        char  ccc[8]; /*country calling code*/
        int nnl; /*maximum national number length*/
        const char * icp; /*international call prefix, ex: 00 in europe*/
+       
 }dial_plan_t;
 
 /* TODO: fill with information for all countries over the world*/
 static dial_plan_t const dial_plans[]={
-       {"France"       , "33"  , 9     , "00"  },
-       {"United States", "1"   , 10    , "011" },
-       {"Turkey"       , "90"  , 10    , "00"  },
-       {"Switzerland"  , "41"  , 9     , "00"  },
-       {NULL           , ""    , 0     , NULL  }
+       {"France"                       ,"FR"           , "33"  , 9             , "00"  },
+       {"United States"        ,"US"           , "1"   , 10    , "011" },
+       {"Turkey"                       ,"TR"           , "90"  , 10    , "00"  },
+       {"Switzerland"          ,"XK"           , "41"  , 9             , "00"  },
+       {NULL           ,NULL,""        , 0     , NULL  }
 };
 
-static dial_plan_t most_common_dialplan={ "generic" , "", 10, "00"};
+static dial_plan_t most_common_dialplan={ "generic" ,"", "", 10, "00"};
+
+int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) {
+       dial_plan_t* dial_plan;
+       for (dial_plan=(dial_plan_t*)dial_plans; dial_plan->country!=NULL; dial_plan++) {
+               if (strcmp(iso, dial_plan->iso_country_code)==0) {
+                       return atoi(dial_plan->ccc);
+               }
+       }
+       return -1;
+}
 
 static void lookup_dial_plan(const char *ccc, dial_plan_t *plan){
        int i;