From a193141d086f05fafbb424768449a758b18a7b8b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 26 Oct 2016 12:13:30 +0200 Subject: [PATCH 01/42] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 3e5e374d4..a734c0cb4 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3e5e374d4e5cb1a0b39e2dfa2c926180b5de35fa +Subproject commit a734c0cb4fbf403636fc2d09a5e8cac91b0b3215 From a24787cfa511ad86da60022be19828c09c39963e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 26 Oct 2016 14:30:22 +0200 Subject: [PATCH 02/42] Update ortp submodule. --- oRTP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oRTP b/oRTP index b1b2c1c27..2ef223888 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit b1b2c1c2729400762050cdb247a466cd2636d92c +Subproject commit 2ef223888157b71d755530a2628f07e9bb9b8900 From 85ffd1e5929feeccb1d4768750906e80829c699f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 26 Oct 2016 15:49:10 +0200 Subject: [PATCH 03/42] Fix build of Python module + fix memory leak of bctbx_list_t objects in the wrapper. --- coreapi/authentication.c | 2 +- coreapi/conference.h | 2 +- coreapi/friendlist.h | 4 +- coreapi/help/Doxyfile.in | 2 +- coreapi/linphone_tunnel.h | 2 +- coreapi/linphonecore.c | 6 +-- coreapi/linphonecore.h | 18 +++---- coreapi/linphonefriend.h | 6 +-- coreapi/lpconfig.h | 6 +-- coreapi/vcard.h | 10 ++-- tools/genapixml.py | 8 +-- .../handwritten_declarations.mustache | 6 +-- .../handwritten_definitions.mustache | 4 +- tools/python/apixml2python/linphone.py | 54 ++++++++++++------- .../apixml2python/linphone_module.mustache | 8 +-- 15 files changed, 78 insertions(+), 60 deletions(-) diff --git a/coreapi/authentication.c b/coreapi/authentication.c index ec956f5f1..773e31fc0 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -484,7 +484,7 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *in /** * Returns an unmodifiable list of currently entered LinphoneAuthInfo. * @param[in] lc The LinphoneCore object - * @return \mslist{LinphoneAuthInfo} + * @return \bctbx_list{LinphoneAuthInfo} **/ const bctbx_list_t *linphone_core_get_auth_info_list(const LinphoneCore *lc){ return lc->auth_info; diff --git a/coreapi/conference.h b/coreapi/conference.h index 269e442f1..1359327cc 100644 --- a/coreapi/conference.h +++ b/coreapi/conference.h @@ -103,7 +103,7 @@ LINPHONE_PUBLIC int linphone_conference_remove_participant(LinphoneConference *o * The returned bctbx_list_t contains URIs of all participant. That list must be * freed after use and each URI must be unref with linphone_address_unref() * @param obj A #LinphoneConference - * @return \mslist{LinphoneAddress} + * @return \bctbx_list{LinphoneAddress} */ LINPHONE_PUBLIC bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj); diff --git a/coreapi/friendlist.h b/coreapi/friendlist.h index 78ff3ca2f..c4c3b78cb 100644 --- a/coreapi/friendlist.h +++ b/coreapi/friendlist.h @@ -87,7 +87,7 @@ LINPHONE_PUBLIC void linphone_core_remove_friend_list(LinphoneCore *lc, Linphone /** * Retrieves the list of LinphoneFriendList from the core. * @param[in] lc LinphoneCore object - * @return \mslist{LinphoneFriendList} a list of LinphoneFriendList + * @return \bctbx_list{LinphoneFriendList} a list of LinphoneFriendList */ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friends_lists(const LinphoneCore *lc); @@ -196,7 +196,7 @@ LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_remove_friend(Linp /** * Retrieves the list of LinphoneFriend from this LinphoneFriendList. * @param[in] list LinphoneFriendList object - * @return \mslist{LinphoneFriend} a list of LinphoneFriend + * @return \bctbx_list{LinphoneFriend} a list of LinphoneFriend */ LINPHONE_PUBLIC const bctbx_list_t * linphone_friend_list_get_friends(const LinphoneFriendList *list); diff --git a/coreapi/help/Doxyfile.in b/coreapi/help/Doxyfile.in index b0230913f..f3b62161a 100644 --- a/coreapi/help/Doxyfile.in +++ b/coreapi/help/Doxyfile.in @@ -228,7 +228,7 @@ TAB_SIZE = 8 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = "mslist{1}=A list of \ref \1 objects. \xmlonly \1 \endxmlonly" +ALIASES = "bctbx_list{1}=A list of \ref \1 objects. \xmlonly \1 \endxmlonly" # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index 399875f46..5716b4fc3 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -227,7 +227,7 @@ LINPHONE_PUBLIC void linphone_tunnel_remove_server(LinphoneTunnel *tunnel, Linph /** * Get added servers * @param tunnel LinphoneTunnel object - * @return \mslist{LinphoneTunnelConfig} + * @return \bctbx_list{LinphoneTunnelConfig} */ LINPHONE_PUBLIC const bctbx_list_t *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e98633ca7..b53345f4a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1975,7 +1975,7 @@ LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc){ /** * Sets the list of audio codecs. * @param[in] lc The LinphoneCore object - * @param[in] codecs \mslist{PayloadType} + * @param[in] codecs \bctbx_list{PayloadType} * @return 0 * * @ingroup media_parameters @@ -1993,7 +1993,7 @@ int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *codecs){ /** * Sets the list of video codecs. * @param[in] lc The LinphoneCore object - * @param[in] codecs \mslist{PayloadType} + * @param[in] codecs \bctbx_list{PayloadType} * @return 0 * * @ingroup media_parameters @@ -4130,7 +4130,7 @@ int linphone_core_terminate_all_calls(LinphoneCore *lc){ /** * Returns the current list of calls. * @param[in] lc The LinphoneCore object - * @return \mslist{LinphoneCall} + * @return \bctbx_list{LinphoneCall} * * Note that this list is read-only and might be changed by the core after a function call to linphone_core_iterate(). * Similarly the LinphoneCall objects inside it might be destroyed without prior notice. diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 4eb5335f6..b2392c648 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1583,7 +1583,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr); * Gets nb_message most recent messages from cr chat room, sorted from oldest to most recent. * @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved * @param[in] nb_message Number of message to retrieve. 0 means everything. - * @return \mslist{LinphoneChatMessage} + * @return \bctbx_list{LinphoneChatMessage} */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message); @@ -1592,7 +1592,7 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *c * @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which messages should be retrieved * @param[in] begin The first message of the range to be retrieved. History most recent message has index 0. * @param[in] end The last message of the range to be retrieved. History oldest message has index of history size - 1 (use #linphone_chat_room_get_history_size to retrieve history size) - * @return \mslist{LinphoneChatMessage} + * @return \bctbx_list{LinphoneChatMessage} */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end); @@ -1643,7 +1643,7 @@ LINPHONE_PUBLIC uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr) /** * Returns an list of chat rooms * @param[in] lc #LinphoneCore object - * @return \mslist{LinphoneChatRoom} + * @return \bctbx_list{LinphoneChatRoom} **/ LINPHONE_PUBLIC const bctbx_list_t* linphone_core_get_chat_rooms(LinphoneCore *lc); LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *msg); @@ -2912,7 +2912,7 @@ LINPHONE_PUBLIC void linphone_core_set_dns_servers(LinphoneCore *lc, const bctbx /** * Returns the list of available audio codecs. * @param[in] lc The LinphoneCore object - * @return \mslist{PayloadType} + * @return \bctbx_list{PayloadType} * * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. @@ -2927,7 +2927,7 @@ LINPHONE_PUBLIC int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_ /** * Returns the list of available video codecs. * @param[in] lc The LinphoneCore object - * @return \mslist{PayloadType} + * @return \bctbx_list{PayloadType} * * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. @@ -2942,7 +2942,7 @@ LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_ /** * Returns the list of available text codecs. * @param[in] lc The LinphoneCore object - * @return \mslist{PayloadType} + * @return \bctbx_list{PayloadType} * * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. @@ -3078,7 +3078,7 @@ LINPHONE_PUBLIC void linphone_core_remove_proxy_config(LinphoneCore *lc, Linphon /** * Returns an unmodifiable list of entered proxy configurations. * @param[in] lc The LinphoneCore object - * @return \mslist{LinphoneProxyConfig} + * @return \bctbx_list{LinphoneProxyConfig} **/ LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_proxy_config_list(const LinphoneCore *lc); @@ -3539,7 +3539,7 @@ LINPHONE_PUBLIC void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *l /** * Get the list of call logs (past calls). * @param[in] lc LinphoneCore object - * @return \mslist{LinphoneCallLog} + * @return \bctbx_list{LinphoneCallLog} **/ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *lc); @@ -3548,7 +3548,7 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *l * At the contrary of linphone_core_get_call_logs, it is your responsability to unref the logs and free this list once you are done using it. * @param[in] lc LinphoneCore object * @param[in] addr LinphoneAddress object - * @return \mslist{LinphoneCallLog} + * @return \bctbx_list{LinphoneCallLog} **/ LINPHONE_PUBLIC bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr); diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index af6f995d8..2e48ca96e 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -175,7 +175,7 @@ LINPHONE_PUBLIC void linphone_friend_add_address(LinphoneFriend *lf, const Linph /** * Returns a list of #LinphoneAddress for this friend * @param lf #LinphoneFriend object - * @return \mslist{LinphoneAddress} + * @return \bctbx_list{LinphoneAddress} */ LINPHONE_PUBLIC const bctbx_list_t* linphone_friend_get_addresses(const LinphoneFriend *lf); @@ -196,7 +196,7 @@ LINPHONE_PUBLIC void linphone_friend_add_phone_number(LinphoneFriend *lf, const /** * Returns a list of phone numbers for this friend * @param lf #LinphoneFriend object - * @return \mslist{const char *} + * @return \bctbx_list{const char *} */ LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf); @@ -444,7 +444,7 @@ LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneF /** * Get Buddy list of LinphoneFriend * @param[in] lc #LinphoneCore object - * @return \mslist{LinphoneFriend} + * @return \bctbx_list{LinphoneFriend} * @deprecated use linphone_core_get_friends_lists() or linphone_friend_list_get_friends() instead. */ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index 59269098e..09a1f8d97 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -111,8 +111,8 @@ LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const * @param[in] lpconfig A LpConfig object * @param[in] section The section from which to retrieve a configuration item * @param[in] key The name of the configuration item to retrieve - * @param[in] default_list \mslist{const char *} - * @return \mslist{const char *} + * @param[in] default_list \bctbx_list{const char *} + * @return \bctbx_list{const char *} */ LINPHONE_PUBLIC bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list); @@ -162,7 +162,7 @@ LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section * @param[in] lpconfig A LpConfig object * @param[in] section The name of the section to put the configuration item into * @param[in] key The name of the configuration item to set - * @param[in] value \mslist{const char *} The value to set + * @param[in] value \bctbx_list{const char *} The value to set */ LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value); diff --git a/coreapi/vcard.h b/coreapi/vcard.h index 7e72b5347..709aff046 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -88,7 +88,7 @@ LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard); * Uses belcard to parse the content of a file and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none. * @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time) * @param[in] file the path to the file to parse - * @return \mslist{LinphoneVcard} + * @return \bctbx_list{LinphoneVcard} */ LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardContext *context, const char *file); @@ -96,7 +96,7 @@ LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(Li * Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none. * @param[in] context the vCard context to use (speed up the process by not creating a Belcard parser each time) * @param[in] buffer the buffer to parse - * @return \mslist{LinphoneVcard} + * @return \bctbx_list{LinphoneVcard} */ LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardContext *context, const char *buffer); @@ -181,7 +181,7 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_ /** * Returns the list of SIP addresses (as LinphoneAddress) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL * @param[in] vCard the LinphoneVcard - * @return const \mslist{LinphoneAddress *} + * @return \bctbx_list{LinphoneAddress} */ LINPHONE_PUBLIC const bctbx_list_t* linphone_vcard_get_sip_addresses(LinphoneVcard *vCard); @@ -202,7 +202,7 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) /** * Returns the list of phone numbers (as string) in the vCard (all the TEL attributes) or NULL * @param[in] vCard the LinphoneVcard - * @return \mslist{const char *} + * @return \bctbx_list{const char *} */ LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard); @@ -293,4 +293,4 @@ void linphone_vcard_clean_cache(LinphoneVcard *vCard); } #endif -#endif \ No newline at end of file +#endif diff --git a/tools/genapixml.py b/tools/genapixml.py index 4c9d3374a..4326055ad 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -305,7 +305,7 @@ class Project: para.remove(n) for n in para.findall('.//ref'): n.attrib = {} - for n in para.findall(".//mslist"): + for n in para.findall(".//bctbx_list"): para.remove(n) if descriptionNode.tag == 'parameterdescription': descriptionNode.tag = 'description' @@ -439,7 +439,7 @@ class Project: returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']") if returndesc is not None: if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t': - n = returndesc.find('.//mslist') + n = returndesc.find('.//bctbxlist') if n is not None: returnarg.containedType = n.text returnarg.description = self.__cleanDescription(returndesc) @@ -510,7 +510,7 @@ class Project: returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']") if returndesc is not None: if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t': - n = returndesc.find('.//mslist') + n = returndesc.find('.//bctbxlist') if n is not None: returnarg.containedType = n.text returnarg.description = self.__cleanDescription(returndesc) @@ -533,7 +533,7 @@ class Project: for paramdesc in paramdescs: if arg.name == paramdesc.find('./parameternamelist').find('./parametername').text: if arg.ctype == 'MSList' or arg.ctype == 'bctbx_list_t': - n = paramdesc.find('.//mslist') + n = paramdesc.find('.//bctbxlist') if n is not None: arg.containedType = n.text arg.description = self.__cleanDescription(paramdesc.find('./parameterdescription')) diff --git a/tools/python/apixml2python/handwritten_declarations.mustache b/tools/python/apixml2python/handwritten_declarations.mustache index ca7cfd1c4..5f87cc257 100644 --- a/tools/python/apixml2python/handwritten_declarations.mustache +++ b/tools/python/apixml2python/handwritten_declarations.mustache @@ -24,8 +24,8 @@ typedef struct { LCSipTransports lcst; } pylinphone_SipTransportsObject; -PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl); -bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl); +PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl); +bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl); int PyLinphoneVideoSize_Check(PyObject *p); MSVideoSize PyLinphoneVideoSize_AsMSVideoSize(PyObject *obj); @@ -44,4 +44,4 @@ static int pylinphone_Buffer_set_content(PyObject *self, PyObject *value, void * static PyObject * pylinphone_Content_get_buffer(PyObject *self, void *closure); static int pylinphone_Content_set_buffer(PyObject *self, PyObject *value, void *closure); -static PyObject * pylinphone_LpConfig_get_sections_names(PyObject *self, void *closure); \ No newline at end of file +static PyObject * pylinphone_LpConfig_get_sections_names(PyObject *self, void *closure); diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index f87dfe7f2..fb27b8864 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -1,4 +1,4 @@ -PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl) { +PyObject * PyList_FromBctbxListOfString(const bctbx_list_t *msl) { PyObject *pyl = PyList_New(0); while (msl != NULL) { PyObject *item = Py_BuildValue("z", (const char *)msl->data); @@ -8,7 +8,7 @@ PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl) { return pyl; } -bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl) { +bctbx_list_t * PyList_AsBctbxListOfString(PyObject *pyl) { bctbx_list_t *msl = NULL; Py_ssize_t idx; Py_ssize_t size = PyList_Size(pyl); diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 288660327..483cd93ed 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -53,6 +53,10 @@ def compute_event_name(s, className): first = False return event_name +def is_const_from_complete_type(complete_type): + splitted_type = complete_type.split(' ') + return 'const' in splitted_type + class HandWrittenCode: def __init__(self, _class, name, func_list, doc = ''): @@ -95,6 +99,7 @@ class ArgumentType: self.check_condition = None self.convert_code = None self.convert_from_func = None + self.free_convert_result_func = None self.fmt_str = 'O' self.cfmt_str = '%p' self.cnativefmt_str = '%p' @@ -102,7 +107,7 @@ class ArgumentType: self.cast_convert_func_result = True self.__compute() if (self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t') and self.contained_type is not None and self.contained_type != 'const char *': - self.linphone_module.mslist_types.add(self.contained_type) + self.linphone_module.bctbxlist_types.add(self.contained_type) def __compute(self): splitted_type = self.complete_type.split(' ') @@ -217,12 +222,14 @@ class ArgumentType: elif self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t': if self.contained_type == 'const char *': self.type_str = 'list of string' - self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOfString({arg_name});\n" - self.convert_from_func = 'PyList_FromMSListOfString' + self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsBctbxListOfString({arg_name});\n" + self.convert_from_func = 'PyList_FromBctbxListOfString' else: self.type_str = 'list of linphone.' + self.contained_type - self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOf" + self.contained_type + "({arg_name});\n" - self.convert_from_func = 'PyList_FromMSListOf' + self.contained_type + self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsBctbxListOf" + self.contained_type + "({arg_name});\n" + self.convert_from_func = 'PyList_FromBctbxListOf' + self.contained_type + if not is_const_from_complete_type(self.complete_type): + self.free_convert_result_func = "bctbx_list_free" self.check_condition = "!PyList_Check({arg_name})" self.fmt_str = 'O' self.cfmt_str = '%p' @@ -372,6 +379,7 @@ class MethodDefinition: def format_c_function_call(self): arg_names = [] c_function_call_code = '' + cfree_argument_code = '' for xml_method_arg in self.xml_method_args: arg_name = "_" + xml_method_arg.get('name') arg_type = xml_method_arg.get('type') @@ -382,6 +390,10 @@ class MethodDefinition: arg_names.append(arg_name + "_native_ptr") elif argument_type.fmt_str == 'O' and argument_type.convert_code is not None: arg_names.append(arg_name + "_native_obj") + if argument_type.free_convert_result_func is not None and not is_const_from_complete_type(arg_complete_type): + cfree_argument_code = \ +"""{free_func}({arg_name}_native_obj); +""".format(free_func=argument_type.free_convert_result_func, arg_name=arg_name) else: arg_names.append(arg_name) if is_callback(self.return_complete_type): @@ -412,6 +424,10 @@ class MethodDefinition: convert_from_code = \ """pyresult = {convert_func}(cresult); """.format(convert_func=return_argument_type.convert_from_func) + if return_argument_type.free_convert_result_func is not None: + cfree_code = \ +"""{free_func}(cresult); +""".format(free_func=return_argument_type.free_convert_result_func) result_variable = 'pyresult' else: result_variable = 'cresult' @@ -421,12 +437,14 @@ class MethodDefinition: cfree_code = 'ms_free(cresult);'; body = \ """ {c_function_call_code} + {cfree_argument_code} pylinphone_dispatch_messages(); {from_native_pointer_code} {convert_from_code} {build_value_code} {cfree_code} """.format(c_function_call_code=c_function_call_code, + cfree_argument_code=cfree_argument_code, from_native_pointer_code=from_native_pointer_code, convert_from_code=convert_from_code, build_value_code=build_value_code, @@ -535,12 +553,6 @@ class MethodDefinition: self.self_arg = self.xml_method_args[0] self.xml_method_args = self.xml_method_args[1:] - def remove_const_from_complete_type(self, complete_type): - splitted_type = complete_type.split(' ') - while 'const' in splitted_type: - splitted_type.remove('const') - return ' '.join(splitted_type) - def find_class_definition(self, basic_type): basic_type = strip_leading_linphone(basic_type) for c in self.linphone_module.classes: @@ -799,15 +811,21 @@ class SetterMethodDefinition(MethodDefinition): """ {method_name}(native_ptr, pylinphone_{class_name}_callback_{callback_name}); pylinphone_dispatch_messages(); """.format(method_name=self.method_node.get('name'), class_name=self.class_['class_name'], callback_name=compute_event_name(self.first_argument_type.complete_type, self.class_['class_name'])) + cfree_argument_code = '' suffix = '' if self.first_argument_type.fmt_str == 'O' and self.first_argument_type.use_native_pointer: suffix = '_native_ptr' elif self.first_argument_type.fmt_str == 'O' and self.first_argument_type.convert_code is not None: suffix = '_native_obj' + if self.first_argument_type.free_convert_result_func is not None and not is_const_from_complete_type(self.first_argument_type.complete_type): + cfree_argument_code = \ +"""{free_func}({arg_name}_native_obj); +""".format(free_func=self.first_argument_type.free_convert_result_func, arg_name="_" + self.first_arg_name) return \ """ {method_name}(native_ptr, {arg_name}{suffix}); + {cfree_argument_code} pylinphone_dispatch_messages(); -""".format(arg_name="_" + self.first_arg_name, method_name=self.method_node.get('name'), suffix=suffix) +""".format(arg_name="_" + self.first_arg_name, method_name=self.method_node.get('name'), suffix=suffix, cfree_argument_code=cfree_argument_code) def format_return_trace(self): return "\tpylinphone_trace(-1, \"[PYLINPHONE] <<< %s -> 0\", __FUNCTION__);\n" @@ -989,7 +1007,7 @@ class LinphoneModule(object): def __init__(self, tree, blacklisted_classes, blacklisted_events, blacklisted_functions, hand_written_codes): self.internal_instance_method_names = ['destroy', 'ref', 'unref'] self.internal_property_names = ['user_data'] - self.mslist_types = Set([]) + self.bctbxlist_types = Set([]) self.enums = [] self.enum_names = [] self.cfunction2methodmap = {} @@ -1225,14 +1243,14 @@ class LinphoneModule(object): except Exception, e: e.args += (c['class_name'], 'dealloc_body') raise - # Convert mslist_types to a list of dictionaries for the template + # Convert bctbxlist_types to a list of dictionaries for the template d = [] - for mslist_type in self.mslist_types: + for bctbxlist_type in self.bctbxlist_types: t = {} - t['c_contained_type'] = mslist_type - t['python_contained_type'] = strip_leading_linphone(mslist_type) + t['c_contained_type'] = bctbxlist_type + t['python_contained_type'] = strip_leading_linphone(bctbxlist_type) d.append(t) - self.mslist_types = d + self.bctbxlist_types = d def __format_doc_node(self, node): desc = '' diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index aca0bd6ca..deadebe2b 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -71,8 +71,8 @@ static PyObject * pylinphone_{{class_name}}_instance_method_{{method_name}}(PyOb {{/class_instance_hand_written_methods}} {{/classes}} -{{#mslist_types}} -PyObject * PyList_FromMSListOf{{c_contained_type}}(const bctbx_list_t *msl) { +{{#bctbxlist_types}} +PyObject * PyList_FromBctbxListOf{{c_contained_type}}(const bctbx_list_t *msl) { PyObject *pyl = PyList_New(0); while (msl != NULL) { {{c_contained_type}} *native_ptr = ({{c_contained_type}} *)msl->data; @@ -83,7 +83,7 @@ PyObject * PyList_FromMSListOf{{c_contained_type}}(const bctbx_list_t *msl) { return pyl; } -bctbx_list_t * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) { +bctbx_list_t * PyList_AsBctbxListOf{{c_contained_type}}(PyObject *pyl) { bctbx_list_t *msl = NULL; Py_ssize_t idx; Py_ssize_t size = PyList_Size(pyl); @@ -95,7 +95,7 @@ bctbx_list_t * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) { return msl; } -{{/mslist_types}} +{{/bctbxlist_types}} {{#core_events}} {{{event_callback_definition}}} From 7fb33e2fa3aeb369d3c692c3f3212cbfbd365ca6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 26 Oct 2016 15:51:22 +0200 Subject: [PATCH 04/42] Fix account_creator_is_account_linked not being used error --- coreapi/linphonecore_jni.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index a42b688c6..447d5761c 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8252,6 +8252,7 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JN linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_is_account_activated); linphone_account_creator_cbs_set_recover_phone_account(cbs, account_creator_phone_account_recovered); linphone_account_creator_cbs_set_is_phone_number_used(cbs, account_creator_is_phone_number_used); + linphone_account_creator_cbs_set_is_account_linked(cbs, account_creator_is_account_linked); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { From 4cea53d26ae2a512974eb2a9298c853a2d945848 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 27 Oct 2016 11:35:14 +0200 Subject: [PATCH 05/42] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index a734c0cb4..09fd8b4b8 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a734c0cb4fbf403636fc2d09a5e8cac91b0b3215 +Subproject commit 09fd8b4b83ab85e028503a7758cfa2f7d0ab0601 From 21556edba3e01b195b1b8a180d624c242cb208fd Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sun, 30 Oct 2016 10:13:34 +0100 Subject: [PATCH 06/42] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 09fd8b4b8..b4cd8284c 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 09fd8b4b83ab85e028503a7758cfa2f7d0ab0601 +Subproject commit b4cd8284c086ac2aa297a00b1a536f3f762d83d0 From 3e91c26f8af0695fe346062d033f23a01ec946f9 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 31 Oct 2016 15:58:01 +0100 Subject: [PATCH 07/42] Remove useless setcontext for linphonecore --- java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 4fbb4de04..46597507d 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -130,7 +130,6 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { File factory = factoryConfig == null ? null : new File(factoryConfig); LinphoneCore lc = new LinphoneCoreImpl(listener, user, factory, userdata); lc.enableOpenH264(openh264Enabled); - if(context!=null) lc.setContext(context); return lc; } catch (IOException e) { throw new LinphoneCoreException("Cannot create LinphoneCore",e); @@ -145,7 +144,6 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { MediastreamerAndroidContext.setContext(context); LinphoneCore lc = new LinphoneCoreImpl(listener); lc.enableOpenH264(openh264Enabled); - if(context!=null) lc.setContext(context); return lc; } catch (IOException e) { throw new LinphoneCoreException("Cannot create LinphoneCore",e); From cdb72ebf7d013a8119c39e0d897ce0aec664d538 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 Nov 2016 16:12:16 +0100 Subject: [PATCH 08/42] Fix call recovery testers that were failing when run one after an other. --- coreapi/linphonecall.c | 36 ++++++++++++++++++++++++++---------- tester/call_single_tester.c | 24 +++++++++++++++--------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 4838e89e6..a657ec11e 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -5160,6 +5160,10 @@ void linphone_call_repair_if_broken(LinphoneCall *call){ case LinphoneCallOutgoingRinging: linphone_call_repair_by_invite_with_replaces(call); break; + case LinphoneCallIncomingEarlyMedia: + case LinphoneCallIncomingReceived: + /* Keep the call broken until a forked INVITE is received from the server. */ + break; default: ms_warning("linphone_call_repair_if_broken(): don't know what to do in state [%s]", linphone_call_state_to_string(call->state)); call->broken = FALSE; @@ -5178,16 +5182,8 @@ void linphone_call_refresh_sockets(LinphoneCall *call){ } void linphone_call_replace_op(LinphoneCall *call, SalOp *op) { - switch (linphone_call_get_state(call)) { - case LinphoneCallConnected: - case LinphoneCallStreamsRunning: - sal_call_terminate(call->op); - break; - default: - break; - } - sal_op_kill_dialog(call->op); - sal_op_release(call->op); + SalOp *oldop = call->op; + LinphoneCallState oldstate = linphone_call_get_state(call); call->op = op; sal_op_set_user_pointer(call->op, call); sal_call_set_local_media_description(call->op, call->localdesc); @@ -5204,4 +5200,24 @@ void linphone_call_replace_op(LinphoneCall *call, SalOp *op) { ms_warning("linphone_call_replace_op(): don't know what to do in state [%s]", linphone_call_state_to_string(call->state)); break; } + switch (oldstate) { + case LinphoneCallIncomingEarlyMedia: + case LinphoneCallIncomingReceived: + sal_op_set_user_pointer(oldop, NULL); /* To make the call does not get terminated by terminating this op. */ + /* Do not terminate a forked INVITE */ + if (sal_call_get_replaces(op)) { + sal_call_terminate(oldop); + } else { + sal_op_kill_dialog(oldop); + } + break; + case LinphoneCallConnected: + case LinphoneCallStreamsRunning: + sal_call_terminate(oldop); + sal_op_kill_dialog(oldop); + break; + default: + break; + } + sal_op_release(oldop); } diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 601b3ad34..116d00009 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4159,6 +4159,7 @@ static void call_record_with_custom_rtp_modifier(void) { } static void recovered_call_on_network_switch_in_early_state_1(void) { + const LinphoneCallParams *remote_params; LinphoneCall *incoming_call; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -4174,6 +4175,12 @@ static void recovered_call_on_network_switch_in_early_state_1(void) { BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 2)); incoming_call = linphone_core_get_current_call(pauline->lc); + remote_params = linphone_call_get_remote_params(incoming_call); + BC_ASSERT_PTR_NOT_NULL(remote_params); + if (remote_params != NULL) { + const char *replaces_header = linphone_call_params_get_custom_header(remote_params, "Replaces"); + BC_ASSERT_PTR_NOT_NULL(replaces_header); + } linphone_core_accept_call(pauline->lc, incoming_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); @@ -4198,7 +4205,6 @@ static void recovered_call_on_network_switch_in_early_state_2(void) { incoming_call = linphone_core_get_current_call(pauline->lc); linphone_core_accept_call(pauline->lc, incoming_call); - //linphone_core_iterate(pauline->lc); linphone_core_set_network_reachable(marie->lc, FALSE); wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1); linphone_core_set_network_reachable(marie->lc, TRUE); @@ -5393,14 +5399,14 @@ test_t call_tests[] = { TEST_NO_TAG("Call record with custom RTP Modifier", call_record_with_custom_rtp_modifier), TEST_NO_TAG("Call with network switch", call_with_network_switch), TEST_NO_TAG("Call with network switch and no recovery possible", call_with_network_switch_no_recovery), - TEST_NO_TAG("Recovered call on network switch in early state 1", recovered_call_on_network_switch_in_early_state_1), - TEST_NO_TAG("Recovered call on network switch in early state 2", recovered_call_on_network_switch_in_early_state_2), - TEST_NO_TAG("Recovered call on network switch in early state 3", recovered_call_on_network_switch_in_early_state_3), - TEST_NO_TAG("Recovered call on network switch in early state 4", recovered_call_on_network_switch_in_early_state_4), - TEST_NO_TAG("Recovered call on network switch during re-invite 1", recovered_call_on_network_switch_during_reinvite_1), - TEST_NO_TAG("Recovered call on network switch during re-invite 2", recovered_call_on_network_switch_during_reinvite_2), - TEST_NO_TAG("Recovered call on network switch during re-invite 3", recovered_call_on_network_switch_during_reinvite_3), - TEST_NO_TAG("Recovered call on network switch during re-invite 4", recovered_call_on_network_switch_during_reinvite_4), + TEST_ONE_TAG("Recovered call on network switch in early state 1", recovered_call_on_network_switch_in_early_state_1, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 2", recovered_call_on_network_switch_in_early_state_2, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 3", recovered_call_on_network_switch_in_early_state_3, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch in early state 4", recovered_call_on_network_switch_in_early_state_4, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 1", recovered_call_on_network_switch_during_reinvite_1, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 2", recovered_call_on_network_switch_during_reinvite_2, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 3", recovered_call_on_network_switch_during_reinvite_3, "CallRecovery"), + TEST_ONE_TAG("Recovered call on network switch during re-invite 4", recovered_call_on_network_switch_during_reinvite_4, "CallRecovery"), TEST_ONE_TAG("Call with network switch and ICE", call_with_network_switch_and_ice, "ICE"), TEST_ONE_TAG("Call with network switch, ICE and RTT", call_with_network_switch_ice_and_rtt, "ICE"), TEST_NO_TAG("Call with network switch with socket refresh", call_with_network_switch_and_socket_refresh), From a2318062c530b65996e53c56747079b89a677f2f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 Nov 2016 16:49:37 +0100 Subject: [PATCH 09/42] Fix possible leak of STUN resolver context. --- coreapi/nat_policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 2d0826ef9..6bae4df98 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -41,6 +41,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); if (policy->stun_resolver_context) { sal_resolve_cancel(policy->stun_resolver_context); + sal_resolver_context_unref(policy->stun_resolver_context); } } From ce1955ff05e0844c0c8e0de51a366afd69abc181 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 Nov 2016 17:06:13 +0100 Subject: [PATCH 10/42] Revert "Fix possible leak of STUN resolver context." This reverts commit a2318062c530b65996e53c56747079b89a677f2f. --- coreapi/nat_policy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 6bae4df98..2d0826ef9 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -41,7 +41,6 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); if (policy->stun_resolver_context) { sal_resolve_cancel(policy->stun_resolver_context); - sal_resolver_context_unref(policy->stun_resolver_context); } } From eee46cc5df6487584fea77f8799e2889be664d9f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 2 Nov 2016 20:45:08 +0100 Subject: [PATCH 11/42] mandatory media encryption is available for all RTP encryption methods. --- gtk/propertybox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtk/propertybox.c b/gtk/propertybox.c index a356f09c6..470196d0f 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -1297,7 +1297,7 @@ static void linphone_gtk_media_encryption_changed(GtkWidget *combo){ gtk_widget_set_sensitive(mandatory_box,TRUE); }else if (strcasecmp(selected,"ZRTP")==0){ linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionZRTP); - gtk_widget_set_sensitive(mandatory_box,FALSE); + gtk_widget_set_sensitive(mandatory_box,TRUE); } else { linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionNone); gtk_widget_set_sensitive(mandatory_box,FALSE); @@ -1389,7 +1389,7 @@ static void linphone_gtk_show_media_encryption(GtkWidget *pb){ case LinphoneMediaEncryptionZRTP: if (zrtp_id!=-1) { gtk_combo_box_set_active(GTK_COMBO_BOX(combo),zrtp_id); - linphone_gtk_set_media_encryption_mandatory_sensitive(pb,FALSE); + linphone_gtk_set_media_encryption_mandatory_sensitive(pb,TRUE); } break; } From 3c3cb9f1cf1e71268ea8da2cb47da4bc2143d898 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Nov 2016 09:43:47 +0100 Subject: [PATCH 12/42] fix compilation error --- coreapi/help/realtimetext_sender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/help/realtimetext_sender.c b/coreapi/help/realtimetext_sender.c index 5e4bfdf84..64493008d 100644 --- a/coreapi/help/realtimetext_sender.c +++ b/coreapi/help/realtimetext_sender.c @@ -111,7 +111,7 @@ int main(int argc, char *argv[]){ /* main loop for sending message and doing background linphonecore work: */ while(running){ - char character; + int character; /*to disable terminal buffering*/ if (system ("/bin/stty raw") == -1){ ms_error("/bin/stty error"); From 8aa52c36a9c680e906357093b8f450f5b77bdb19 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 3 Nov 2016 11:11:04 +0100 Subject: [PATCH 13/42] Prevent useless DNS resolution of STUN server. --- coreapi/nat_policy.c | 3 +-- tester/call_single_tester.c | 19 ++++++++++++------- tester/call_video_tester.c | 3 +++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 2d0826ef9..a16bc8104 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -185,7 +185,6 @@ void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char * } if (new_stun_server != NULL) { policy->stun_server = new_stun_server; - linphone_nat_policy_resolve_stun_server(policy); } } @@ -250,7 +249,7 @@ const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNat * - if no cached value exists, block for a short time; this case must be unprobable because the resolution will be asked each * time the stun server value is changed. */ - if (linphone_nat_policy_stun_server_activated(policy)) { + if (linphone_nat_policy_stun_server_activated(policy) && (policy->stun_addrinfo == NULL)) { int wait_ms = 0; int wait_limit = 1000; linphone_nat_policy_resolve_stun_server(policy); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 116d00009..7042346cf 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -1325,39 +1325,41 @@ static void ice_added_by_reinvite(void){ LinphoneCallParams *params; LinphoneCall *c; bool_t call_ok; - + lp_config_set_int(linphone_core_get_config(marie->lc), "net", "allow_late_ice", 1); lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "allow_late_ice", 1); BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; liblinphone_tester_check_rtcp(marie,pauline); - + /*enable ICE on both ends*/ pol = linphone_core_get_nat_policy(marie->lc); linphone_nat_policy_enable_ice(pol, TRUE); linphone_nat_policy_enable_stun(pol, TRUE); linphone_core_set_nat_policy(marie->lc, pol); - + pol = linphone_core_get_nat_policy(pauline->lc); linphone_nat_policy_enable_ice(pol, TRUE); linphone_nat_policy_enable_stun(pol, TRUE); linphone_core_set_nat_policy(pauline->lc, pol); - + + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + c = linphone_core_get_current_call(marie->lc); params = linphone_core_create_call_params(marie->lc, c); linphone_core_update_call(marie->lc, c, params); linphone_call_params_destroy(params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1)); /*wait for the ICE reINVITE*/ BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); - + end_call(pauline, marie); - + end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -1800,6 +1802,9 @@ static void audio_call_with_ice_no_matching_audio_codecs(void) { linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + out_call = linphone_core_invite_address(marie->lc, pauline->identity); linphone_call_ref(out_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 62a19ae23..354a9b325 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -1092,6 +1092,9 @@ static void call_with_ice_video_and_rtt(void) { linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + linphone_core_set_audio_port(marie->lc, -1); linphone_core_set_video_port(marie->lc, -1); linphone_core_set_text_port(marie->lc, -1); From 5fe70faf8f0f70319f563d32245b9e45ff226c5c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Nov 2016 11:58:42 +0100 Subject: [PATCH 14/42] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index b4cd8284c..3a1db4a3b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b4cd8284c086ac2aa297a00b1a536f3f762d83d0 +Subproject commit 3a1db4a3b30bfb3044d3dfb8c977fe66300c44f2 From b930b64e25faa0ae50a8a37de77b5ede56923006 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 3 Nov 2016 15:20:15 +0100 Subject: [PATCH 15/42] Update ortp submodule. --- oRTP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oRTP b/oRTP index 2ef223888..49fdc102f 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 2ef223888157b71d755530a2628f07e9bb9b8900 +Subproject commit 49fdc102fe59adda8011a9d554493749aebad35b From 1e0661a2684ebaf3e57219e7b18235773d2b14cb Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 3 Nov 2016 17:27:28 +0100 Subject: [PATCH 16/42] fix linphone_proxy_config_normalize_number for better optionnal num part handling --- coreapi/dial_plan.c | 24 +++++++--- coreapi/linphonecore_utils.h | 8 +++- coreapi/proxy.c | 87 +++++++++++++++++++----------------- tester/local_tester_hosts | 5 ++- tester/proxy_config_tester.c | 20 +++++---- 5 files changed, 86 insertions(+), 58 deletions(-) diff --git a/coreapi/dial_plan.c b/coreapi/dial_plan.c index 6441cb2f3..90bfc7627 100644 --- a/coreapi/dial_plan.c +++ b/coreapi/dial_plan.c @@ -261,6 +261,10 @@ int linphone_dial_plan_lookup_ccc_from_e164(const char* e164) { LinphoneDialPlan* elected_dial_plan=NULL; unsigned int found; unsigned int i=0; + + if (e164[0]!='+') { + return -1;/*not an e164 number*/ + } if (e164[1]=='1') { /*USA case*/ return 1; @@ -292,14 +296,13 @@ int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) { return -1; } -const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { +const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_ushort(unsigned short ccc) { int i; - if (!ccc) { - return &most_common_dialplan; - } - + char ccc_as_char[4] = {0}; + snprintf(ccc_as_char,sizeof(ccc_as_char),"%i",ccc); + for(i=0;dial_plans[i].country!=NULL;++i){ - if (strcmp(ccc,dial_plans[i].ccc)==0){ + if (strcmp(ccc_as_char,dial_plans[i].ccc)==0){ return &dial_plans[i]; } } @@ -307,6 +310,15 @@ const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { return &most_common_dialplan; } + +const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { + if (!ccc) { + return &most_common_dialplan; + } + + return linphone_dial_plan_by_ccc_as_ushort(strtol(ccc,NULL,10)); +} + const LinphoneDialPlan* linphone_dial_plan_get_all() { return dial_plans; } diff --git a/coreapi/linphonecore_utils.h b/coreapi/linphonecore_utils.h index 83c46054c..411608460 100644 --- a/coreapi/linphonecore_utils.h +++ b/coreapi/linphonecore_utils.h @@ -133,7 +133,13 @@ LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_get_all(void); * @return Return matching dial plan, or a generic one if none found **/ LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc); - +/** + * Find best match for given CCC + * @return Return matching dial plan, or a generic one if none found + **/ +LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_ushort(unsigned short ccc); + + /** * Return if given plan is generic **/ diff --git a/coreapi/proxy.c b/coreapi/proxy.c index f344f6307..66fa4b01a 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -594,19 +594,8 @@ static char *flatten_number(const char *number){ char *result=ms_malloc0(strlen(number)+1); char *w=result; const char *r; - bool_t removing_trunk_prefix = FALSE; for(r=number;*r!='\0';++r){ - if (result[0] == '+') { - /*e164 case*/ - if (*r=='(') { - /*start removing trunk prefix as we are in form +33 (0) 6 222222*/ - removing_trunk_prefix=TRUE; - } else if (*r==')') { - /*stop removing trunk prefix*/ - removing_trunk_prefix=FALSE; - } - } - if (removing_trunk_prefix == FALSE && (*r=='+' || isdigit(*r))){ + if (*r=='+' || isdigit(*r)){ *w++=*r; } } @@ -634,46 +623,62 @@ bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, const char *username) { LinphoneProxyConfig *tmpproxy = proxy ? proxy : linphone_proxy_config_new(); char* result = NULL; + LinphoneDialPlan dialplan = {0}; + char * nationnal_significant_number = NULL; + int ccc = -1; + if (linphone_proxy_config_is_phone_number(tmpproxy, username)){ - LinphoneDialPlan dialplan = *linphone_dial_plan_by_ccc(tmpproxy->dial_prefix); //copy dial plan; char * flatten=flatten_number(username); ms_debug("Flattened number is '%s' for '%s'",flatten, username); - if (tmpproxy->dial_prefix){ - if (strcmp(tmpproxy->dial_prefix,dialplan.ccc) != 0){ - //probably generic dialplan, preserving proxy dial prefix - strncpy(dialplan.ccc,tmpproxy->dial_prefix,sizeof(dialplan.ccc)); + ccc = linphone_dial_plan_lookup_ccc_from_e164(flatten); + if (ccc>-1) { /*e164 like phone number*/ + dialplan = *linphone_dial_plan_by_ccc_as_ushort(ccc); + nationnal_significant_number = strnstr(flatten, dialplan.ccc,4 /*+ +maximun 3 digits*/); + if (nationnal_significant_number) { + nationnal_significant_number +=strlen(dialplan.ccc); } + } else if (flatten[0] =='+') { + ms_message ("Unknown ccc for e164 like number [%s]", flatten); + goto end; + } else { + dialplan = *linphone_dial_plan_by_ccc(tmpproxy->dial_prefix); //copy dial plan; + if (tmpproxy->dial_prefix){ + if (strcmp(tmpproxy->dial_prefix,dialplan.ccc) != 0){ + //probably generic dialplan, preserving proxy dial prefix + strncpy(dialplan.ccc,tmpproxy->dial_prefix,sizeof(dialplan.ccc)); + } + } + if (strnstr(flatten,dialplan.icp,strlen(dialplan.icp))==flatten) { + char *e164 = replace_icp_with_plus(flatten,dialplan.icp); + result = linphone_proxy_config_normalize_phone_number(tmpproxy,e164); + ms_free(e164); + goto end; + } + nationnal_significant_number=flatten; } + /*if proxy has a dial prefix, modify phonenumber accordingly*/ - if (tmpproxy->dial_prefix!=NULL && tmpproxy->dial_prefix[0]!='\0'){ + if (dialplan.ccc[0]!='\0') { ms_debug("Using dial plan '%s'",dialplan.country); /* the number already starts with + or international prefix*/ - if (flatten[0]=='+'||strstr(flatten,dialplan.icp)==flatten){ - ms_debug("Prefix already present."); - if (tmpproxy->dial_escape_plus) { - result = replace_plus_with_icp(flatten,dialplan.icp); - } else { - result = replace_icp_with_plus(flatten,dialplan.icp); - } - }else{ - /*0. keep at most national number significant digits */ - char* flatten_start = flatten + MAX(0, (int)strlen(flatten) - (int)dialplan.nnl); - ms_debug("Prefix not present. Keeping at most %d digits: %s", dialplan.nnl, flatten_start); + /*0. keep at most national number significant digits */ + char* nationnal_significant_number_start = nationnal_significant_number + + MAX(0, (int)strlen(nationnal_significant_number) + - (int)dialplan.nnl); + ms_debug("Prefix not present. Keeping at most %d digits: %s", dialplan.nnl, nationnal_significant_number_start); - /*1. First prepend international calling prefix or +*/ - /*2. Second add prefix*/ - /*3. Finally add user digits */ - result = ms_strdup_printf("%s%s%s" - , tmpproxy->dial_escape_plus ? dialplan.icp : "+" - , dialplan.ccc - , flatten_start); - ms_debug("Prepended prefix resulted in %s", result); - } - }else if (tmpproxy->dial_escape_plus){ - /* user did not provide dial prefix, so we'll take the most generic one */ - result = replace_plus_with_icp(flatten,dialplan.icp); + /*1. First prepend international calling prefix or +*/ + /*2. Second add prefix*/ + /*3. Finally add user digits */ + result = ms_strdup_printf("%s%s%s" + , tmpproxy->dial_escape_plus ? dialplan.icp : "+" + , dialplan.ccc + , nationnal_significant_number_start); + ms_debug("Prepended prefix resulted in %s", result); } + + end: if (result==NULL) { result = flatten; } else { diff --git a/tester/local_tester_hosts b/tester/local_tester_hosts index de1edc48c..0a78dd3e9 100644 --- a/tester/local_tester_hosts +++ b/tester/local_tester_hosts @@ -1 +1,4 @@ -127.0.0.1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org +127.0.0.1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org sipv4.example.org +2001:41d0:2:14b0::1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org +188.165.46.90 tunnel.wildcard2.linphone.org +64:ff9b::94.23.19.176 sipv4-nat64.example.org diff --git a/tester/proxy_config_tester.c b/tester/proxy_config_tester.c index 9e9afd6ec..edd01f04f 100644 --- a/tester/proxy_config_tester.c +++ b/tester/proxy_config_tester.c @@ -36,10 +36,10 @@ static void phone_normalization_without_proxy(void) { BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "012 345 6789"), "0123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33012345678"), "+33012345678"); - BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 0012345678"), "+330012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 0012345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33012345678"), "+33012345678"); - BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+3301234567891"), "+3301234567891"); - BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 01234567891"), "+3301234567891"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+3301234567891"), "+33234567891"); + BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "+33 01234567891"), "+33234567891"); BC_ASSERT_PTR_NULL(phone_normalization(NULL, "I_AM_NOT_A_NUMBER")); // invalid phone number BC_ASSERT_STRING_EQUAL(phone_normalization(NULL, "0"), "0"); @@ -59,14 +59,16 @@ static void phone_normalization_with_proxy(void) { LinphoneProxyConfig *proxy = linphone_proxy_config_new(); linphone_proxy_config_set_dial_prefix(proxy, "33"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "012 3456 789"), "+33123456789"); + linphone_proxy_config_set_dial_prefix(proxy, NULL); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33123456789"), "+33123456789"); - BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33 0123456789"), "+330123456789"); - BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330012345678"), "+330012345678"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33 0123456789"), "+33123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330012345678"), "+33012345678"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301 2345678"), "+33012345678"); - BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567891"), "+3301234567891"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567891"), "+33234567891"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33 (0) 1 23 45 67 89"), "+33123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+90 (903) 1234567"), "+909031234567"); - + linphone_proxy_config_set_dial_prefix(proxy, "33"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, " 0123456789"), "+33123456789"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "0012345678"), "+12345678"); @@ -106,8 +108,8 @@ static void phone_normalization_with_proxy(void) { BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123456"), "+330123456"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567"), "+3301234567"); BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+33012345678"), "+33012345678"); - BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123456789"), "+330123456789"); - BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567890"), "+3301234567890"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+330123456789"), "+33123456789"); + BC_ASSERT_STRING_EQUAL(phone_normalization(proxy, "+3301234567890"), "+33234567890"); // invalid prefix - use a generic dialplan with 10 max length linphone_proxy_config_set_dial_prefix(proxy, "99"); From 64ac0d50819fb1e400a1a744cdd9fdf7286b70a9 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Nov 2016 22:57:40 +0100 Subject: [PATCH 17/42] If multicast is used, create RTP socket with the same address familly as the multicast address, in order to workaround issues with dual stack sockets and multicast, especially on mac os. --- coreapi/linphonecall.c | 9 ++++++--- mediastreamer2 | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a657ec11e..bbf1b27ff 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -668,13 +668,16 @@ static const char *linphone_call_get_bind_ip_for_stream(LinphoneCall *call, int const char *bind_ip = lp_config_get_string(call->core->config,"rtp","bind_address", call->af == AF_INET6 ? "::0" : "0.0.0.0"); PortConfig *pc = &call->media_ports[stream_index]; - if (stream_index<2 && pc->multicast_ip[0]!='\0'){ + if (pc->multicast_ip[0]!='\0'){ if (call->dir==LinphoneCallOutgoing){ /*as multicast sender, we must decide a local interface to use to send multicast, and bind to it*/ linphone_core_get_local_ip_for(strchr(pc->multicast_ip,':') ? AF_INET6 : AF_INET, NULL, pc->multicast_bind_ip); bind_ip = pc->multicast_bind_ip; - + }else{ + /*otherwise we shall use an address family of the same family of the multicast address, because + * dual stack socket and multicast don't work well on Mac OS (linux is OK, as usual).*/ + bind_ip = strchr(pc->multicast_ip,':') ? "::0" : "0.0.0.0"; } } return bind_ip; @@ -683,7 +686,7 @@ static const char *linphone_call_get_bind_ip_for_stream(LinphoneCall *call, int static const char *linphone_call_get_public_ip_for_stream(LinphoneCall *call, int stream_index){ const char *public_ip=call->media_localip; - if (stream_index<2 && call->media_ports[stream_index].multicast_ip[0]!='\0') + if (call->media_ports[stream_index].multicast_ip[0]!='\0') public_ip=call->media_ports[stream_index].multicast_ip; return public_ip; } diff --git a/mediastreamer2 b/mediastreamer2 index 3a1db4a3b..3f00520a6 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3a1db4a3b30bfb3044d3dfb8c977fe66300c44f2 +Subproject commit 3f00520a6159dfe53f85f8e6e26ff79dc54f6277 From 5762a1e94d0e0e657d645a6bc0bc9e84e5511676 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 4 Nov 2016 08:49:38 +0100 Subject: [PATCH 18/42] replace strnstr by strstr because more portable --- coreapi/proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 66fa4b01a..bac2334b2 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -634,7 +634,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c ccc = linphone_dial_plan_lookup_ccc_from_e164(flatten); if (ccc>-1) { /*e164 like phone number*/ dialplan = *linphone_dial_plan_by_ccc_as_ushort(ccc); - nationnal_significant_number = strnstr(flatten, dialplan.ccc,4 /*+ +maximun 3 digits*/); + nationnal_significant_number = strstr(flatten, dialplan.ccc); if (nationnal_significant_number) { nationnal_significant_number +=strlen(dialplan.ccc); } @@ -649,7 +649,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c strncpy(dialplan.ccc,tmpproxy->dial_prefix,sizeof(dialplan.ccc)); } } - if (strnstr(flatten,dialplan.icp,strlen(dialplan.icp))==flatten) { + if (strstr(flatten,dialplan.icp)==flatten) { char *e164 = replace_icp_with_plus(flatten,dialplan.icp); result = linphone_proxy_config_normalize_phone_number(tmpproxy,e164); ms_free(e164); From 42ad4a004e77aed1a93f171212fb310e7309efd6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 4 Nov 2016 09:12:35 +0100 Subject: [PATCH 19/42] fix compilation issue --- coreapi/proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index bac2334b2..404476af0 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -603,9 +603,9 @@ static char *flatten_number(const char *number){ return result; } -static char* replace_plus_with_icp(char *phone, const char* icp){ +/*static char* replace_plus_with_icp(char *phone, const char* icp){ return (icp && phone[0]=='+') ? ms_strdup_printf("%s%s", icp, phone+1) : ms_strdup(phone); -} +}*/ static char* replace_icp_with_plus(char *phone, const char *icp){ return (strstr(phone, icp) == phone) ? ms_strdup_printf("+%s", phone+strlen(icp)) : ms_strdup(phone); From 2504ad83796eaa0daea906c43c9578fb9d218ab1 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 4 Nov 2016 09:29:57 +0100 Subject: [PATCH 20/42] fix c90 compilation issue --- coreapi/proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 404476af0..ca875b07b 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -657,10 +657,10 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c } nationnal_significant_number=flatten; } + ms_debug("Using dial plan '%s'",dialplan.country); /*if proxy has a dial prefix, modify phonenumber accordingly*/ if (dialplan.ccc[0]!='\0') { - ms_debug("Using dial plan '%s'",dialplan.country); /* the number already starts with + or international prefix*/ /*0. keep at most national number significant digits */ char* nationnal_significant_number_start = nationnal_significant_number From a567e95ee1055e8ddb652f09fc5f831085421ce4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 10:33:47 +0100 Subject: [PATCH 21/42] fix compilation errors on windows --- coreapi/dial_plan.c | 8 ++++---- coreapi/linphonecore_utils.h | 2 +- coreapi/proxy.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/coreapi/dial_plan.c b/coreapi/dial_plan.c index 90bfc7627..2c36723d7 100644 --- a/coreapi/dial_plan.c +++ b/coreapi/dial_plan.c @@ -296,10 +296,10 @@ int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) { return -1; } -const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_ushort(unsigned short ccc) { +const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_int(int ccc) { int i; - char ccc_as_char[4] = {0}; - snprintf(ccc_as_char,sizeof(ccc_as_char),"%i",ccc); + char ccc_as_char[16] = {0}; + snprintf(ccc_as_char,sizeof(ccc_as_char)-1,"%i",ccc); for(i=0;dial_plans[i].country!=NULL;++i){ if (strcmp(ccc_as_char,dial_plans[i].ccc)==0){ @@ -316,7 +316,7 @@ const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *ccc) { return &most_common_dialplan; } - return linphone_dial_plan_by_ccc_as_ushort(strtol(ccc,NULL,10)); + return linphone_dial_plan_by_ccc_as_int((int)strtol(ccc,NULL,10)); } const LinphoneDialPlan* linphone_dial_plan_get_all() { diff --git a/coreapi/linphonecore_utils.h b/coreapi/linphonecore_utils.h index 411608460..d7da908ac 100644 --- a/coreapi/linphonecore_utils.h +++ b/coreapi/linphonecore_utils.h @@ -137,7 +137,7 @@ LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc(const char *cc * Find best match for given CCC * @return Return matching dial plan, or a generic one if none found **/ -LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_ushort(unsigned short ccc); +LINPHONE_PUBLIC const LinphoneDialPlan* linphone_dial_plan_by_ccc_as_int(int ccc); /** diff --git a/coreapi/proxy.c b/coreapi/proxy.c index ca875b07b..6203f1f19 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -633,7 +633,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c ccc = linphone_dial_plan_lookup_ccc_from_e164(flatten); if (ccc>-1) { /*e164 like phone number*/ - dialplan = *linphone_dial_plan_by_ccc_as_ushort(ccc); + dialplan = *linphone_dial_plan_by_ccc_as_int(ccc); nationnal_significant_number = strstr(flatten, dialplan.ccc); if (nationnal_significant_number) { nationnal_significant_number +=strlen(dialplan.ccc); From df5339911df9ab442f073b84b3f753f980da4864 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 11:36:19 +0100 Subject: [PATCH 22/42] fix bug resulting in LinphoneFriend's main sip address not being updated. --- coreapi/friend.c | 4 ++-- tester/presence_tester.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 16bf62912..03f0f05ae 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -744,8 +744,6 @@ void linphone_friend_edit(LinphoneFriend *fr) { void linphone_friend_done(LinphoneFriend *fr) { ms_return_if_fail(fr); if (!fr->lc) return; - linphone_friend_apply(fr, fr->lc); - linphone_friend_save(fr, fr->lc); if (fr && linphone_core_vcard_supported() && fr->vcard) { if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) { @@ -756,6 +754,8 @@ void linphone_friend_done(LinphoneFriend *fr) { } } } + linphone_friend_apply(fr, fr->lc); + linphone_friend_save(fr, fr->lc); } #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 823dd19e6..24dd44052 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -545,7 +545,9 @@ static void simple_subscribe_with_friend_from_rc(void) { if (bctbx_list_size(linphone_core_get_friend_list(marie->lc))>0) { pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data; + linphone_friend_edit(pauline_as_friend); linphone_friend_set_address(pauline_as_friend, pauline->identity); /*hack to update addr with port number*/ + linphone_friend_done(pauline_as_friend); } BC_ASSERT_TRUE (wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnline,1)); From 48d88e2ab81d67c5c780106d1b16c77b476b3fa1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 15:27:57 +0100 Subject: [PATCH 23/42] fix bad subject and update ms2 for ICE bugfix --- coreapi/linphonecore.c | 2 +- mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b53345f4a..03b344712 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3568,7 +3568,7 @@ int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){ subject="Conference"; }else if (call->params->internal_call_update){ subject="ICE processing concluded"; - }else if (!no_user_consent){ + }else if (no_user_consent){ subject="Refreshing"; }else{ subject="Media change"; diff --git a/mediastreamer2 b/mediastreamer2 index 3f00520a6..8497e612c 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3f00520a6159dfe53f85f8e6e26ff79dc54f6277 +Subproject commit 8497e612c327d203ce0a64bd6d938738df1878f8 From b78cc33f9a15e7575c306ad36b5a78e60d100226 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 4 Nov 2016 16:36:58 +0100 Subject: [PATCH 24/42] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 8497e612c..56a978c04 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 8497e612c327d203ce0a64bd6d938738df1878f8 +Subproject commit 56a978c041f84ec4bdebf50debbe71b23dafcafd From 3bc59a20c78efc9705db715b4e72cc921e54c835 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Fri, 4 Nov 2016 16:59:52 +0100 Subject: [PATCH 25/42] Add synchronize to add and remove listener method --- coreapi/vtables.c | 4 +- .../org/linphone/core/LinphoneCoreImpl.java | 58 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 12ca9fc30..e106fef01 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -43,7 +43,7 @@ LinphoneCoreVTable *linphone_core_get_current_vtable(LinphoneCore *lc) { static void cleanup_dead_vtable_refs(LinphoneCore *lc){ bctbx_list_t *it,*next_it; - + if (lc->vtable_notify_recursion > 0) return; /*don't cleanup vtable if we are iterating through a listener list.*/ for(it=lc->vtable_refs; it!=NULL; ){ VTableReference *ref=(VTableReference*)it->data; @@ -327,7 +327,7 @@ void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable){ void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable) { bctbx_list_t *it; - ms_message("Vtable [%p] unregistered on core [%p]",lc,vtable); + ms_message("Vtable [%p] unregistered on core [%p]",vtable,lc); for(it=lc->vtable_refs; it!=NULL; it=it->next){ VTableReference *ref=(VTableReference*)it->data; if (ref->vtable==vtable) diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 40cbf5416..61a44582e 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -222,13 +222,13 @@ class LinphoneCoreImpl implements LinphoneCore { mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); setAndroidPowerManager(mContext.getSystemService(Context.POWER_SERVICE)); if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) { - WifiManager wifiManager=(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); + WifiManager wifiManager=(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiLock lock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "linphonecore ["+ nativePtr+"] wifi-lock"); lock.setReferenceCounted(true); setAndroidWifiLock(nativePtr,lock); } if (Version.sdkAboveOrEqual(Version.API14_ICE_CREAM_SANDWICH_40)) { - WifiManager wifiManager=(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); + WifiManager wifiManager=(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); MulticastLock lock = wifiManager.createMulticastLock("linphonecore ["+ nativePtr+"] multicast-lock"); lock.setReferenceCounted(true); setAndroidMulticastLock(nativePtr, lock); @@ -476,17 +476,17 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void addFriend(LinphoneFriend lf) throws LinphoneCoreException { addFriend(nativePtr, ((LinphoneFriendImpl) lf).nativePtr); } - + public synchronized LinphoneFriendList createLinphoneFriendList() { return new LinphoneFriendListImpl(this); } - + public synchronized void addFriendList(LinphoneFriendList friendList) throws LinphoneCoreException { addFriendList(nativePtr,((LinphoneFriendListImpl)friendList).nativePtr); } - + public synchronized void removeFriendList(LinphoneFriendList friendList) throws LinphoneCoreException { removeFriendList(nativePtr,((LinphoneFriendListImpl)friendList).nativePtr); } @@ -494,7 +494,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized LinphoneFriend[] getFriendList() { return getFriendList(nativePtr); } - + private native LinphoneFriendList[] getFriendLists(long nativePtr); public synchronized LinphoneFriendList[] getFriendLists() { return getFriendLists(nativePtr); @@ -932,25 +932,25 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void tunnelEnable(boolean enable) { tunnelEnable(nativePtr, enable); } - + private native void tunnelSetMode(long nativePtr, int mode); @Override public synchronized void tunnelSetMode(LinphoneCore.TunnelMode mode) { tunnelSetMode(nativePtr, TunnelMode.enumToInt(mode)); } - + private native int tunnelGetMode(long nativePtr); @Override public synchronized LinphoneCore.TunnelMode tunnelGetMode() { return LinphoneCore.TunnelMode.intToEnum(tunnelGetMode(nativePtr)); } - + private native void tunnelEnableSip(long nativePtr, boolean enable); @Override public void tunnelEnableSip(boolean enable) { tunnelEnableSip(nativePtr, enable); } - + private native boolean tunnelSipEnabled(long nativePtr); @Override public boolean tunnelSipEnabled() { @@ -1270,7 +1270,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setCallLogsDatabasePath(String path) { setCallLogsDatabasePath(nativePtr, path); } - + public synchronized void setFriendsDatabasePath(String path) { setFriendsDatabasePath(nativePtr, path); } @@ -1453,13 +1453,13 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized void setVideoJittcomp(int value) { setVideoJittcomp(nativePtr, value); } - + private native void setFileTransferServer(long ptr, String serverUrl); @Override public synchronized void setFileTransferServer(String serverUrl) { setFileTransferServer(nativePtr, serverUrl); } - + private native String getFileTransferServer(long ptr); @Override public synchronized String getFileTransferServer() { @@ -1476,16 +1476,16 @@ class LinphoneCoreImpl implements LinphoneCore { return null; } } - + private native void addListener(long nativePtr, LinphoneCoreListener listener); @Override - public void addListener(LinphoneCoreListener listener) { + public synchronized void addListener(LinphoneCoreListener listener) { addListener(nativePtr, listener); } - + private native void removeListener(long nativePtr, LinphoneCoreListener listener); @Override - public void removeListener(LinphoneCoreListener listener) { + public synchronized void removeListener(LinphoneCoreListener listener) { removeListener(nativePtr, listener); } private native void setRemoteRingbackTone(long nativePtr, String file); @@ -1498,7 +1498,7 @@ class LinphoneCoreImpl implements LinphoneCore { public String getRemoteRingbackTone() { return getRemoteRingbackTone(nativePtr); } - + private native void uploadLogCollection(long nativePtr); @Override public void uploadLogCollection() { @@ -1507,7 +1507,7 @@ class LinphoneCoreImpl implements LinphoneCore { @Override public native void resetLogCollection(); - + private native void setPreferredFramerate(long nativePtr, float fps); @Override public void setPreferredFramerate(float fps) { @@ -1518,8 +1518,8 @@ class LinphoneCoreImpl implements LinphoneCore { public float getPreferredFramerate() { return getPreferredFramerate(nativePtr); } - - + + private native int setAudioMulticastAddr(long nativePtr, String ip); @Override public void setAudioMulticastAddr(String ip) throws LinphoneCoreException { @@ -1547,18 +1547,18 @@ class LinphoneCoreImpl implements LinphoneCore { public void setAudioMulticastTtl(int ttl) throws LinphoneCoreException { if (setAudioMulticastTtl(nativePtr, ttl)!=0) throw new LinphoneCoreException("bad ttl value ["+ttl+"]"); - + } private native int setVideoMulticastTtl(long ptr,int ttl); @Override public void setVideoMulticastTtl(int ttl) throws LinphoneCoreException { if (setVideoMulticastTtl(nativePtr, ttl)!=0) - throw new LinphoneCoreException("bad ttl value ["+ttl+"]"); + throw new LinphoneCoreException("bad ttl value ["+ttl+"]"); } private native int getAudioMulticastTtl(long ptr); @Override public int getAudioMulticastTtl() { - return getAudioMulticastTtl(nativePtr); + return getAudioMulticastTtl(nativePtr); } private native int getVideoMulticastTtl(long ptr); @Override @@ -1576,7 +1576,7 @@ class LinphoneCoreImpl implements LinphoneCore { return audioMulticastEnabled(nativePtr); } private native void enableVideoMulticast(long ptr,boolean yesno); - + @Override public void enableVideoMulticast(boolean yesno) { enableVideoMulticast(nativePtr,yesno); @@ -1683,7 +1683,7 @@ class LinphoneCoreImpl implements LinphoneCore { public void setSipNetworkReachable(boolean isReachable) { setSipNetworkReachable(nativePtr, isReachable); } - + private native void setMediaNetworkReachable(long nativePtr, boolean isReachable); @Override public void setMediaNetworkReachable(boolean isReachable) { @@ -1717,17 +1717,17 @@ class LinphoneCoreImpl implements LinphoneCore { public void setDefaultSoundDevices() { setDefaultSoundDevices(nativePtr); } - + private native boolean isLimeEncryptionAvailable(long nativePtr); public synchronized boolean isLimeEncryptionAvailable() { return isLimeEncryptionAvailable(nativePtr); } - + private native void setLimeEncryption(long nativePtr, int value); public synchronized void setLimeEncryption(LinphoneLimeState lime) { setLimeEncryption(nativePtr, lime.mValue); } - + private native int getLimeEncryption(long nativePtr); public synchronized LinphoneLimeState getLimeEncryption() { return LinphoneLimeState.fromInt(getLimeEncryption(nativePtr)); From 651830fda325d1fa873938e4caae6e24f0bb7ce1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 22:48:12 +0100 Subject: [PATCH 26/42] add new test and skip a test that cannot work on windows. --- tester/eventapi_tester.c | 63 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 76533857b..a4cbb1d87 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -307,6 +307,12 @@ static void subscribe_test_manually_refreshed(void){ } static void subscribe_loosing_dialog(void) { +#ifdef WIN32 + /*Unfortunately this test doesn't work on windows due to the way closed TCP ports behave. + * Unlike linux and macOS, released TCP port don't send an ICMP error (or maybe at least for a period of time. + * This prevents this test from working, see comments below*/ + ms_warning("subscribe_loosing_dialog() skipped on windows."); +#else LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneContent* content; @@ -345,12 +351,16 @@ static void subscribe_loosing_dialog(void) { pauline = linphone_core_manager_new( "pauline_tcp_rc"); lcs = bctbx_list_append(lcs, pauline->lc); - /*marie will retry the subscription*/ + /* Marie will retry the subscription. + * She will first receive a 503 Service unavailable from flexisip thanks the ICMP error returned by the no longer existing Pauline. + * Then she will forge a new SUBSCRIBE in order to restart a new dialog, and this one will reach the new Pauline.*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingProgress,2,8000)); /*and get it accepted again*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,5000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,5000)); - BC_ASSERT_EQUAL(linphone_event_get_subscription_state(pauline->lev), LinphoneSubscriptionActive, int, "%d"); + BC_ASSERT_PTR_NOT_NULL(pauline->lev); + if (pauline->lev) BC_ASSERT_EQUAL(linphone_event_get_subscription_state(pauline->lev), LinphoneSubscriptionActive, int, "%d"); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,2,5000)); linphone_event_terminate(lev); @@ -362,6 +372,7 @@ static void subscribe_loosing_dialog(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); bctbx_list_free(lcs); +#endif } static void subscribe_with_io_error(void) { @@ -418,6 +429,53 @@ static void subscribe_with_io_error(void) { bctbx_list_free(lcs); } +static void subscribe_not_timely_responded(void) { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneContent* content; + LinphoneEvent *lev; + int expires= 4; + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + + lcs=bctbx_list_append(lcs,pauline->lc); + + content = linphone_core_create_content(marie->lc); + linphone_content_set_type(content,"application"); + linphone_content_set_subtype(content,"somexml"); + linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + + lev=linphone_core_create_subscribe(marie->lc,pauline->identity,"dodo",expires); + linphone_event_add_custom_header(lev,"My-Header","pouet"); + linphone_event_add_custom_header(lev,"My-Header2","pimpon"); + linphone_event_send_subscribe(lev,content); + + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingProgress,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000)); + + + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,5000)); + + /*make sure marie receives first notification before terminating*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,5000)); + + /* now pauline is no longer scheduled (simulating a very big latency in the network) */ + lcs = bctbx_list_remove(lcs, pauline->lc); + /*marie's dialog will expire while the SUBSCRIBE refresh is in progress*/ + wait_for_list(lcs, NULL, 0, 8000); + + lcs = bctbx_list_append(lcs, pauline->lc); + wait_for_list(lcs, NULL, 0, 3000); + linphone_event_terminate(lev); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,5000)); + + linphone_content_unref(content); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + bctbx_list_free(lcs); +} + static void publish_test_with_args(bool_t refresh, int expires){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); @@ -513,6 +571,7 @@ test_t event_tests[] = { TEST_ONE_TAG("Subscribe with io error", subscribe_with_io_error, "presence"), TEST_ONE_TAG("Subscribe manually refreshed", subscribe_test_manually_refreshed, "presence"), TEST_ONE_TAG("Subscribe terminated by notifier", subscribe_test_terminated_by_notifier, "presence"), + TEST_ONE_TAG("Subscribe not timely responded", subscribe_not_timely_responded, "presence"), TEST_ONE_TAG("Publish", publish_test, "presence"), TEST_ONE_TAG("Publish without expires", publish_without_expires, "presence"), TEST_ONE_TAG("Publish without automatic refresh",publish_no_auto_test, "presence"), From 30c95b726428d5e4f1fe17752bac30ab9acc2a6a Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 23:05:39 +0100 Subject: [PATCH 27/42] relax timeout --- tester/register_tester.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/register_tester.c b/tester/register_tester.c index 9915bbe5b..557c680cf 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -592,7 +592,7 @@ static void transport_dont_bind(void){ tr.tls_port = LC_SIP_TRANSPORT_DONTBIND; linphone_core_set_sip_transports(pauline->lc, &tr); - BC_ASSERT_TRUE(wait_for_until(pauline->lc,pauline->lc,&counters->number_of_LinphoneRegistrationOk,2,9000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc,pauline->lc,&counters->number_of_LinphoneRegistrationOk,2,15000)); memset(&tr, 0, sizeof(tr)); linphone_core_get_sip_transports_used(pauline->lc, &tr); BC_ASSERT_EQUAL(tr.udp_port, 0, int, "%i"); From 0e06d9b9688caa386edd50b98f971f6f974b171d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Nov 2016 23:22:28 +0100 Subject: [PATCH 28/42] fix test (adjust waits to take into account that dialog expiration doesn't trigger a new refresh (we let the SUBSCRIBE transaction timeout to trigger a new one instead). --- tester/presence_server_tester.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c index c26af0bb9..a74abc7d0 100644 --- a/tester/presence_server_tester.c +++ b/tester/presence_server_tester.c @@ -633,13 +633,14 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { ms_message("Simulating in/out packets losses"); sal_set_send_error(laure->lc->sal,1500); /*make sure no refresh is sent, trash the message without generating error*/ sal_set_recv_error(laure->lc->sal, 1500); /*make sure server notify to close the dialog is also ignored*/ - wait_for_list(lcs, &dummy, 1, 5000); /* Wait a little bit for the subscribe to happen */ + wait_for_list(lcs, &dummy, 1, 32000); /* Wait a little bit for the subscribe transaction to timeout */ } /*restart normal behavior*/ sal_set_send_error(laure->lc->sal,0); sal_set_recv_error(laure->lc->sal, 1); + /*a new subscribe should be sent */ - BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 3, 6000)); /* give time for subscription to recover to avoid to receive 491 Request pending*/ + BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 3, 9000)); /* give time for subscription to recover to avoid to receive 491 Request pending*/ linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL)); From 29db7d5fdbdff2ad61b0d712b522d871e59c9caf Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sat, 5 Nov 2016 00:06:51 +0100 Subject: [PATCH 29/42] fix memory leak --- tester/call_single_tester.c | 2 ++ tester/message_tester.c | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 7042346cf..cff0219c2 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -4492,6 +4492,8 @@ static void _call_with_network_switch(bool_t use_ice, bool_t with_socket_refresh if (use_ice){ linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); } if (with_socket_refresh){ lp_config_set_int(linphone_core_get_config(marie->lc), "net", "recreate_sockets_when_network_is_up", 1); diff --git a/tester/message_tester.c b/tester/message_tester.c index 3c49bd180..6abfe697f 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -860,6 +860,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st LinphoneChatMessageCbs *cbs; char *pauline_id, *marie_id; char *filepath; + MSList * msg_list = NULL; marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new( "pauline_tcp_rc"); @@ -909,11 +910,10 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st const LinphoneContent* content; if (download_file_from_stored_msg) { LinphoneChatRoom *marie_room = linphone_core_get_chat_room(marie->lc, pauline->identity); - MSList * msgs = linphone_chat_room_get_history(marie_room,1); - BC_ASSERT_PTR_NOT_NULL(msgs); - if (!msgs) goto end; - recv_msg = (LinphoneChatMessage *)msgs->data; - ms_list_free(msgs); + msg_list = linphone_chat_room_get_history(marie_room,1); + BC_ASSERT_PTR_NOT_NULL(msg_list); + if (!msg_list) goto end; + recv_msg = (LinphoneChatMessage *)msg_list->data; } else { recv_msg = marie->stat.last_received_chat_message; } @@ -928,6 +928,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); linphone_chat_message_download_file(recv_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); + bctbx_list_free_with_data(msg_list, (bctbx_list_free_func)linphone_chat_message_unref); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,2, int, "%d"); // file transfer From 869aa1e39df0b19ee917756ca93bcdf1b3601a49 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sat, 5 Nov 2016 21:55:41 +0100 Subject: [PATCH 30/42] fix mismatched malloc/frees (can crash on windows) --- tester/vcard_tester.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 3bbff9141..f0449e6e4 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -53,8 +53,8 @@ static void linphone_vcard_import_export_friends_test(void) { linphone_friend_list_unref(lfl); remove(export_filepath); - ms_free(import_filepath); - ms_free(export_filepath); + bc_free(import_filepath); + bc_free(export_filepath); linphone_core_manager_destroy(manager); } @@ -106,7 +106,7 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { linphone_friend_list_unref(lfl); - ms_free(import_filepath); + bc_free(import_filepath); linphone_core_manager_destroy(manager); } @@ -244,7 +244,7 @@ static void friends_migration(void) { friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); unlink(friends_db); - ms_free(friends_db); + bc_free(friends_db); linphone_core_manager_destroy(manager); } @@ -369,7 +369,7 @@ static void friends_sqlite_storage(void) { end: ms_free(stats); unlink(friends_db); - ms_free(friends_db); + bc_free(friends_db); linphone_address_unref(addr); linphone_core_destroy(lc); linphone_core_v_table_destroy(v_table); @@ -473,7 +473,7 @@ static void carddav_sync_2(void) { ms_free(stats); unlink(friends_db); - ms_free(friends_db); + bc_free(friends_db); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); } @@ -513,7 +513,7 @@ static void carddav_sync_3(void) { ms_free(stats); unlink(friends_db); - ms_free(friends_db); + bc_free(friends_db); linphone_carddav_context_destroy(c); c = NULL; linphone_core_manager_destroy(manager); From 15f5ac08d03e3f0e19a5ccfede4a738164becc48 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sat, 5 Nov 2016 21:59:00 +0100 Subject: [PATCH 31/42] give more time to send publish --- tester/quality_reporting_tester.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 5a15109c1..67f707eb8 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -414,7 +414,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { end_call(marie, pauline); /*wait for publish triggered by the end of call to be completed*/ - wait_for_until(marie->lc,pauline->lc,NULL,0,3000); + wait_for_until(marie->lc,pauline->lc,NULL,0,6000); } linphone_call_params_destroy(marie_params); From 7c827c71344499495daa82cc061346a2641267b8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 7 Nov 2016 15:16:00 +0100 Subject: [PATCH 32/42] Fix incorrect status report by linphonecsh. --- console/commands.c | 2 +- tester/flexisip/flexisip.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/console/commands.c b/console/commands.c index 72510bd65..449af0695 100644 --- a/console/commands.c +++ b/console/commands.c @@ -2070,7 +2070,7 @@ static int lpc_cmd_status(LinphoneCore *lc, char *args) linphonec_out("hook=paused sip:%s\n",linphonec_get_callee()); break; case LinphoneCallIdle: - linphonec_out("hook=offhook\n"); + linphonec_out("hook=on-hook\n"); break; case LinphoneCallStreamsRunning: case LinphoneCallConnected: diff --git a/tester/flexisip/flexisip.conf b/tester/flexisip/flexisip.conf index 5ad6cb028..5c29e9e7f 100644 --- a/tester/flexisip/flexisip.conf +++ b/tester/flexisip/flexisip.conf @@ -605,7 +605,7 @@ time-period=15000 # Maximum packet rate received in [time-period] millisecond(s) to # consider it as a DoS attack. # Default value: 20 -packet-rate-limit=5 +packet-rate-limit=10 # Number of minutes to ban the ip/port using iptables (might be # less because it justs uses the minutes of the clock, not the seconds. From c1e5007667b2a39dba7d81ac7f0bc53494bc90d1 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 7 Nov 2016 15:29:12 +0100 Subject: [PATCH 33/42] avoid unneccessary and time consuming linphone friend parsing --- gtk/calllogs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/calllogs.c b/gtk/calllogs.c index 98daa9f12..5f5384d45 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -314,7 +314,7 @@ void linphone_gtk_call_log_update(GtkWidget *w){ start_date[strlen(start_date) - 1] = '\0'; } #endif - lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr); + lf=linphone_core_find_friend(linphone_gtk_get_core(),la); if(lf != NULL){ /*update display name from friend*/ display = linphone_friend_get_name(lf); From a95e3ce0fe08902b2757c0a1c8dde50e91ba5f71 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 8 Nov 2016 10:33:34 +0100 Subject: [PATCH 34/42] Change your password in linphone settings --- coreapi/account_creator.c | 39 +++++++++++++++++++++++++++++++++++++++ coreapi/account_creator.h | 8 ++++++++ coreapi/private.h | 1 + 3 files changed, 48 insertions(+) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index e26f6157c..8072dc7f4 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -367,6 +367,45 @@ const char * linphone_account_creator_get_password(const LinphoneAccountCreator return creator->password; } +LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + if (creator->callbacks->password_updated != NULL) { + LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + if (strcmp(resp, "OK") == 0) { + status = LinphoneAccountCreatorOK; + } else if (strcmp(resp, "ERROR_PASSWORD_DOESNT_MATCH") == 0) { + status = LinphoneAccountCreatorAccountNotExist; + } else { + status = LinphoneAccountCreatorErrorServer; + } + } + creator->callbacks->password_updated(creator, status, resp); + } +} + +LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd){ + LinphoneXmlRpcRequest *request; + const char * username = creator->username ? creator->username : creator->phone_number; + const char * ha1 = ms_strdup(creator->password ? ha1_for_passwd(username, creator->domain, creator->password) : creator->ha1); + const char * new_ha1 = ms_strdup(ha1_for_passwd(username, creator->domain, new_pwd)); + + request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, username, + LinphoneXmlRpcArgString, ha1, + LinphoneXmlRpcArgString, new_ha1, + LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgNone); + + linphone_xml_rpc_request_set_user_data(request, creator); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _password_updated_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneAccountCreatorOK; +} + LinphoneAccountCreatorStatus linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1){ set_string(&creator->ha1, ha1, FALSE); return LinphoneAccountCreatorOK; diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index c308ba3df..a8aa2c210 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -145,6 +145,14 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_userna **/ LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator); +/** + * Update the password. + * @param[in] creator LinphoneAccountCreator object + * @param[in] new_pwd const char * : new password for the account creator + * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd); + /** * Set the phone number normalized. * @param[in] creator LinphoneAccountCreator object diff --git a/coreapi/private.h b/coreapi/private.h index f8fe6cda6..ec4c955e6 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1342,6 +1342,7 @@ struct _LinphoneAccountCreatorCbs { LinphoneAccountCreatorCbsStatusCb activate_phone_number_link; LinphoneAccountCreatorCbsStatusCb recover_phone_account; LinphoneAccountCreatorCbsStatusCb is_account_linked; + LinphoneAccountCreatorCbsStatusCb password_updated; }; BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorCbs); From eb35e05943224a86cd9d3db2551ff0410e9ecffa Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 8 Nov 2016 10:51:57 +0100 Subject: [PATCH 35/42] add callbacks to previsous commit --- coreapi/account_creator.c | 12 ++++++++++-- coreapi/account_creator.h | 14 ++++++++++++++ coreapi/private.h | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 8072dc7f4..d2071e6b3 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -61,6 +61,14 @@ void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, cbs->user_data = ud; } +void *linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs) { + return cbs->update_hash; +} + +void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, void *ud) { + cbs->update_hash = ud; +} + LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs) { return cbs->is_account_used; } @@ -369,7 +377,7 @@ const char * linphone_account_creator_get_password(const LinphoneAccountCreator LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->password_updated != NULL) { + if (creator->callbacks->update_hash != NULL) { LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { @@ -381,7 +389,7 @@ LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) { status = LinphoneAccountCreatorErrorServer; } } - creator->callbacks->password_updated(creator, status, resp); + creator->callbacks->update_hash(creator, status, resp); } } diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index a8aa2c210..b52f715dd 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -387,6 +387,20 @@ LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_user_data(const LinphoneA **/ LINPHONE_PUBLIC void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud); +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorCbs object. + * @param[in] cbs LinphoneAccountCreatorCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorCbs object. + * @param[in] cbs LinphoneAccountCreatorCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, void *ud); + /** * Get the current linked tested callback. * @param[in] cbs LinphoneAccountCreatorCbs object. diff --git a/coreapi/private.h b/coreapi/private.h index ec4c955e6..432b63fc8 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1342,7 +1342,7 @@ struct _LinphoneAccountCreatorCbs { LinphoneAccountCreatorCbsStatusCb activate_phone_number_link; LinphoneAccountCreatorCbsStatusCb recover_phone_account; LinphoneAccountCreatorCbsStatusCb is_account_linked; - LinphoneAccountCreatorCbsStatusCb password_updated; + LinphoneAccountCreatorCbsStatusCb update_hash; }; BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorCbs); From 4749f195b8835367e6dff9c7b2502c6ea50c75ec Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 8 Nov 2016 11:16:26 +0100 Subject: [PATCH 36/42] right way to do the callbacks --- coreapi/account_creator.c | 6 +++--- coreapi/account_creator.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index d2071e6b3..c7d3c3207 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -61,12 +61,12 @@ void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, cbs->user_data = ud; } -void *linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs) { +LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs) { return cbs->update_hash; } -void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, void *ud) { - cbs->update_hash = ud; +void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { + cbs->update_hash = cb; } LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs) { diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index b52f715dd..16b702722 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -392,14 +392,14 @@ LINPHONE_PUBLIC void linphone_account_creator_cbs_set_user_data(LinphoneAccountC * @param[in] cbs LinphoneAccountCreatorCbs object. * @return The user pointer associated with the LinphoneAccountCreatorCbs object. **/ -LINPHONE_PUBLIC void *linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs); +LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_update_hash(const LinphoneAccountCreatorCbs *cbs); /** * Assign a user pointer to a LinphoneAccountCreatorCbs object. * @param[in] cbs LinphoneAccountCreatorCbs object. * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorCbs object. **/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, void *ud); +LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); /** * Get the current linked tested callback. From a988e996ca9df932737ee2fe3000ec10f5865f7a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 8 Nov 2016 10:35:42 +0100 Subject: [PATCH 37/42] Add JNI for update password --- coreapi/account_creator.c | 17 +++++++-- coreapi/account_creator.h | 2 +- coreapi/linphonecore_jni.cc | 38 +++++++++++++++++++ .../linphone/core/LinphoneAccountCreator.java | 3 ++ .../core/LinphoneAccountCreatorImpl.java | 6 +++ 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index c7d3c3207..9b47f4206 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -375,7 +375,7 @@ const char * linphone_account_creator_get_password(const LinphoneAccountCreator return creator->password; } -LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) { +static void _password_updated_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); if (creator->callbacks->update_hash != NULL) { LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; @@ -390,13 +390,22 @@ LinphoneAccountCreator _password_updated_cb(LinphoneXmlRpcRequest *request) { } } creator->callbacks->update_hash(creator, status, resp); - } + } } -LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd){ +LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd){ LinphoneXmlRpcRequest *request; + char *identity = _get_identity(creator); + if (!identity || (!creator->username && !creator->phone_number + && !creator->domain && (!creator->password || !creator->ha1))) { + if (creator->callbacks->update_hash != NULL) { + creator->callbacks->update_hash(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + } + return LinphoneAccountCreatorReqFailed; + } + const char * username = creator->username ? creator->username : creator->phone_number; - const char * ha1 = ms_strdup(creator->password ? ha1_for_passwd(username, creator->domain, creator->password) : creator->ha1); + const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, creator->domain, creator->password) ); const char * new_ha1 = ms_strdup(ha1_for_passwd(username, creator->domain, new_pwd)); request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index 16b702722..1b678f765 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -151,7 +151,7 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_username(const Linphon * @param[in] new_pwd const char * : new password for the account creator * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(const LinphoneAccountCreator *creator, const char *new_pwd); +LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password(LinphoneAccountCreator *creator, const char *new_pwd); /** * Set the phone number normalized. diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 447d5761c..c4301e9ff 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8224,6 +8224,34 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } +static void account_creator_password_updated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM\n"); + return; + } + + ms_warning("test callback password updated"); + + LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + if (listener == NULL) { + ms_error("account_creator_response() notification without listener"); + return ; + } + + LinphoneCore *lc = (LinphoneCore *)creator->core; + LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); + + jclass clazz = (jclass) env->GetObjectClass(listener); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPasswordUpdated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + env->DeleteLocalRef(clazz); + + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); +} + extern "C" jlong Java_org_linphone_core_LinphoneAccountCreatorImpl_newLinphoneAccountCreator(JNIEnv *env, jobject thiz, jlong core, jstring jurl) { const char *url = GetStringUTFChars(env, jurl); LinphoneAccountCreator *account_creator = linphone_account_creator_new((LinphoneCore *)core, url); @@ -8253,6 +8281,7 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JN linphone_account_creator_cbs_set_recover_phone_account(cbs, account_creator_phone_account_recovered); linphone_account_creator_cbs_set_is_phone_number_used(cbs, account_creator_is_phone_number_used); linphone_account_creator_cbs_set_is_account_linked(cbs, account_creator_is_account_linked); + linphone_account_creator_cbs_set_update_hash(cbs, account_creator_password_updated); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { @@ -8451,6 +8480,15 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_recoverPhoneAc return (jint) linphone_account_creator_recover_phone_account(account_creator); } +extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_updatePassword(JNIEnv *env, jobject thiz, jlong ptr, jstring jpasswd) { + jint status; + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + const char* passwd = GetStringUTFChars(env, jpasswd); + status = (jint) linphone_account_creator_update_password(account_creator, passwd); + ReleaseStringUTFChars(env, jpasswd, passwd); + return status; +} + extern "C" jobject Java_org_linphone_core_LinphoneAccountCreatorImpl_configure(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; LinphoneProxyConfig *lpc = linphone_account_creator_configure(account_creator); diff --git a/java/common/org/linphone/core/LinphoneAccountCreator.java b/java/common/org/linphone/core/LinphoneAccountCreator.java index 78297b15d..72cdebbab 100644 --- a/java/common/org/linphone/core/LinphoneAccountCreator.java +++ b/java/common/org/linphone/core/LinphoneAccountCreator.java @@ -32,6 +32,7 @@ public interface LinphoneAccountCreator { void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status); void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status); void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, Status status); + void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, Status status); } public static class Status { @@ -157,5 +158,7 @@ public interface LinphoneAccountCreator { Status recoverPhoneAccount(); + Status updatePassword(String newPassword); + LinphoneProxyConfig configure(); } diff --git a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java index a43b9d33b..66333eec8 100644 --- a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java +++ b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java @@ -226,6 +226,12 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { return Status.fromInt(recoverPhoneAccount(nativePtr)); } + private native int updatePassword(long ptr, String newPassword); + @Override + public Status updatePassword(String newPassword) { + return Status.fromInt(updatePassword(nativePtr, newPassword)); + } + private native LinphoneProxyConfig configure(long ptr); @Override public LinphoneProxyConfig configure() { From fef54c658d32a6aa5b6f29a95d11757c68f2b9ac Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 8 Nov 2016 17:33:03 +0100 Subject: [PATCH 38/42] Memory leak fixes. --- coreapi/nat_policy.c | 1 + tester/vcard_tester.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index a16bc8104..d7f176beb 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -41,6 +41,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); if (policy->stun_resolver_context) { sal_resolve_cancel(policy->stun_resolver_context); + sal_resolver_context_unref(policy->stun_resolver_context); } } diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index f0449e6e4..150e41768 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -798,8 +798,8 @@ test_t vcard_tests[] = { TEST_NO_TAG("vCard creation for existing friends", linphone_vcard_update_existing_friends_test), TEST_NO_TAG("vCard phone numbers and SIP addresses", linphone_vcard_phone_numbers_and_sip_addresses), #ifdef SQLITE_STORAGE_ENABLED - TEST_ONE_TAG("Friends working if no db set", friends_if_no_db_set, "LeaksMemory"), - TEST_ONE_TAG("Friends storage migration from rc to db", friends_migration, "LeaksMemory"), + TEST_NO_TAG("Friends working if no db set", friends_if_no_db_set), + TEST_NO_TAG("Friends storage migration from rc to db", friends_migration), TEST_NO_TAG("Friends storage in sqlite database", friends_sqlite_storage), #endif TEST_NO_TAG("CardDAV clean", carddav_clean), // This is to ensure the content of the test addressbook is in the correct state for the following tests From a7a9733531e770e3531b4f73bbf99f8c8357edc7 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 8 Nov 2016 17:37:44 +0100 Subject: [PATCH 39/42] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 56a978c04..e84be0bfa 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 56a978c041f84ec4bdebf50debbe71b23dafcafd +Subproject commit e84be0bfaf9bbd2786228db6064811ef2a58aee6 From 7fbb24ece6d1f58098441c88e840a2c00b0a81e6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 8 Nov 2016 17:40:09 +0100 Subject: [PATCH 40/42] Remove -Wdeclaration-after-statement compilation option. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee02b53b1..be0eb299f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,7 @@ if(MSVC) endif() else() list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") - list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Werror=strict-prototypes") + list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes" "-Werror=strict-prototypes") if(CMAKE_C_COMPILER_ID STREQUAL "GNU") list(APPEND STRICT_OPTIONS_C "-fno-inline-small-functions") endif() From e25f326f8469708462d31e99d06fa0d1d9fc0f69 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 Nov 2016 10:33:54 +0100 Subject: [PATCH 41/42] Also remove -Wdeclaration-after-statement compilation option when building with the autotools. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 80c7c7b4d..474d52799 100644 --- a/configure.ac +++ b/configure.ac @@ -776,7 +776,7 @@ AC_ARG_ENABLE(strict, ) STRICT_OPTIONS="-Wall -Wuninitialized" -STRICT_OPTIONS_CC="-Wdeclaration-after-statement -Wstrict-prototypes" +STRICT_OPTIONS_CC="-Wstrict-prototypes" STRICT_OPTIONS_CXX="" #for clang From 8b1d320feb3b38b1840deea40f7693c8d638fb43 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 Nov 2016 17:06:16 +0100 Subject: [PATCH 42/42] Fix crash in VCard testers on Windows. --- coreapi/friend.c | 2 +- tester/vcard_tester.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 03f0f05ae..0cecfb3a0 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1221,7 +1221,7 @@ void linphone_core_friends_storage_init(LinphoneCore *lc) { linphone_create_table(db); if (linphone_update_table(db)) { // After updating schema, database need to be closed/reopenned - sqlite3_close(lc->friends_db); + sqlite3_close(db); _linphone_sqlite3_open(lc->friends_db_file, &db); } diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 150e41768..31d243955 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -243,9 +243,9 @@ static void friends_migration(void) { BC_ASSERT_EQUAL(lp_config_get_int(lpc, "misc", "friends_migration_done", 0), 1, int, "%i"); friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); + linphone_core_manager_destroy(manager); unlink(friends_db); bc_free(friends_db); - linphone_core_manager_destroy(manager); } typedef struct _LinphoneFriendListStats { @@ -368,11 +368,11 @@ static void friends_sqlite_storage(void) { end: ms_free(stats); - unlink(friends_db); - bc_free(friends_db); linphone_address_unref(addr); linphone_core_destroy(lc); linphone_core_v_table_destroy(v_table); + unlink(friends_db); + bc_free(friends_db); } #endif @@ -472,10 +472,10 @@ static void carddav_sync_2(void) { BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); ms_free(stats); - unlink(friends_db); - bc_free(friends_db); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); + unlink(friends_db); + bc_free(friends_db); } static void carddav_sync_3(void) { @@ -512,11 +512,10 @@ static void carddav_sync_3(void) { BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); ms_free(stats); + linphone_carddav_context_destroy(c); + linphone_core_manager_destroy(manager); unlink(friends_db); bc_free(friends_db); - linphone_carddav_context_destroy(c); - c = NULL; - linphone_core_manager_destroy(manager); } static void carddav_sync_4(void) {