From 795fc66a2d1781fd3b136b786deb32b25f67e22b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 10 Jan 2018 13:32:38 +0100 Subject: [PATCH] fix(DialPlan): remove unused wrapped functions and clean code --- coreapi/proxy.c | 4 ++-- src/c-wrapper/api/c-dial-plan.cpp | 18 +++--------------- src/dial-plan/dial-plan.cpp | 2 +- src/dial-plan/dial-plan.h | 2 +- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 39cbeaed0..d5f3ea5ad 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -660,7 +660,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c ccc = DialPlan::lookupCccFromE164(flatten); if (ccc>-1) { /*e164 like phone number*/ - dialplan = DialPlan::findByCccAsInt(ccc); + dialplan = DialPlan::findByCcc(ccc); nationnal_significant_number = strstr(flatten, dialplan.getCountryCallingCode().c_str()); if (nationnal_significant_number) { nationnal_significant_number +=strlen(dialplan.getCountryCallingCode().c_str()); @@ -679,7 +679,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c //probably generic dialplan, preserving proxy dial prefix dialplan.setCountryCallingCode(tmpproxy->dial_prefix); } - + /*it does not make sens to try replace icp with + if we are not sure from the country we are (I.E tmpproxy->dial_prefix==NULL)*/ if (strstr(flatten, dialplan.getInternationalCallPrefix().c_str()) == flatten) { char *e164 = replace_icp_with_plus(flatten, dialplan.getInternationalCallPrefix().c_str()); diff --git a/src/c-wrapper/api/c-dial-plan.cpp b/src/c-wrapper/api/c-dial-plan.cpp index a3aad76fb..af36ab06f 100644 --- a/src/c-wrapper/api/c-dial-plan.cpp +++ b/src/c-wrapper/api/c-dial-plan.cpp @@ -29,14 +29,6 @@ using namespace std; L_DECLARE_C_CLONABLE_OBJECT_IMPL(DialPlan); -LinphoneDialPlan *linphone_dial_plan_ref (LinphoneDialPlan *dp) { - return reinterpret_cast(belle_sip_object_ref(dp)); -} - -void linphone_dial_plan_unref (LinphoneDialPlan *dp) { - belle_sip_object_unref(dp); -} - const char *linphone_dial_plan_get_country (const LinphoneDialPlan *dp) { return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getCountry()); } @@ -66,21 +58,17 @@ int linphone_dial_plan_lookup_ccc_from_iso (const char *iso) { } const LinphoneDialPlan *linphone_dial_plan_by_ccc_as_int (int ccc) { - const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCccAsInt(ccc); + static const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCcc(ccc); return L_GET_C_BACK_PTR(&dp); } const LinphoneDialPlan *linphone_dial_plan_by_ccc (const char *ccc) { - const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCcc(L_C_TO_STRING(ccc)); + static const LinphonePrivate::DialPlan &dp = LinphonePrivate::DialPlan::findByCcc(L_C_TO_STRING(ccc)); return L_GET_C_BACK_PTR(&dp); } -const LinphoneDialPlan *linphone_dial_plan_get_all () { - return nullptr; -} - const bctbx_list_t *linphone_dial_plan_get_all_list () { - const list &dps = LinphonePrivate::DialPlan::getAllDialPlans(); + static const list &dps = LinphonePrivate::DialPlan::getAllDialPlans(); return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(dps); } diff --git a/src/dial-plan/dial-plan.cpp b/src/dial-plan/dial-plan.cpp index e05ec6fa1..f36fa2fbe 100644 --- a/src/dial-plan/dial-plan.cpp +++ b/src/dial-plan/dial-plan.cpp @@ -379,7 +379,7 @@ int DialPlan::lookupCccFromIso (const string &iso) { return -1; } -const DialPlan &DialPlan::findByCccAsInt (int ccc) { +const DialPlan &DialPlan::findByCcc (int ccc) { return DialPlan::findByCcc(Utils::toString(ccc)); } diff --git a/src/dial-plan/dial-plan.h b/src/dial-plan/dial-plan.h index b4be177df..6e9be89ef 100644 --- a/src/dial-plan/dial-plan.h +++ b/src/dial-plan/dial-plan.h @@ -55,7 +55,7 @@ public: static int lookupCccFromE164 (const std::string &e164); static int lookupCccFromIso (const std::string &iso); - static const DialPlan &findByCccAsInt (int ccc); + static const DialPlan &findByCcc (int ccc); static const DialPlan &findByCcc (const std::string &ccc); static const std::list &getAllDialPlans ();