diff --git a/include/linphone/api/c-dial-plan.h b/include/linphone/api/c-dial-plan.h index 00339ae1b..3a11b24f1 100644 --- a/include/linphone/api/c-dial-plan.h +++ b/include/linphone/api/c-dial-plan.h @@ -33,10 +33,34 @@ * @{ */ + /** + * Returns the country name of the dialplan + * @return the country name + */ LINPHONE_PUBLIC const char * linphone_dial_plan_get_country(const LinphoneDialPlan *dp); + + /** + * Returns the iso country code of the dialplan + * @return the iso country code + */ LINPHONE_PUBLIC const char * linphone_dial_plan_get_iso_country_code(const LinphoneDialPlan *dp); + + /** + * Returns the country calling code of the dialplan + * @return the country calling code + */ LINPHONE_PUBLIC const char * linphone_dial_plan_get_country_calling_code(const LinphoneDialPlan *dp); + + /** + * Returns the national number length of the dialplan + * @return the national number length + */ LINPHONE_PUBLIC int linphone_dial_plan_get_national_number_length(const LinphoneDialPlan *dp); + + /** + * Returns the international call prefix of the dialplan + * @return the international call prefix + */ LINPHONE_PUBLIC const char * linphone_dial_plan_get_international_call_prefix(const LinphoneDialPlan *dp); /** diff --git a/src/c-wrapper/api/c-dial-plan.cpp b/src/c-wrapper/api/c-dial-plan.cpp index 2ec2f2f58..faf706a6c 100644 --- a/src/c-wrapper/api/c-dial-plan.cpp +++ b/src/c-wrapper/api/c-dial-plan.cpp @@ -19,7 +19,6 @@ #include "linphone/api/c-dial-plan.h" -#include "linphone/wrapper_utils.h" #include "c-wrapper/c-wrapper.h" #include "dial-plan/dial-plan.h" @@ -30,28 +29,23 @@ using namespace std; L_DECLARE_C_OBJECT_IMPL(DialPlan); const char * linphone_dial_plan_get_country(const LinphoneDialPlan *dp) { - //return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp).getCountry()); - return NULL; + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getCountry()); } const char * linphone_dial_plan_get_iso_country_code(const LinphoneDialPlan *dp) { - //return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp).getIsoCountryCode()); - return NULL; + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getIsoCountryCode()); } const char * linphone_dial_plan_get_country_calling_code(const LinphoneDialPlan *dp) { - //return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp).getCountryCallingCode()); - return NULL; + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getCountryCallingCode()); } int linphone_dial_plan_get_national_number_length(const LinphoneDialPlan *dp) { - //return L_GET_CPP_PTR_FROM_C_OBJECT(dp).getNationalNumberLength(); - return -1; + return L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getNationalNumberLength(); } const char * linphone_dial_plan_get_international_call_prefix(const LinphoneDialPlan *dp) { - //return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp).getInternationalCallPrefix()); - return NULL; + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(dp)->getInternationalCallPrefix()); } int linphone_dial_plan_lookup_ccc_from_e164(const char* e164) { @@ -63,15 +57,13 @@ int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) { } const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_int(int ccc) { - //LinphonePrivate::DialPlan dp = LinphonePrivate::DialPlan::findByCccAsInt(ccc); - //return L_GET_C_BACK_PTR(); - return NULL; //TODO + const LinphonePrivate::DialPlan& dp = LinphonePrivate::DialPlan::findByCccAsInt(ccc); + return L_GET_C_BACK_PTR(&dp); } const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { - //LinphonePrivate::DialPlan dp = LinphonePrivate::DialPlan::findByCcc(L_C_TO_STRING(ccc)); - //return L_GET_C_BACK_PTR(); - return NULL; //TODO + 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() { @@ -79,12 +71,10 @@ const LinphoneDialPlan* linphone_dial_plan_get_all() { } const bctbx_list_t * linphone_dial_plan_get_all_list() { - //const list dps = LinphonePrivate::DialPlan::getAllDialPlans(); - //return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(); - return NULL; //TODO + const list& dps = LinphonePrivate::DialPlan::getAllDialPlans(); + return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(dps); } bool_t linphone_dial_plan_is_generic(const LinphoneDialPlan *ccc) { - //return L_GET_CPP_PTR_FROM_C_OBJECT(ccc).isGeneric(); - return FALSE; + return L_GET_CPP_PTR_FROM_C_OBJECT(ccc)->isGeneric(); } \ No newline at end of file diff --git a/src/c-wrapper/c-wrapper.h b/src/c-wrapper/c-wrapper.h index c7322f97e..6b932c0c5 100644 --- a/src/c-wrapper/c-wrapper.h +++ b/src/c-wrapper/c-wrapper.h @@ -37,6 +37,7 @@ F(ChatRoom, ChatRoom) \ F(ConferenceEvent, ConferenceEvent) \ F(ConferenceParticipantEvent, ConferenceParticipantEvent) \ + F(DialPlan, DialPlan) \ F(EventLog, EventLog) \ F(MediaSessionParams, CallParams) \ F(Participant, Participant) @@ -72,7 +73,6 @@ BELLE_SIP_TYPE_ID(LinphoneContactSearch), BELLE_SIP_TYPE_ID(LinphoneContent), BELLE_SIP_TYPE_ID(LinphoneCore), BELLE_SIP_TYPE_ID(LinphoneCoreCbs), -BELLE_SIP_TYPE_ID(LinphoneDialPlan), BELLE_SIP_TYPE_ID(LinphoneErrorInfo), BELLE_SIP_TYPE_ID(LinphoneEvent), BELLE_SIP_TYPE_ID(LinphoneFactory), diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index f533caf50..e36e288f4 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -381,7 +381,7 @@ public: static inline bctbx_list_t *getResolvedCListFromCppList (const std::list &cppList) { bctbx_list_t *result = nullptr; for (const auto &value : cppList) - result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(value))); + result = bctbx_list_append(result, belle_sip_object_ref(getCBackPtr(&value))); return result; } diff --git a/src/dial-plan/dial-plan.cpp b/src/dial-plan/dial-plan.cpp index 8b66c1bce..af6146b0e 100644 --- a/src/dial-plan/dial-plan.cpp +++ b/src/dial-plan/dial-plan.cpp @@ -34,7 +34,7 @@ LINPHONE_BEGIN_NAMESPACE * http://en.wikipedia.org/wiki/Telephone_numbers_in_Europe * imported from https://en.wikipedia.org/wiki/List_of_mobile_phone_number_series_by_country */ -static list const DialPlans = { +list const DialPlan::DialPlans = { //Country , iso country code, e164 country calling code, number length, international usual prefix {"Afghanistan" ,"AF" , "93" , 9 , "00" }, {"Albania" ,"AL" , "355" , 9 , "00" },