From e729b823d695c3b209a10f92a309efdcae314417 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 27 Mar 2017 17:09:29 +0200 Subject: [PATCH 01/32] Add some accessors for the call stats. --- coreapi/linphonecall.c | 12 ++++++++++++ include/linphone/call_stats.h | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index afe792887..d57ee984c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4149,6 +4149,10 @@ bool_t linphone_call_media_in_progress(LinphoneCall *call){ return ret; } +LinphoneStreamType linphone_call_stats_get_type(const LinphoneCallStats *stats) { + return stats->type; +} + float linphone_call_stats_get_sender_loss_rate(const LinphoneCallStats *stats) { const report_block_t *srb = NULL; @@ -4255,6 +4259,14 @@ LinphoneUpnpState linphone_call_stats_get_upnp_state(const LinphoneCallStats *st return stats->upnp_state; } +LinphoneAddressFamily linphone_call_stats_get_ip_family_of_remote(const LinphoneCallStats *stats) { + return (LinphoneAddressFamily)stats->rtp_remote_family; +} + +float linphone_call_stats_get_jitter_buffer_size_ms(const LinphoneCallStats *stats) { + return stats->jitter_stats.jitter_buffer_size_ms; +} + void linphone_call_start_recording(LinphoneCall *call){ if (!call->params->record_file){ ms_error("linphone_call_start_recording(): no output file specified. Use linphone_call_params_set_record_file()."); diff --git a/include/linphone/call_stats.h b/include/linphone/call_stats.h index a56a71548..11044c1c6 100644 --- a/include/linphone/call_stats.h +++ b/include/linphone/call_stats.h @@ -68,6 +68,13 @@ struct _LinphoneCallStats { bool_t rtcp_received_via_mux; /*private flag, for non-regression test only*/ }; +/** + * Get the type of the stream the stats refer to. + * @param[in] stats LinphoneCallStats object + * @return The type of the stream the stats refer to + */ +LINPHONE_PUBLIC LinphoneStreamType linphone_call_stats_get_type(const LinphoneCallStats *stats); + /** * Get the local loss rate since last report * @return The sender loss rate @@ -131,6 +138,20 @@ LINPHONE_PUBLIC LinphoneIceState linphone_call_stats_get_ice_state(const Linphon */ LINPHONE_PUBLIC LinphoneUpnpState linphone_call_stats_get_upnp_state(const LinphoneCallStats *stats); +/** + * Get the IP address family of the remote peer. + * @param[in] stats LinphoneCallStats object + * @return The IP address family of the remote peer. + */ +LINPHONE_PUBLIC LinphoneAddressFamily linphone_call_stats_get_ip_family_of_remote(const LinphoneCallStats *stats); + +/** + * Get the jitter buffer size in ms. + * @param[in] stats LinphoneCallStats object + * @return The jitter buffer size in ms. + */ +LINPHONE_PUBLIC float linphone_call_stats_get_jitter_buffer_size_ms(const LinphoneCallStats *stats); + /** * @} */ From f5269c919d9dc0a099f00e5453653fda6244e995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Mon, 27 Mar 2017 13:38:50 +0200 Subject: [PATCH 02/32] Add extern "C" block in im_encryption_engine.h --- include/linphone/im_encryption_engine.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linphone/im_encryption_engine.h b/include/linphone/im_encryption_engine.h index a65fac88e..9141c5361 100644 --- a/include/linphone/im_encryption_engine.h +++ b/include/linphone/im_encryption_engine.h @@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/types.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * @addtogroup misc * @{ @@ -242,4 +246,8 @@ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_generate_file_transfe * @} */ +#ifdef __cplusplus +} +#endif + #endif /* LINPHONE_IM_ENCRYPTION_ENGINE_H */ From bdde8f88027afa26ee06b70cd402a0dac14ced5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Mon, 27 Mar 2017 13:40:16 +0200 Subject: [PATCH 03/32] C++ wrapper: Unblacklist some class --- wrappers/cpp/abstractapi.py | 6 +----- wrappers/cpp/genwrapper.py | 9 +++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index ef27d4ec0..eeaf10e08 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -490,11 +490,7 @@ class CParser(object): 'linphone_core_get_sip_transports', # not wrappable 'linphone_core_get_sip_transports_used'] # not wrappable - self.classBl = ['LinphoneImEncryptionEngine', - 'LinphoneImEncryptionEngineCbs', - 'LinphoneImNotifPolicy', - 'LpConfig', - 'LinphoneErrorInfo', + self.classBl = ['LpConfig', 'LinphonePayloadType', 'LinphonePlayer'] # temporarly blacklisted diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 751c90428..8948432e8 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -274,8 +274,6 @@ class CppTranslator(object): if type(exprtype) is AbsApi.BaseType: if exprtype.name == 'string': cExpr = 'StringUtilities::cppStringToC({0})'.format(cppExpr); - elif exprtype.name not in ['void', 'string', 'string_array'] and exprtype.isref: - cExpr = '&' + cppExpr else: cExpr = cppExpr elif type(exprtype) is AbsApi.EnumType: @@ -315,9 +313,7 @@ class CppTranslator(object): def _wrap_c_expression_to_cpp(self, cExpr, exprtype, usedNamespace=None): if type(exprtype) is AbsApi.BaseType: - if exprtype.name == 'void' and not exprtype.isref: - return cExpr - elif exprtype.name == 'string': + if exprtype.name == 'string': return 'StringUtilities::cStringToCpp({0})'.format(cExpr) elif exprtype.name == 'string_array': return 'StringUtilities::cStringArrayToCppList({0})'.format(cExpr) @@ -391,6 +387,7 @@ class CppTranslator(object): res = _type.size else: res = 'int{0}_t'.format(_type.size) + elif _type.name == 'floatant': if _type.size is not None and _type.size == 'double': res = 'double' @@ -418,7 +415,7 @@ class CppTranslator(object): res = 'const ' + res if _type.isref: - res += ' &' + res += ' *' return res def translate_enum_type(self, _type, **params): From 33d7528c133417ad5c5f7f94d11f8c8c10b42756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Mon, 27 Mar 2017 17:36:55 +0200 Subject: [PATCH 04/32] Add a custom Doxygen command to notfy wrapper generators to do not wrap functions or structs --- coreapi/help/Doxyfile.in | 3 ++- tools/genapixml.py | 5 +++++ wrappers/cpp/CMakeLists.txt | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/coreapi/help/Doxyfile.in b/coreapi/help/Doxyfile.in index f01cbd771..169f6cf2a 100644 --- a/coreapi/help/Doxyfile.in +++ b/coreapi/help/Doxyfile.in @@ -228,7 +228,8 @@ TAB_SIZE = 8 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = "bctbx_list{1}=A list of \ref \1 objects. \xmlonly \1 \endxmlonly" +ALIASES = bctbx_list{1}="A list of \ref \1 objects. \xmlonly \1 \endxmlonly" +ALIASES += donotwrap="\xmlonly \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/tools/genapixml.py b/tools/genapixml.py index bd8d9d493..dc3a132b0 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -304,6 +304,9 @@ class Project: descriptionNode.tag = 'description' descriptionNode.attrib = {} return descriptionNode + + def __canBeWrapped(self, node): + return node.find('./detaileddescription//donotwrap') is None def __discoverClasses(self): for td in self.__typedefs: @@ -491,6 +494,8 @@ class Project: self.add(td) def __parseCFunctionMemberdef(self, node): + if not Project.__canBeWrapped(self, node): + return None internal = node.find("./detaileddescription/internal") if internal is not None: return None diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index 4720a3054..b4c6bfba8 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -22,7 +22,14 @@ add_custom_command(OUTPUT include/linphone++/linphone.hh src/linphone++.cc COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genwrapper.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml" - DEPENDS abstractapi.py genwrapper.py class_header.mustache class_impl.mustache enums_header.mustache main_header.mustache linphone-doc + DEPENDS ${PROJECT_SOURCE_DIR}/tools/genapixml.py + abstractapi.py + genwrapper.py + class_header.mustache + class_impl.mustache + enums_header.mustache + main_header.mustache + linphone-doc "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml" ) From 652f26cb81f44653436efb75bada9e787da847ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Mon, 27 Mar 2017 17:38:17 +0200 Subject: [PATCH 05/32] Disable wrapping of functions or structs that are deprecated at that commit time Also add compiler depecation tag on functions that are marked as deperecated in their documentation. --- include/linphone/address.h | 2 + include/linphone/call.h | 1 + include/linphone/call_log.h | 3 +- include/linphone/call_params.h | 1 + include/linphone/chat.h | 10 ++++- include/linphone/conference.h | 1 + include/linphone/core.h | 75 ++++++++++++++++++++++++--------- include/linphone/friend.h | 8 +++- include/linphone/info_message.h | 1 + include/linphone/lpconfig.h | 1 + include/linphone/misc.h | 3 +- include/linphone/proxy_config.h | 28 +++++++----- include/linphone/tunnel.h | 6 +++ include/linphone/types.h | 12 ++++-- include/linphone/vcard.h | 2 + wrappers/cpp/abstractapi.py | 55 +----------------------- 16 files changed, 117 insertions(+), 92 deletions(-) diff --git a/include/linphone/address.h b/include/linphone/address.h index b5f0f55f9..3ad35fa5c 100644 --- a/include/linphone/address.h +++ b/include/linphone/address.h @@ -110,6 +110,7 @@ LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri); /** * Returns true if address refers to a secure location (sips) * @deprecated use linphone_address_get_secure() + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC bool_t linphone_address_is_secure(const LinphoneAddress *addr); @@ -219,6 +220,7 @@ LINPHONE_PUBLIC const char * linphone_address_get_uri_param(const LinphoneAddres /** * Destroys a LinphoneAddress object (actually calls linphone_address_unref()). * @deprecated Use linphone_address_unref() instead + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_address_destroy(LinphoneAddress *u); diff --git a/include/linphone/call.h b/include/linphone/call.h index 8d5985274..242fac2eb 100644 --- a/include/linphone/call.h +++ b/include/linphone/call.h @@ -303,6 +303,7 @@ LINPHONE_PUBLIC void linphone_call_cancel_dtmfs(LinphoneCall *call); * @param call #LinphoneCall * @return TRUE if part of a conference. * @deprecated Use linphone_call_get_conference() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_call_is_in_conference(const LinphoneCall *call); diff --git a/include/linphone/call_log.h b/include/linphone/call_log.h index 7ed668913..914fab331 100644 --- a/include/linphone/call_log.h +++ b/include/linphone/call_log.h @@ -211,8 +211,9 @@ LINPHONE_PUBLIC void linphone_call_log_unref(LinphoneCallLog *cl); * Destroy a LinphoneCallLog. * @param cl LinphoneCallLog object * @deprecated Use linphone_call_log_unref() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_call_log_destroy(LinphoneCallLog *cl); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_call_log_destroy(LinphoneCallLog *cl); /** * @} diff --git a/include/linphone/call_params.h b/include/linphone/call_params.h index f9517b66d..2220f595c 100644 --- a/include/linphone/call_params.h +++ b/include/linphone/call_params.h @@ -441,6 +441,7 @@ LINPHONE_PUBLIC void linphone_call_params_clear_custom_sdp_media_attributes(Linp * Destroy a LinphoneCallParams object. * @param[in] cp LinphoneCallParams object * @deprecated Use linphone_call_params_unref() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_call_params_destroy(LinphoneCallParams *cp); diff --git a/include/linphone/chat.h b/include/linphone/chat.h index fc78c9ce9..954d55611 100644 --- a/include/linphone/chat.h +++ b/include/linphone/chat.h @@ -39,8 +39,9 @@ extern "C" { * @param status LinphoneChatMessageState * @param ud application user data * @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead. + * @donotwrap */ -typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); +LINPHONE_DEPRECATED typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); /** * Call back used to notify message delivery status @@ -80,6 +81,7 @@ typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneC * Destroy a LinphoneChatRoom. * @param cr #LinphoneChatRoom object * @deprecated Use linphone_chat_room_unref() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_destroy(LinphoneChatRoom *cr); /** @@ -150,6 +152,7 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_peer_address(Linph * @deprecated Use linphone_chat_room_send_chat_message() instead. * @param cr #LinphoneChatRoom object * @param msg message to be sent + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); @@ -162,6 +165,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message(Linphon * @deprecated Use linphone_chat_room_send_chat_message() instead. * @note The LinphoneChatMessage must not be destroyed until the the callback is called. * The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangedCb status_cb,void* ud); @@ -172,6 +176,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_send_message2(Linpho * The state of the message sending will be notified via the callbacks defined in the LinphoneChatMessageCbs object that can be obtained * by calling linphone_chat_message_get_callbacks(). * The LinphoneChatMessage reference is transfered to the function and thus doesn't need to be unref'd by the application. + * @donotwrap */ LINPHONE_PUBLIC void linphone_chat_room_send_chat_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg); @@ -244,6 +249,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_unread_messages_count(LinphoneChatRoo /** * Returns back pointer to #LinphoneCore object. * @deprecated use linphone_chat_room_get_core() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneCore* linphone_chat_room_get_lc(LinphoneChatRoom *cr); @@ -426,6 +432,7 @@ LINPHONE_PUBLIC void linphone_chat_message_set_to_be_stored(LinphoneChatMessage * @param status_cb LinphoneChatMessageStateChangeCb status callback invoked when file is downloaded or could not be downloaded * @param ud user data * @deprecated Use linphone_chat_message_download_file() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_start_file_download(LinphoneChatMessage* message, LinphoneChatMessageStateChangedCb status_cb, void* ud); @@ -444,6 +451,7 @@ LINPHONE_PUBLIC void linphone_chat_message_cancel_file_transfer(LinphoneChatMess /** * Resend a chat message if it is in the 'not delivered' state for whatever reason. * @param[in] msg LinphoneChatMessage object + * @donotwrap */ LINPHONE_PUBLIC void linphone_chat_message_resend(LinphoneChatMessage *msg); diff --git a/include/linphone/conference.h b/include/linphone/conference.h index a5e3e8890..1334da06c 100644 --- a/include/linphone/conference.h +++ b/include/linphone/conference.h @@ -61,6 +61,7 @@ LINPHONE_PUBLIC void linphone_conference_params_unref(LinphoneConferenceParams * * Free a #LinphoneConferenceParams * @param params #LinphoneConferenceParams to free * @deprecated Use linphone_conference_params_unref() instead. + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_conference_params_free(LinphoneConferenceParams *params); diff --git a/include/linphone/core.h b/include/linphone/core.h index c27a6ce2b..4f3bc85a3 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -183,24 +183,28 @@ typedef LinphoneCoreCbsRegistrationStateChangedCb LinphoneCoreRegistrationStateC /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*ShowInterfaceCb)(LinphoneCore *lc); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayStatusCb)(LinphoneCore *lc, const char *message); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayMessageCb)(LinphoneCore *lc, const char *message); /** * Callback prototype * @deprecated + * @donotwrap */ typedef void (*DisplayUrlCb)(LinphoneCore *lc, const char *message, const char *url); @@ -288,11 +292,12 @@ typedef LinphoneCoreCbsCallLogUpdatedCb LinphoneCoreCallLogUpdatedCb; /** * Callback prototype - * @deprecated use #LinphoneCoreMessageReceivedCb instead. * @param lc #LinphoneCore object * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. * @param from #LinphoneAddress from * @param message incoming message + * @deprecated use #LinphoneCoreMessageReceivedCb instead. + * @donotwrap */ typedef void (*LinphoneCoreTextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); @@ -604,6 +609,7 @@ LINPHONE_PUBLIC void *linphone_core_cbs_get_user_data(const LinphoneCoreCbs *cbs * This is meant only to be called from a callback to be able to get the user_data associated with the #LinphoneCoreCbs that is calling the callback. * @param lc the linphonecore * @return the #LinphoneCoreCbs that has called the last callback + * @donotwrap */ LINPHONE_PUBLIC LinphoneCoreCbs *linphone_core_get_current_callbacks(const LinphoneCore *lc); @@ -1094,29 +1100,25 @@ LINPHONE_PUBLIC void linphone_core_set_log_level_mask(unsigned int loglevel); /** * Enable logs in supplied FILE*. - * - * @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead. - * * @param file a C FILE* where to fprintf logs. If null stdout is used. - * + * @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file); /** * Enable logs through the user's supplied log callback. - * - * @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead. - * * @param logfunc The address of a OrtpLogFunc callback whose protoype is * typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args); - * + * @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc); /** * Entirely disable logging. - * * @deprecated Use #linphone_core_set_log_level instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_disable_logs(void); @@ -1138,11 +1140,13 @@ LINPHONE_PUBLIC const char *linphone_core_get_user_agent(LinphoneCore *lc); /** * @deprecated Use #linphone_core_get_user_agent instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_name(void); /** * @deprecated Use #linphone_core_get_user_agent instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_version(void); @@ -1169,6 +1173,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_ver * callbacks) using linphone_core_get_user_data(). * @see linphone_core_new_with_config * @deprecated Use linphone_factory_create_core() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config_path, void* userdata); @@ -1185,6 +1190,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const Linpho * callbacks) using linphone_core_get_user_data(). * @see linphone_core_new * @deprecated Use linphone_factory_create_core_with_config() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, LpConfig *config, void *userdata); @@ -1228,6 +1234,7 @@ LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc); * @param vtable a LinphoneCoreVTable structure holding your application callbacks. Object is owned by linphone core until linphone_core_remove_listener. * @param lc object * @deprecated Use linphone_core_add_callbacks() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable); @@ -1246,6 +1253,7 @@ LINPHONE_PUBLIC void linphone_core_add_callbacks(LinphoneCore *lc, LinphoneCoreC * @param lc object * @param vtable a LinphoneCoreVTable structure holding your application callbacks. * @deprecated Use linphone_core_remove_callbacks() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable); @@ -1631,7 +1639,7 @@ LINPHONE_PUBLIC LinphoneCall *linphone_core_get_call_by_remote_address2(Linphone * This function only works during calls. The dtmf is automatically played to the user. * @param lc The LinphoneCore object * @param dtmf The dtmf name specified as a char, such as '0', '#' etc... - * + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf); @@ -2011,6 +2019,7 @@ LINPHONE_PUBLIC bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, cons * @return TRUE if the payload type represents a VBR codec, FALSE if disabled. * @ingroup media_parameters * @deprecated Use linphone_payload_type_is_vbr() instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayloadType *pt); @@ -2070,6 +2079,7 @@ LINPHONE_PUBLIC LinphonePayloadType* linphone_core_find_payload_type(LinphoneCor * Returns the payload type number assigned for this codec. * @ingroup media_parameters * @deprecated Use linphone_payload_type_get_number() instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); @@ -2078,6 +2088,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_payload_type_number(Li * to override the automatic assignment mechanism. * @ingroup media_parameters * @deprecated Use linphone_payload_type_set_number() instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_payload_type_number(LinphoneCore *lc, PayloadType *pt, int number); @@ -2135,6 +2146,7 @@ LINPHONE_PUBLIC void linphone_core_set_default_proxy_index(LinphoneCore *lc, int /** * @return the default proxy configuration, that is the one used to determine the current identity. * @deprecated Use linphone_core_get_default_proxy_config() instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); @@ -2455,8 +2467,9 @@ LINPHONE_PUBLIC bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc); * @param[in] port The UDP port to be used by SIP * @ingroup network_parameters * @deprecated use linphone_core_set_sip_transports() instead. + * @donotwrap **/ -LINPHONE_PUBLIC void linphone_core_set_sip_port(LinphoneCore *lc, int port); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_sip_port(LinphoneCore *lc, int port); /** * Gets the UDP port used by SIP. @@ -2464,8 +2477,9 @@ LINPHONE_PUBLIC void linphone_core_set_sip_port(LinphoneCore *lc, int port); * @return The UDP port used by SIP * @ingroup network_parameters * @deprecated use linphone_core_get_sip_transports() instead. + * @donotwrap **/ -LINPHONE_PUBLIC int linphone_core_get_sip_port(LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_sip_port(LinphoneCore *lc); /** * Sets the ports to be used for each of transport (UDP or TCP) @@ -2486,6 +2500,7 @@ LINPHONE_PUBLIC int linphone_core_set_sip_transports(LinphoneCore *lc, const Lin * @param[out] transports A #LinphoneSipTransports structure that will receive the configured ports * @return 0 * @ingroup network_parameters + * @donotwrap **/ LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LinphoneSipTransports *transports); @@ -2496,6 +2511,7 @@ LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LinphoneS * @param[in] lc LinphoneCore object * @param[out] tr A #LinphoneSipTransports structure that will receive the ports being used * @ingroup network_parameters + * @donotwrap **/ LINPHONE_PUBLIC void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTransports *tr); @@ -2637,6 +2653,7 @@ LINPHONE_PUBLIC const char *linphone_core_get_nat_address(const LinphoneCore *lc * @param[in] pol The #LinphoneFirewallPolicy to use. * @ingroup network_parameters * @deprecated Use linphone_core_set_nat_policy() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol); @@ -2645,7 +2662,8 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_set_firewall_policy(Linph * @param[in] lc #LinphoneCore object. * @return The #LinphoneFirewallPolicy that is being used. * @ingroup network_parameters - * @deprecated Use linphone_core_get_nat_policy() instead. + * @deprecated Use linphone_core_get_nat_policy() instead + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc); @@ -2714,6 +2732,7 @@ LINPHONE_PUBLIC bool_t linphone_core_sound_device_can_playback(LinphoneCore *lc, * Get ring sound level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_ring_level(LinphoneCore *lc); @@ -2721,6 +2740,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_ring_level(LinphoneCor * Get playback sound level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_play_level(LinphoneCore *lc); @@ -2728,6 +2748,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_play_level(LinphoneCor * Get sound capture level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_rec_level(LinphoneCore *lc); @@ -2735,6 +2756,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_rec_level(LinphoneCore * Set sound ring level in 0-100 scale. * @ingroup media_parameters * @deprecated + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_ring_level(LinphoneCore *lc, int level); @@ -2742,6 +2764,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_ring_level(LinphoneCo * Set sound playback level in 0-100 scale. * @deprecated * @ingroup media_parameters + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_play_level(LinphoneCore *lc, int level); @@ -2749,6 +2772,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_play_level(LinphoneCo * Set sound capture level in 0-100 scale. * @deprecated * @ingroup media_parameters + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_rec_level(LinphoneCore *lc, int level); @@ -3021,12 +3045,14 @@ bool_t linphone_core_agc_enabled(const LinphoneCore *lc); /** * @deprecated Use #linphone_core_enable_mic instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted); /** * Get mic state. * @deprecated Use #linphone_core_mic_enabled instead + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_core_is_mic_muted(LinphoneCore *lc); @@ -3170,6 +3196,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_supported(LinphoneCore *lc); * @param display_enabled indicates whether video display should be shown * @ingroup media_parameters * @deprecated Use #linphone_core_enable_video_capture and #linphone_core_enable_video_display instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); @@ -3732,6 +3759,7 @@ LINPHONE_PUBLIC LinphoneConfig * linphone_core_get_config(LinphoneCore *lc); * @param[in] filename The filename of the config file to read to fill the instantiated LpConfig * @ingroup misc * @deprecated Use linphone_core_create_config() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneConfig * linphone_core_create_lp_config(LinphoneCore *lc, const char *filename); @@ -3758,6 +3786,7 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_sip_setups(LinphoneCore * * @param[in] lc LinphoneCore object * @ingroup initializing * @deprecated Use linphone_core_unref() instead. + * @donotwrap **/ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_destroy(LinphoneCore *lc); @@ -4805,8 +4834,9 @@ LINPHONE_PUBLIC LinphoneFriend * linphone_core_create_friend_with_address(Linpho * @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved * @param[in] os #LinphoneOnlineStatus * @deprecated Use linphone_core_set_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os); /** * Set my presence model @@ -4820,8 +4850,9 @@ LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, Linphone * @param[in] lc #LinphoneCore object * @return #LinphoneOnlineStatus * @deprecated Use linphone_core_get_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); /** * Get my presence model @@ -4846,8 +4877,9 @@ LINPHONE_PUBLIC void linphone_core_set_consolidated_presence(LinphoneCore *lc, L /** * @deprecated Use linphone_core_interpret_url() instead + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result); /** * Add a friend to the current buddy list, if \link linphone_friend_enable_subscribes() subscription attribute \endlink is set, a SIP SUBSCRIBE message is sent. @@ -4862,8 +4894,9 @@ LINPHONE_PUBLIC void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend * * @param lc #LinphoneCore object * @param fr #LinphoneFriend to remove * @deprecated use linphone_friend_list_remove_friend() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); /** * Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy; @@ -4877,8 +4910,9 @@ LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneF * @param[in] lc #LinphoneCore object * @return \bctbx_list{LinphoneFriend} * @deprecated use linphone_core_get_friends_lists() or linphone_friend_list_get_friends() instead. + * @donotwrap */ -LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); /** * Notify all friends that have subscribed @@ -4893,8 +4927,9 @@ LINPHONE_PUBLIC void linphone_core_notify_all_friends(LinphoneCore *lc, Linphone * @param[in] addr The address to use to search the friend. * @return The #LinphoneFriend object corresponding to the given address. * @deprecated use linphone_core_find_friend() instead. + * @donotwrap */ -LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr); /** * Search a LinphoneFriend by its address. diff --git a/include/linphone/friend.h b/include/linphone/friend.h index f3520f857..3c1e5d1b5 100644 --- a/include/linphone/friend.h +++ b/include/linphone/friend.h @@ -35,6 +35,7 @@ extern "C" { * Contructor * @return a new empty #LinphoneFriend * @deprecated use #linphone_core_create_friend instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend * linphone_friend_new(void); @@ -43,6 +44,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend * linphone_friend_new(void); * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink * @deprecated use #linphone_core_create_friend_with_address instead + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_friend_new_with_address(const char *addr); @@ -56,8 +58,9 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneFriend *linphone_friend_new_with_add * Destroy a LinphoneFriend. * @param lf LinphoneFriend object * @deprecated Use linphone_friend_unref() instead. + * @donotwrap */ -LINPHONE_PUBLIC void linphone_friend_destroy(LinphoneFriend *lf); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_friend_destroy(LinphoneFriend *lf); /** * Set #LinphoneAddress for this friend @@ -191,8 +194,9 @@ LINPHONE_PUBLIC void linphone_friend_done(LinphoneFriend *fr); * @param[in] lf A #LinphoneFriend object * @return #LinphoneOnlineStatus * @deprecated Use linphone_friend_get_presence_model() instead + * @donotwrap */ -LINPHONE_PUBLIC LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf); /** * Get subscription state of a friend diff --git a/include/linphone/info_message.h b/include/linphone/info_message.h index 5fe3e5db2..06a59ee2a 100644 --- a/include/linphone/info_message.h +++ b/include/linphone/info_message.h @@ -77,6 +77,7 @@ LINPHONE_PUBLIC void linphone_info_message_unref(LinphoneInfoMessage *im); /** * Destroy a LinphoneInfoMessage. * @deprecated Use linphone_info_message_unref() instead. + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_info_message_destroy(LinphoneInfoMessage *im); diff --git a/include/linphone/lpconfig.h b/include/linphone/lpconfig.h index 330d7e8ff..a76a1580e 100644 --- a/include/linphone/lpconfig.h +++ b/include/linphone/lpconfig.h @@ -276,6 +276,7 @@ LINPHONE_PUBLIC void linphone_config_write_relative_file(const LinphoneConfig *l * @param data Buffer where read string will be stored * @param max_length Length of the buffer * @return 0 on success, -1 on failure + * @donotwrap */ LINPHONE_PUBLIC int linphone_config_read_relative_file(const LinphoneConfig *lpconfig, const char *filename, char *data, size_t max_length); diff --git a/include/linphone/misc.h b/include/linphone/misc.h index ce9d2e74a..cb27cbe54 100644 --- a/include/linphone/misc.h +++ b/include/linphone/misc.h @@ -113,8 +113,9 @@ LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err); * Return humain readable presence status * @param ss * @deprecated Use #LinphonePresenceModel, #LinphonePresenceActivity and linphone_presence_activity_to_string() instead. + * @donotwrap */ -LINPHONE_PUBLIC const char *linphone_online_status_to_string(LinphoneOnlineStatus ss); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_online_status_to_string(LinphoneOnlineStatus ss); /** * Convert a string into LinphoneTunnelMode enum diff --git a/include/linphone/proxy_config.h b/include/linphone/proxy_config.h index eb6a30d02..6c305140b 100644 --- a/include/linphone/proxy_config.h +++ b/include/linphone/proxy_config.h @@ -33,8 +33,9 @@ extern "C" { /** * Creates an empty proxy config. * @deprecated, use #linphone_core_create_proxy_config instead + * @donotwrap **/ -LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_new(void); +LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneProxyConfig *linphone_proxy_config_new(void); /** * Acquire a reference to the proxy config. @@ -75,8 +76,9 @@ LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *c /** * @deprecated Use linphone_proxy_config_set_identity_address() + * @donotwrap **/ -LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity); +LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_proxy_config_set_identity(LinphoneProxyConfig *cfg, const char *identity); /** * Sets the user identity as a SIP address. @@ -228,8 +230,9 @@ LINPHONE_PUBLIC LinphoneRegistrationState linphone_proxy_config_get_state(const /** * @return a boolean indicating that the user is sucessfully registered on the proxy. * @deprecated Use linphone_proxy_config_get_state() instead. + * @donotwrap **/ -LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *cfg); /** * Get the domain name of the given proxy config. @@ -249,7 +252,6 @@ LINPHONE_PUBLIC const char *linphone_proxy_config_get_realm(const LinphoneProxyC * Set the realm of the given proxy config. * @param[in] cfg #LinphoneProxyConfig object. * @param[in] realm New realm value. - * @return The realm of the proxy config. **/ LINPHONE_PUBLIC void linphone_proxy_config_set_realm(LinphoneProxyConfig *cfg, const char * realm); @@ -265,8 +267,9 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_proxy_config_get_identity_addres /** * @deprecated use linphone_proxy_config_get_identity_address() + * @donotwrap **/ -LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *cfg); /** * @return TRUE if PUBLISH request is enabled for this proxy. @@ -380,12 +383,12 @@ LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphonePr /** * Destroys a proxy config. - * @deprecated - * * @note: LinphoneProxyConfig that have been removed from LinphoneCore with * linphone_core_remove_proxy_config() must not be freed. + * @deprecated + * @donotwrap **/ -LINPHONE_PUBLIC void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg); LINPHONE_PUBLIC void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type); @@ -409,6 +412,7 @@ LINPHONE_PUBLIC bool_t linphone_proxy_config_is_phone_number(LinphoneProxyConfig * @param result_len the size of the normalized number \a result * @return TRUE if a phone number was recognized, FALSE otherwise. * @deprecated use linphone_proxy_config_normalize_phone_number() + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_proxy_config_normalize_number(LinphoneProxyConfig *proxy, const char *username, char *result, size_t result_len); @@ -456,6 +460,7 @@ LINPHONE_PUBLIC LinphonePrivacyMask linphone_proxy_config_get_privacy(const Linp * @param[in] cfg #LinphoneProxyConfig object. * @param server_url URL of the file server like https://file.linphone.org/upload.php * @warning That function isn't implemented yet. + * @donotwrap * */ LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProxyConfig *cfg, const char * server_url); @@ -464,6 +469,7 @@ LINPHONE_PUBLIC void linphone_proxy_config_set_file_transfer_server(LinphoneProx * @param[in] cfg #LinphoneProxyConfig object. * @return URL of the file server like https://file.linphone.org/upload.php * @warning That function isn't implemented yet. + * @donotwrap * */ LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const LinphoneProxyConfig *cfg); @@ -472,16 +478,18 @@ LINPHONE_PUBLIC const char* linphone_proxy_config_get_file_transfer_server(const * @param[in] cfg #LinphoneProxyConfig object. * @param[in] enable True to enable AVPF/SAVF, false to disable it. * @deprecated use linphone_proxy_config_set_avpf_mode() + * @donotwrap */ -LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); +LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_proxy_config_enable_avpf(LinphoneProxyConfig *cfg, bool_t enable); /** * Indicates whether AVPF/SAVPF is being used for calls using this proxy config. * @param[in] cfg #LinphoneProxyConfig object. * @return True if AVPF/SAVPF is enabled, false otherwise. * @deprecated use linphone_proxy_config_set_avpf_mode() + * @donotwrap */ -LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); +LINPHONE_DEPRECATED LINPHONE_PUBLIC bool_t linphone_proxy_config_avpf_enabled(LinphoneProxyConfig *cfg); /** * Set the interval between regular RTCP reports when using AVPF/SAVPF. diff --git a/include/linphone/tunnel.h b/include/linphone/tunnel.h index 462a49fc3..3fbfa9c4b 100644 --- a/include/linphone/tunnel.h +++ b/include/linphone/tunnel.h @@ -208,6 +208,7 @@ LINPHONE_PUBLIC void linphone_tunnel_config_unref(LinphoneTunnelConfig *cfg); * Destroy a tunnel configuration * @param tunnel LinphoneTunnelConfig object * @deprecated use linphone_tunnel_config_unref(). + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel); @@ -342,6 +343,7 @@ LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy(LinphoneTunnel *tunnel, cons * @param port http proxy port * @param username Optional http proxy username if the proxy request authentication. Currently only basic authentication is supported. Use NULL if not needed. * @param passwd Optional http proxy password. Use NULL if not needed. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_tunnel_get_http_proxy(LinphoneTunnel*tunnel,const char **host, int *port, const char **username, const char **passwd); @@ -359,6 +361,7 @@ LINPHONE_PUBLIC void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel*tun * @param enabled If true enter in tunneled mode, if false exits from tunneled mode. * The TunnelManager takes care of refreshing SIP registration when switching on or off the tunneled mode. * @deprecated Replaced by linphone_tunnel_set_mode() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled); @@ -367,6 +370,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_enable(LinphoneTunnel * * @param tunnel Tunnel object * @return Returns a boolean indicating whether tunneled operation is enabled. * @deprecated Replaced by linphone_tunnel_get_mode() + * @donotwrap **/ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel); @@ -377,6 +381,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_enabled(const Linphon *
In case of success, the tunnel is automatically turned off. Otherwise, if no udp communication is feasible, tunnel mode is turned on. *
Call this method each time to run the auto detection algorithm * @deprecated Replaced by linphone_tunnel_set_mode(LinphoneTunnelModeAuto) + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel); @@ -385,6 +390,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_tunnel_auto_detect(LinphoneTun * @param[in] tunnel LinphoneTunnel object. * @return TRUE if auto detection is enabled, FALSE otherwise. * @deprecated Replaced by linphone_tunnel_get_mode() + * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel); diff --git a/include/linphone/types.h b/include/linphone/types.h index 1b6f2f6ad..3782621e9 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -227,8 +227,8 @@ typedef enum _LinphoneCallState{ LinphoneCallIncomingEarlyMedia, /**< We are proposing early media to an incoming call */ LinphoneCallUpdating, /**< A call update has been initiated by us */ LinphoneCallReleased, /**< The call object is no more retained by the core */ - LinphoneCallEarlyUpdatedByRemote, /*< The call is updated by remote while not yet answered (early dialog SIP UPDATE received) */ - LinphoneCallEarlyUpdating /*< We are updating the call while not yet answered (early dialog SIP UPDATE sent) */ + LinphoneCallEarlyUpdatedByRemote, /**< The call is updated by remote while not yet answered (early dialog SIP UPDATE received) */ + LinphoneCallEarlyUpdating /**< We are updating the call while not yet answered (early dialog SIP UPDATE sent) */ } LinphoneCallState; /** @@ -362,8 +362,9 @@ typedef unsigned int LinphoneContactSearchID; /** * Old name of LinphoneContactSearchID * @deprecated + * @donotwrap */ -typedef LinphoneContactSearchID ContactSearchID; +LINPHONE_DEPRECATED typedef LinphoneContactSearchID ContactSearchID; /** * The LinphoneContent object holds data that can be embedded in a signaling message. @@ -428,6 +429,7 @@ typedef struct _LinphoneFactory LinphoneFactory; * Policy to use to pass through firewalls. * @ingroup network_parameters * @deprecated Use #LinphoneNatPolicy instead. + * @donotwrap **/ typedef enum _LinphoneFirewallPolicy { LinphonePolicyNoFirewall, /**< Do not use any mechanism to pass through firewalls */ @@ -590,6 +592,7 @@ typedef struct _LinphoneNatPolicy LinphoneNatPolicy; /** * Enum describing remote friend status * @deprecated Use #LinphonePresenceModel and #LinphonePresenceActivity instead + * @donotwrap */ typedef enum _LinphoneOnlineStatus{ LinphoneStatusOffline, /**< Offline */ @@ -912,8 +915,9 @@ typedef struct _LinphoneSipTransports { /** * Old name of LinphoneSipTransports * @deprecated + * @donotwrap */ -typedef struct _LinphoneSipTransports LCSipTransports; +LINPHONE_DEPRECATED typedef struct _LinphoneSipTransports LCSipTransports; typedef struct _LinphoneSoundDaemon LinphoneSoundDaemon; diff --git a/include/linphone/vcard.h b/include/linphone/vcard.h index ef82e91c1..23b3e9d42 100644 --- a/include/linphone/vcard.h +++ b/include/linphone/vcard.h @@ -41,6 +41,7 @@ extern "C" * Creates a LinphoneVcard object that has a pointer to an empty vCard * @return a new LinphoneVcard object * @deprecated Use linphone_factory_create_vcard() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); @@ -48,6 +49,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneVcard* linphone_vcard_new(void); * Deletes a LinphoneVcard object properly * @param[in] vCard the LinphoneVcard to destroy * @deprecated Use linphone_vcard_unref() or belle_sip_object_unref() instead. + * @donotwrap */ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard); diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index eeaf10e08..c5fcc8066 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -433,62 +433,11 @@ class CParser(object): self.cListType = 'bctbx_list_t' self.regexFixedSizeInteger = '^(u?)int(\d?\d)_t$' self.methodBl = ['ref', 'unref', 'new', 'destroy', 'getCurrentCallbacks', 'setUserData', 'getUserData'] - self.functionBl = ['linphone_tunnel_get_http_proxy', - 'linphone_core_can_we_add_call', - 'linphone_core_add_listener', - 'linphone_core_remove_listener', + self.functionBl = [ 'linphone_core_get_current_callbacks', - 'linphone_proxy_config_set_file_transfer_server', - 'linphone_proxy_config_get_file_transfer_server', 'linphone_factory_create_core', # manualy wrapped 'linphone_factory_create_core_with_config', # manualy wrapped - 'linphone_buffer_get_content', - 'linphone_chat_room_send_chat_message', # overloaded - 'linphone_chat_message_resend', # overloaded - 'linphone_config_read_relative_file', - 'linphone_vcard_get_belcard', # manualy wrapped - 'linphone_chat_room_destroy', # was deprecated when the wrapper generator was made - 'linphone_chat_room_send_message', # was deprecated when the wrapper generator was made - 'linphone_chat_room_send_message2', # was deprecated when the wrapper generator was made - 'linphone_chat_room_get_lc', # was deprecated when the wrapper generator was made - 'linphone_chat_message_start_file_download', # was deprecated when the wrapper generator was made - 'linphone_vcard_new', # was deprecated when the wrapper generator was made - 'linphone_vcard_free', # was deprecated when the wrapper generator was made - 'linphone_call_params_destroy', # was deprecated when the wrapper generator was made - 'linphone_address_is_secure', # was deprecated when the wrapper generator was made - 'linphone_address_destroy', # was deprecated when the wrapper generator was made - 'linphone_core_enable_logs', # was deprecated when the wrapper generator was made - 'linphone_core_enable_logs_with_cb', # was deprecated when the wrapper generator was made - 'linphone_core_disable_logs', # was deprecated when the wrapper generator was made - 'linphone_core_get_user_agent_name', # was deprecated when the wrapper generator was made - 'linphone_core_get_user_agent_version', # was deprecated when the wrapper generator was made - 'linphone_core_new', # was deprecated when the wrapper generator was made - 'linphone_core_new_with_config', # was deprecated when the wrapper generator was made - 'linphone_core_add_listener', # was deprecated when the wrapper generator was made - 'linphone_core_remove_listener', # was deprecated when the wrapper generator was made - 'linphone_core_send_dtmf', # was deprecated when the wrapper generator was made - 'linphone_core_get_default_proxy', # was deprecated when the wrapper generator was made - 'linphone_core_set_firewall_policy', # was deprecated when the wrapper generator was made - 'linphone_core_get_firewall_policy', # was deprecated when the wrapper generator was made - 'linphone_core_get_ring_level', # was deprecated when the wrapper generator was made - 'linphone_core_get_play_level', # was deprecated when the wrapper generator was made - 'linphone_core_get_rec_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_ring_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_play_level', # was deprecated when the wrapper generator was made - 'linphone_core_set_rec_level', # was deprecated when the wrapper generator was made - 'linphone_core_mute_mic', # was deprecated when the wrapper generator was made - 'linphone_core_is_mic_muted', # was deprecated when the wrapper generator was made - 'linphone_core_enable_video', # was deprecated when the wrapper generator was made - 'linphone_core_create_lp_config', # was deprecated when the wrapper generator was made - 'linphone_core_destroy', # was deprecated when the wrapper generator was made - 'linphone_proxy_config_normalize_number', # was deprecated when the wrapper generator was made - 'linphone_call_is_in_conference', # was deprecated when the wrapper generator was made - 'linphone_friend_new', # was deprecated when the wrapper generator was made - 'linphone_friend_new_with_address', # was deprecated when the wrapper generator was made - 'linphone_core_get_sound_source', # was deprecated when the wrapper generator was made - 'linphone_core_set_sound_source', # was deprecated when the wrapper generator was made - 'linphone_core_get_sip_transports', # not wrappable - 'linphone_core_get_sip_transports_used'] # not wrappable + 'linphone_vcard_get_belcard'] # manualy wrapped self.classBl = ['LpConfig', 'LinphonePayloadType', From c724a3fb3788f8f602e5d91756a6c81e4691ff61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 28 Mar 2017 08:49:04 +0200 Subject: [PATCH 06/32] Fix several compilation warnings caused by newly deprecated functions --- coreapi/contact_providers_priv.h | 2 +- coreapi/contactprovider.c | 2 +- coreapi/linphonecore.c | 12 ++++++------ coreapi/misc.c | 4 ++-- coreapi/private.h | 2 +- coreapi/proxy.c | 2 +- include/linphone/chat.h | 2 +- include/linphone/contactprovider.h | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/coreapi/contact_providers_priv.h b/coreapi/contact_providers_priv.h index 58527c9d6..d52af6c5f 100644 --- a/coreapi/contact_providers_priv.h +++ b/coreapi/contact_providers_priv.h @@ -24,7 +24,7 @@ struct _LinphoneContactSearch{ belle_sip_object_t base; - ContactSearchID id; + LinphoneContactSearchID id; char* predicate; ContactSearchCallback cb; void* data; diff --git a/coreapi/contactprovider.c b/coreapi/contactprovider.c index ac5d9fc4d..5c1a36b75 100644 --- a/coreapi/contactprovider.c +++ b/coreapi/contactprovider.c @@ -38,7 +38,7 @@ static void linphone_contact_search_destroy( LinphoneContactSearch* req) { if( req->predicate ) ms_free(req->predicate); } -ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj) +LinphoneContactSearchID linphone_contact_search_get_id(LinphoneContactSearch* obj) { return obj->id; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 7d85d2717..3e496caa3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1231,7 +1231,7 @@ static void certificates_config_read(LinphoneCore *lc) { static void sip_config_read(LinphoneCore *lc) { char *contact; const char *tmpstr; - LCSipTransports tr; + LinphoneSipTransports tr; int i,tmp; int ipv6_default = TRUE; @@ -2557,7 +2557,7 @@ void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833) } int linphone_core_get_sip_port(LinphoneCore *lc){ - LCSipTransports tr; + LinphoneSipTransports tr; linphone_core_get_sip_transports_used(lc,&tr); return tr.udp_port>0 ? tr.udp_port : (tr.tcp_port > 0 ? tr.tcp_port : tr.tls_port); } @@ -2592,7 +2592,7 @@ static void transport_error(LinphoneCore *lc, const char* transport, int port){ ms_free(msg); } -static bool_t transports_unchanged(const LCSipTransports * tr1, const LCSipTransports * tr2){ +static bool_t transports_unchanged(const LinphoneSipTransports * tr1, const LinphoneSipTransports * tr2){ return tr2->udp_port==tr1->udp_port && tr2->tcp_port==tr1->tcp_port && @@ -2614,7 +2614,7 @@ static void __linphone_core_invalidate_registers(LinphoneCore* lc){ int _linphone_core_apply_transports(LinphoneCore *lc){ Sal *sal=lc->sal; const char *anyaddr; - LCSipTransports *tr=&lc->sip_conf.transports; + LinphoneSipTransports *tr=&lc->sip_conf.transports; const char* listening_address; /*first of all invalidate all current registrations so that we can register again with new transports*/ __linphone_core_invalidate_registers(lc); @@ -2662,7 +2662,7 @@ bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTra } int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * tr_config /*config to be saved*/){ - LCSipTransports tr=*tr_config; + LinphoneSipTransports tr=*tr_config; if (lp_config_get_int(lc->config,"sip","sip_random_port",0)==1) { /*legacy random mode*/ @@ -2707,7 +2707,7 @@ void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTranspor } void linphone_core_set_sip_port(LinphoneCore *lc,int port) { - LCSipTransports tr; + LinphoneSipTransports tr; memset(&tr,0,sizeof(tr)); tr.udp_port=port; linphone_core_set_sip_transports (lc,&tr); diff --git a/coreapi/misc.c b/coreapi/misc.c index c57dfe764..6b4d655d2 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1291,7 +1291,7 @@ void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun } static int get_unique_transport(LinphoneCore *lc, LinphoneTransportType *type, int *port){ - LCSipTransports tp; + LinphoneSipTransports tp; linphone_core_get_sip_transports(lc,&tp); if (tp.tcp_port==0 && tp.tls_port==0 && tp.udp_port!=0){ *type=LinphoneTransportUdp; @@ -1341,7 +1341,7 @@ int linphone_core_migrate_to_multi_transport(LinphoneCore *lc){ LinphoneTransportType tpt; int port; if (get_unique_transport(lc,&tpt,&port)==0){ - LCSipTransports newtp={0}; + LinphoneSipTransports newtp={0}; if (lp_config_get_int(lc->config,"sip","sip_random_port",0)) port=-1; ms_message("Core is using a single SIP transport, migrating proxy config and enabling multi-transport."); diff --git a/coreapi/private.h b/coreapi/private.h index be8e480ea..543b4efcb 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -811,7 +811,7 @@ typedef struct sip_config int in_call_timeout; /*timeout after a call is hangup */ int delayed_timeout; /*timeout after a delayed call is resumed */ unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ - LCSipTransports transports; + LinphoneSipTransports transports; bool_t guess_hostname; bool_t loopback_only; bool_t ipv6_enabled; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 1968d7896..758347676 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -688,7 +688,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c ms_free(flatten); } } - if (proxy==NULL) linphone_proxy_config_destroy(tmpproxy); + if (proxy==NULL) linphone_proxy_config_unref(tmpproxy); return result; } diff --git a/include/linphone/chat.h b/include/linphone/chat.h index 954d55611..7d41e3c59 100644 --- a/include/linphone/chat.h +++ b/include/linphone/chat.h @@ -41,7 +41,7 @@ extern "C" { * @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead. * @donotwrap */ -LINPHONE_DEPRECATED typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); +typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); /** * Call back used to notify message delivery status diff --git a/include/linphone/contactprovider.h b/include/linphone/contactprovider.h index bb435cd41..7dd83974a 100644 --- a/include/linphone/contactprovider.h +++ b/include/linphone/contactprovider.h @@ -28,7 +28,7 @@ extern "C" { /* LinphoneContactSearchRequest */ void linphone_contact_search_init(LinphoneContactSearch *obj, const char *predicate, ContactSearchCallback cb, void *cb_data); -ContactSearchID linphone_contact_search_get_id(LinphoneContactSearch *obj); +LinphoneContactSearchID linphone_contact_search_get_id(LinphoneContactSearch *obj); const char* linphone_contact_search_get_predicate(LinphoneContactSearch *obj); void linphone_contact_search_invoke_cb(LinphoneContactSearch *req, MSList *friends); LINPHONE_PUBLIC LinphoneContactSearch* linphone_contact_search_ref(void *obj); From 0f08eba9cd825cd226a2290c7f294afc602fc9a5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 28 Mar 2017 10:20:02 +0200 Subject: [PATCH 07/32] switch linphone_address parsing to fast version of belle_sip_header_address --- coreapi/bellesip_sal/sal_address_impl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index 3ee8343d7..6a9afe9d5 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SalAddress * sal_address_new(const char *uri){ belle_sip_header_address_t* result; if (uri) { - result=belle_sip_header_address_parse (uri); + result=belle_sip_header_address_fast_parse (uri); /*may return NULL*/ } else { result = belle_sip_header_address_new(); From 91c0fc4a174ba25fb5335f5abfb3e07aec086168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 28 Mar 2017 11:25:49 +0200 Subject: [PATCH 08/32] Fix a memory leak in "Remote conference" tests --- tester/tester.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tester/tester.c b/tester/tester.c index 1049ec17e..b2966cb96 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -895,5 +895,6 @@ LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bo } void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv) { + linphone_core_cbs_unref(conf_srv->cbs); linphone_core_manager_destroy((LinphoneCoreManager *)conf_srv); } From 9b236e535d607b1baa5c4beec0b7409c54dbd03a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 28 Mar 2017 15:49:44 +0200 Subject: [PATCH 09/32] avoid useless uri parsing when no presence model found for a friend --- coreapi/friend.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 216ba4c00..485739750 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -115,7 +115,11 @@ static LinphoneFriendPresence * find_presence_model_for_uri_or_tel(const Linphon ms_warning("Cannot find uri of tel [%s] from friend [%p] because not associated to any Linphone core object",uri_or_tel,lf); return NULL; } - iterator = lf->presence_models; + if ((iterator = lf->presence_models) == NULL) { + /*no need to move forward, just reutn to avoid useless uri parsing*/ + return NULL; + }; + uri_or_tel_addr = linphone_core_interpret_url(lf->lc, uri_or_tel); while (uri_or_tel_addr && iterator) { From 64584409aea15318d86ae7eca5434fc459375152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 28 Mar 2017 16:41:05 +0200 Subject: [PATCH 10/32] C++ wrapper: CMake scripts improvements --- CMakeLists.txt | 3 +-- coreapi/help/CMakeLists.txt | 9 ++++----- wrappers/cpp/CMakeLists.txt | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ddf728a6..d64ef8f1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,10 +312,9 @@ else() set(EXPORT_TARGETS_NAME "Linphone") endif() - +add_subdirectory(include) add_subdirectory(java) add_subdirectory(coreapi) -add_subdirectory(include) add_subdirectory(share) if(ENABLE_CONSOLE_UI) add_subdirectory(console) diff --git a/coreapi/help/CMakeLists.txt b/coreapi/help/CMakeLists.txt index 21051817a..5520284fc 100644 --- a/coreapi/help/CMakeLists.txt +++ b/coreapi/help/CMakeLists.txt @@ -26,14 +26,13 @@ if (ENABLE_DOC OR CXX_WRAPPER) if(DOXYGEN_DOT_FOUND) set(top_srcdir "${CMAKE_CURRENT_LIST_DIR}/../../") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - file(GLOB DOC_INPUT_FILES - [^.]*.c - [^.]*.dox - ../../include/linphone/[^.]*.h + set(DOC_INPUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + ${LINPHONE_HEADER_FILES} + ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.dox ) add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html" COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${DOC_INPUT_FILES} + DEPENDS ${DOC_INPUT_FILES} ) add_custom_target(linphone-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html") install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html" "${CMAKE_CURRENT_BINARY_DIR}/doc/xml" diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index b4c6bfba8..2ff57dd1f 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -44,8 +44,8 @@ target_link_libraries(linphone++ ) target_include_directories(linphone++ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include - PRIVATE ${CMAKE_BINARY_DIR}/include - PRIVATE ${CMAKE_SOURCE_DIR}/include + PRIVATE ${PROJECT_BINARY_DIR}/include + PRIVATE ${PROJECT_SOURCE_DIR}/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${BCTOOLBOX_INCLUDE_DIRS} PRIVATE ${BELLESIP_INCLUDE_DIRS} From d410536b2d9a57f4c9332be8cfcdc90d2ef5bc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 28 Mar 2017 16:41:52 +0200 Subject: [PATCH 11/32] =?UTF-8?q?C++=20wrapper:=C2=A0public=20structure=20?= =?UTF-8?q?support=20improvement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wrappers/cpp/abstractapi.py | 1 + wrappers/cpp/genwrapper.py | 8 +++++++- wrappers/cpp/tools.hh | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index c5fcc8066..01489ba41 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -726,6 +726,7 @@ class CParser(object): elif cType.ctype in self.classesIndex or cType.ctype in self.interfacesIndex: absType = ClassType(cType.ctype) absType.isconst = cType.completeType.startswith('const ') + absType.isref = cType.completeType.endswith('*') elif cType.ctype == self.cListType: absType = ListType(cType.containedType) else: diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index 8948432e8..d8e5d5fde 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -334,7 +334,13 @@ class CppTranslator(object): else: return 'Object::cPtrToSharedPtr<{0}>({1})'.format(cppReturnType, cExpr) else: - return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr); + if exprtype.isref: + return '{0}({1})'.format(exprtype.desc.name.to_camel_case(), cExpr) + else: + return '{0}(StructWrapper<::{1}>({2}).ptr())'.format( + exprtype.desc.name.to_camel_case(), + exprtype.desc.name.to_c(), + cExpr) elif type(exprtype) is AbsApi.ListType: if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': return 'StringBctbxListWrapper::bctbxListToCppList({0})'.format(cExpr) diff --git a/wrappers/cpp/tools.hh b/wrappers/cpp/tools.hh index 5d2fae0da..4ef512992 100644 --- a/wrappers/cpp/tools.hh +++ b/wrappers/cpp/tools.hh @@ -119,6 +119,20 @@ namespace linphone { static std::list cStringArrayToCppList(const char **cArray); }; + template + class StructWrapper { + public: + StructWrapper(const T &s) { + mStruct = s; + } + const void *ptr() const { + return &mStruct; + } + + private: + T mStruct; + }; + }; #endif // _TOOLS_HH From ee5b550ecb4b36fb3a93e8610bdd0fc12d0c7fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 28 Mar 2017 16:42:30 +0200 Subject: [PATCH 12/32] Linphone API: new functions to get port ranges --- coreapi/linphonecore.c | 24 ++++++++++++++++++++++++ coreapi/misc.c | 19 +++++++++++++++++++ include/linphone/core.h | 21 +++++++++++++++++++++ include/linphone/types.h | 10 ++++++++++ include/linphone/wrapper_utils.h | 24 ++++++++++++++++++++++++ 5 files changed, 98 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3e496caa3..4a0eccb36 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2442,6 +2442,14 @@ void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, i *max_port = lc->rtp_conf.audio_rtp_max_port; } +LinphoneIntRange linphone_core_get_audio_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.audio_rtp_min_port, + .max = lc->rtp_conf.audio_rtp_max_port + }; + return range; +} + int linphone_core_get_video_port(const LinphoneCore *lc){ return lc->rtp_conf.video_rtp_min_port; } @@ -2451,6 +2459,14 @@ void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, i *max_port = lc->rtp_conf.video_rtp_max_port; } +LinphoneIntRange linphone_core_get_video_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.video_rtp_min_port, + .max = lc->rtp_conf.video_rtp_max_port + }; + return range; +} + int linphone_core_get_text_port(const LinphoneCore *lc) { return lc->rtp_conf.text_rtp_min_port; } @@ -2460,6 +2476,14 @@ void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, in *max_port = lc->rtp_conf.text_rtp_max_port; } +LinphoneIntRange linphone_core_get_text_port_range_2(const LinphoneCore *lc) { + LinphoneIntRange range = { + .min = lc->rtp_conf.text_rtp_min_port, + .max = lc->rtp_conf.text_rtp_max_port + }; + return range; +} + int linphone_core_get_nortp_timeout(const LinphoneCore *lc){ return lc->rtp_conf.nortp_timeout; } diff --git a/coreapi/misc.c b/coreapi/misc.c index 6b4d655d2..862d8f570 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1884,3 +1884,22 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, linphone_call_set_symmetric_rtp(call, linphone_core_symmetric_rtp_enabled(linphone_call_get_core(call))); } } + + +/* Functions to mainpulate the LinphoneIntRange structure */ + +int linphone_int_range_get_min(const LinphoneIntRange *range) { + return range->min; +} + +int linphone_int_range_get_max(const LinphoneIntRange *range) { + return range->max; +} + +void linphone_int_range_set_min(LinphoneIntRange *range, int min) { + range->min = min; +} + +void linphone_int_range_set_max(LinphoneIntRange *range, int max) { + range->max = max; +} diff --git a/include/linphone/core.h b/include/linphone/core.h index 4f3bc85a3..0b1638380 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -2313,9 +2313,16 @@ LINPHONE_PUBLIC int linphone_core_get_audio_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the audio port range being used * @param[out] max_port The upper bound of the audio port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_audio_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_audio_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_audio_port_range_2(const LinphoneCore *lc); + /** * Gets the UDP port used for video streaming. * @param[in] lc LinphoneCore object @@ -2330,9 +2337,16 @@ LINPHONE_PUBLIC int linphone_core_get_video_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the video port range being used * @param[out] max_port The upper bound of the video port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_video_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_video_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_video_port_range_2(const LinphoneCore *lc); + /** * Gets the UDP port used for text streaming. * @param[in] lc LinphoneCore object @@ -2347,9 +2361,16 @@ LINPHONE_PUBLIC int linphone_core_get_text_port(const LinphoneCore *lc); * @param[out] min_port The lower bound of the text port range being used * @param[out] max_port The upper bound of the text port range being used * @ingroup network_parameters + * @donotwrap */ LINPHONE_PUBLIC void linphone_core_get_text_port_range(const LinphoneCore *lc, int *min_port, int *max_port); +/** + * Overload of linphone_core_get_text_port_range(). + * @ingroup network_parameters + */ +LINPHONE_PUBLIC LinphoneIntRange linphone_core_get_text_port_range_2(const LinphoneCore *lc); + /** * Gets the value of the no-rtp timeout. * diff --git a/include/linphone/types.h b/include/linphone/types.h index 3782621e9..4f1f3f4a3 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -1104,4 +1104,14 @@ typedef enum _LinphoneXmlRpcStatus { typedef struct _LsdPlayer LsdPlayer; +/** + * Structure describing a range of integers + * @ingroup misc + */ +typedef struct _LinphoneIntRange { + int min; /**< Minimum value */ + int max; /**< Maximum value */ +} LinphoneIntRange; + + #endif /* LINPHONE_TYPES_H_ */ diff --git a/include/linphone/wrapper_utils.h b/include/linphone/wrapper_utils.h index 5c05a1cc0..d06d5eab3 100644 --- a/include/linphone/wrapper_utils.h +++ b/include/linphone/wrapper_utils.h @@ -65,6 +65,30 @@ LINPHONE_PUBLIC void linphone_chat_message_resend(LinphoneChatMessage *msg); */ LINPHONE_PUBLIC void *linphone_vcard_get_belcard(LinphoneVcard *vcard); + + +/* Functions to mainpulate the LinphoneIntRange structure */ + +/** + * Get the minimum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC int linphone_int_range_get_min(const LinphoneIntRange *range); + +/** + * Get the maximum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC int linphone_int_range_get_max(const LinphoneIntRange *range); + +/** + * Set the minimum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC void linphone_int_range_set_min(LinphoneIntRange *range, int min); + +/** + * Set the maximum value of a #LinphoneIntRange. + */ +LINPHONE_PUBLIC void linphone_int_range_set_max(LinphoneIntRange *range, int max); + /** * @} */ From 54a0a0ff2f060316b33d404cafabd93a4a819aa3 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Mar 2017 17:13:13 +0100 Subject: [PATCH 13/32] Add account creator tester --- tester/CMakeLists.txt | 1 + tester/Makefile.am | 1 + tester/account_creator_tester.c | 401 ++++++++++++++++++++++++++++++ tester/liblinphone_tester.h | 1 + tester/rcfiles/account_creator_rc | 13 + tester/tester.c | 3 +- 6 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 tester/account_creator_tester.c create mode 100644 tester/rcfiles/account_creator_rc diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index e6073ef7c..cb3d4c129 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -159,6 +159,7 @@ set(IOS_RESOURCES_FILES set(SOURCE_FILES_C accountmanager.c + account_creator_tester.c audio_bypass_tester.c call_multicast_tester.c call_multi_tester.c diff --git a/tester/Makefile.am b/tester/Makefile.am index edcfd27d7..0b3bc0497 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -122,6 +122,7 @@ liblinphonetester_la_HEADERS = audio_bypass_wav_header.h liblinphonetester_la_SOURCES = \ accountmanager.c \ + account_creator_tester.c \ audio_bypass_tester.c \ call_multi_tester.c \ call_multicast_tester.c \ diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c new file mode 100644 index 000000000..2ae8cb6b0 --- /dev/null +++ b/tester/account_creator_tester.c @@ -0,0 +1,401 @@ +/* + liblinphone_tester - liblinphone test suite + Copyright (C) 2017 Belledonne Communications SARL + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "liblinphone_tester.h" + +static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php"; +static const char DOMAIN_URL[] = "sip.accounttest.org"; +static const char ROUTE_URL[] = "sip2.linphone.org:5072"; + +static const int TIMEOUT_REQUEST = 100000; + +/////////// LOCAL TESTS /////////// + +////// USERNAME ////// +static void local_username_too_short(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, ""), + LinphoneAccountCreatorUsernameTooShort, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_username_too_long(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, "usernametoolong"), + LinphoneAccountCreatorUsernameTooLong, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_username_invalid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, "use!"), + LinphoneAccountCreatorUsernameInvalid, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_username_invalid_size(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, "sizeinv"), + LinphoneAccountCreatorUsernameInvalidSize, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_username_ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, "user"), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// PASSWORD ////// + +static void local_password_too_short(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_password(creator, ""), + LinphoneAccountCreatorPasswordTooShort, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_password_too_long(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_password(creator, "passwordtoolong"), + LinphoneAccountCreatorPasswordTooLong, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_password_ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_username(creator, "pass"), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// EMAIL ////// + +static void local_email_invalid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test.linphone.org"), + LinphoneAccountCreatorEmailInvalid, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_email_ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test@linphone.org"), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// PHONE NUMBER ////// + +static void local_phone_number_too_short(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_phone_number(creator, "0123", "33"), + LinphoneAccountCreatorPhoneNumberTooShort, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_phone_number_too_long(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_phone_number(creator, "01234567891011", "33"), + LinphoneAccountCreatorPhoneNumberTooLong, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_phone_number_invalid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_phone_number(creator, NULL, "33"), + LinphoneAccountCreatorPhoneNumberInvalid, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_country_code_invalid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_phone_number(creator, "0123", ""), + LinphoneAccountCreatorCountryCodeInvalid, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// TRANSPORT ////// + +static void local_transport_not_supported(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_transport(creator, (LinphoneTransportType)4), + LinphoneAccountCreatorTransportNotSupported, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_transport_ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_transport(creator, LinphoneTransportTcp), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +////// DOMAIN ////// + +// Not implemented +/*static void local_domain_invalid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + BC_ASSERT_EQUAL( + linphone_account_creator_set_domain(creator, "sop2.linphone.org"), + LinphoneAccountCreatorDomainInvalid, + LinphoneAccountCreatorStatus, + "%i"); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +}*/ + +static void local_domain_ok(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_domain(creator, "sip2.linphone.org"), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +/////////// SERVER TESTS /////////// + +typedef struct _LinphoneAccountCreatorStats { + int cb_done; +} LinphoneAccountCreatorStats; + +static LinphoneAccountCreatorStats* new_linphone_account_creator_stats(void) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) ms_new0(LinphoneAccountCreatorStats, 1); + return stats; +} + +static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs); + stats->cb_done++; + BC_ASSERT_TRUE(stats->cb_done); +} + +/*static void account_creator_reset_cb_done(LinphoneAccountCreatorCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs); + stats->cb_done = 0; + BC_ASSERT_FALSE(stats->cb_done); +}*/ + +static void account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { + LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorStatus expected_status = (LinphoneAccountCreatorStatus)linphone_account_creator_get_user_data(creator); + BC_ASSERT_EQUAL( + status, + expected_status, + LinphoneAccountCreatorStatus, + "%i"); + account_creator_set_cb_done(cbs); +} + +static void server_account_doesnt_exist(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_cbs_set_user_data(cbs, stats); + linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountNotExist); + linphone_account_creator_set_username(creator, "user_not_exist"); + linphone_account_creator_set_route(creator, ROUTE_URL); + linphone_account_creator_set_domain(creator, DOMAIN_URL); + linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_used(creator), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_account_exist(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_cbs_set_user_data(cbs, stats); + linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_route(creator, ROUTE_URL); + linphone_account_creator_set_domain(creator, DOMAIN_URL); + linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_used(creator), + LinphoneAccountCreatorOK, + LinphoneAccountCreatorStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +test_t account_creator_tests[] = { + TEST_NO_TAG("Local - Username too short", local_username_too_short), + TEST_NO_TAG("Local - Username too long", local_username_too_long), + TEST_NO_TAG("Local - Username invalid", local_username_invalid), + TEST_NO_TAG("Local - Username invalid size", local_username_invalid_size), + TEST_NO_TAG("Local - Username Ok", local_username_ok), + TEST_NO_TAG("Local - Password too short", local_password_too_short), + TEST_NO_TAG("Local - Password too long", local_password_too_long), + TEST_NO_TAG("Local - Password Ok", local_password_ok), + TEST_NO_TAG("Local - Email invalid", local_email_invalid), + TEST_NO_TAG("Local - Email Ok", local_email_ok), + TEST_NO_TAG("Local - Phone number too short", local_phone_number_too_short), + TEST_NO_TAG("Local - Phone number too long", local_phone_number_too_long), + TEST_NO_TAG("Local - Phone number invalid", local_phone_number_invalid), + TEST_NO_TAG("Local - Country code invalid", local_country_code_invalid), + TEST_NO_TAG("Local - Transport not supported", local_transport_not_supported), + TEST_NO_TAG("Local - Transport Ok", local_transport_ok), + //TEST_NO_TAG("Local - Domain invalid", local_domain_invalid), Not implemented + TEST_NO_TAG("Local - Domain ok", local_domain_ok), + TEST_NO_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist), + TEST_NO_TAG("Server - Account exist", server_account_exist), +}; + +test_suite_t account_creator_test_suite = {"Account creator", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, + sizeof(account_creator_tests) / sizeof(account_creator_tests[0]), account_creator_tests}; diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 7ffcb969a..cf180625c 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -61,6 +61,7 @@ extern test_suite_t video_test_suite; extern test_suite_t multicast_call_test_suite; extern test_suite_t multi_call_test_suite; extern test_suite_t proxy_config_test_suite; +extern test_suite_t account_creator_test_suite; #ifdef VCARD_ENABLED extern test_suite_t vcard_test_suite; #endif diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc new file mode 100644 index 000000000..7b9aeaa87 --- /dev/null +++ b/tester/rcfiles/account_creator_rc @@ -0,0 +1,13 @@ +[assistant] +domain=sip.accounttest.org +password_max_length=8 +password_min_length=3 +username_length=4 +username_max_length=8 +username_min_length=3 +username_regex=^[a-z0-9_.\-]*$ +xmlrpc_url=https://sip2.linphone.org:445/wizard.php + +[proxy] +reg_proxy= +realm=sip.accounttest.org diff --git a/tester/tester.c b/tester/tester.c index b2966cb96..363e84b4e 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -419,7 +419,7 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) { LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); - + linphone_core_manager_init(manager, rc_file, phone_alias); linphone_core_manager_start(manager, check_for_proxies); return manager; @@ -560,6 +560,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&message_test_suite); bc_tester_add_suite(&presence_test_suite); bc_tester_add_suite(&presence_server_test_suite); + bc_tester_add_suite(&account_creator_test_suite); #ifdef UPNP bc_tester_add_suite(&upnp_test_suite); #endif From b41b920426e2d4ab2dbc6aa6e5ac6423023ca1e7 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 15 Mar 2017 17:25:51 +0100 Subject: [PATCH 14/32] Refactoring of account creator + tester of account creator --- coreapi/account_creator.c | 1319 ++++++++++++++++------------ coreapi/private.h | 89 +- gtk/setupwizard.c | 42 +- include/linphone/account_creator.h | 755 ++++++++++------ include/linphone/types.h | 143 ++- tester/account_creator_tester.c | 1260 +++++++++++++++++++++++--- tester/rcfiles/account_creator_rc | 5 +- 7 files changed, 2555 insertions(+), 1058 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index a5dc42705..32048b17d 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -1,6 +1,6 @@ /* linphone -Copyright (C) 2010-2015 Belledonne Communications SARL +Copyright (C) 2010-2017 Belledonne Communications SARL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,188 +25,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include -BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorCbs); +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorRequestCbs); -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorCbs, belle_sip_object_t, +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorRequestCbs, belle_sip_object_t, NULL, // destroy NULL, // clone NULL, // marshal FALSE ); +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorResponseCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorResponseCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +/************************** Start Misc **************************/ static const char* ha1_for_passwd(const char* username, const char* realm, const char* passwd) { static char ha1[33]; sal_auth_compute_ha1(username, realm, passwd, ha1); return ha1; } -static LinphoneAccountCreatorCbs * linphone_account_creator_cbs_new(void) { - return belle_sip_object_new(LinphoneAccountCreatorCbs); -} - -LinphoneAccountCreatorCbs * linphone_account_creator_cbs_ref(LinphoneAccountCreatorCbs *cbs) { - belle_sip_object_ref(cbs); - return cbs; -} - -void linphone_account_creator_cbs_unref(LinphoneAccountCreatorCbs *cbs) { - belle_sip_object_unref(cbs); -} - -void *linphone_account_creator_cbs_get_user_data(const LinphoneAccountCreatorCbs *cbs) { - return cbs->user_data; -} - -void linphone_account_creator_cbs_set_user_data(LinphoneAccountCreatorCbs *cbs, void *ud) { - cbs->user_data = ud; -} - -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, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->update_hash = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_used; -} - -void linphone_account_creator_cbs_set_is_account_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_used = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_create_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->create_account; -} - -void linphone_account_creator_cbs_set_create_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->create_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->activate_account; -} - -void linphone_account_creator_cbs_set_activate_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->activate_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_link_phone_number_with_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->link_phone_number_with_account; -} - -void linphone_account_creator_cbs_set_link_phone_number_with_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->link_phone_number_with_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_phone_number_link(const LinphoneAccountCreatorCbs *cbs) { - return cbs->activate_phone_number_link; -} - -void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->activate_phone_number_link = cb; -} - -void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_linked = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_linked; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_account_activated; -} - -void linphone_account_creator_cbs_set_is_account_activated(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_account_activated = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_recover_phone_account(const LinphoneAccountCreatorCbs *cbs) { - return cbs->recover_phone_account; -} - -void linphone_account_creator_cbs_set_recover_phone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->recover_phone_account = cb; -} - -LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_phone_number_used(const LinphoneAccountCreatorCbs *cbs) { - return cbs->is_phone_number_used; -} - -void linphone_account_creator_cbs_set_is_phone_number_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) { - cbs->is_phone_number_used = cb; -} - - -static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { - linphone_xml_rpc_session_release(creator->xmlrpc_session); /*this will drop all pending requests if any*/ - linphone_account_creator_cbs_unref(creator->callbacks); - if (creator->username) ms_free(creator->username); - if (creator->password) ms_free(creator->password); - if (creator->ha1) ms_free(creator->ha1); - if (creator->domain) ms_free(creator->domain); - if (creator->route) ms_free(creator->route); - if (creator->email) ms_free(creator->email); - if (creator->display_name) ms_free(creator->display_name); - if (creator->phone_country_code) ms_free(creator->phone_country_code); - if (creator->activation_code) ms_free(creator->activation_code); - if (creator->language) ms_free(creator->language); -} - -BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreator); - -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, - (belle_sip_object_destroy_t)_linphone_account_creator_destroy, - NULL, // clone - NULL, // marshal - FALSE -); - - -LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { - LinphoneAccountCreator *creator; - const char* domain = lp_config_get_string(core->config, "assistant", "domain", NULL); - creator = belle_sip_object_new(LinphoneAccountCreator); - creator->callbacks = linphone_account_creator_cbs_new(); - creator->core = core; - creator->xmlrpc_session = linphone_xml_rpc_session_new(core, xmlrpc_url); - if (domain) { - linphone_account_creator_set_domain(creator, domain); - } - return creator; -} - -LinphoneAccountCreator * linphone_account_creator_ref(LinphoneAccountCreator *creator) { - belle_sip_object_ref(creator); - return creator; -} - -void linphone_account_creator_unref(LinphoneAccountCreator *creator) { - belle_sip_object_unref(creator); -} - -void *linphone_account_creator_get_user_data(const LinphoneAccountCreator *creator) { - return creator->user_data; -} - -void linphone_account_creator_set_user_data(LinphoneAccountCreator *creator, void *ud) { - creator->user_data = ud; -} - -static LinphoneAccountCreatorStatus validate_uri(const char* username, const char* domain, const char* route, const char* display_name) { +static unsigned int validate_uri(LinphoneCore *lc, LinphoneProxyConfig *proxy, const char* username, const char* display_name) { LinphoneAddress* addr; - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; - LinphoneProxyConfig* proxy = linphone_proxy_config_new(); - linphone_proxy_config_set_identity(proxy, "sip:userame@domain.com"); - - if (route && linphone_proxy_config_set_route(proxy, route) != 0) { - status = LinphoneAccountCreatorRouteInvalid; - goto end; - } if (username) { addr = linphone_proxy_config_normalize_sip_uri(proxy, username); @@ -214,40 +59,29 @@ static LinphoneAccountCreatorStatus validate_uri(const char* username, const cha addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); } - if (addr == NULL) { - status = LinphoneAccountCreatorUsernameInvalid; - goto end; - } - - if (domain && linphone_address_set_domain(addr, domain) != 0) { - status = LinphoneAccountCreatorDomainInvalid; - } + if (addr == NULL) + return 1; if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { - status = LinphoneAccountCreatorDisplayNameInvalid; + linphone_address_unref(addr); + return 1; } + linphone_address_unref(addr); -end: - linphone_proxy_config_destroy(proxy); - return status; + return 0; } static char* _get_identity(const LinphoneAccountCreator *creator) { char *identity = NULL; - if ((creator->username || creator->phone_number) && creator->domain) { + if ((creator->username || creator->phone_number)) { //we must escape username - LinphoneProxyConfig* proxy = linphone_proxy_config_new(); + LinphoneProxyConfig* proxy = creator->proxy_cfg; LinphoneAddress* addr; - // creator->domain may contain some port or some transport (eg. toto.org:443;transport=tcp), - // we will accept that - char * tmpidentity = ms_strdup_printf("sip:username@%s", creator->domain); - linphone_proxy_config_set_identity(proxy, tmpidentity); - ms_free(tmpidentity); + addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username ? creator->username : creator->phone_number); identity = linphone_address_as_string(addr); linphone_address_unref(addr); - linphone_proxy_config_destroy(proxy); } return identity; } @@ -271,258 +105,23 @@ static bool_t is_matching_regex(const char *entry, const char* regex) { #endif } -LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username) { - int min_length = lp_config_get_int(creator->core->config, "assistant", "username_min_length", -1); - int fixed_length = lp_config_get_int(creator->core->config, "assistant", "username_length", -1); - int max_length = lp_config_get_int(creator->core->config, "assistant", "username_max_length", -1); - bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0); - const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0); - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorOK; - if (!username) { - creator->username = NULL; - return LinphoneAccountCreatorOK; - } else if (min_length > 0 && strlen(username) < (size_t)min_length) { - return LinphoneAccountCreatorUsernameTooShort; - } else if (max_length > 0 && strlen(username) > (size_t)max_length) { - return LinphoneAccountCreatorUsernameTooLong; - } else if (fixed_length > 0 && strlen(username) != (size_t)fixed_length) { - return LinphoneAccountCreatorUsernameInvalidSize; - } else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) { - return LinphoneAccountCreatorUsernameInvalid; - } else if (regex && !is_matching_regex(username, regex)) { - return LinphoneAccountCreatorUsernameInvalid; - } else if ((status = validate_uri(username, NULL, NULL, NULL)) != LinphoneAccountCreatorOK) { - return status; - } - - set_string(&creator->username, username, TRUE); - - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator) { - return creator->username; -} - - -LinphoneAccountCreatorStatus linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code) { - char *normalized_phone_number; - LinphoneAccountCreatorStatus return_status; - if (!phone_number || !country_code) { - if (!phone_number && !country_code) { - creator->phone_number = NULL; - creator->phone_country_code = NULL; - return LinphoneAccountCreatorOK; - } else { - return LinphoneAccountCreatorPhoneNumberInvalid; - } - } else { - LinphoneProxyConfig *numCfg = linphone_proxy_config_new(); - creator->phone_country_code = ms_strdup(country_code[0] == '+' ? &country_code[1] : country_code); - linphone_proxy_config_set_dial_prefix(numCfg, creator->phone_country_code); - normalized_phone_number = linphone_proxy_config_normalize_phone_number(numCfg, phone_number); - linphone_proxy_config_destroy(numCfg); - if (!normalized_phone_number) { - return LinphoneAccountCreatorPhoneNumberInvalid; - } - - // if phone is valid, we lastly want to check that length is OK - { - const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(creator->phone_country_code); - int size = (int)strlen(phone_number); - if (linphone_dial_plan_is_generic(plan)) { - return_status = LinphoneAccountCreatorCountryCodeInvalid; - goto end; - } - if (size < plan->nnl - 1) { - return_status = LinphoneAccountCreatorPhoneNumberTooShort; - goto end; - } else if (size > plan->nnl + 1) { - return_status = LinphoneAccountCreatorPhoneNumberTooLong; - goto end; - } - } - } - set_string(&creator->phone_number, normalized_phone_number, TRUE); - return_status = LinphoneAccountCreatorOK; - -end: - ms_free(normalized_phone_number); - return return_status; -} - -const char * linphone_account_creator_get_phone_number(const LinphoneAccountCreator *creator) { - return creator->phone_number; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password){ - int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1); - int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1); - if (!password) { - creator->password = NULL; - return LinphoneAccountCreatorPasswordTooShort; - } - if (min_length > 0 && strlen(password) < (size_t)min_length) { - return LinphoneAccountCreatorPasswordTooShort; - } else if (max_length > 0 && strlen(password) > (size_t)max_length) { - return LinphoneAccountCreatorPasswordTooLong; - } - set_string(&creator->password, password, FALSE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_password(const LinphoneAccountCreator *creator) { - return creator->password; -} - -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; - 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->update_hash(creator, status, resp); - } -} - -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->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, - 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; -} - -const char * linphone_account_creator_get_ha1(const LinphoneAccountCreator *creator) { - return creator->ha1; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code){ - set_string(&creator->activation_code, activation_code, FALSE); - return LinphoneAccountCreatorOK; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang) { - set_string(&creator->language, lang, FALSE); - return LinphoneAccountCreatorOK; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_transport(LinphoneAccountCreator *creator, LinphoneTransportType transport){ - if (!linphone_core_sip_transport_supported(creator->core, transport)) { - return LinphoneAccountCreatorTransportNotSupported; - } - creator->transport = transport; - return LinphoneAccountCreatorOK; -} - -LinphoneTransportType linphone_account_creator_get_transport(const LinphoneAccountCreator *creator) { - return creator->transport; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain){ - if (validate_uri(NULL, domain, NULL, NULL) != 0) { - return LinphoneAccountCreatorDomainInvalid; - } - set_string(&creator->domain, domain, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator) { - return creator->domain; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route) { - if (validate_uri(NULL, NULL, route, NULL) != 0) { - return LinphoneAccountCreatorRouteInvalid; - } - set_string(&creator->route, route, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator) { - return creator->route; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name) { - if (validate_uri(NULL, NULL, NULL, display_name) != 0) { - return LinphoneAccountCreatorDisplayNameInvalid; - } - set_string(&creator->display_name, display_name, FALSE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_display_name(const LinphoneAccountCreator *creator) { - return creator->display_name; -} - -LinphoneAccountCreatorStatus linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email) { - if (!is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) { - return LinphoneAccountCreatorEmailInvalid; - } - set_string(&creator->email, email, TRUE); - return LinphoneAccountCreatorOK; -} - -const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator) { - return creator->email; -} - -LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator) { - return creator->callbacks; -} - LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator) { LinphoneAuthInfo *info; - LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core); + LinphoneProxyConfig *cfg = creator->proxy_cfg; char *identity_str = _get_identity(creator); - LinphoneAddress *identity = linphone_address_new(identity_str); - char *route = NULL; - char *domain = NULL; + LinphoneAddress *identity = linphone_address_new(identity_str); + // char *route = NULL; + // char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } - if (creator->route) { - route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); - } - if (creator->domain) { - domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); - } + // if (creator->route) { + // route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); + // } + // if (creator->domain) { + // domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); + // } linphone_proxy_config_set_identity_address(cfg, identity); if (creator->phone_country_code) { linphone_proxy_config_set_dial_prefix(cfg, creator->phone_country_code); @@ -532,14 +131,14 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr snprintf(buff, sizeof(buff), "%d", dial_prefix_number); linphone_proxy_config_set_dial_prefix(cfg, buff); } - if (linphone_proxy_config_get_server_addr(cfg) == NULL) - linphone_proxy_config_set_server_addr(cfg, domain); - if (linphone_proxy_config_get_route(cfg) == NULL) - linphone_proxy_config_set_route(cfg, route); + // if (linphone_proxy_config_get_server_addr(cfg) == NULL) + // linphone_proxy_config_set_server_addr(cfg, domain); + // if (linphone_proxy_config_get_route(cfg) == NULL) + // linphone_proxy_config_set_route(cfg, route); linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); - if (strcmp(creator->domain, "sip.linphone.org") == 0) { + if (strcmp(linphone_proxy_config_get_realm(creator->proxy_cfg), "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { @@ -575,66 +174,587 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr linphone_proxy_config_unref(cfg); return NULL; } +/************************** End Misc **************************/ + +/************************** Start Account Creator requests_cbs **************************/ +static LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void) { + return belle_sip_object_new(LinphoneAccountCreatorRequestCbs); +} + +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_ref(requests_cbs); + return requests_cbs; +} + +void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_unref(requests_cbs); +} + +void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->user_data; +} + +void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud) { + requests_cbs->user_data = ud; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->create_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->create_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_exist_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_exist_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->activate_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->activate_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_activated_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_activated_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->link_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->link_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_alias_used_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_alias_used_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_linked_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->recover_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->update_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->update_account_request_cb = cb; +} + +/************************** End Account Creator requests_cbs **************************/ + +/************************** Start Account Creator Cbs **************************/ + +static LinphoneAccountCreatorResponseCbs * linphone_account_creator_reponses_cbs_new(void) { + return belle_sip_object_new(LinphoneAccountCreatorResponseCbs); +} + +LinphoneAccountCreatorResponseCbs * linphone_account_creator_responses_cbs_ref(LinphoneAccountCreatorResponseCbs *responses_cbs) { + belle_sip_object_ref(responses_cbs); + return responses_cbs; +} + +void linphone_account_creator_responses_cbs_unref(LinphoneAccountCreatorResponseCbs *responses_cbs) { + belle_sip_object_unref(responses_cbs); +} + +void *linphone_account_creator_responses_cbs_get_user_data(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->user_data; +} + +void linphone_account_creator_responses_cbs_set_user_data(LinphoneAccountCreatorResponseCbs *responses_cbs, void *ud) { + responses_cbs->user_data = ud; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_create_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->create_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_create_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->create_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_exist_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_exist_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_exist_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->activate_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_activate_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->activate_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_activated_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_activated_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_activated_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_link_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->link_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_link_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->link_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_alias_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->activate_alias_response_cb; +} + +void linphone_account_creator_responses_cbs_set_activate_alias_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->activate_alias_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_alias_used_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_alias_used_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_alias_used_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->is_account_linked_response_cb; +} + +void linphone_account_creator_responses_cbs_set_is_account_linked_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->is_account_linked_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_recover_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->recover_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_recover_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->recover_account_response_cb = cb; +} + +LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_update_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs) { + return responses_cbs->update_account_response_cb; +} + +void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb) { + responses_cbs->update_account_response_cb = cb; +} +/************************** End Account Creator Cbs **************************/ + +/************************** Start Account Creator data **************************/ +static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { + linphone_xml_rpc_session_release(creator->xmlrpc_session); /*this will drop all pending requests if any*/ + linphone_account_creator_requests_cbs_unref(creator->requests_cbs); + linphone_account_creator_responses_cbs_unref(creator->responses_cbs); + linphone_proxy_config_destroy(creator->proxy_cfg); + if (creator->username) ms_free(creator->username); + if (creator->display_name) ms_free(creator->display_name); + if (creator->password) ms_free(creator->password); + if (creator->ha1) ms_free(creator->ha1); + if (creator->phone_number) ms_free(creator->phone_number); + if (creator->phone_country_code) ms_free(creator->phone_country_code); + if (creator->email) ms_free(creator->email); + if (creator->language) ms_free(creator->language); + if (creator->activation_code) ms_free(creator->activation_code); +} + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreator); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, + (belle_sip_object_destroy_t)_linphone_account_creator_destroy, + NULL, // clone + NULL, // marshal + FALSE +); + +LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { + LinphoneAccountCreator *creator; + creator = belle_sip_object_new(LinphoneAccountCreator); + creator->requests_cbs = linphone_account_creator_requests_cbs_new(); + creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); + creator->core = core; + creator->xmlrpc_session = linphone_xml_rpc_session_new(core, xmlrpc_url); + creator->proxy_cfg = linphone_core_create_proxy_config(core); + linphone_account_creator_set_linphone_impl(creator); + return creator; +} + +void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator) { + creator->requests_cbs->create_account_request_cb = linphone_account_creator_create_account_custom; + creator->requests_cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; + creator->requests_cbs->activate_account_request_cb = linphone_account_creator_activate_account_custom; + creator->requests_cbs->is_account_activated_request_cb = linphone_account_creator_is_account_activated_custom; + creator->requests_cbs->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_custom; + creator->requests_cbs->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_custom; + creator->requests_cbs->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_custom; + creator->requests_cbs->is_account_linked_request_cb = linphone_account_creator_is_account_linked_custom; + creator->requests_cbs->recover_account_request_cb = linphone_account_creator_recover_phone_account_custom; + creator->requests_cbs->update_account_request_cb = linphone_account_creator_update_password_custom; +} + +LinphoneAccountCreator * linphone_account_creator_ref(LinphoneAccountCreator *creator) { + belle_sip_object_ref(creator); + return creator; +} + +void linphone_account_creator_unref(LinphoneAccountCreator *creator) { + belle_sip_object_unref(creator); +} + +void *linphone_account_creator_get_user_data(const LinphoneAccountCreator *creator) { + return creator->user_data; +} + +void linphone_account_creator_set_user_data(LinphoneAccountCreator *creator, void *ud) { + creator->user_data = ud; +} + +LinphoneUsernameCheck linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username) { + int min_length = lp_config_get_int(creator->core->config, "assistant", "username_min_length", -1); + int max_length = lp_config_get_int(creator->core->config, "assistant", "username_max_length", -1); + bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0); + const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0); + if (!username) { + creator->username = NULL; + return LinphoneUsernameOk; + } else if (min_length > 0 && strlen(username) < (size_t)min_length) { + return LinphoneUsernameTooShort; + } else if (max_length > 0 && strlen(username) > (size_t)max_length) { + return LinphoneUsernameTooLong; + } else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) { + return LinphoneUsernameInvalid; + } else if (regex && !is_matching_regex(username, regex)) { + return LinphoneUsernameInvalidCharacters; + } else if (validate_uri(creator->core, creator->proxy_cfg, username, NULL) != 0) { + return LinphoneUsernameInvalid; + } + + set_string(&creator->username, username, TRUE); + return LinphoneUsernameOk; +} + +const char * linphone_account_creator_get_username(const LinphoneAccountCreator *creator) { + return creator->username; +} + +LinphonePhoneNumberMask linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code) { + char *normalized_phone_number; + LinphonePhoneNumberMask return_status = 0; + if (!phone_number || !country_code) { + if (!phone_number && !country_code) { + creator->phone_number = NULL; + creator->phone_country_code = NULL; + return (LinphonePhoneNumberMask)LinphonePhoneNumberOk; + } else { + return (LinphonePhoneNumberMask)LinphonePhoneNumberInvalid; + } + } else { + LinphoneProxyConfig *numCfg = creator->proxy_cfg; + creator->phone_country_code = ms_strdup(country_code[0] == '+' ? &country_code[1] : country_code); + linphone_proxy_config_set_dial_prefix(numCfg, creator->phone_country_code); + normalized_phone_number = linphone_proxy_config_normalize_phone_number(numCfg, phone_number); + if (!normalized_phone_number) { + return LinphonePhoneNumberInvalid; + } + + // if phone is valid, we lastly want to check that length is OK + { + const LinphoneDialPlan* plan = linphone_dial_plan_by_ccc(creator->phone_country_code); + int size = (int)strlen(phone_number); + if (linphone_dial_plan_is_generic(plan)) { + return_status = LinphonePhoneNumberCountryCodeInvalid; + } + if (size < plan->nnl - 1) { + return_status += LinphonePhoneNumberTooShort; + goto end; + } else if (size > plan->nnl + 1) { + return_status += LinphonePhoneNumberTooLong; + goto end; + } else if (return_status & LinphonePhoneNumberCountryCodeInvalid) { + goto end; + } + } + } + set_string(&creator->phone_number, normalized_phone_number, TRUE); + return_status = LinphonePhoneNumberOk; +end: + ms_free(normalized_phone_number); + return return_status; +} + +const char * linphone_account_creator_get_phone_number(const LinphoneAccountCreator *creator) { + return creator->phone_number; +} + +LinphonePasswordCheck linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password) { + int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1); + int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1); + if (!password) { + creator->password = NULL; + return LinphonePasswordTooShort; + } + if (min_length > 0 && strlen(password) < (size_t)min_length) { + return LinphonePasswordTooShort; + } else if (max_length > 0 && strlen(password) > (size_t)max_length) { + return LinphonePasswordTooLong; + } + set_string(&creator->password, password, FALSE); + return LinphonePasswordOk; +} + +const char * linphone_account_creator_get_password(const LinphoneAccountCreator *creator) { + return creator->password; +} + +LinphonePasswordCheck linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1){ + set_string(&creator->ha1, ha1, FALSE); + return LinphonePasswordOk; +} + +const char * linphone_account_creator_get_ha1(const LinphoneAccountCreator *creator) { + return creator->ha1; +} + +LinphoneActivationCodeCheck linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code){ + set_string(&creator->activation_code, activation_code, FALSE); + return LinphoneActivationCodeOk; +} + +const char * linphone_account_creator_get_activation_code(const LinphoneAccountCreator *creator) { + return creator->activation_code; +} + +LinphoneLanguageCheck linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang) { + set_string(&creator->language, lang, FALSE); + return LinphoneLanguageOk; +} + +const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator) { + return creator->language; +} + +LinphoneUsernameCheck linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name) { + if (validate_uri(creator->core, creator->proxy_cfg, NULL, display_name) != 0) { + return LinphoneUsernameInvalid; + } + set_string(&creator->display_name, display_name, FALSE); + return LinphoneUsernameOk; +} + +const char * linphone_account_creator_get_display_name(const LinphoneAccountCreator *creator) { + return creator->display_name; +} + +LinphoneEmailCheck linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email) { + if (!is_matching_regex(email, "^.+@.+\\..*$")) { + return LinphoneEmailMalformed; + } + if (!is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) { + return LinphoneEmailInvalidCharacters; + } + set_string(&creator->email, email, TRUE); + return LinphoneEmailOk; +} + +const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator) { + return creator->email; +} + +LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator) { + return creator->responses_cbs; +} + +LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator) { + return creator->requests_cbs; +} + +LinphoneRequestStatus linphone_account_creator_is_account_exist(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_exist_request_cb == NULL + || creator->responses_cbs->is_account_exist_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_exist_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->create_account_request_cb == NULL + || creator->responses_cbs->create_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->create_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_activated_request_cb == NULL + || creator->responses_cbs->is_account_activated_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_activated_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->activate_account_request_cb == NULL + || creator->responses_cbs->activate_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->activate_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_link_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->link_account_request_cb == NULL + || creator->responses_cbs->link_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->link_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_activate_alias(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->activate_alias_request_cb == NULL + || creator->responses_cbs->activate_alias_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->activate_alias_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_alias_used(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_alias_used_request_cb == NULL + || creator->responses_cbs->is_alias_used_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_alias_used_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->is_account_linked_request_cb == NULL + || creator->responses_cbs->is_account_linked_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->is_account_linked_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->recover_account_request_cb == NULL + || creator->responses_cbs->recover_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->recover_account_request_cb(creator); +} + +LinphoneRequestStatus linphone_account_creator_update_account(LinphoneAccountCreator *creator) { + if (creator->requests_cbs->update_account_request_cb == NULL + || creator->responses_cbs->update_account_response_cb == NULL) { + return LinphoneRequestMissingCallbacks; + } + + return creator->requests_cbs->update_account_request_cb(creator); +} +/************************** End Account Creator data **************************/ + +/************************** Start Account Creator Linphone **************************/ /****************** START OF ACCOUNT USED SECTION *****************************/ -static void _is_account_used_cb(LinphoneXmlRpcRequest *request) { +static void _is_account_exist_response_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_used != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_exist_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotExist : ( - (strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountExist : - LinphoneAccountCreatorAccountExistWithAlias); - if (status == LinphoneAccountCreatorAccountExistWithAlias) { + status = (strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0) ? LinphoneRequestAccountNotExist : ( + (strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneRequestAccountExist : + LinphoneRequestAccountExistWithAlias); + if (status == LinphoneRequestAccountExistWithAlias) { set_string(&creator->phone_number, resp, FALSE); } } - creator->callbacks->is_account_used(creator, status, resp); + creator->responses_cbs->is_account_exist_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_used(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_exist_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->username && !creator->phone_number) { - if (creator->callbacks->is_account_used != NULL) { - creator->callbacks->is_account_used(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_exist_response_cb != NULL) { + creator->responses_cbs->is_account_exist_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_used_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_exist_response_cb); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT USED SECTION ************************/ /****************** START OF CREATE ACCOUNT SECTION ***************************/ -static void _create_account_cb(LinphoneXmlRpcRequest *request) { +static void _create_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->create_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->create_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorAccountCreated - : (strcmp(resp, "ERROR_CANNOT_SEND_SMS") == 0) ? LinphoneAccountCreatorErrorServer - : (strcmp(resp, "ERROR_ACCOUNT_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExist - : (strcmp(resp, "ERROR_ALIAS_ALREADY_IN_USE") == 0) ? LinphoneAccountCreatorAccountExistWithAlias - :LinphoneAccountCreatorAccountNotCreated; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestAccountCreated + : (strcmp(resp, "ERROR_CANNOT_SEND_SMS") == 0) ? LinphoneRequestErrorServer + : (strcmp(resp, "ERROR_ACCOUNT_ALREADY_IN_USE") == 0) ? LinphoneRequestAccountExist + : (strcmp(resp, "ERROR_ALIAS_ALREADY_IN_USE") == 0) ? LinphoneRequestAccountExistWithAlias + :LinphoneRequestAccountNotCreated; } - creator->callbacks->create_account(creator, status, resp); + creator->responses_cbs->create_account_response_cb(creator, status, resp); } } -static LinphoneXmlRpcRequest * _create_account_with_phone(LinphoneAccountCreator *creator) { +static LinphoneXmlRpcRequest * _create_account_with_phone_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number) { return NULL; @@ -642,78 +762,78 @@ static LinphoneXmlRpcRequest * _create_account_with_phone(LinphoneAccountCreator request = linphone_xml_rpc_request_new_with_args("create_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->password ? ha1_for_passwd(creator->username ? creator->username : creator->phone_number, creator->domain, creator->password) : "", + LinphoneXmlRpcArgString, creator->password ? ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) : "", LinphoneXmlRpcArgString, linphone_core_get_user_agent(creator->core), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); return request; } -static LinphoneXmlRpcRequest * _create_account_with_email(LinphoneAccountCreator *creator) { +static LinphoneXmlRpcRequest * _create_account_with_email_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->username || !creator->email) { + if (!creator->username || !creator->email || !creator->password) { return NULL; } request = linphone_xml_rpc_request_new_with_args("create_email_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->email, - LinphoneXmlRpcArgString, ha1_for_passwd(creator->username ? creator->username : creator->phone_number, creator->domain, creator->password), + LinphoneXmlRpcArgString, ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password), LinphoneXmlRpcArgString, linphone_core_get_user_agent(creator->core), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); return request; } -LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_create_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); - if (!identity || (!(request = _create_account_with_phone(creator)) - && !(request = _create_account_with_email(creator)))) { - if (creator->callbacks->create_account != NULL) { - creator->callbacks->create_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (!identity || (!(request = _create_account_with_phone_custom(creator)) + && !(request = _create_account_with_email_custom(creator)))) { + if (creator->responses_cbs->create_account_response_cb != NULL) { + creator->responses_cbs->create_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } if (identity) ms_free(identity); - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _create_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _create_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT SECTION *****************************/ /****************** START OF VALIDATE ACCOUNT SECTION *************************/ -static void _activate_account_cb(LinphoneXmlRpcRequest *request) { +static void _activate_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->activate_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->activate_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { if (strcmp(resp, "ERROR_ACCOUNT_ALREADY_ACTIVATED") == 0) { - status = LinphoneAccountCreatorAccountAlreadyActivated; + status = LinphoneRequestAccountAlreadyActivated; } else if (strstr(resp, "ERROR_") == resp) { - status = LinphoneAccountCreatorAccountNotActivated; + status = LinphoneRequestAccountNotActivated; } else { - status = LinphoneAccountCreatorAccountActivated; + status = LinphoneRequestAccountActivated; set_string(&creator->ha1, resp, FALSE); } } - creator->callbacks->activate_account(creator, status, resp); + creator->responses_cbs->activate_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_activate_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity || !creator->activation_code) { - if (creator->callbacks->is_account_activated != NULL) { - creator->callbacks->is_account_activated(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + creator->responses_cbs->is_account_activated_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } if (creator->phone_number) { @@ -721,236 +841,293 @@ LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneA LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->domain, + linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); } else { request = linphone_xml_rpc_request_new_with_args("activate_email_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->domain, + linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); } linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE VALIDATE ACCOUNT SECTION ********************/ /****************** START OF ACCOUNT VALIDATED SECTION ************************/ -static void _is_account_activated_cb(LinphoneXmlRpcRequest *request) { +static void _is_account_activated_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_activated != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorAccountActivated : LinphoneAccountCreatorAccountNotActivated; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestAccountActivated : LinphoneRequestAccountNotActivated; } - creator->callbacks->is_account_activated(creator, status, resp); + creator->responses_cbs->is_account_activated_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_activated_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity) { - if (creator->callbacks->is_account_activated != NULL) { - creator->callbacks->is_account_activated(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_account_activated_response_cb != NULL) { + creator->responses_cbs->is_account_activated_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("is_account_activated", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_activated_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_account_activated_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF CREATE ACCOUNT VALIDATED SECTION********************/ /****************** START OF PHONE NUMBER VALIDATED SECTION *******************/ -static void _is_phone_number_used_cb(LinphoneXmlRpcRequest *request) { +static void _is_phone_number_used_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_phone_number_used != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_alias_used_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK_ACCOUNT") == 0) ? LinphoneAccountCreatorPhoneNumberUsedAccount - : (strcmp(resp, "OK_ALIAS") == 0) ? LinphoneAccountCreatorPhoneNumberUsedAlias - : LinphoneAccountCreatorPhoneNumberNotUsed; + status = (strcmp(resp, "OK_ACCOUNT") == 0) ? LinphoneRequestAliasIsAccount + : (strcmp(resp, "OK_ALIAS") == 0) ? LinphoneRequestAliasExist + : LinphoneRequestAliasNotExist; } - creator->callbacks->is_phone_number_used(creator, status, resp); + creator->responses_cbs->is_alias_used_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_phone_number_used_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; char *identity = _get_identity(creator); if (!identity) { - if (creator->callbacks->is_phone_number_used != NULL) { - creator->callbacks->is_phone_number_used(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->is_alias_used_response_cb != NULL) { + creator->responses_cbs->is_alias_used_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("is_phone_number_used", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_phone_number_used_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _is_phone_number_used_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); ms_free(identity); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF PHONE NUMBER VALIDATED SECTION *********************/ /****************** START OF LINK PHONE NUMBER WITH ACCOUNT SECTION ***********/ -static void _link_phone_number_with_account_cb(LinphoneXmlRpcRequest *request) { +static void _link_phone_number_with_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->link_phone_number_with_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->link_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strcmp(resp, "OK") == 0) ? LinphoneAccountCreatorOK : LinphoneAccountCreatorReqFailed; + status = (strcmp(resp, "OK") == 0) ? LinphoneRequestOk : LinphoneRequestAccountNotLinked; } - creator->callbacks->link_phone_number_with_account(creator, status, resp); + creator->responses_cbs->link_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_link_phone_number_with_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number || !creator->username) { - if (creator->callbacks->link_phone_number_with_account != NULL) { - creator->callbacks->link_phone_number_with_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->link_account_response_cb != NULL) { + creator->responses_cbs->link_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("link_phone_number_with_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _link_phone_number_with_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _link_phone_number_with_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } -static void _get_phone_number_for_account_cb(LinphoneXmlRpcRequest *request) { +static void _get_phone_number_for_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->is_account_linked != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->is_account_linked_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { status = (strcmp(resp, "ERROR_USERNAME_PARAMETER_NOT_FOUND") == 0 || strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0 - || strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneAccountCreatorAccountNotLinked : LinphoneAccountCreatorAccountLinked; + || strcmp(resp, "ERROR_ALIAS_DOESNT_EXIST") == 0) ? LinphoneRequestAccountNotLinked : LinphoneRequestAccountLinked; } - creator->callbacks->link_phone_number_with_account(creator, status, resp); + creator->responses_cbs->is_account_linked_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_is_account_linked_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->username || !creator->domain) { - return LinphoneAccountCreatorReqFailed; + if (!creator->username || !linphone_proxy_config_get_domain(creator->proxy_cfg)) { + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account",LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->username, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_phone_number_for_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_phone_number_for_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF LINK PHONE NUMBER WITH ACCOUNT SECTION *************/ /****************** START OF ACTIVE PHONE NUMBER LINK **************************/ -static void _activate_phone_number_link_cb(LinphoneXmlRpcRequest *request) { +static void _activate_phone_number_link_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->activate_phone_number_link != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->activate_alias_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strstr(resp, "ERROR_") == resp) ? LinphoneAccountCreatorReqFailed : LinphoneAccountCreatorOK; + status = (strstr(resp, "ERROR_") == resp) ? LinphoneRequestAccountNotActivated : LinphoneRequestOk; } - creator->callbacks->activate_phone_number_link(creator, status, resp); + creator->responses_cbs->activate_alias_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_activate_phone_number_link_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; - if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !creator->domain) { - if (creator->callbacks->activate_phone_number_link != NULL) { - creator->callbacks->activate_phone_number_link(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (!creator->phone_number || !creator->username || !creator->activation_code || (!creator->password && !creator->ha1) || !linphone_proxy_config_get_domain(creator->proxy_cfg)) { + if (creator->responses_cbs->activate_alias_response_cb != NULL) { + creator->responses_cbs->activate_alias_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("activate_phone_number_link", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, - LinphoneXmlRpcArgString, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, creator->domain, creator->password), - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, creator->ha1 ? creator->ha1 : ha1_for_passwd(creator->username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password), + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_phone_number_link_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _activate_phone_number_link_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF ACTIVE PHONE NUMBER LINK **************************/ /****************** START OF ACTIVE PHONE NUMBER LINK **************************/ -static void _recover_phone_account_cb(LinphoneXmlRpcRequest *request) { +static void _recover_phone_account_cb_custom(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); - if (creator->callbacks->recover_phone_account != NULL) { - LinphoneAccountCreatorStatus status = LinphoneAccountCreatorReqFailed; + if (creator->responses_cbs->recover_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { if (strstr(resp, "ERROR_") == resp) { - status = (strstr(resp, "ERROR_CANNOT_SEND_SMS") == resp) ? LinphoneAccountCreatorErrorServer - : (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp) ? LinphoneAccountCreatorAccountNotExist - : LinphoneAccountCreatorReqFailed; + status = (strstr(resp, "ERROR_CANNOT_SEND_SMS") == resp) ? LinphoneRequestErrorServer + : (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp) ? LinphoneRequestAccountNotExist + : LinphoneRequestFailed; } else { - status = LinphoneAccountCreatorOK; + status = LinphoneRequestOk; set_string(&creator->username, resp, FALSE); } } - creator->callbacks->recover_phone_account(creator, status, resp); + creator->responses_cbs->recover_account_response_cb(creator, status, resp); } } -LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator) { +LinphoneRequestStatus linphone_account_creator_recover_phone_account_custom(LinphoneAccountCreator *creator) { LinphoneXmlRpcRequest *request; if (!creator->phone_number) { - if (creator->callbacks->recover_phone_account != NULL) { - creator->callbacks->recover_phone_account(creator, LinphoneAccountCreatorReqFailed, "Missing required parameters"); + if (creator->responses_cbs->recover_account_response_cb != NULL) { + creator->responses_cbs->recover_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); } - return LinphoneAccountCreatorReqFailed; + return LinphoneRequestMissingArguments; } request = linphone_xml_rpc_request_new_with_args("recover_phone_account", LinphoneXmlRpcArgString, LinphoneXmlRpcArgString, creator->phone_number, - LinphoneXmlRpcArgString, creator->domain, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, LinphoneXmlRpcArgNone); linphone_xml_rpc_request_set_user_data(request, creator); - linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _recover_phone_account_cb); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _recover_phone_account_cb_custom); linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); linphone_xml_rpc_request_unref(request); - return LinphoneAccountCreatorOK; + return LinphoneRequestOk; } /****************** END OF ACTIVE PHONE NUMBER LINK **************************/ + +/****************** START OF UPDATE ACCOUNT **************************/ +static void _password_updated_cb_custom(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + if (creator->responses_cbs->update_account_response_cb != NULL) { + LinphoneRequestStatus status = LinphoneRequestFailed; + 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 = LinphoneRequestOk; + } else if (strcmp(resp, "ERROR_PASSWORD_DOESNT_MATCH") == 0) { + status = LinphoneRequestAccountNotExist; + } else { + status = LinphoneRequestErrorServer; + } + } + creator->responses_cbs->update_account_response_cb(creator, status, resp); + } +} + +LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator){ + LinphoneXmlRpcRequest *request; + char *identity = _get_identity(creator); + const char* new_pwd = (const char*)linphone_account_creator_get_user_data(creator); + if (!identity || + (!creator->username || !creator->phone_number + || !linphone_proxy_config_get_domain(creator->proxy_cfg) + || (!creator->password && !creator->ha1) || !new_pwd + ) + ) { + if (creator->responses_cbs->update_account_response_cb != NULL) { + creator->responses_cbs->update_account_response_cb(creator, LinphoneRequestMissingArguments, "Missing required parameters"); + } + return LinphoneRequestMissingArguments; + } + + const char * username = creator->username ? creator->username : creator->phone_number; + const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) ); + const char * new_ha1 = ms_strdup(ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), new_pwd)); + + request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, username, + LinphoneXmlRpcArgString, ha1, + LinphoneXmlRpcArgString, new_ha1, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), + 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_custom); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} +/****************** END OF UPDATE ACCOUNT **************************/ + +/************************** End Account Creator Linphone **************************/ diff --git a/coreapi/private.h b/coreapi/private.h index 543b4efcb..c61e9e4d4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1389,43 +1389,73 @@ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneXmlRpcSession); * Account creator interface * ****************************************************************************/ -struct _LinphoneAccountCreatorCbs { +struct _LinphoneAccountCreatorRequestCbs { belle_sip_object_t base; void *user_data; - LinphoneAccountCreatorCbsStatusCb is_account_used; - LinphoneAccountCreatorCbsStatusCb create_account; - LinphoneAccountCreatorCbsStatusCb activate_account; - LinphoneAccountCreatorCbsStatusCb is_account_activated; - LinphoneAccountCreatorCbsStatusCb is_phone_number_used; - LinphoneAccountCreatorCbsStatusCb link_phone_number_with_account; - LinphoneAccountCreatorCbsStatusCb activate_phone_number_link; - LinphoneAccountCreatorCbsStatusCb recover_phone_account; - LinphoneAccountCreatorCbsStatusCb is_account_linked; - LinphoneAccountCreatorCbsStatusCb update_hash; + + LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */ + LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */ + + LinphoneAccountCreatorRequestFunc activate_account_request_cb; /**< Request to activate account */ + LinphoneAccountCreatorRequestFunc is_account_activated_request_cb; /**< Request to know if account is activated */ + + LinphoneAccountCreatorRequestFunc link_account_request_cb; /**< Request to link account with an alias */ + LinphoneAccountCreatorRequestFunc activate_alias_request_cb; /**< Request to activate the link of alias */ + LinphoneAccountCreatorRequestFunc is_alias_used_request_cb; /**< Request to know if alias is used */ + LinphoneAccountCreatorRequestFunc is_account_linked_request_cb; /**< Request to know if account is linked with an alias */ + + LinphoneAccountCreatorRequestFunc recover_account_request_cb; /**< Request to recover account */ + LinphoneAccountCreatorRequestFunc update_account_request_cb; /**< Request to update account */ }; -BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreatorCbs); +BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorRequestCbs); + +struct _LinphoneAccountCreatorResponseCbs { + belle_sip_object_t base; + void *user_data; + + LinphoneAccountCreatorResponseFunc create_account_response_cb; /**< Response of create_account request */ + LinphoneAccountCreatorResponseFunc is_account_exist_response_cb; /**< Response of is_account_exist request */ + + LinphoneAccountCreatorResponseFunc activate_account_response_cb; /**< Response of activate_account request */ + LinphoneAccountCreatorResponseFunc is_account_activated_response_cb; /**< Response of is_account_activated request */ + + LinphoneAccountCreatorResponseFunc link_account_response_cb; /**< Response of link_account request */ + LinphoneAccountCreatorResponseFunc activate_alias_response_cb; /**< Response of activation alias */ + LinphoneAccountCreatorResponseFunc is_alias_used_response_cb; /**< Response of is_alias_used request */ + LinphoneAccountCreatorResponseFunc is_account_linked_response_cb; /**< Response of is_account_linked request */ + + LinphoneAccountCreatorResponseFunc recover_account_response_cb; /**< Response of recover_account request */ + LinphoneAccountCreatorResponseFunc update_account_response_cb; /**< Response of update_account request */ +}; + +BELLE_SIP_DECLARE_VPTR(LinphoneAccountCreatorResponseCbs); struct _LinphoneAccountCreator { belle_sip_object_t base; void *user_data; - LinphoneAccountCreatorCbs *callbacks; - LinphoneXmlRpcSession *xmlrpc_session; LinphoneCore *core; - char *xmlrpc_url; - char *username; - char *phone_number; - char *password; - char *domain; - char *route; - char *email; - bool_t subscribe_to_newsletter; - char *display_name; - LinphoneTransportType transport; - char *activation_code; - char *ha1; - char *phone_country_code; - char *language; + + /* AccountCreator */ + LinphoneAccountCreatorRequestCbs *requests_cbs; /**< Account creator requests cbs */ + LinphoneAccountCreatorResponseCbs *responses_cbs; /**< Account creator responses cbs */ + LinphoneXmlRpcSession *xmlrpc_session; /**< XML-RPC session */ + LinphoneProxyConfig *proxy_cfg; /**< Default proxy config */ + + /* User */ + char *username; /**< Username */ + char *display_name; /**< Display name */ + /* Password */ + char *password; /**< Plain text password */ + char *ha1; /**< Hash password */ + /* Phone Number(Alias) */ + char *phone_number; /**< User phone number*/ + char *phone_country_code; /**< User phone number country code */ + /* Email(Alias) */ + char *email; /**< User email */ + /* Misc */ + char *language; /**< User language */ + char *activation_code; /**< Account validation code */ }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreator); @@ -1576,7 +1606,8 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(Li BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000) BELLE_SIP_TYPE_ID(LinphoneAccountCreator), -BELLE_SIP_TYPE_ID(LinphoneAccountCreatorCbs), +BELLE_SIP_TYPE_ID(LinphoneAccountCreatorRequestCbs), +BELLE_SIP_TYPE_ID(LinphoneAccountCreatorResponseCbs), BELLE_SIP_TYPE_ID(LinphoneBuffer), BELLE_SIP_TYPE_ID(LinphoneContactProvider), BELLE_SIP_TYPE_ID(LinphoneContactSearch), diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index 1a002f797..accc2e0d7 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -31,9 +31,9 @@ static LinphoneAccountCreator * linphone_gtk_assistant_get_creator(GtkWidget *w) return (LinphoneAccountCreator *)g_object_get_data(G_OBJECT(w), "creator"); } -static void linphone_gtk_create_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_create_account_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorAccountCreated) { + if (status == LinphoneRequestAccountCreated) { // Go to page_6_linphone_account_validation_wait gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 6); } else { // Error when attempting to create the account @@ -48,9 +48,9 @@ static void create_account(GtkWidget *assistant) { linphone_account_creator_create_account(creator); } -static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); - if (status == LinphoneAccountCreatorAccountActivated) { + if (status == LinphoneRequestAccountActivated) { // Go to page_9_finish gtk_assistant_set_current_page(GTK_ASSISTANT(assistant), 9); } else { @@ -61,7 +61,9 @@ static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *crea static void check_account_validation(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); - linphone_account_creator_is_account_activated(creator); + (linphone_account_creator_requests_cbs_get_is_account_activated_cb( + linphone_account_creator_get_requests_cbs(creator)) + )(creator); } void linphone_gtk_assistant_closed(GtkWidget *w) { @@ -79,9 +81,7 @@ void linphone_gtk_assistant_prepare(GtkWidget *assistant) { check_account_validation(assistant); break; case 9: - if (linphone_account_creator_configure(linphone_gtk_assistant_get_creator(assistant)) != NULL) { - linphone_gtk_load_identities(); - } + linphone_gtk_load_identities(); gtk_assistant_commit(GTK_ASSISTANT(assistant)); break; default: @@ -128,12 +128,8 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { case 2: { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_username")); - GtkEntry *domain_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_domain")); - GtkEntry *proxy_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_proxy")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); - linphone_account_creator_set_domain(creator, gtk_entry_get_text(domain_entry)); - linphone_account_creator_set_route(creator, gtk_entry_get_text(proxy_entry)); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -143,8 +139,6 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_username")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); - linphone_account_creator_set_domain(creator, "sip.linphone.org"); - linphone_account_creator_set_route(creator, "sip.linphone.org"); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -215,11 +209,11 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { GtkLabel* usernameError = GTK_LABEL(linphone_gtk_get_widget(assistant, "p4_label_error")); int account_status = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(page), "is_username_used")); - if (account_status == LinphoneAccountCreatorAccountNotExist) { + if (account_status == LinphoneRequestAccountNotExist) { g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(1)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_OK, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_label_set_text(usernameError, ""); - } else if (account_status == LinphoneAccountCreatorAccountExist) { + } else if (account_status == LinphoneRequestAccountExist) { gtk_label_set_text(usernameError, _("Username is already in use!")); g_object_set_data(G_OBJECT(page), "is_username_available", GINT_TO_POINTER(0)); gtk_image_set_from_stock(isUsernameOk, GTK_STOCK_NO, GTK_ICON_SIZE_LARGE_TOOLBAR); @@ -232,7 +226,7 @@ static gboolean update_interface_with_username_availability(GtkWidget *page) { return FALSE; } -static void linphone_gtk_test_account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { +static void linphone_gtk_test_account_existence_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { GtkWidget *assistant = (GtkWidget *)linphone_account_creator_get_user_data(creator); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); g_object_set_data(G_OBJECT(page), "is_username_used", GINT_TO_POINTER(status)); @@ -243,7 +237,9 @@ static gboolean check_username_availability(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); g_object_set_data(G_OBJECT(page), "usernameAvailabilityTimerID", GUINT_TO_POINTER(0)); - linphone_account_creator_is_account_used(creator); + (linphone_account_creator_requests_cbs_get_is_account_exist_cb( + linphone_account_creator_get_requests_cbs(creator)) + )(creator); return FALSE; } @@ -257,8 +253,6 @@ void linphone_gtk_account_creation_username_changed(GtkEntry *entry) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); linphone_account_creator_set_username(creator, gtk_entry_get_text(username)); - linphone_account_creator_set_domain(creator, "sip.linphone.org"); - linphone_account_creator_set_route(creator, "sip.linphone.org"); if (check_username_validity(gtk_entry_get_text(username))) { guint timerID = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(page), "usernameAvailabilityTimerID")); @@ -324,11 +318,11 @@ void linphone_gtk_account_creation_password_changed(GtkEntry *entry) { static void linphone_gtk_assistant_init(GtkWidget *w) { LinphoneAccountCreator *creator = linphone_account_creator_new(linphone_gtk_get_core(), "https://subscribe.linphone.org:444/wizard.php"); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); linphone_account_creator_set_user_data(creator, w); - linphone_account_creator_cbs_set_is_account_used(cbs, linphone_gtk_test_account_existence_cb); - linphone_account_creator_cbs_set_is_account_activated(cbs, linphone_gtk_test_account_validation_cb); - linphone_account_creator_cbs_set_create_account(cbs, linphone_gtk_create_account_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, linphone_gtk_test_account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, linphone_gtk_test_account_validation_cb); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, linphone_gtk_create_account_cb); g_object_set_data(G_OBJECT(w), "creator", creator); gtk_assistant_set_forward_page_func(GTK_ASSISTANT(w), linphone_gtk_assistant_forward, w, NULL); diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index c17e8c54c..423f2b7eb 100644 --- a/include/linphone/account_creator.h +++ b/include/linphone/account_creator.h @@ -1,6 +1,6 @@ /* account_creator.h -Copyright (C) 2010-2015 Belledonne Communications SARL +Copyright (C) 2010-2017 Belledonne Communications SARL This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,25 +27,109 @@ extern "C" { #endif /** - * @addtogroup misc + * @addtogroup account_creator * @{ */ + /** + * Function to set custom server request. + * @param[in] creator LinphoneAccountCreator object + */ + typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccountCreator *creator); + /** - * Callback to notify a status change of the account creator. + * Callback to notify a response of server. * @param[in] creator LinphoneAccountCreator object * @param[in] status The status of the LinphoneAccountCreator test existence operation that has just finished **/ -typedef void (*LinphoneAccountCreatorCbsStatusCb)(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp); +typedef void (*LinphoneAccountCreatorResponseFunc)(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp); + +/************************** Start Account Creator data **************************/ /** - * Create a LinphoneAccountCreator. + * Create a LinphoneAccountCreator and set Linphone Request callbacks. * @param[in] core The LinphoneCore used for the XML-RPC communication * @param[in] xmlrpc_url The URL to the XML-RPC server. Must be NON NULL. - * @return The new LinphoneAccountCreator object + * @return The new LinphoneAccountCreator object. **/ LINPHONE_PUBLIC LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url); +/** + * Set Linphone functions to LinphoneAccountCreator. + * @param[in] creator LinphoneAccountCreator object +**/ +LINPHONE_PUBLIC void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know the existence of account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_exist(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to create an account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an account is activated on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to activate an account on server. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to link an account to an alias. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_link_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to activate an alias. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_alias(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an alias is used. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_alias_used(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to know if an account is linked. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to recover an account. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator); + +/** + * Send a XML-RPC request to update an account. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_update_account(LinphoneAccountCreator *creator); + /** * Acquire a reference to the LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object. @@ -77,9 +161,9 @@ LINPHONE_PUBLIC void linphone_account_creator_set_user_data(LinphoneAccountCreat * Set the username. * @param[in] creator LinphoneAccountCreator object * @param[in] username The username to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneUsernameOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username); +LINPHONE_PUBLIC LinphoneUsernameCheck linphone_account_creator_set_username(LinphoneAccountCreator *creator, const char *username); /** * Get the username. @@ -88,22 +172,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(LinphoneAccountCreator *creator, const char *new_pwd); - /** * Set the phone number normalized. * @param[in] creator LinphoneAccountCreator object * @param[in] phone_number The phone number to set * @param[in] country_code Country code to associate phone number with - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePhoneNumberOk if everything is OK, or specific(s) error(s) otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code); +LINPHONE_PUBLIC LinphonePhoneNumberMask linphone_account_creator_set_phone_number(LinphoneAccountCreator *creator, const char *phone_number, const char *country_code); /** * Get the RFC 3966 normalized phone number. @@ -116,9 +192,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_phone_number(const Lin * Set the password. * @param[in] creator LinphoneAccountCreator object * @param[in] password The password to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePasswordOk if everything is OK, or specific(s) error(s) otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password); +LINPHONE_PUBLIC LinphonePasswordCheck linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password); /** * Get the password. @@ -131,9 +207,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_password(const Linphon * Set the ha1. * @param[in] creator LinphoneAccountCreator object * @param[in] ha1 The ha1 to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphonePasswordOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1); +LINPHONE_PUBLIC LinphonePasswordCheck linphone_account_creator_set_ha1(LinphoneAccountCreator *creator, const char *ha1); /** * Get the ha1. @@ -146,71 +222,42 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_ha1(const LinphoneAcco * Set the activation code. * @param[in] creator LinphoneAccountCreator object * @param[in] activation_code The activation code to set + * @return LinphoneActivationCodeOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code); +LINPHONE_PUBLIC LinphoneActivationCodeCheck linphone_account_creator_set_activation_code(LinphoneAccountCreator *creator, const char *activation_code); + +/** + * Get the activation code. + * @param[in] creator LinphoneAccountCreator object + * @return The activation code of the LinphoneAccountCreator +**/ +LINPHONE_PUBLIC const char * linphone_account_creator_get_activation_code(const LinphoneAccountCreator *creator); /** * Set the language to use in email or SMS if supported. * @param[in] creator LinphoneAccountCreator object * @param[in] lang The language to use + * @return LinphoneLanguageOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang); +LINPHONE_PUBLIC LinphoneLanguageCheck linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang); /** - * Set the transport. + * Get the language use in email of SMS. * @param[in] creator LinphoneAccountCreator object - * @param[in] transport The transport to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error if given transport is not supported by linphone core. + * @return The language of the LinphoneAccountCreator **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_transport(LinphoneAccountCreator *creator, LinphoneTransportType transport); +LINPHONE_PUBLIC const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator); /** - * Get the transport. - * @param[in] creator LinphoneAccountCreator object - * @return The transport of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC LinphoneTransportType linphone_account_creator_get_transport(const LinphoneAccountCreator *creator); - -/** - * Set the domain. - * @param[in] creator LinphoneAccountCreator object - * @param[in] domain The domain to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain); - -/** - * Get the domain. - * @param[in] creator LinphoneAccountCreator object - * @return The domain of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator); - -/** - * Set the route. - * @param[in] creator LinphoneAccountCreator object - * @param[in] route The route to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route); - -/** - * Get the route. - * @param[in] creator LinphoneAccountCreator object - * @return The route of the LinphoneAccountCreator -**/ -LINPHONE_PUBLIC const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator); - -/** - * Set the email. + * Set the display name. * @param[in] creator LinphoneAccountCreator object * @param[in] display_name The display name to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneUsernameOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name); +LINPHONE_PUBLIC LinphoneUsernameCheck linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name); /** - * Get the email. + * Get the display name. * @param[in] creator LinphoneAccountCreator object * @return The display name of the LinphoneAccountCreator **/ @@ -220,9 +267,9 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_display_name(const Lin * Set the email. * @param[in] creator LinphoneAccountCreator object * @param[in] email The email to set - * @return LinphoneAccountCreatorOk if everything is OK, or a specific error otherwise. + * @return LinphoneEmailOk if everything is OK, or a specific error otherwise. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email); +LINPHONE_PUBLIC LinphoneEmailCheck linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email); /** * Get the email. @@ -232,234 +279,446 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_set_email( LINPHONE_PUBLIC const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator); /** - * Get the LinphoneAccountCreatorCbs object associated with a LinphoneAccountCreator. + * Get the LinphoneAccountCreatorResponseCbs object associated with a LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object - * @return The LinphoneAccountCreatorCbs object associated with the LinphoneAccountCreator. + * @return The LinphoneAccountCreatorResponseCbs object associated with the LinphoneAccountCreator. **/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_get_callbacks(const LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator); + +/** + * Get the LinphoneAccountCreatorRequestCbs object associated with a LinphoneAccountCreator. + * @param[in] creator LinphoneAccountCreator object + * @return The LinphoneAccountCreatorRequestCbs object associated with the LinphoneAccountCreator. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator); + +/************************** End Account Creator data **************************/ + +/************************** Start Account Creator Linphone **************************/ /** * Send an XML-RPC request to test the existence of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_used(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_exist_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to create a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_create_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to activate a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to test the validation of a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_activated_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to test the existence a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOk if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_phone_number_used(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_phone_number_used_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to link a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOK if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_link_phone_number_with_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to activate the link of a phone number with a Linphone account. * @param[in] creator LinphoneAccountCreator object - * @return LinphoneAccountCreatorOK if the request has been sent, LinphoneAccountCreatorReqFailed otherwise + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_activate_phone_number_link(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_phone_number_link_custom(LinphoneAccountCreator *creator); -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_recover_phone_account(LinphoneAccountCreator *creator); +/** + * Send an XML-RPC request to a Linphone account with the phone number. + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_recover_phone_account_custom(LinphoneAccountCreator *creator); /** * Send an XML-RPC request to ask if an account is linked with a phone number * @param[in] creator LinphoneAccountCreator object * @return if this account is linked with a phone number **/ -LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked_custom(LinphoneAccountCreator *creator); + +/** + * Send an XML-RPC request to ask if an account is linked with a phone number + * @param[in] creator LinphoneAccountCreator object + * @param[in] new_pwd const char * : new password for the account creator + * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. +**/ +// TODO viré new_pwd qui sera remplacé par le get_user_data de creator +LINPHONE_PUBLIC /*TODO*/ LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator); + +/************************** End Account Creator Linphone **************************/ + +/************************** Start Account Creator Requests **************************/ + +/** + * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The same LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); + +/** + * Get the create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The create account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account exist request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account exist request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account exist request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current activate account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account activated request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account activated request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account activated request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the link account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The link account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate alias request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate alias request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is alias used request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is alias used request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is alias used request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account linked request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account linked request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account linked request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the recover account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current recover account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The recover account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the update account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current update account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The update account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/************************** End Account Creator Requests **************************/ + +/************************** Start Account Creator Cbs **************************/ + +/** + * Acquire a reference to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The same LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_responses_cbs_ref(LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_unref(LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_responses_cbs_get_user_data(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorResponseCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_user_data(LinphoneAccountCreatorResponseCbs *responses_cbs, void *ud); + +/** + * Get the create account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_create_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The create account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_create_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account exist request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account exist request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account exist request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_exist_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the activate account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current activate account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The activate account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account activated request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account activated request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account activated request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_activated_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the link account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_link_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The link account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_link_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the activate alias request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_alias_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The activate alias request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_alias_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is alias used request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is alias used request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is alias used request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_alias_used_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the is account linked request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current is account linked request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The is account linked request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_linked_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the recover account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current recover account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_recover_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The recover account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_recover_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/** + * Get the update account request. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @return The current update account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_update_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. + * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @param[in] cb The update account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); + +/************************** End Account Creator Cbs **************************/ /** * Configure an account (create a proxy config and authentication info for it). * @param[in] creator LinphoneAccountCreator object * @return A LinphoneProxyConfig object if successful, NULL otherwise -**/ + **/ LINPHONE_PUBLIC LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCreator *creator); -/** - * Acquire a reference to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The same LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbs * linphone_account_creator_cbs_ref(LinphoneAccountCreatorCbs *cbs); - -/** - * Release a reference to a LinphoneAccountCreatorCbs object. - * @param[in] cbs LinphoneAccountCreatorCbs object. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_unref(LinphoneAccountCreatorCbs *cbs); - -/** - * 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_user_data(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_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 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] cb The update hash callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_hash(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the current linked tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current linked tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_linked(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the linked tested callback - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The existence tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_linked(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the existence tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current existence tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_used(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the existence tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The existence tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the create account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current create account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_create_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the create account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The create account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_create_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the activate account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current activate account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the activate account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The activate account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_activate_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the link phone number with account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current link phone number with account callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_link_phone_number_with_account(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the link phone number with account callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The link phone number with account callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_link_phone_number_with_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the activate phone number link callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current activate phone number link callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_activate_phone_number_link(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the activate phone number link callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The activate phone number link callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_activate_phone_number_link(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the validation tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current validation tested callback. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_account_activated(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the validation tested callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb The validation tested callback to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_account_activated(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -/** - * Get the is phone number used callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @return The current is phone number used callback -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_is_phone_number_used(const LinphoneAccountCreatorCbs *cbs); - -/** - * Set the is phone number used callback. - * @param[in] cbs LinphoneAccountCreatorCbs object. - * @param[in] cb is phone number to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_is_phone_number_used(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -LINPHONE_PUBLIC void linphone_account_creator_cbs_set_recover_phone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb); - -LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_recover_phone_account(const LinphoneAccountCreatorCbs *cbs); - /** * @} */ diff --git a/include/linphone/types.h b/include/linphone/types.h index 4f1f3f4a3..18f73c39f 100644 --- a/include/linphone/types.h +++ b/include/linphone/types.h @@ -28,64 +28,127 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. /** - * The LinphoneAccountCreator object used to create an account on a server via XML-RPC. - * @ingroup misc + * The LinphoneAccountCreator object used to configure an account on a server via XML-RPC. + * @ingroup account_creator **/ typedef struct _LinphoneAccountCreator LinphoneAccountCreator; /** - * An object to handle the callbacks for handling the LinphoneAccountCreator operations. - * @ingroup misc + * An object to handle the requests callbacks for handling the LinphoneAccountCreator server requests. + * @ingroup account_creator **/ -typedef struct _LinphoneAccountCreatorCbs LinphoneAccountCreatorCbs; +typedef struct _LinphoneAccountCreatorRequestCbs LinphoneAccountCreatorRequestCbs; /** -* Enum describing the status of a LinphoneAccountCreator operation. -* @ingroup misc + * An object to handle the responses callbacks for handling the LinphoneAccountCreator operations. + * @ingroup account_creator **/ -typedef enum _LinphoneAccountCreatorStatus { - LinphoneAccountCreatorOK, - LinphoneAccountCreatorReqFailed, +typedef struct _LinphoneAccountCreatorResponseCbs LinphoneAccountCreatorResponseCbs; - LinphoneAccountCreatorAccountCreated, - LinphoneAccountCreatorAccountNotCreated, +/** + * Enum describing Phone number checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphonePhoneNumberCheck { + LinphonePhoneNumberOk = 0x1, /**< Phone number ok */ + LinphonePhoneNumberTooShort = 0x2, /**< Phone number too short */ + LinphonePhoneNumberTooLong = 0x4, /**< Phone number too long */ + LinphonePhoneNumberCountryCodeInvalid = 0x8, /**< Country code invalid */ + LinphonePhoneNumberInvalid = 0x10, /**< Phone number invalid */ +} LinphonePhoneNumberCheck; - LinphoneAccountCreatorAccountExist, - LinphoneAccountCreatorAccountExistWithAlias, - LinphoneAccountCreatorAccountNotExist, +/** + * A mask of #LinphonePhoneNumberCheck values + * @ingroup account_creator_checking + */ +typedef unsigned int LinphonePhoneNumberMask; - LinphoneAccountCreatorAccountActivated, - LinphoneAccountCreatorAccountAlreadyActivated, - LinphoneAccountCreatorAccountNotActivated, +/** + * Enum describing Username checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneUsernameCheck { + LinphoneUsernameOk, /**< Username ok */ + LinphoneUsernameTooShort, /**< Username too short */ + LinphoneUsernameTooLong, /**< Username too long */ + LinphoneUsernameInvalidCharacters, /**< Contain invalid characters */ + LinphoneUsernameInvalid, /**< Invalid username */ +} LinphoneUsernameCheck; - LinphoneAccountCreatorAccountLinked, - LinphoneAccountCreatorAccountNotLinked, +/** + * Enum describing Email checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneEmailCheck { + LinphoneEmailOk, /**< Email ok */ + LinphoneEmailMalformed, /**< Email malformed */ + LinphoneEmailInvalidCharacters, /**< Contain invalid characters */ +} LinphoneEmailCheck; - LinphoneAccountCreatorEmailInvalid, +/** + * Enum describing Password checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphonePasswordCheck { + LinphonePasswordOk, /**< Password ok */ + LinphonePasswordTooShort, /**< Password too short */ + LinphonePasswordTooLong, /**< Password too long */ + LinphonePasswordInvalidCharacters, /**< Contain invalid characters */ + LinphonePasswordMissingCharacters, /**< Missing specific characters */ +} LinphonePasswordCheck; - LinphoneAccountCreatorUsernameInvalid, - LinphoneAccountCreatorUsernameTooShort, - LinphoneAccountCreatorUsernameTooLong, - LinphoneAccountCreatorUsernameInvalidSize, +/** + * Enum describing language checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneLanguageCheck { + LinphoneLanguageOk, /**< Language ok */ +} LinphoneLanguageCheck; - LinphoneAccountCreatorPhoneNumberInvalid, - LinphoneAccountCreatorPhoneNumberTooShort, - LinphoneAccountCreatorPhoneNumberTooLong, - LinphoneAccountCreatorPhoneNumberUsedAccount, - LinphoneAccountCreatorPhoneNumberUsedAlias, - LinphoneAccountCreatorPhoneNumberNotUsed, +/** + * Enum describing Activation code checking. + * @ingroup account_creator_checking +**/ +typedef enum _LinphoneActivationCodeCheck { + LinphoneActivationCodeOk, /**< Activation code ok */ + LinphoneActivationCodeTooShort, /**< Activation code too short */ + LinphoneActivationCodeTooLong, /**< Activation code too long */ + LinphoneActivationCodeInvalidCharacters, /**< Contain invalid characters */ +} LinphoneActivationCodeCheck; - LinphoneAccountCreatorPasswordTooShort, - LinphoneAccountCreatorPasswordTooLong, +/** + * Enum describing the status of server request. + * @ingroup account_creator_request +**/ +typedef enum _LinphoneRequestStatus { + /** Request status **/ + LinphoneRequestOk, /**< Request passed */ + LinphoneRequestFailed, /**< Request failed */ + LinphoneRequestMissingArguments, /**< Request failed due to missing argument(s) */ + LinphoneRequestMissingCallbacks, /**< Request failed due to missing callback(s) */ - LinphoneAccountCreatorDomainInvalid, - LinphoneAccountCreatorRouteInvalid, - LinphoneAccountCreatorDisplayNameInvalid, - LinphoneAccountCreatorTransportNotSupported, - LinphoneAccountCreatorCountryCodeInvalid, + /** Account status **/ + /* Creation */ + LinphoneRequestAccountCreated, /**< Account created */ + LinphoneRequestAccountNotCreated, /**< Account not created */ + /* Existence */ + LinphoneRequestAccountExist, /**< Account exist */ + LinphoneRequestAccountExistWithAlias, /**< Account exist with alias */ + LinphoneRequestAccountNotExist, /**< Account not exist */ + LinphoneRequestAliasIsAccount, /**< Account was created with Alias */ + LinphoneRequestAliasExist, /**< Alias exist */ + LinphoneRequestAliasNotExist, /**< Alias not exist */ + /* Activation */ + LinphoneRequestAccountActivated, /**< Account activated */ + LinphoneRequestAccountAlreadyActivated, /**< Account already activated */ + LinphoneRequestAccountNotActivated, /**< Account not activated */ + /* Linking */ + LinphoneRequestAccountLinked, /**< Account linked */ + LinphoneRequestAccountNotLinked, /**< Account not linked */ - LinphoneAccountCreatorErrorServer, -} LinphoneAccountCreatorStatus; + /** Server **/ + LinphoneRequestErrorServer, /**< Error server */ +} LinphoneRequestStatus; struct SalAddress; diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 2ae8cb6b0..39a6b4c66 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -19,10 +19,8 @@ #include "liblinphone_tester.h" static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php"; -static const char DOMAIN_URL[] = "sip.accounttest.org"; -static const char ROUTE_URL[] = "sip2.linphone.org:5072"; -static const int TIMEOUT_REQUEST = 100000; +static const int TIMEOUT_REQUEST = 10000; /////////// LOCAL TESTS /////////// @@ -33,8 +31,8 @@ static void local_username_too_short(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, ""), - LinphoneAccountCreatorUsernameTooShort, - LinphoneAccountCreatorStatus, + LinphoneUsernameTooShort, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); @@ -46,51 +44,37 @@ static void local_username_too_long(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "usernametoolong"), - LinphoneAccountCreatorUsernameTooLong, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_username(creator, "usernametoolongforyou"), + LinphoneUsernameTooLong, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -static void local_username_invalid(void) { +static void local_username_invalid_character(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "use!"), - LinphoneAccountCreatorUsernameInvalid, - LinphoneAccountCreatorStatus, + LinphoneUsernameInvalidCharacters, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -static void local_username_invalid_size(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "sizeinv"), - LinphoneAccountCreatorUsernameInvalidSize, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - static void local_username_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "user"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + LinphoneUsernameOk, + LinphoneUsernameCheck, "%i"); linphone_account_creator_unref(creator); @@ -105,8 +89,8 @@ static void local_password_too_short(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, ""), - LinphoneAccountCreatorPasswordTooShort, - LinphoneAccountCreatorStatus, + LinphonePasswordTooShort, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -119,8 +103,8 @@ static void local_password_too_long(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, "passwordtoolong"), - LinphoneAccountCreatorPasswordTooLong, - LinphoneAccountCreatorStatus, + LinphonePasswordTooLong, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -132,9 +116,9 @@ static void local_password_ok(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "pass"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_password(creator, "pass"), + LinphonePasswordOk, + LinphonePasswordCheck, "%i"); linphone_account_creator_unref(creator); @@ -143,14 +127,52 @@ static void local_password_ok(void) { ////// EMAIL ////// -static void local_email_invalid(void) { +static void local_email_malformed(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test.linphone.org"), - LinphoneAccountCreatorEmailInvalid, - LinphoneAccountCreatorStatus, + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test@linphone"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "@linphone.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "linphone@.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, ".linphone@.org"), + LinphoneEmailMalformed, + LinphoneEmailCheck, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void local_email_invalid_character(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test@linphone.org$"), + LinphoneEmailInvalidCharacters, + LinphoneEmailCheck, "%i"); linphone_account_creator_unref(creator); @@ -163,8 +185,20 @@ static void local_email_ok(void) { BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test@linphone.org"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + LinphoneEmailOk, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "test02@linphone5252.org"), + LinphoneEmailOk, + LinphoneEmailCheck, + "%i"); + + BC_ASSERT_EQUAL( + linphone_account_creator_set_email(creator, "9053test@50255linphone.org"), + LinphoneEmailOk, + LinphoneEmailCheck, "%i"); linphone_account_creator_unref(creator); @@ -178,9 +212,9 @@ static void local_phone_number_too_short(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "0123", "33"), - LinphoneAccountCreatorPhoneNumberTooShort, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123", "33")&LinphonePhoneNumberTooShort, + LinphonePhoneNumberTooShort, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -192,9 +226,9 @@ static void local_phone_number_too_long(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "01234567891011", "33"), - LinphoneAccountCreatorPhoneNumberTooLong, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "01234567891011", "33")&LinphonePhoneNumberTooLong, + LinphonePhoneNumberTooLong, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -206,9 +240,9 @@ static void local_phone_number_invalid(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, NULL, "33"), - LinphoneAccountCreatorPhoneNumberInvalid, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, NULL, "33")&LinphonePhoneNumberInvalid, + LinphonePhoneNumberInvalid, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -220,68 +254,23 @@ static void local_country_code_invalid(void) { LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "0123", ""), - LinphoneAccountCreatorCountryCodeInvalid, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123", "")&LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCountryCodeInvalid, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); linphone_core_manager_destroy(marie); } -////// TRANSPORT ////// - -static void local_transport_not_supported(void) { +static void local_phone_number_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_transport(creator, (LinphoneTransportType)4), - LinphoneAccountCreatorTransportNotSupported, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - -static void local_transport_ok(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_transport(creator, LinphoneTransportTcp), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, - "%i"); - - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -} - -////// DOMAIN ////// - -// Not implemented -/*static void local_domain_invalid(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - BC_ASSERT_EQUAL( - linphone_account_creator_set_domain(creator, "sop2.linphone.org"), - LinphoneAccountCreatorDomainInvalid, - LinphoneAccountCreatorStatus, - "%i"); - linphone_account_creator_unref(creator); - linphone_core_manager_destroy(marie); -}*/ - -static void local_domain_ok(void) { - LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); - - BC_ASSERT_EQUAL( - linphone_account_creator_set_domain(creator, "sip2.linphone.org"), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_set_phone_number(creator, "0123456789", "33")&LinphonePhoneNumberOk, + LinphonePhoneNumberOk, + LinphonePhoneNumberCheck, "%i"); linphone_account_creator_unref(creator); @@ -299,8 +288,8 @@ static LinphoneAccountCreatorStats* new_linphone_account_creator_stats(void) { return stats; } -static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) { - LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs); +static void account_creator_set_cb_done(LinphoneAccountCreatorResponseCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_responses_cbs_get_user_data(cbs); stats->cb_done++; BC_ASSERT_TRUE(stats->cb_done); } @@ -311,34 +300,36 @@ static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) { BC_ASSERT_FALSE(stats->cb_done); }*/ -static void account_existence_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) { - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - LinphoneAccountCreatorStatus expected_status = (LinphoneAccountCreatorStatus)linphone_account_creator_get_user_data(creator); +static void account_creator_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneRequestStatus expected_status = (LinphoneRequestStatus)linphone_account_creator_requests_cbs_get_user_data( + linphone_account_creator_get_requests_cbs(creator)); BC_ASSERT_EQUAL( status, expected_status, - LinphoneAccountCreatorStatus, + LinphoneRequestStatus, "%i"); account_creator_set_cb_done(cbs); } +/****************** Start Is Account Exist ************************/ static void server_account_doesnt_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_cbs_set_user_data(cbs, stats); - linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountNotExist); + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_set_username(creator, "user_not_exist"); - linphone_account_creator_set_route(creator, ROUTE_URL); - linphone_account_creator_set_domain(creator, DOMAIN_URL); - linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( - linphone_account_creator_is_account_used(creator), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_is_account_exist(creator), + LinphoneRequestOk, + LinphoneRequestStatus, "%i"); wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); @@ -351,20 +342,20 @@ static void server_account_doesnt_exist(void) { static void server_account_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_cbs_set_user_data(cbs, stats); - linphone_account_creator_set_user_data(creator, (void*)LinphoneAccountCreatorAccountExist); + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_route(creator, ROUTE_URL); - linphone_account_creator_set_domain(creator, DOMAIN_URL); - linphone_account_creator_cbs_set_is_account_used(cbs, account_existence_cb); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( - linphone_account_creator_is_account_used(creator), - LinphoneAccountCreatorOK, - LinphoneAccountCreatorStatus, + linphone_account_creator_is_account_exist(creator), + LinphoneRequestOk, + LinphoneRequestStatus, "%i"); wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); @@ -374,27 +365,1008 @@ static void server_account_exist(void) { linphone_core_manager_destroy(marie); } +static void server_is_account_exist_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_exist_arg_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_exist(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Exist ************************/ + +/****************** Start Create Account ************************/ +static void server_account_created_with_email(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountCreated); + linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_with_email(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_account_created_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_as_account_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_already_create_as_alias_with_phone_number(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotExist); + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_email_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_email_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_phone_number_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_create_account_with_phone_number_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_create_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Create Account ************************/ + +/****************** Start Is Account Activated ************************/ +static void server_is_account_activated_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Activated ************************/ + +/****************** Start Activate Account ************************/ +static void server_activate_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_email_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_email_activated_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_phone_number_activated_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_activation_code(creator, "123456789"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_with_phone_number_activated_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Activate Account ************************/ + +/****************** Start Link Account ************************/ +static void server_link_account_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_link_account_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_link_account_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Link Account ************************/ + +/****************** Start Activate Alias ************************/ +static void server_activate_alias_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_activation_code_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_alias_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Activate Alias ************************/ + +/****************** Start Is Alias Used ************************/ +static void server_is_alias_used_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_alias_used_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Alias Used ************************/ + +/****************** Start Is Account Linked ************************/ +static void server_is_account_linked_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_is_account_linked_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Is Account Linked ************************/ + +/****************** Start Recover Account ************************/ +static void server_recover_account_with_phone_number_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_recover_account_with_phone_number_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Recover Account ************************/ + +/****************** Start Update Account ************************/ +static void server_update_account_password_cb_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingCallbacks, + LinphoneRequestStatus, + "%i"); + + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_username_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_phone_number_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_arg_new_password_missing(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestMissingArguments); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestMissingArguments, + LinphoneRequestStatus, + "%i"); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} +/****************** End Update Account ************************/ + test_t account_creator_tests[] = { - TEST_NO_TAG("Local - Username too short", local_username_too_short), - TEST_NO_TAG("Local - Username too long", local_username_too_long), - TEST_NO_TAG("Local - Username invalid", local_username_invalid), - TEST_NO_TAG("Local - Username invalid size", local_username_invalid_size), - TEST_NO_TAG("Local - Username Ok", local_username_ok), - TEST_NO_TAG("Local - Password too short", local_password_too_short), - TEST_NO_TAG("Local - Password too long", local_password_too_long), - TEST_NO_TAG("Local - Password Ok", local_password_ok), - TEST_NO_TAG("Local - Email invalid", local_email_invalid), - TEST_NO_TAG("Local - Email Ok", local_email_ok), - TEST_NO_TAG("Local - Phone number too short", local_phone_number_too_short), - TEST_NO_TAG("Local - Phone number too long", local_phone_number_too_long), - TEST_NO_TAG("Local - Phone number invalid", local_phone_number_invalid), - TEST_NO_TAG("Local - Country code invalid", local_country_code_invalid), - TEST_NO_TAG("Local - Transport not supported", local_transport_not_supported), - TEST_NO_TAG("Local - Transport Ok", local_transport_ok), - //TEST_NO_TAG("Local - Domain invalid", local_domain_invalid), Not implemented - TEST_NO_TAG("Local - Domain ok", local_domain_ok), - TEST_NO_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist), - TEST_NO_TAG("Server - Account exist", server_account_exist), + TEST_ONE_TAG("Local - Username too short", local_username_too_short, "Local"), + TEST_ONE_TAG("Local - Username too long", local_username_too_long, "Local"), + TEST_ONE_TAG("Local - Username invalid character", local_username_invalid_character, "Local"), + TEST_ONE_TAG("Local - Username Ok", local_username_ok, "Local"), + TEST_ONE_TAG("Local - Password too short", local_password_too_short, "Local"), + TEST_ONE_TAG("Local - Password too long", local_password_too_long, "Local"), + TEST_ONE_TAG("Local - Password Ok", local_password_ok, "Local"), + TEST_ONE_TAG("Local - Email malformed", local_email_malformed, "Local"), + TEST_ONE_TAG("Local - Email invalid character",local_email_invalid_character, "Local"), + TEST_ONE_TAG("Local - Email Ok", local_email_ok, "Local"), + TEST_ONE_TAG("Local - Phone number too short", local_phone_number_too_short, "Local"), + TEST_ONE_TAG("Local - Phone number too long", local_phone_number_too_long, "Local"), + TEST_ONE_TAG("Local - Phone number invalid", local_phone_number_invalid, "Local"), + TEST_ONE_TAG("Local - Country code invalid", local_country_code_invalid, "Local"), + TEST_ONE_TAG("Local - Phone number ok", local_phone_number_ok, "Local"), + + TEST_ONE_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist, "Server"), + TEST_ONE_TAG("Server - Account exist", server_account_exist, "Server"), + TEST_ONE_TAG("Local - Is account exist callback missing", server_is_account_exist_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account exist arguments missing", server_is_account_exist_arg_missing, "Local"), + TEST_ONE_TAG("Server - Account created with email", server_account_created_with_email, "Server"), + TEST_ONE_TAG("Server - Account already create with email", server_create_account_already_create_with_email, "Server"), + TEST_ONE_TAG("Server - Account created with phone number", server_account_created_with_phone_number, "Server"), + TEST_ONE_TAG("Server - Account already created with phone number as account", server_create_account_already_create_as_account_with_phone_number, "Server"), + TEST_ONE_TAG("Server - Account already created with phone number as alias", server_create_account_already_create_as_alias_with_phone_number, "Server"), + TEST_ONE_TAG("Local - Create Account callback missing", server_create_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments username missing", server_create_account_with_email_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments email missing", server_create_account_with_email_arg_email_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with email arguments password missing", server_create_account_with_email_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with phone number arguments username missing", server_create_account_with_phone_number_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Create Account with phone number arguments phone number missing", server_create_account_with_phone_number_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Is account activated callbacks missing", server_is_account_activated_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account activated arguments username missing", server_is_account_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account callbacks missing", server_activate_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with email arguments username missing", server_activate_account_with_email_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with email arguments activation code missing", server_activate_account_with_email_activated_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with phone number arguments username missing", server_activate_account_with_phone_number_activated_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate account with phone number arguments activation code missing", server_activate_account_with_phone_number_activated_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Link account callbacks missing", server_link_account_cb_missing, "Local"), + TEST_ONE_TAG("Local - Link account arguments username missing", server_link_account_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Link account arguments phone number missing", server_link_account_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias callbacks missing", server_activate_alias_cb_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments username missing", server_activate_alias_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments phone number missing", server_activate_alias_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments activation code missing", server_activate_alias_arg_activation_code_missing, "Local"), + TEST_ONE_TAG("Local - Activate alias arguments password missing", server_activate_alias_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Is alias used callbacks missing", server_is_alias_used_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is alias used arguments phone number missing", server_is_alias_used_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Is account link callbacks missing", server_is_account_linked_cb_missing, "Local"), + TEST_ONE_TAG("Local - Is account link arguments username missing", server_is_account_linked_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Recover account with phone number callbacks missing", server_recover_account_with_phone_number_cb_missing, "Local"), + TEST_ONE_TAG("Local - Recover account with phone number arguments phone number missing", server_recover_account_with_phone_number_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Update account password callbacks missing", server_update_account_password_cb_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments username missing", server_update_account_password_arg_username_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments phone number missing", server_update_account_password_arg_phone_number_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments password missing", server_update_account_password_arg_password_missing, "Local"), + TEST_ONE_TAG("Local - Update account password arguments new password missing", server_update_account_password_arg_new_password_missing, "Local"), }; test_suite_t account_creator_test_suite = {"Account creator", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc index 7b9aeaa87..864a56e32 100644 --- a/tester/rcfiles/account_creator_rc +++ b/tester/rcfiles/account_creator_rc @@ -3,11 +3,12 @@ domain=sip.accounttest.org password_max_length=8 password_min_length=3 username_length=4 -username_max_length=8 +username_max_length=14 username_min_length=3 username_regex=^[a-z0-9_.\-]*$ xmlrpc_url=https://sip2.linphone.org:445/wizard.php -[proxy] +[proxy_default_values] reg_proxy= realm=sip.accounttest.org +reg_identity=sip:user@sip.accounttest.org From 1deaf92b67e8324a87d6ab70af1b3f0b617552c1 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Fri, 17 Mar 2017 11:47:28 +0100 Subject: [PATCH 15/32] Add new tests for account creator --- coreapi/account_creator.c | 7 +- tester/account_creator_tester.c | 928 +++++++++++++++++++++++++++--- tester/rcfiles/account_creator_rc | 2 +- 3 files changed, 862 insertions(+), 75 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 32048b17d..222e402b7 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -378,7 +378,8 @@ void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccoun /************************** Start Account Creator data **************************/ static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { - linphone_xml_rpc_session_release(creator->xmlrpc_session); /*this will drop all pending requests if any*/ + /*this will drop all pending requests if any*/ + if (creator->xmlrpc_session) linphone_xml_rpc_session_release(creator->xmlrpc_session); linphone_account_creator_requests_cbs_unref(creator->requests_cbs); linphone_account_creator_responses_cbs_unref(creator->responses_cbs); linphone_proxy_config_destroy(creator->proxy_cfg); @@ -408,7 +409,7 @@ LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const creator->requests_cbs = linphone_account_creator_requests_cbs_new(); creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); creator->core = core; - creator->xmlrpc_session = linphone_xml_rpc_session_new(core, xmlrpc_url); + creator->xmlrpc_session = (xmlrpc_url) ? linphone_xml_rpc_session_new(core, xmlrpc_url) : NULL; creator->proxy_cfg = linphone_core_create_proxy_config(core); linphone_account_creator_set_linphone_impl(creator); return creator; @@ -1005,7 +1006,7 @@ static void _activate_phone_number_link_cb_custom(LinphoneXmlRpcRequest *request LinphoneRequestStatus status = LinphoneRequestFailed; const char* resp = linphone_xml_rpc_request_get_string_response(request); if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { - status = (strstr(resp, "ERROR_") == resp) ? LinphoneRequestAccountNotActivated : LinphoneRequestOk; + status = (strstr(resp, "ERROR_") == resp) ? LinphoneRequestAccountNotActivated : LinphoneRequestAccountActivated; } creator->responses_cbs->activate_alias_response_cb(creator, status, resp); } diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 39a6b4c66..817d4a0cf 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -406,7 +406,7 @@ static void server_is_account_exist_arg_missing(void) { /****************** End Is Account Exist ************************/ /****************** Start Create Account ************************/ -static void server_account_created_with_email(void) { +static void server_account_created_with_email(void) { //TODO synchro server LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); @@ -443,7 +443,7 @@ static void server_create_account_already_create_with_email(void) { linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotExist); + (void*)LinphoneRequestAccountExist); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_email(creator, "test@bc.com"); linphone_account_creator_set_password(creator, "password"); @@ -462,7 +462,7 @@ static void server_create_account_already_create_with_email(void) { linphone_core_manager_destroy(marie); } -static void server_account_created_with_phone_number(void) { +static void server_account_created_with_phone_number(void) { //TODO synchro server LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); @@ -471,7 +471,7 @@ static void server_account_created_with_phone_number(void) { linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotExist); + (void*)LinphoneRequestAccountCreated); linphone_account_creator_set_username(creator, "user_1"); linphone_account_creator_set_email(creator, "user_1@linphone.org"); linphone_account_creator_set_password(creator, "password"); @@ -499,7 +499,7 @@ static void server_create_account_already_create_as_account_with_phone_number(vo linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotExist); + (void*)LinphoneRequestAccountExist); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_email(creator, "test@bc.com"); linphone_account_creator_set_phone_number(creator, "01234567","33"); @@ -527,7 +527,7 @@ static void server_create_account_already_create_as_alias_with_phone_number(void linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotExist); + (void*)LinphoneRequestAccountExistWithAlias); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_email(creator, "test@bc.com"); linphone_account_creator_set_phone_number(creator, "01234567","33"); @@ -696,13 +696,65 @@ static void server_create_account_with_phone_number_arg_phone_number_missing(voi /****************** End Create Account ************************/ /****************** Start Is Account Activated ************************/ +static void server_account_not_activated(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotActivated); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_account_already_activated(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "u_activated"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountActivated); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_activated(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_is_account_activated_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_activation_code(creator, "123456789"); - linphone_account_creator_set_email(creator, "user_1@linphone.org"); BC_ASSERT_EQUAL( linphone_account_creator_is_account_activated(creator), @@ -739,6 +791,93 @@ static void server_is_account_activated_arg_username_missing(void) { /****************** End Is Account Activated ************************/ /****************** Start Activate Account ************************/ +static void server_activate_account_not_activated(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_activation_code(creator, "58c93c745df56"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_account_already_activated(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "u_activated"); + linphone_account_creator_set_activation_code(creator, "1234"); + linphone_account_creator_set_email(creator, "test2@bc.com"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountAlreadyActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_non_existent_account(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "unknown_user"); + linphone_account_creator_set_activation_code(creator, "58c93c745df56"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotActivated); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_activate_account_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); @@ -861,6 +1000,62 @@ static void server_activate_account_with_phone_number_activated_arg_activation_c /****************** End Activate Account ************************/ /****************** Start Link Account ************************/ +static void server_link_account_with_phone_number(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountLinked); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_link_non_existent_account_with_phone_number(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "unknown_user"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_link_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_link_account_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); @@ -930,12 +1125,70 @@ static void server_link_account_arg_phone_number_missing(void) { /****************** End Link Account ************************/ /****************** Start Activate Alias ************************/ +static void server_activate_phone_number_for_non_existent_account(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + linphone_account_creator_set_activation_code(creator, "12345679"); + linphone_account_creator_set_password(creator, "password"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_activate_phone_number_for_account(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "unknown_user"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_activate_alias(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_activate_alias_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); linphone_account_creator_set_activation_code(creator, "12345679"); linphone_account_creator_set_password(creator, "password"); @@ -955,7 +1208,7 @@ static void server_activate_alias_arg_username_missing(void) { LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); linphone_account_creator_set_activation_code(creator, "12345679"); linphone_account_creator_set_password(creator, "password"); @@ -983,7 +1236,7 @@ static void server_activate_alias_arg_activation_code_missing(void) { LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); linphone_account_creator_set_password(creator, "password"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); @@ -1010,7 +1263,7 @@ static void server_activate_alias_arg_password_missing(void) { LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); linphone_account_creator_set_activation_code(creator, "12345679"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); @@ -1059,11 +1312,92 @@ static void server_activate_alias_arg_phone_number_missing(void) { /****************** End Activate Alias ************************/ /****************** Start Is Alias Used ************************/ +static void server_phone_number_is_used_as_alias(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_phone_number_is_used_as_account(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_phone_number_not_used(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_alias_used(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_is_alias_used_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_phone_number(creator, "012345678", "33"); BC_ASSERT_EQUAL( linphone_account_creator_is_alias_used(creator), @@ -1100,6 +1434,60 @@ static void server_is_alias_used_arg_phone_number_missing(void) { /****************** End Is Alias Used ************************/ /****************** Start Is Account Linked ************************/ +static void server_account_link_with_phone_number(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_account_not_link_with_phone_number(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_is_account_linked(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_is_account_linked_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); @@ -1141,6 +1529,60 @@ static void server_is_account_linked_arg_username_missing(void) { /****************** End Is Account Linked ************************/ /****************** Start Recover Account ************************/ +static void server_recover_account_with_phone_number_used(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_recover_account_with_phone_number_not_used(void) { //TODO synchro server + phone number + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_phone_number(creator, "012345678", "33"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_recover_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_recover_account_with_phone_number_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); @@ -1182,6 +1624,96 @@ static void server_recover_account_with_phone_number_arg_phone_number_missing(vo /****************** End Recover Account ************************/ /****************** Start Update Account ************************/ +static void server_update_account_password_with_wrong_password(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_with_correct_password(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + +static void server_update_account_password_for_non_existent_account(void) { //TODO synchro server + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_user_data(creator, "newpassword"); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestAccountNotLinked); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); + + BC_ASSERT_EQUAL( + linphone_account_creator_update_account(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + static void server_update_account_password_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); @@ -1310,64 +1842,318 @@ static void server_update_account_password_arg_new_password_missing(void) { /****************** End Update Account ************************/ test_t account_creator_tests[] = { - TEST_ONE_TAG("Local - Username too short", local_username_too_short, "Local"), - TEST_ONE_TAG("Local - Username too long", local_username_too_long, "Local"), - TEST_ONE_TAG("Local - Username invalid character", local_username_invalid_character, "Local"), - TEST_ONE_TAG("Local - Username Ok", local_username_ok, "Local"), - TEST_ONE_TAG("Local - Password too short", local_password_too_short, "Local"), - TEST_ONE_TAG("Local - Password too long", local_password_too_long, "Local"), - TEST_ONE_TAG("Local - Password Ok", local_password_ok, "Local"), - TEST_ONE_TAG("Local - Email malformed", local_email_malformed, "Local"), - TEST_ONE_TAG("Local - Email invalid character",local_email_invalid_character, "Local"), - TEST_ONE_TAG("Local - Email Ok", local_email_ok, "Local"), - TEST_ONE_TAG("Local - Phone number too short", local_phone_number_too_short, "Local"), - TEST_ONE_TAG("Local - Phone number too long", local_phone_number_too_long, "Local"), - TEST_ONE_TAG("Local - Phone number invalid", local_phone_number_invalid, "Local"), - TEST_ONE_TAG("Local - Country code invalid", local_country_code_invalid, "Local"), - TEST_ONE_TAG("Local - Phone number ok", local_phone_number_ok, "Local"), + TEST_ONE_TAG( + "Local - Username too short", + local_username_too_short, + "Local"), + TEST_ONE_TAG( + "Local - Username too long", + local_username_too_long, + "Local"), + TEST_ONE_TAG( + "Local - Username invalid character", + local_username_invalid_character, + "Local"), + TEST_ONE_TAG( + "Local - Username Ok", + local_username_ok, + "Local"), + TEST_ONE_TAG( + "Local - Password too short", + local_password_too_short, + "Local"), + TEST_ONE_TAG( + "Local - Password too long", + local_password_too_long, + "Local"), + TEST_ONE_TAG( + "Local - Password Ok", + local_password_ok, + "Local"), + TEST_ONE_TAG( + "Local - Email malformed", + local_email_malformed, + "Local"), + TEST_ONE_TAG( + "Local - Email invalid character", + local_email_invalid_character, + "Local"), + TEST_ONE_TAG( + "Local - Email Ok", + local_email_ok, + "Local"), + TEST_ONE_TAG( + "Local - Phone number too short", + local_phone_number_too_short, + "Local"), + TEST_ONE_TAG( + "Local - Phone number too long", + local_phone_number_too_long, + "Local"), + TEST_ONE_TAG( + "Local - Phone number invalid", + local_phone_number_invalid, + "Local"), + TEST_ONE_TAG( + "Local - Country code invalid", + local_country_code_invalid, + "Local"), + TEST_ONE_TAG( + "Local - Phone number ok", + local_phone_number_ok, + "Local"), - TEST_ONE_TAG("Server - Account doesn\'t exist", server_account_doesnt_exist, "Server"), - TEST_ONE_TAG("Server - Account exist", server_account_exist, "Server"), - TEST_ONE_TAG("Local - Is account exist callback missing", server_is_account_exist_cb_missing, "Local"), - TEST_ONE_TAG("Local - Is account exist arguments missing", server_is_account_exist_arg_missing, "Local"), - TEST_ONE_TAG("Server - Account created with email", server_account_created_with_email, "Server"), - TEST_ONE_TAG("Server - Account already create with email", server_create_account_already_create_with_email, "Server"), - TEST_ONE_TAG("Server - Account created with phone number", server_account_created_with_phone_number, "Server"), - TEST_ONE_TAG("Server - Account already created with phone number as account", server_create_account_already_create_as_account_with_phone_number, "Server"), - TEST_ONE_TAG("Server - Account already created with phone number as alias", server_create_account_already_create_as_alias_with_phone_number, "Server"), - TEST_ONE_TAG("Local - Create Account callback missing", server_create_account_cb_missing, "Local"), - TEST_ONE_TAG("Local - Create Account with email arguments username missing", server_create_account_with_email_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Create Account with email arguments email missing", server_create_account_with_email_arg_email_missing, "Local"), - TEST_ONE_TAG("Local - Create Account with email arguments password missing", server_create_account_with_email_arg_password_missing, "Local"), - TEST_ONE_TAG("Local - Create Account with phone number arguments username missing", server_create_account_with_phone_number_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Create Account with phone number arguments phone number missing", server_create_account_with_phone_number_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Is account activated callbacks missing", server_is_account_activated_cb_missing, "Local"), - TEST_ONE_TAG("Local - Is account activated arguments username missing", server_is_account_activated_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Activate account callbacks missing", server_activate_account_cb_missing, "Local"), - TEST_ONE_TAG("Local - Activate account with email arguments username missing", server_activate_account_with_email_activated_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Activate account with email arguments activation code missing", server_activate_account_with_email_activated_arg_activation_code_missing, "Local"), - TEST_ONE_TAG("Local - Activate account with phone number arguments username missing", server_activate_account_with_phone_number_activated_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Activate account with phone number arguments activation code missing", server_activate_account_with_phone_number_activated_arg_activation_code_missing, "Local"), - TEST_ONE_TAG("Local - Link account callbacks missing", server_link_account_cb_missing, "Local"), - TEST_ONE_TAG("Local - Link account arguments username missing", server_link_account_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Link account arguments phone number missing", server_link_account_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Activate alias callbacks missing", server_activate_alias_cb_missing, "Local"), - TEST_ONE_TAG("Local - Activate alias arguments username missing", server_activate_alias_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Activate alias arguments phone number missing", server_activate_alias_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Activate alias arguments activation code missing", server_activate_alias_arg_activation_code_missing, "Local"), - TEST_ONE_TAG("Local - Activate alias arguments password missing", server_activate_alias_arg_password_missing, "Local"), - TEST_ONE_TAG("Local - Is alias used callbacks missing", server_is_alias_used_cb_missing, "Local"), - TEST_ONE_TAG("Local - Is alias used arguments phone number missing", server_is_alias_used_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Is account link callbacks missing", server_is_account_linked_cb_missing, "Local"), - TEST_ONE_TAG("Local - Is account link arguments username missing", server_is_account_linked_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Recover account with phone number callbacks missing", server_recover_account_with_phone_number_cb_missing, "Local"), - TEST_ONE_TAG("Local - Recover account with phone number arguments phone number missing", server_recover_account_with_phone_number_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Update account password callbacks missing", server_update_account_password_cb_missing, "Local"), - TEST_ONE_TAG("Local - Update account password arguments username missing", server_update_account_password_arg_username_missing, "Local"), - TEST_ONE_TAG("Local - Update account password arguments phone number missing", server_update_account_password_arg_phone_number_missing, "Local"), - TEST_ONE_TAG("Local - Update account password arguments password missing", server_update_account_password_arg_password_missing, "Local"), - TEST_ONE_TAG("Local - Update account password arguments new password missing", server_update_account_password_arg_new_password_missing, "Local"), + TEST_ONE_TAG( + "Server - Account doesn\'t exist", + server_account_doesnt_exist, + "Server"), + TEST_ONE_TAG( + "Server - Account exist", + server_account_exist, + "Server"), + TEST_ONE_TAG( + "Local - Is account exist callback missing", + server_is_account_exist_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Is account exist arguments missing", + server_is_account_exist_arg_missing, + "Local"), + TEST_ONE_TAG( + "Server - Account created with email", + server_account_created_with_email, + "Server"),//TODO synchro server + TEST_ONE_TAG( + "Server - Account already create with email", + server_create_account_already_create_with_email, + "Server"), + TEST_ONE_TAG( + "Server - Account created with phone number", + server_account_created_with_phone_number, + "Server"),//TODO synchro server + TEST_ONE_TAG( + "Server - Account already created with phone number as account", + server_create_account_already_create_as_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Account already created with phone number as alias", + server_create_account_already_create_as_alias_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Local - Create Account callback missing", + server_create_account_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Create Account with email arguments username missing", + server_create_account_with_email_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Create Account with email arguments email missing", + server_create_account_with_email_arg_email_missing, + "Local"), + TEST_ONE_TAG( + "Local - Create Account with email arguments password missing", + server_create_account_with_email_arg_password_missing, + "Local"), + TEST_ONE_TAG( + "Local - Create Account with phone number arguments username missing", + server_create_account_with_phone_number_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Create Account with phone number arguments phone number missing", + server_create_account_with_phone_number_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Server - Account not activated", + server_account_not_activated, + "Server"), + TEST_ONE_TAG( + "Server - Account already activated", + server_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Local - Is account activated callbacks missing", + server_is_account_activated_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Is account activated arguments username missing", + server_is_account_activated_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Server - Activate account", + server_activate_account_not_activated, + "Server"), //TODO synchro server + TEST_ONE_TAG( + "Server - Activate account already activated", + server_activate_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Server - Activate a non existent account", + server_activate_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Local - Activate account callbacks missing", + server_activate_account_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate account with email arguments username missing", + server_activate_account_with_email_activated_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate account with email arguments activation code missing", + server_activate_account_with_email_activated_arg_activation_code_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate account with phone number arguments username missing", + server_activate_account_with_phone_number_activated_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate account with phone number arguments activation code missing", + server_activate_account_with_phone_number_activated_arg_activation_code_missing, + "Local"), + TEST_ONE_TAG( + "Server - Link account with phone number", + server_link_account_with_phone_number, + "Server"), //TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Link a non existent account with phone number", + server_link_non_existent_account_with_phone_number, + "Server"), //TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Link a non existent account with phone number", + server_link_non_existent_account_with_phone_number, + "Server"), //TODO synchro server + phone number + TEST_ONE_TAG( + "Local - Link account callbacks missing", + server_link_account_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Link account arguments username missing", + server_link_account_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Link account arguments phone number missing", + server_link_account_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Server - Activate phone number for an account", + server_activate_phone_number_for_account, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Activate phone number for a non existent account", + server_activate_phone_number_for_non_existent_account, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Local - Activate alias callbacks missing", + server_activate_alias_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate alias arguments username missing", + server_activate_alias_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate alias arguments phone number missing", + server_activate_alias_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate alias arguments activation code missing", + server_activate_alias_arg_activation_code_missing, + "Local"), + TEST_ONE_TAG( + "Local - Activate alias arguments password missing", + server_activate_alias_arg_password_missing, + "Local"), + TEST_ONE_TAG( + "Local - Is alias used callbacks missing", + server_is_alias_used_cb_missing, + "Local"), + TEST_ONE_TAG( + "Server - Phone number is used as alias", + server_phone_number_is_used_as_alias, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Phone number is used as account", + server_phone_number_is_used_as_account, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Phone number not used", + server_phone_number_not_used, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Local - Is alias used arguments phone number missing", + server_is_alias_used_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Server - Account link with phone number", + server_account_link_with_phone_number, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Account not link with phone number", + server_account_not_link_with_phone_number, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Local - Is account link callbacks missing", + server_is_account_linked_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Is account link arguments username missing", + server_is_account_linked_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Server - Recover account with phone number used", + server_recover_account_with_phone_number_used, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Server - Recover account with phone number not used", + server_recover_account_with_phone_number_not_used, + "Server"),//TODO synchro server + phone number + TEST_ONE_TAG( + "Local - Recover account with phone number callbacks missing", + server_recover_account_with_phone_number_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Recover account with phone number arguments phone number missing", + server_recover_account_with_phone_number_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Server - Update account password with wrong password ", + server_update_account_password_with_wrong_password, + "Server"),//TODO synchro server + TEST_ONE_TAG( + "Server - Update account password with correct password ", + server_update_account_password_with_correct_password, + "Server"),//TODO synchro server + TEST_ONE_TAG( + "Server - Update account password for a non existent account ", + server_update_account_password_for_non_existent_account, + "Server"),//TODO synchro server + TEST_ONE_TAG( + "Local - Update account password callbacks missing", + server_update_account_password_cb_missing, + "Local"), + TEST_ONE_TAG( + "Local - Update account password arguments username missing", + server_update_account_password_arg_username_missing, + "Local"), + TEST_ONE_TAG( + "Local - Update account password arguments phone number missing", + server_update_account_password_arg_phone_number_missing, + "Local"), + TEST_ONE_TAG( + "Local - Update account password arguments password missing", + server_update_account_password_arg_password_missing, + "Local"), + TEST_ONE_TAG( + "Local - Update account password arguments new password missing", + server_update_account_password_arg_new_password_missing, + "Local"), }; -test_suite_t account_creator_test_suite = {"Account creator", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, - sizeof(account_creator_tests) / sizeof(account_creator_tests[0]), account_creator_tests}; +test_suite_t account_creator_test_suite = { + "Account creator", + NULL, + NULL, + liblinphone_tester_before_each, + liblinphone_tester_after_each, + sizeof(account_creator_tests) / sizeof(account_creator_tests[0]), + account_creator_tests}; diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc index 864a56e32..5946e5b27 100644 --- a/tester/rcfiles/account_creator_rc +++ b/tester/rcfiles/account_creator_rc @@ -6,7 +6,7 @@ username_length=4 username_max_length=14 username_min_length=3 username_regex=^[a-z0-9_.\-]*$ -xmlrpc_url=https://sip2.linphone.org:445/wizard.php +xmlrpc_url=https://sip2.linphone.org:446/wizard.php [proxy_default_values] reg_proxy= From 2482371bc479afeaf4da6757dade8a7062ee268b Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 21 Mar 2017 13:31:07 +0100 Subject: [PATCH 16/32] Add account creator request engine + some changes --- build/android/Android.mk | 8 +- coreapi/CMakeLists.txt | 1 + coreapi/Makefile.am | 1 + coreapi/account_creator.c | 127 +-------- coreapi/account_creator_request_engine.c | 157 +++++++++++ coreapi/linphonecore.c | 22 ++ coreapi/private.h | 4 + gtk/setupwizard.c | 8 +- include/CMakeLists.txt | 1 + include/linphone/Makefile.am | 1 + include/linphone/account_creator.h | 206 +------------- .../linphone/account_creator_request_engine.h | 253 ++++++++++++++++++ include/linphone/core.h | 15 ++ 13 files changed, 478 insertions(+), 326 deletions(-) create mode 100644 coreapi/account_creator_request_engine.c create mode 100644 include/linphone/account_creator_request_engine.h diff --git a/build/android/Android.mk b/build/android/Android.mk index 705ddc2ab..e4f847250 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -27,6 +27,7 @@ LOCAL_CPP_EXTENSION := .cc LOCAL_SRC_FILES := \ account_creator.c \ + account_creator_request_engine.c \ address.c \ authentication.c \ bellesip_sal/sal_address_impl.c \ @@ -192,10 +193,10 @@ endif ifneq ($(BUILD_WEBRTC_AECM),0) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_aecm + libwebrtc_aecm ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_aecm_neon + libwebrtc_aecm_neon endif endif @@ -211,7 +212,7 @@ endif ifneq ($(BUILD_ILBC),0) LOCAL_STATIC_LIBRARIES += \ - libwebrtc_ilbc + libwebrtc_ilbc endif @@ -323,4 +324,3 @@ LOCAL_CFLAGS += -Wdeclaration-after-statement LOCAL_LDFLAGS := -Wl,-soname,$(LOCAL_MODULE_FILENAME).so $(call import-module,android/cpufeatures) - diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index c107c22eb..21b1c7c35 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -52,6 +52,7 @@ set(LINPHONE_PRIVATE_HEADER_FILES set(LINPHONE_SOURCE_FILES_C account_creator.c + account_creator_request_engine.c address.c authentication.c bellesip_sal/sal_address_impl.c diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 1ea19e35c..41c36f4f9 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -26,6 +26,7 @@ lib_LTLIBRARIES=liblinphone.la liblinphone_la_SOURCES=\ account_creator.c \ + account_creator_request_engine.c \ address.c \ authentication.c \ buffer.c \ diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 222e402b7..8e9879b44 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone/account_creator.h" +#include "linphone/core.h" #include "private.h" #if !_WIN32 #include "regex.h" @@ -25,15 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include -BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorRequestCbs); - -BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorRequestCbs, belle_sip_object_t, - NULL, // destroy - NULL, // clone - NULL, // marshal - FALSE -); - BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorResponseCbs); BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorResponseCbs, belle_sip_object_t, @@ -176,102 +168,6 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr } /************************** End Misc **************************/ -/************************** Start Account Creator requests_cbs **************************/ -static LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void) { - return belle_sip_object_new(LinphoneAccountCreatorRequestCbs); -} - -LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs) { - belle_sip_object_ref(requests_cbs); - return requests_cbs; -} - -void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs) { - belle_sip_object_unref(requests_cbs); -} - -void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->user_data; -} - -void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud) { - requests_cbs->user_data = ud; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->create_account_request_cb; -} - -void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->create_account_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->is_account_exist_request_cb; -} - -void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->is_account_exist_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->activate_account_request_cb; -} - -void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->activate_account_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->is_account_activated_request_cb; -} - -void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->is_account_activated_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->link_account_request_cb; -} - -void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->link_account_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->is_alias_used_request_cb; -} - -void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->is_alias_used_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->is_account_linked_request_cb; -} - -void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->is_account_linked_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->is_account_linked_request_cb; -} - -void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->recover_account_request_cb = cb; -} - -LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return requests_cbs->update_account_request_cb; -} - -void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { - requests_cbs->update_account_request_cb = cb; -} - -/************************** End Account Creator requests_cbs **************************/ - /************************** Start Account Creator Cbs **************************/ static LinphoneAccountCreatorResponseCbs * linphone_account_creator_reponses_cbs_new(void) { @@ -380,7 +276,8 @@ void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccoun static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { /*this will drop all pending requests if any*/ if (creator->xmlrpc_session) linphone_xml_rpc_session_release(creator->xmlrpc_session); - linphone_account_creator_requests_cbs_unref(creator->requests_cbs); + if (linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs) != NULL) + linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs)(creator); linphone_account_creator_responses_cbs_unref(creator->responses_cbs); linphone_proxy_config_destroy(creator->proxy_cfg); if (creator->username) ms_free(creator->username); @@ -406,28 +303,16 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { LinphoneAccountCreator *creator; creator = belle_sip_object_new(LinphoneAccountCreator); - creator->requests_cbs = linphone_account_creator_requests_cbs_new(); + creator->requests_cbs = linphone_core_get_account_creator_request_engine_cbs(core); creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); creator->core = core; creator->xmlrpc_session = (xmlrpc_url) ? linphone_xml_rpc_session_new(core, xmlrpc_url) : NULL; creator->proxy_cfg = linphone_core_create_proxy_config(core); - linphone_account_creator_set_linphone_impl(creator); + if (linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs) != NULL) + linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs)(creator); return creator; } -void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator) { - creator->requests_cbs->create_account_request_cb = linphone_account_creator_create_account_custom; - creator->requests_cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; - creator->requests_cbs->activate_account_request_cb = linphone_account_creator_activate_account_custom; - creator->requests_cbs->is_account_activated_request_cb = linphone_account_creator_is_account_activated_custom; - creator->requests_cbs->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_custom; - creator->requests_cbs->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_custom; - creator->requests_cbs->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_custom; - creator->requests_cbs->is_account_linked_request_cb = linphone_account_creator_is_account_linked_custom; - creator->requests_cbs->recover_account_request_cb = linphone_account_creator_recover_phone_account_custom; - creator->requests_cbs->update_account_request_cb = linphone_account_creator_update_password_custom; -} - LinphoneAccountCreator * linphone_account_creator_ref(LinphoneAccountCreator *creator) { belle_sip_object_ref(creator); return creator; diff --git a/coreapi/account_creator_request_engine.c b/coreapi/account_creator_request_engine.c new file mode 100644 index 000000000..42b3e9d27 --- /dev/null +++ b/coreapi/account_creator_request_engine.c @@ -0,0 +1,157 @@ +/* +account_creator_request_engine.c +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "linphone/account_creator_request_engine.h" +#include "linphone/core.h" +#include "private.h" + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorRequestCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorRequestCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +/************************** Start Account Creator requests_cbs **************************/ +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void) { + return belle_sip_object_new(LinphoneAccountCreatorRequestCbs); +} + +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_ref(requests_cbs); + return requests_cbs; +} + +void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs) { + belle_sip_object_unref(requests_cbs); +} + +void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->user_data; +} + +void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud) { + requests_cbs->user_data = ud; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_constructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->account_creator_request_constructor_cb; +} + +void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { + requests_cbs->account_creator_request_constructor_cb = func; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->account_creator_request_destructor_cb; +} + +void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { + requests_cbs->account_creator_request_destructor_cb = func; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->create_account_request_cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_exist_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_exist_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->activate_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->activate_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_activated_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_activated_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->link_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->link_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return request_cbs->activate_alias_request_cb; +} + +void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { + request_cbs->activate_alias_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_alias_used_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_alias_used_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->is_account_linked_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->is_account_linked_request_cb; +} + +void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->recover_account_request_cb = cb; +} + +LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { + return requests_cbs->update_account_request_cb; +} + +void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->update_account_request_cb = cb; +} + +/************************** End Account Creator requests_cbs **************************/ + +void linphone_core_set_account_creator_request_engine_cbs(LinphoneCore *lc, LinphoneAccountCreatorRequestCbs *cbs) { + if (lc->default_ac_request_cbs) + linphone_account_creator_requests_cbs_unref(lc->default_ac_request_cbs); + lc->default_ac_request_cbs = cbs; +} + +LinphoneAccountCreatorRequestCbs* linphone_core_get_account_creator_request_engine_cbs(LinphoneCore *lc) { + return lc->default_ac_request_cbs; +} diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 4a0eccb36..aab38ce1a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2072,6 +2072,23 @@ static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, } } +static void _linphone_core_init_account_creator_request_cbs(LinphoneCore *lc) { + LinphoneAccountCreatorRequestCbs *cbs = linphone_account_creator_requests_cbs_new(); + cbs->account_creator_request_constructor_cb = NULL; + cbs->account_creator_request_destructor_cb = NULL; + cbs->create_account_request_cb = linphone_account_creator_create_account_custom; + cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; + cbs->activate_account_request_cb = linphone_account_creator_activate_account_custom; + cbs->is_account_activated_request_cb = linphone_account_creator_is_account_activated_custom; + cbs->link_account_request_cb = linphone_account_creator_link_phone_number_with_account_custom; + cbs->activate_alias_request_cb = linphone_account_creator_activate_phone_number_link_custom; + cbs->is_alias_used_request_cb = linphone_account_creator_is_phone_number_used_custom; + cbs->is_account_linked_request_cb = linphone_account_creator_is_account_linked_custom; + cbs->recover_account_request_cb = linphone_account_creator_recover_phone_account_custom; + cbs->update_account_request_cb = linphone_account_creator_update_password_custom; + linphone_core_set_account_creator_request_engine_cbs(lc, cbs); +} + static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata){ const char *remote_provisioning_uri = NULL; LinphoneFactory *lfactory = linphone_factory_get(); @@ -2152,6 +2169,8 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL); } // else linphone_core_start will be called after the remote provisioning (see linphone_core_iterate) lc->bw_controller = ms_bandwidth_controller_new(); + + _linphone_core_init_account_creator_request_cbs(lc); } LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata) { @@ -5736,6 +5755,9 @@ static void linphone_core_uninit(LinphoneCore *lc) if (lc->im_encryption_engine) { linphone_im_encryption_engine_unref(lc->im_encryption_engine); } + if (lc->default_ac_request_cbs) { + linphone_account_creator_requests_cbs_unref(lc->default_ac_request_cbs); + } linphone_core_free_payload_types(lc); if (lc->supported_formats) ms_free((void *)lc->supported_formats); diff --git a/coreapi/private.h b/coreapi/private.h index c61e9e4d4..bac7e352f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1104,6 +1104,7 @@ struct _LinphoneCore LinphoneAddress *default_rls_addr; /*default resource list server*/ LinphoneImEncryptionEngine *im_encryption_engine; + struct _LinphoneAccountCreatorRequestCbs *default_ac_request_cbs; MSBandwidthController *bw_controller; }; @@ -1393,6 +1394,9 @@ struct _LinphoneAccountCreatorRequestCbs { belle_sip_object_t base; void *user_data; + LinphoneAccountCreatorRequestFunc account_creator_request_constructor_cb; /**< Constructor */ + LinphoneAccountCreatorRequestFunc account_creator_request_destructor_cb; /**< Destructor */ + LinphoneAccountCreatorRequestFunc create_account_request_cb; /**< Request to create account */ LinphoneAccountCreatorRequestFunc is_account_exist_request_cb; /**< Request to know if account exist */ diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index accc2e0d7..8dd5f403c 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -61,9 +61,7 @@ static void linphone_gtk_test_account_validation_cb(LinphoneAccountCreator *crea static void check_account_validation(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); - (linphone_account_creator_requests_cbs_get_is_account_activated_cb( - linphone_account_creator_get_requests_cbs(creator)) - )(creator); + linphone_account_creator_is_account_activated(creator); } void linphone_gtk_assistant_closed(GtkWidget *w) { @@ -237,9 +235,7 @@ static gboolean check_username_availability(GtkWidget *assistant) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); GtkWidget *page = gtk_assistant_get_nth_page(GTK_ASSISTANT(assistant), gtk_assistant_get_current_page(GTK_ASSISTANT(assistant))); g_object_set_data(G_OBJECT(page), "usernameAvailabilityTimerID", GUINT_TO_POINTER(0)); - (linphone_account_creator_requests_cbs_get_is_account_exist_cb( - linphone_account_creator_get_requests_cbs(creator)) - )(creator); + linphone_account_creator_is_account_exist(creator); return FALSE; } diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index a26d72714..3884222bc 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -22,6 +22,7 @@ set(HEADER_FILES account_creator.h + account_creator_request_engine.h address.h auth_info.h buffer.h diff --git a/include/linphone/Makefile.am b/include/linphone/Makefile.am index 55e8edb0e..7056185cf 100644 --- a/include/linphone/Makefile.am +++ b/include/linphone/Makefile.am @@ -2,6 +2,7 @@ linphone_includedir=$(includedir)/linphone linphone_include_HEADERS=\ account_creator.h \ + account_creator_request_engine.h \ address.h \ auth_info.h \ buffer.h \ diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index 423f2b7eb..9e05972b4 100644 --- a/include/linphone/account_creator.h +++ b/include/linphone/account_creator.h @@ -31,12 +31,6 @@ extern "C" { * @{ */ - /** - * Function to set custom server request. - * @param[in] creator LinphoneAccountCreator object - */ - typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccountCreator *creator); - /** * Callback to notify a response of server. * @param[in] creator LinphoneAccountCreator object @@ -55,76 +49,70 @@ typedef void (*LinphoneAccountCreatorResponseFunc)(LinphoneAccountCreator *creat LINPHONE_PUBLIC LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url); /** - * Set Linphone functions to LinphoneAccountCreator. - * @param[in] creator LinphoneAccountCreator object -**/ -LINPHONE_PUBLIC void linphone_account_creator_set_linphone_impl(LinphoneAccountCreator *creator); - -/** - * Send a XML-RPC request to know the existence of account on server. + * Send a request to know the existence of account on server. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_exist(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to create an account on server. + * Send a request to create an account on server. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_create_account(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to know if an account is activated on server. + * Send a request to know if an account is activated on server. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_activated(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to activate an account on server. + * Send a request to activate an account on server. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_account(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to link an account to an alias. + * Send a request to link an account to an alias. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_link_account(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to activate an alias. + * Send a request to activate an alias. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_activate_alias(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to know if an alias is used. + * Send a request to know if an alias is used. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_alias_used(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to know if an account is linked. + * Send a request to know if an account is linked. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to recover an account. + * Send a request to recover an account. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_recover_account(LinphoneAccountCreator *creator); /** - * Send a XML-RPC request to update an account. + * Send a request to update an account. * @param[in] creator LinphoneAccountCreator object * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise **/ @@ -365,182 +353,10 @@ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_is_account_linked * @param[in] new_pwd const char * : new password for the account creator * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. **/ -// TODO viré new_pwd qui sera remplacé par le get_user_data de creator -LINPHONE_PUBLIC /*TODO*/ LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator); +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAccountCreator *creator); /************************** End Account Creator Linphone **************************/ -/************************** Start Account Creator Requests **************************/ - -/** - * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The same LinphoneAccountCreatorRequestCbs object. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Release a reference to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Retrieve the user pointer associated with a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The user pointer associated with the LinphoneAccountCreatorRequestCbs object. -**/ -LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorRequestCbs object. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); - -/** - * Get the create account request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current create account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The create account request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the is account exist request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current is account exist request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account exist request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the activate account request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current activate account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The activate account request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the is account activated request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current is account activated request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account activated request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the link account request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current link account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The link account request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the activate alias request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current link account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The activate alias request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the is alias used request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current is alias used request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is alias used request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the is account linked request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current is account linked request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account linked request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the recover account request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current recover account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The recover account request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/** - * Get the update account request. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @return The current update account request. -**/ -LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); - -/** - * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. - * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The update account request to be used. -**/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); - -/************************** End Account Creator Requests **************************/ - /************************** Start Account Creator Cbs **************************/ /** diff --git a/include/linphone/account_creator_request_engine.h b/include/linphone/account_creator_request_engine.h new file mode 100644 index 000000000..48ca2be08 --- /dev/null +++ b/include/linphone/account_creator_request_engine.h @@ -0,0 +1,253 @@ +/* +account_creator_request_engine.h +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ +#define LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ + +#include "linphone/types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Function to set custom server request. + * @param[in] creator LinphoneAccountCreator object + */ +typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccountCreator *creator); + +/** + * @addtogroup account_creator_request + * @{ + */ + +/************************** Start Account Creator Requests **************************/ + +/** + * Create a new LinphoneAccountCreatorRequestCbs object. + * @return a new LinphoneAccountCreatorRequestCbs object. +**/ +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void); + +/** + * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The same LinphoneAccountCreatorRequestCbs object. +**/ +LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Release a reference to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. +**/ +void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Retrieve the user pointer associated with a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The user pointer associated with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorRequestCbs object. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The constructor of account creator requests. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the constructor of account creator requests. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current constructor of create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_constructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The destructor. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the destructor of create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current destructor of create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Get the create account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current create account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The create account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account exist request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account exist request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account exist request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current activate account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account activated request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account activated request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account activated request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the link account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The link account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the activate alias request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current link account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The activate alias request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is alias used request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is alias used request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is alias used request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the is account linked request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current is account linked request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The is account linked request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the recover account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current recover account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The recover account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/** + * Get the update account request. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @return The current update account request. +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); + +/** + * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. + * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @param[in] func The update account request to be used. +**/ +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); + +/************************** End Account Creator Requests **************************/ + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* LINPHONE_ACCOUNT_CREATOR_REQUEST_ENGINE_H_ */ diff --git a/include/linphone/core.h b/include/linphone/core.h index 0b1638380..253b4e501 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/sipsetup.h" #include "linphone/account_creator.h" +#include "linphone/account_creator_request_engine.h" #include "linphone/address.h" #include "linphone/auth_info.h" #include "linphone/buffer.h" @@ -2235,6 +2236,20 @@ LINPHONE_PUBLIC void linphone_core_abort_authentication(LinphoneCore *lc, Linpho **/ LINPHONE_PUBLIC void linphone_core_clear_all_auth_info(LinphoneCore *lc); +/** + * Sets an default account creator request cbs in the core + * @param lc LinphoneCore object + * @param cbs LinphoneAccountCreatorRequestCbs object +**/ +LINPHONE_PUBLIC void linphone_core_set_account_creator_request_engine_cbs(LinphoneCore *lc, LinphoneAccountCreatorRequestCbs *cbs); + +/** + * Get default account creator request cbs from the core + * @param lc LinphoneCore object + * @return LinphoneAccountCreatorRequestCbs object +**/ +LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs* linphone_core_get_account_creator_request_engine_cbs(LinphoneCore *lc); + /** * Enable or disable the audio adaptive jitter compensation. * @param[in] lc #LinphoneCore object From d59489825364c3b1568f6896c8a44d0fabf6a658 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 21 Mar 2017 17:00:28 +0100 Subject: [PATCH 17/32] Some params name changes on account creator request engine --- coreapi/account_creator_request_engine.c | 14 +++--- .../linphone/account_creator_request_engine.h | 48 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/coreapi/account_creator_request_engine.c b/coreapi/account_creator_request_engine.c index 42b3e9d27..9396a629f 100644 --- a/coreapi/account_creator_request_engine.c +++ b/coreapi/account_creator_request_engine.c @@ -56,16 +56,16 @@ LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_cons return requests_cbs->account_creator_request_constructor_cb; } -void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { - requests_cbs->account_creator_request_constructor_cb = func; +void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->account_creator_request_constructor_cb = cb; } LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { return requests_cbs->account_creator_request_destructor_cb; } -void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { - requests_cbs->account_creator_request_destructor_cb = func; +void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->account_creator_request_destructor_cb = cb; } LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { @@ -105,11 +105,11 @@ void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCr } LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { - return request_cbs->activate_alias_request_cb; + return requests_cbs->activate_alias_request_cb; } -void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func) { - request_cbs->activate_alias_request_cb = cb; +void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->activate_alias_request_cb = cb; } LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { diff --git a/include/linphone/account_creator_request_engine.h b/include/linphone/account_creator_request_engine.h index 48ca2be08..a0f4f7236 100644 --- a/include/linphone/account_creator_request_engine.h +++ b/include/linphone/account_creator_request_engine.h @@ -75,9 +75,9 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(Linphon /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The constructor of account creator requests. + * @param[in] cb The constructor of account creator requests. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the constructor of account creator requests. @@ -89,9 +89,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The destructor. + * @param[in] cb The destructor. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the destructor of create account request. @@ -110,9 +110,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The create account request to be used. + * @param[in] cb The create account request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the is account exist request. @@ -124,9 +124,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account exist request to be used. + * @param[in] cb The is account exist request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the activate account request. @@ -138,9 +138,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The activate account request to be used. + * @param[in] cb The activate account request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the is account activated request. @@ -152,9 +152,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account activated request to be used. + * @param[in] cb The is account activated request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the link account request. @@ -166,9 +166,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The link account request to be used. + * @param[in] cb The link account request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the activate alias request. @@ -180,9 +180,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The activate alias request to be used. + * @param[in] cb The activate alias request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the is alias used request. @@ -194,9 +194,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is alias used request to be used. + * @param[in] cb The is alias used request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the is account linked request. @@ -208,9 +208,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The is account linked request to be used. + * @param[in] cb The is account linked request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the recover account request. @@ -222,9 +222,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The recover account request to be used. + * @param[in] cb The recover account request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /** * Get the update account request. @@ -236,9 +236,9 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque /** * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. - * @param[in] func The update account request to be used. + * @param[in] cb The update account request to be used. **/ -LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc func); +LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); /************************** End Account Creator Requests **************************/ From 85c635521378b76522c10e408a674f8d8726fc07 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 22 Mar 2017 10:26:19 +0100 Subject: [PATCH 18/32] Add new implementation of acocunt creator to Java --- coreapi/linphonecore_jni.cc | 166 ++++----- .../linphone/core/LinphoneAccountCreator.java | 339 ++++++++++++++---- .../core/LinphoneAccountCreatorImpl.java | 116 ++---- 3 files changed, 359 insertions(+), 262 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 352258055..5952c76af 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8157,15 +8157,15 @@ extern "C" void Java_org_linphone_core_LinphoneXmlRpcSessionImpl_sendRequest(JNI // Account creator -static void account_creator_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_used(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { ms_error("cannot attach VM\n"); return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8182,7 +8182,7 @@ static void account_creator_is_account_used(LinphoneAccountCreator *creator, Lin env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_create_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_create_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8190,8 +8190,8 @@ static void account_creator_create_account(LinphoneAccountCreator *creator, Linp return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8208,7 +8208,7 @@ static void account_creator_create_account(LinphoneAccountCreator *creator, Linp env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_activate_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_activate_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8216,8 +8216,8 @@ static void account_creator_activate_account(LinphoneAccountCreator *creator, Li return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8234,7 +8234,7 @@ static void account_creator_activate_account(LinphoneAccountCreator *creator, Li env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8242,8 +8242,8 @@ static void account_creator_link_phone_number_with_account(LinphoneAccountCreato return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8260,7 +8260,7 @@ static void account_creator_link_phone_number_with_account(LinphoneAccountCreato env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8268,8 +8268,8 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8286,7 +8286,7 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_linked(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8294,8 +8294,8 @@ static void account_creator_is_account_linked(LinphoneAccountCreator *creator, L return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8312,7 +8312,7 @@ static void account_creator_is_account_linked(LinphoneAccountCreator *creator, L env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8320,8 +8320,8 @@ static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8338,7 +8338,7 @@ static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_is_account_activated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_is_account_activated(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8346,8 +8346,8 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8364,7 +8364,7 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } -static void account_creator_phone_account_recovered(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +static void account_creator_phone_account_recovered(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8372,8 +8372,8 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea return; } - LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator); - jobject listener = (jobject) linphone_account_creator_cbs_get_user_data(cbs); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8390,7 +8390,7 @@ 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) { +static void account_creator_password_updated(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char *resp) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -8398,10 +8398,8 @@ static void account_creator_password_updated(LinphoneAccountCreator *creator, Li 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); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + jobject listener = (jobject) linphone_account_creator_responses_cbs_get_user_data(cbs); if (listener == NULL) { ms_error("account_creator_response() notification without listener"); return ; @@ -8434,26 +8432,26 @@ extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_unref(JNIEnv * extern "C" void Java_org_linphone_core_LinphoneAccountCreatorImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; jobject listener = env->NewGlobalRef(jlistener); - LinphoneAccountCreatorCbs *cbs; + LinphoneAccountCreatorResponseCbs *cbs; - cbs = linphone_account_creator_get_callbacks(account_creator); - linphone_account_creator_cbs_set_user_data(cbs, listener); - linphone_account_creator_cbs_set_is_account_used(cbs, account_creator_is_account_used); - linphone_account_creator_cbs_set_create_account(cbs, account_creator_create_account); - linphone_account_creator_cbs_set_activate_account(cbs, account_creator_activate_account); - linphone_account_creator_cbs_set_link_phone_number_with_account(cbs, account_creator_link_phone_number_with_account); - linphone_account_creator_cbs_set_activate_phone_number_link(cbs, account_creator_activate_phone_number_link); - 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); - linphone_account_creator_cbs_set_update_hash(cbs, account_creator_password_updated); + cbs = linphone_account_creator_get_responses_cbs(account_creator); + linphone_account_creator_responses_cbs_set_user_data(cbs, listener); + linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_is_account_used); + linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_create_account); + linphone_account_creator_responses_cbs_set_activate_account_cb(cbs, account_creator_activate_account); + linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_link_phone_number_with_account); + linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_activate_phone_number_link); + linphone_account_creator_responses_cbs_set_is_account_activated_cb(cbs, account_creator_is_account_activated); + linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_phone_account_recovered); + linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_is_phone_number_used); + linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_is_account_linked); + linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_password_updated); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setUsername(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { const char *username = GetStringUTFChars(env, jusername); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_username(account_creator, username); + LinphoneUsernameCheck status = linphone_account_creator_set_username(account_creator, username); ReleaseStringUTFChars(env, jusername, username); return (jint) status; } @@ -8468,7 +8466,7 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setPhoneNumber const char *phone_number = GetStringUTFChars(env, jphonenumber); const char *country_code = GetStringUTFChars(env, jcountrycode); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, phone_number, country_code); + LinphonePhoneNumberMask status = linphone_account_creator_set_phone_number(account_creator, phone_number, country_code); ReleaseStringUTFChars(env, jphonenumber, phone_number); ReleaseStringUTFChars(env, jcountrycode, country_code); return (jint) status; @@ -8483,7 +8481,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getPhoneNum extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setPassword(JNIEnv *env, jobject thiz, jlong ptr, jstring jpassword) { const char *password = GetStringUTFChars(env, jpassword); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_password(account_creator, password); + LinphonePasswordCheck status = linphone_account_creator_set_password(account_creator, password); ReleaseStringUTFChars(env, jpassword, password); return (jint) status; } @@ -8497,7 +8495,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getPassword extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setHa1(JNIEnv *env, jobject thiz, jlong ptr, jstring jha1) { const char *ha1 = GetStringUTFChars(env, jha1); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_ha1(account_creator, ha1); + LinphonePasswordCheck status = linphone_account_creator_set_ha1(account_creator, ha1); ReleaseStringUTFChars(env, jha1, ha1); return (jint) status; } @@ -8511,7 +8509,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getHa1(JNIE extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setActivationCode(JNIEnv *env, jobject thiz, jlong ptr, jstring jcode) { const char *activation_code = GetStringUTFChars(env, jcode); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_activation_code(account_creator, activation_code); + LinphoneActivationCodeCheck status = linphone_account_creator_set_activation_code(account_creator, activation_code); ReleaseStringUTFChars(env, jcode, activation_code); return (jint) status; } @@ -8519,55 +8517,15 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setActivationC extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setLanguage(JNIEnv *env, jobject thiz, jlong ptr, jstring jlang) { const char *lang = GetStringUTFChars(env, jlang); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_language(account_creator, lang); + LinphoneLanguageCheck status = linphone_account_creator_set_language(account_creator, lang); ReleaseStringUTFChars(env, jlang, lang); return (jint) status; } -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setTransport(JNIEnv *env, jobject thiz, jlong ptr, jint jtransport) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_transport(account_creator, (LinphoneTransportType)jtransport); - return (jint) status; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_getTransport(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneTransportType transport = linphone_account_creator_get_transport(account_creator); - return (jint) transport; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setDomain(JNIEnv *env, jobject thiz, jlong ptr, jstring jdomain) { - const char *domain = GetStringUTFChars(env, jdomain); - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_domain(account_creator, domain); - ReleaseStringUTFChars(env, jdomain, domain); - return (jint) status; -} - -extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getDomain(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - const char *domain = linphone_account_creator_get_domain(account_creator); - return domain ? env->NewStringUTF(domain) : NULL; -} - -extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setRoute(JNIEnv *env, jobject thiz, jlong ptr, jstring jroute) { - const char *route = GetStringUTFChars(env, jroute); - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_route(account_creator, route); - ReleaseStringUTFChars(env, jroute, route); - return (jint) status; -} - -extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getRoute(JNIEnv *env, jobject thiz, jlong ptr) { - LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - const char *route = linphone_account_creator_get_route(account_creator); - return route ? env->NewStringUTF(route) : NULL; -} - extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setDisplayName(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { const char *name = GetStringUTFChars(env, jname); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_display_name(account_creator, name); + LinphoneUsernameCheck status = linphone_account_creator_set_display_name(account_creator, name); ReleaseStringUTFChars(env, jname, name); return (jint) status; } @@ -8581,7 +8539,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getDisplayN extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_setEmail(JNIEnv *env, jobject thiz, jlong ptr, jstring jemail) { const char *email = GetStringUTFChars(env, jemail); LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - LinphoneAccountCreatorStatus status = linphone_account_creator_set_email(account_creator, email); + LinphoneEmailCheck status = linphone_account_creator_set_email(account_creator, email); ReleaseStringUTFChars(env, jemail, email); return (jint) status; } @@ -8603,7 +8561,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getEmail(JN extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_is_account_used(account_creator); + return (jint) linphone_account_creator_is_account_linked(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_createAccount(JNIEnv *env, jobject thiz, jlong ptr) { @@ -8623,7 +8581,7 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountLinke extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isPhoneNumberUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_is_phone_number_used(account_creator); + return (jint) linphone_account_creator_is_alias_used(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActivated(JNIEnv *env, jobject thiz, jlong ptr) { @@ -8633,26 +8591,28 @@ extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountActiv extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_linkPhoneNumberWithAccount(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_link_phone_number_with_account(account_creator); + return (jint) linphone_account_creator_link_account(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_activatePhoneNumberLink(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_activate_phone_number_link(account_creator); + return (jint) linphone_account_creator_activate_alias(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_recoverPhoneAccount(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_recover_phone_account(account_creator); + return (jint) linphone_account_creator_recover_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; + LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; + const char* passwd = GetStringUTFChars(env, jpasswd); + linphone_account_creator_set_user_data(account_creator, (void*)passwd); + status = (jint) linphone_account_creator_update_account(account_creator); + linphone_account_creator_set_user_data(account_creator, (void*)NULL); + ReleaseStringUTFChars(env, jpasswd, passwd); + return status; } extern "C" jobject Java_org_linphone_core_LinphoneAccountCreatorImpl_configure(JNIEnv *env, jobject thiz, jlong ptr) { diff --git a/java/common/org/linphone/core/LinphoneAccountCreator.java b/java/common/org/linphone/core/LinphoneAccountCreator.java index 72cdebbab..4b716521d 100644 --- a/java/common/org/linphone/core/LinphoneAccountCreator.java +++ b/java/common/org/linphone/core/LinphoneAccountCreator.java @@ -23,68 +23,263 @@ import org.linphone.core.LinphoneAddress.TransportType; public interface LinphoneAccountCreator { interface LinphoneAccountCreatorListener { - void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, Status status); - void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, Status status); + void onAccountCreatorIsAccountUsed(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountCreated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorAccountLinkedWithPhoneNumber(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPhoneNumberLinkActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsAccountActivated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPhoneAccountRecovered(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsAccountLinked(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorIsPhoneNumberUsed(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); + void onAccountCreatorPasswordUpdated(LinphoneAccountCreator accountCreator, RequestStatus RequestStatus); } - public static class Status { - static private Vector values = new Vector(); + public static class UsernameCheck { + static private Vector values = new Vector(); private final int mValue; private final String mStringValue; public final int value() { return mValue; } - public final static Status Ok = new Status(0, "Ok"); - public final static Status Failed = new Status(1, "Failed"); - public final static Status AccountCreated = new Status(2, "AccountCreated"); - public final static Status AccountNotCreated = new Status(3, "AccountNotCreated"); - public final static Status AccountExist = new Status(4, "AccountExist"); - public final static Status AccountExistWithAlias = new Status(5, "AccountExistWithAlias"); - public final static Status AccountNotExist = new Status(6, "AccountNotExist"); - public final static Status AccountActivated = new Status(7, "AccountActivated"); - public final static Status AccountAlreadyActivated = new Status(8, "AccountAlreadyActivated"); - public final static Status AccountNotActivated = new Status(9, "AccountNotActivated"); - public final static Status AccountLinked = new Status(10, "AccountLinked"); - public final static Status AccountNotLinked = new Status(11, "AccountNotLinked"); - public final static Status EmailInvalid = new Status(12, "EmailInvalid"); - public final static Status UsernameInvalid = new Status(13, "UsernameInvalid"); - public final static Status UsernameTooShort = new Status(14, "UsernameTooShort"); - public final static Status UsernameTooLong = new Status(15, "UsernameTooLong"); - public final static Status UsernameInvalidSize = new Status(16, "UsernameInvalidSize"); - public final static Status PhoneNumberInvalid = new Status(17, "PhoneNumberInvalid"); - public final static Status PhoneNumberTooShort = new Status(18, "PhoneNumberTooShort"); - public final static Status PhoneNumberTooLong = new Status(19, "PhoneNumberTooLong"); - public final static Status PhoneNumberUsedAccount = new Status(20, "PhoneNumberUsed"); - public final static Status PhoneNumberUsedAlias = new Status(21, "PhoneNumberUsed"); - public final static Status PhoneNumberNotUsed = new Status(22, "PhoneNumberNotUsed"); - public final static Status PasswordTooShort = new Status(23, "PasswordTooShort"); - public final static Status PasswordTooLong = new Status(24, "PasswordTooLong"); - public final static Status DomainInvalid = new Status(25, "DomainInvalid"); - public final static Status RouteInvalid = new Status(26, "RouteInvalid"); - public final static Status DisplayNameInvalid = new Status(27, "DisplayNameInvalid"); - public final static Status TransportNotSupported = new Status(28, "TransportNotSupported"); - public final static Status CountryCodeInvalid = new Status(29, "CountryCodeInvalid"); - public final static Status ErrorServer = new Status(30, "ErrorServer"); + public final static UsernameCheck Ok = new UsernameCheck(0, "Ok"); + public final static UsernameCheck TooShort = new UsernameCheck(1, "TooShort"); + public final static UsernameCheck TooLong = new UsernameCheck(2, "TooLong"); + public final static UsernameCheck InvalidCharacters = new UsernameCheck(3, "InvalidCharacters"); + public final static UsernameCheck Invalid = new UsernameCheck(4, "Invalid"); - private Status(int value, String stringValue) { + private UsernameCheck(int value, String stringValue) { mValue = value; values.addElement(this); mStringValue = stringValue; } - public static Status fromInt(int value) { + public static UsernameCheck fromInt(int value) { for (int i=0; i < values.size(); i++) { - Status state = (Status) values.elementAt(i); + UsernameCheck state = (UsernameCheck) values.elementAt(i); if (state.mValue == value) return state; } - throw new RuntimeException("Status not found [" + value + "]"); + throw new RuntimeException("UsernameCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class PhoneNumberCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static PhoneNumberCheck Ok = new PhoneNumberCheck(0x1, "Ok"); + public final static PhoneNumberCheck TooShort = new PhoneNumberCheck(0x2, "TooShort"); + public final static PhoneNumberCheck TooLong = new PhoneNumberCheck(0x4, "TooLong"); + public final static PhoneNumberCheck CountryCodeInvalid = new PhoneNumberCheck(0x8, "CountryCodeInvalid"); + public final static PhoneNumberCheck Invalid = new PhoneNumberCheck(0x10, "Invalid"); + + private PhoneNumberCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static PhoneNumberCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + PhoneNumberCheck state = (PhoneNumberCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("UsernameCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class EmailCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static EmailCheck Ok = new EmailCheck(0, "Ok"); + public final static EmailCheck Malformed = new EmailCheck(1, "Malformed"); + public final static EmailCheck InvalidCharacters = new EmailCheck(2, "InvalidCharacters"); + + private EmailCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static EmailCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + EmailCheck state = (EmailCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("EmailCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class PasswordCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static PasswordCheck Ok = new PasswordCheck(0, "Ok"); + public final static PasswordCheck TooShort = new PasswordCheck(1, "TooShort"); + public final static PasswordCheck TooLong = new PasswordCheck(2, "TooLong"); + public final static PasswordCheck InvalidCharacters = new PasswordCheck(3, "InvalidCharacters"); + public final static PasswordCheck MissingCharacters = new PasswordCheck(4, "MissingCharacters"); + + private PasswordCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static PasswordCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + PasswordCheck state = (PasswordCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("PasswordCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class LanguageCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static LanguageCheck Ok = new LanguageCheck(0, "Ok"); + + private LanguageCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static LanguageCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + LanguageCheck state = (LanguageCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("LanguageCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class ActivationCodeCheck { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static ActivationCodeCheck Ok = new ActivationCodeCheck(0, "Ok"); + public final static ActivationCodeCheck TooShort = new ActivationCodeCheck(1, "TooShort"); + public final static ActivationCodeCheck TooLong = new ActivationCodeCheck(2, "TooLong"); + public final static ActivationCodeCheck InvalidCharacters = new ActivationCodeCheck(3, "InvalidCharacters"); + + private ActivationCodeCheck(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static ActivationCodeCheck fromInt(int value) { + for (int i=0; i < values.size(); i++) { + ActivationCodeCheck state = (ActivationCodeCheck) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("ActivationCodeCheck not found [" + value + "]"); + } + + public String toString() { + return mStringValue; + } + + public int toInt() { + return mValue; + } + } + + public static class RequestStatus { + static private Vector values = new Vector(); + private final int mValue; + private final String mStringValue; + public final int value() { return mValue; } + + public final static RequestStatus Ok = new RequestStatus(0, "Ok"); + public final static RequestStatus Failed = new RequestStatus(1, "Failed"); + public final static RequestStatus MissingArguments = new RequestStatus(2, "MissingArguments"); + public final static RequestStatus MissingCallbacks = new RequestStatus(3, "MissingCallbacks"); + + public final static RequestStatus AccountCreated = new RequestStatus(4, "AccountCreated"); + public final static RequestStatus AccountNotCreated = new RequestStatus(5, "AccountNotCreated"); + + public final static RequestStatus AccountExist = new RequestStatus(6, "AccountExist"); + public final static RequestStatus AccountExistWithAlias = new RequestStatus(7, "AccountExistWithAlias"); + public final static RequestStatus AccountNotExist = new RequestStatus(8, "AccountNotExist"); + public final static RequestStatus AliasIsAccount = new RequestStatus(9, "AliasIsAccount"); + public final static RequestStatus AliasExist = new RequestStatus(10, "AliasExist"); + public final static RequestStatus AliasNotExist = new RequestStatus(11, "AliasNotExist"); + + public final static RequestStatus AccountActivated = new RequestStatus(12, "AccountActivated"); + public final static RequestStatus AccountAlreadyActivated = new RequestStatus(13, "AccountAlreadyActivated"); + public final static RequestStatus AccountNotActivated = new RequestStatus(14, "AccountNotActivated"); + + public final static RequestStatus AccountLinked = new RequestStatus(15, "AccountLinked"); + public final static RequestStatus AccountNotLinked = new RequestStatus(16, "AccountNotLinked"); + + public final static RequestStatus ErrorServer = new RequestStatus(17, "ErrorServer"); + + private RequestStatus(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + + public static RequestStatus fromInt(int value) { + for (int i=0; i < values.size(); i++) { + RequestStatus state = (RequestStatus) values.elementAt(i); + if (state.mValue == value) return state; + } + throw new RuntimeException("RequestStatus not found [" + value + "]"); } public String toString() { @@ -98,67 +293,53 @@ public interface LinphoneAccountCreator { void setListener(LinphoneAccountCreatorListener listener); - Status setUsername(String username); + UsernameCheck setUsername(String username); String getUsername(); - Status setPhoneNumber(String phoneNumber, String countryCode); + int setPhoneNumber(String phoneNumber, String countryCode); String getPhoneNumber(); - Status setPassword(String password); + PasswordCheck setPassword(String password); String getPassword(); - Status setHa1(String ha1); + PasswordCheck setHa1(String ha1); String getHa1(); - Status setActivationCode(String activationCode); + ActivationCodeCheck setActivationCode(String activationCode); - Status setLanguage(String lang); + LanguageCheck setLanguage(String lang); - Status setTransport(TransportType transport); - - TransportType getTransport(); - - Status setDomain(String domain); - - String getDomain(); - - Status setRoute(String route); - - String getRoute(); - - Status setDisplayName(String displayName); + UsernameCheck setDisplayName(String displayName); String getDisplayName(); - Status setEmail(String email); + EmailCheck setEmail(String email); String getEmail(); String getPrefix(String phone); - Status isAccountUsed(); + RequestStatus isAccountUsed(); - Status createAccount(); + RequestStatus createAccount(); - Status activateAccount(); + RequestStatus activateAccount(); - Status isAccountActivated(); + RequestStatus isAccountActivated(); - Status linkPhoneNumberWithAccount(); + RequestStatus linkPhoneNumberWithAccount(); - Status activatePhoneNumberLink(); + RequestStatus activatePhoneNumberLink(); - Status isAccountLinked(); + RequestStatus isAccountLinked(); - Status isPhoneNumberUsed(); + RequestStatus isPhoneNumberUsed(); - Status recoverPhoneAccount(); + RequestStatus recoverPhoneAccount(); - Status updatePassword(String newPassword); - - LinphoneProxyConfig configure(); + RequestStatus updatePassword(String newPassword); } diff --git a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java index 66333eec8..6519a693e 100644 --- a/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java +++ b/java/impl/org/linphone/core/LinphoneAccountCreatorImpl.java @@ -17,8 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; -import org.linphone.core.LinphoneAddress.TransportType; - public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { protected long nativePtr; @@ -48,8 +46,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setUsername(long ptr, String username); @Override - public Status setUsername(String username) { - return Status.fromInt(setUsername(nativePtr, username)); + public UsernameCheck setUsername(String username) { + return UsernameCheck.fromInt(setUsername(nativePtr, username)); } private native String getUsername(long ptr); @@ -60,8 +58,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setPhoneNumber(long ptr, String phoneNumber, String countryCode); @Override - public Status setPhoneNumber(String phoneNumber, String countryCode) { - return Status.fromInt(setPhoneNumber(nativePtr, phoneNumber, countryCode)); + public int setPhoneNumber(String phoneNumber, String countryCode) { + return setPhoneNumber(nativePtr, phoneNumber, countryCode); } private native String getPhoneNumber(long ptr); @@ -72,8 +70,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setPassword(long ptr, String password); @Override - public Status setPassword(String password) { - return Status.fromInt(setPassword(nativePtr, password)); + public PasswordCheck setPassword(String password) { + return PasswordCheck.fromInt(setPassword(nativePtr, password)); } private native String getPassword(long ptr); @@ -84,8 +82,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setHa1(long ptr, String ha1); @Override - public Status setHa1(String ha1) { - return Status.fromInt(setHa1(nativePtr, ha1)); + public PasswordCheck setHa1(String ha1) { + return PasswordCheck.fromInt(setHa1(nativePtr, ha1)); } private native String getHa1(long ptr); @@ -96,56 +94,20 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setActivationCode(long ptr, String activationCode); @Override - public Status setActivationCode(String activationCode) { - return Status.fromInt(setActivationCode(nativePtr, activationCode)); + public ActivationCodeCheck setActivationCode(String activationCode) { + return ActivationCodeCheck.fromInt(setActivationCode(nativePtr, activationCode)); } private native int setLanguage(long ptr, String lang); @Override - public Status setLanguage(String lang) { - return Status.fromInt(setLanguage(nativePtr, lang)); - } - - private native int setTransport(long ptr, int transport); - @Override - public Status setTransport(TransportType transport) { - return Status.fromInt(setTransport(nativePtr, transport.toInt())); - } - - private native int getTransport(long ptr); - @Override - public TransportType getTransport() { - return TransportType.fromInt(getTransport(nativePtr)); - } - - private native int setDomain(long ptr, String domain); - @Override - public Status setDomain(String domain) { - return Status.fromInt(setDomain(nativePtr, domain)); - } - - private native String getDomain(long ptr); - @Override - public String getDomain() { - return getDomain(nativePtr); - } - - private native int setRoute(long ptr, String route); - @Override - public Status setRoute(String route) { - return Status.fromInt(setRoute(nativePtr, route)); - } - - private native String getRoute(long ptr); - @Override - public String getRoute() { - return getRoute(nativePtr); + public LanguageCheck setLanguage(String lang) { + return LanguageCheck.fromInt(setLanguage(nativePtr, lang)); } private native int setDisplayName(long ptr, String displayName); @Override - public Status setDisplayName(String displayName) { - return Status.fromInt(setDisplayName(nativePtr, displayName)); + public UsernameCheck setDisplayName(String displayName) { + return UsernameCheck.fromInt(setDisplayName(nativePtr, displayName)); } private native String getDisplayName(long ptr); @@ -156,8 +118,8 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int setEmail(long ptr, String email); @Override - public Status setEmail(String email) { - return Status.fromInt(setEmail(nativePtr, email)); + public EmailCheck setEmail(String email) { + return EmailCheck.fromInt(setEmail(nativePtr, email)); } private native String getEmail(long ptr); @@ -174,67 +136,61 @@ public class LinphoneAccountCreatorImpl implements LinphoneAccountCreator { private native int isAccountUsed(long ptr); @Override - public Status isAccountUsed() { - return Status.fromInt(isAccountUsed(nativePtr)); + public RequestStatus isAccountUsed() { + return RequestStatus.fromInt(isAccountUsed(nativePtr)); } private native int createAccount(long ptr); @Override - public Status createAccount() { - return Status.fromInt(createAccount(nativePtr)); + public RequestStatus createAccount() { + return RequestStatus.fromInt(createAccount(nativePtr)); } private native int activateAccount(long ptr); @Override - public Status activateAccount() { - return Status.fromInt(activateAccount(nativePtr)); + public RequestStatus activateAccount() { + return RequestStatus.fromInt(activateAccount(nativePtr)); } private native int isAccountLinked(long ptr); @Override - public Status isAccountLinked() { - return Status.fromInt(isAccountLinked(nativePtr)); + public RequestStatus isAccountLinked() { + return RequestStatus.fromInt(isAccountLinked(nativePtr)); } private native int isPhoneNumberUsed(long ptr); @Override - public Status isPhoneNumberUsed() { - return Status.fromInt(isPhoneNumberUsed(nativePtr)); + public RequestStatus isPhoneNumberUsed() { + return RequestStatus.fromInt(isPhoneNumberUsed(nativePtr)); } private native int isAccountActivated(long ptr); @Override - public Status isAccountActivated() { - return Status.fromInt(isAccountActivated(nativePtr)); + public RequestStatus isAccountActivated() { + return RequestStatus.fromInt(isAccountActivated(nativePtr)); } private native int linkPhoneNumberWithAccount(long ptr); @Override - public Status linkPhoneNumberWithAccount() { - return Status.fromInt(linkPhoneNumberWithAccount(nativePtr)); + public RequestStatus linkPhoneNumberWithAccount() { + return RequestStatus.fromInt(linkPhoneNumberWithAccount(nativePtr)); } private native int activatePhoneNumberLink(long ptr); @Override - public Status activatePhoneNumberLink() { - return Status.fromInt(activatePhoneNumberLink(nativePtr)); + public RequestStatus activatePhoneNumberLink() { + return RequestStatus.fromInt(activatePhoneNumberLink(nativePtr)); } private native int recoverPhoneAccount(long ptr); @Override - public Status recoverPhoneAccount() { - return Status.fromInt(recoverPhoneAccount(nativePtr)); + public RequestStatus recoverPhoneAccount() { + return RequestStatus.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() { - return configure(nativePtr); + public RequestStatus updatePassword(String newPassword) { + return RequestStatus.fromInt(updatePassword(nativePtr, newPassword)); } } From 48882eb92bc3aa7365c02b9c7f72089ba0c54e3f Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 22 Mar 2017 13:33:57 +0100 Subject: [PATCH 19/32] Fix JNI + Account_creator --- coreapi/account_creator.c | 4 +- coreapi/linphonecore_jni.cc | 80 +++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 8e9879b44..78245ba36 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -276,7 +276,7 @@ void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccoun static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { /*this will drop all pending requests if any*/ if (creator->xmlrpc_session) linphone_xml_rpc_session_release(creator->xmlrpc_session); - if (linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs) != NULL) + if (creator->requests_cbs != NULL && linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs) != NULL) linphone_account_creator_requests_cbs_get_destructor_cb(creator->requests_cbs)(creator); linphone_account_creator_responses_cbs_unref(creator->responses_cbs); linphone_proxy_config_destroy(creator->proxy_cfg); @@ -308,7 +308,7 @@ LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const creator->core = core; creator->xmlrpc_session = (xmlrpc_url) ? linphone_xml_rpc_session_new(core, xmlrpc_url) : NULL; creator->proxy_cfg = linphone_core_create_proxy_config(core); - if (linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs) != NULL) + if (creator->requests_cbs != NULL && linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs) != NULL) linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs)(creator); return creator; } diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 5952c76af..f0a5e3ec5 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -386,8 +386,20 @@ public: accountCreatorClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreatorImpl")); accountCreatorCtrId = env->GetMethodID(accountCreatorClass, "", "(J)V"); - accountCreatorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$Status")); - accountCreatorStatusFromIntId = env->GetStaticMethodID(accountCreatorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$Status;"); + accountCreatorRequestStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$RequestStatus")); + accountCreatorRequestStatusFromIntId = env->GetStaticMethodID(accountCreatorRequestStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;"); + accountCreatorUsernameCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$UsernameCheck")); + accountCreatorUsernameCheckFromIntId = env->GetStaticMethodID(accountCreatorUsernameCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$UsernameCheck;"); + accountCreatorPasswordCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$PasswordCheck")); + accountCreatorPasswordCheckFromIntId = env->GetStaticMethodID(accountCreatorPasswordCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$PasswordCheck;"); + accountCreatorEmailCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$EmailCheck")); + accountCreatorEmailCheckFromIntId = env->GetStaticMethodID(accountCreatorEmailCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$EmailCheck;"); + accountCreatorLanguageCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$LanguageCheck")); + accountCreatorLanguageCheckFromIntId = env->GetStaticMethodID(accountCreatorLanguageCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$LanguageCheck;"); + accountCreatorCodeActivationCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$ActivationCodeCheck")); + accountCreatorCodeActivationCheckFromIntId = env->GetStaticMethodID(accountCreatorCodeActivationCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$ActivationCodeCheck;"); + accountCreatorPhoneNumberCheckClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAccountCreator$PhoneNumberCheck")); + accountCreatorPhoneNumberCheckFromIntId = env->GetStaticMethodID(accountCreatorPhoneNumberCheckClass,"fromInt","(I)Lorg/linphone/core/LinphoneAccountCreator$PhoneNumberCheck;"); } void setCore(jobject c) { @@ -424,7 +436,13 @@ public: env->DeleteGlobalRef(logCollectionUploadStateClass); env->DeleteGlobalRef(msFactoryClass); env->DeleteGlobalRef(accountCreatorClass); - env->DeleteGlobalRef(accountCreatorStatusClass); + env->DeleteGlobalRef(accountCreatorRequestStatusClass); + env->DeleteGlobalRef(accountCreatorUsernameCheckClass); + env->DeleteGlobalRef(accountCreatorPasswordCheckClass); + env->DeleteGlobalRef(accountCreatorEmailCheckClass); + env->DeleteGlobalRef(accountCreatorLanguageCheckClass); + env->DeleteGlobalRef(accountCreatorCodeActivationCheckClass); + env->DeleteGlobalRef(accountCreatorPhoneNumberCheckClass); } jobject core; @@ -538,8 +556,20 @@ public: jclass accountCreatorClass; jmethodID accountCreatorCtrId; - jclass accountCreatorStatusClass; - jmethodID accountCreatorStatusFromIntId; + jclass accountCreatorRequestStatusClass; + jmethodID accountCreatorRequestStatusFromIntId; + jclass accountCreatorUsernameCheckClass; + jmethodID accountCreatorUsernameCheckFromIntId; + jclass accountCreatorPasswordCheckClass; + jmethodID accountCreatorPasswordCheckFromIntId; + jclass accountCreatorEmailCheckClass; + jmethodID accountCreatorEmailCheckFromIntId; + jclass accountCreatorLanguageCheckClass; + jmethodID accountCreatorLanguageCheckFromIntId; + jclass accountCreatorCodeActivationCheckClass; + jmethodID accountCreatorCodeActivationCheckFromIntId; + jclass accountCreatorPhoneNumberCheckClass; + jmethodID accountCreatorPhoneNumberCheckFromIntId; }; /* @@ -8175,10 +8205,10 @@ static void account_creator_is_account_used(LinphoneAccountCreator *creator, Lin LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8201,10 +8231,10 @@ static void account_creator_create_account(LinphoneAccountCreator *creator, Linp LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountCreated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountCreated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8227,10 +8257,10 @@ static void account_creator_activate_account(LinphoneAccountCreator *creator, Li LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8253,10 +8283,10 @@ static void account_creator_link_phone_number_with_account(LinphoneAccountCreato LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountLinkedWithPhoneNumber","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorAccountLinkedWithPhoneNumber","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8279,10 +8309,10 @@ static void account_creator_activate_phone_number_link(LinphoneAccountCreator *c LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneNumberLinkActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8305,10 +8335,10 @@ static void account_creator_is_account_linked(LinphoneAccountCreator *creator, L LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountLinked","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8331,10 +8361,10 @@ static void account_creator_is_phone_number_used(LinphoneAccountCreator *creator LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsPhoneNumberUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsPhoneNumberUsed","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8357,10 +8387,10 @@ static void account_creator_is_account_activated(LinphoneAccountCreator *creator LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorIsAccountActivated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8383,10 +8413,10 @@ static void account_creator_phone_account_recovered(LinphoneAccountCreator *crea LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jclass clazz = (jclass) env->GetObjectClass(listener); - jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneAccountRecovered","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$Status;)V"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPhoneAccountRecovered","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } @@ -8409,10 +8439,10 @@ static void account_creator_password_updated(LinphoneAccountCreator *creator, Li 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"); + jmethodID method = env->GetMethodID(clazz, "onAccountCreatorPasswordUpdated","(Lorg/linphone/core/LinphoneAccountCreator;Lorg/linphone/core/LinphoneAccountCreator$RequestStatus;)V"); env->DeleteLocalRef(clazz); - jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorStatusClass, ljb->accountCreatorStatusFromIntId, (jint)status); + jobject statusObject = env->CallStaticObjectMethod(ljb->accountCreatorRequestStatusClass, ljb->accountCreatorRequestStatusFromIntId, (jint)status); env->CallVoidMethod(listener, method, getAccountCreator(env, creator), statusObject); } From a02b4c60ce09c8d89d0208a8f20b120f5889e10a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Thu, 23 Mar 2017 10:34:38 +0100 Subject: [PATCH 20/32] Fix crash in linphone_proxy_config_normalize_sip_uri --- coreapi/proxy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 758347676..9018ad3c1 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -64,7 +64,7 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi LinphoneAddress *current_proxy=cfg->reg_proxy?linphone_address_new(cfg->reg_proxy):NULL; LinphoneProxyConfigAddressComparisonResult result_identity; LinphoneProxyConfigAddressComparisonResult result; - + result = linphone_proxy_config_address_equal(cfg->saved_identity,cfg->identity_address); if (result == LinphoneProxyConfigAddressDifferent) goto end; result_identity = result; @@ -629,7 +629,7 @@ char* linphone_proxy_config_normalize_phone_number(LinphoneProxyConfig *proxy, c LinphoneDialPlan dialplan = {0}; char * nationnal_significant_number = NULL; int ccc = -1; - + if (linphone_proxy_config_is_phone_number(tmpproxy, username)){ char * flatten=flatten_number(username); ms_debug("Flattened number is '%s' for '%s'",flatten, username); @@ -739,13 +739,13 @@ LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *pr } } - if (proxy!=NULL){ + if (proxy!=NULL && linphone_proxy_config_get_identity_address(proxy)!=NULL){ /* append the proxy domain suffix but remove any custom parameters/headers */ LinphoneAddress *uri=linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); - linphone_address_clean(uri); if (uri==NULL){ return NULL; } else { + linphone_address_clean(uri); linphone_address_set_display_name(uri,NULL); linphone_address_set_username(uri,username); return _linphone_core_destroy_addr_if_not_sip(uri); @@ -798,7 +798,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) if (cfg->commit){ linphone_proxy_config_pause_register(cfg); } - + if (linphone_proxy_config_compute_publish_params_hash(cfg)) { ms_message("Publish params have changed on proxy config [%p]",cfg); if (cfg->long_term_event) { @@ -818,7 +818,7 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) } else { ms_message("Publish params have not changed on proxy config [%p]",cfg); } - + linphone_proxy_config_write_all_to_config_file(cfg->lc); return 0; } From ed9c2fd4785b0dd2d543bc61d1dac3c26ec31e9f Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Thu, 23 Mar 2017 10:36:22 +0100 Subject: [PATCH 21/32] Changes in account_creator -Add deprecated tag to domain and route function -Add custom constructor for linphone account --- coreapi/account_creator.c | 98 +++++++++++++++++++++++------- coreapi/linphonecore.c | 6 +- coreapi/private.h | 4 ++ gtk/setupwizard.c | 12 +++- include/linphone/account_creator.h | 37 +++++++++++ 5 files changed, 130 insertions(+), 27 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 78245ba36..ac40a7b92 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -42,8 +42,11 @@ static const char* ha1_for_passwd(const char* username, const char* realm, const return ha1; } -static unsigned int validate_uri(LinphoneCore *lc, LinphoneProxyConfig *proxy, const char* username, const char* display_name) { +static unsigned int validate_uri(const char* username, const char* domain, const char* display_name) { LinphoneAddress* addr; + int status = 0; + LinphoneProxyConfig* proxy = linphone_proxy_config_new(); + linphone_proxy_config_set_identity(proxy, "sip:userame@domain.com"); if (username) { addr = linphone_proxy_config_normalize_sip_uri(proxy, username); @@ -51,16 +54,22 @@ static unsigned int validate_uri(LinphoneCore *lc, LinphoneProxyConfig *proxy, c addr = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy)); } - if (addr == NULL) - return 1; - - if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { - linphone_address_unref(addr); - return 1; + if (addr == NULL) { + status = 1; + goto end; } + if (domain && linphone_address_set_domain(addr, domain) != 0) { + status = 1; + } + + if (display_name && (!strlen(display_name) || linphone_address_set_display_name(addr, display_name) != 0)) { + status = 1; + } linphone_address_unref(addr); - return 0; +end: + linphone_proxy_config_destroy(proxy); + return status; } static char* _get_identity(const LinphoneAccountCreator *creator) { @@ -71,6 +80,7 @@ static char* _get_identity(const LinphoneAccountCreator *creator) { LinphoneAddress* addr; addr = linphone_proxy_config_normalize_sip_uri(proxy, creator->username ? creator->username : creator->phone_number); + if (addr == NULL) return NULL; identity = linphone_address_as_string(addr); linphone_address_unref(addr); @@ -102,18 +112,18 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr LinphoneProxyConfig *cfg = creator->proxy_cfg; char *identity_str = _get_identity(creator); LinphoneAddress *identity = linphone_address_new(identity_str); - // char *route = NULL; - // char *domain = NULL; + char *route = NULL; + char *domain = NULL; ms_free(identity_str); if (creator->display_name) { linphone_address_set_display_name(identity, creator->display_name); } - // if (creator->route) { - // route = ms_strdup_printf("%s;transport=%s", creator->route, linphone_transport_to_string(creator->transport)); - // } - // if (creator->domain) { - // domain = ms_strdup_printf("%s;transport=%s", creator->domain, linphone_transport_to_string(creator->transport)); - // } + if (creator->route) { + route = ms_strdup_printf("%s", creator->route); + } + if (creator->domain) { + domain = ms_strdup_printf("%s", creator->domain); + } linphone_proxy_config_set_identity_address(cfg, identity); if (creator->phone_country_code) { linphone_proxy_config_set_dial_prefix(cfg, creator->phone_country_code); @@ -123,14 +133,16 @@ LinphoneProxyConfig * linphone_account_creator_configure(const LinphoneAccountCr snprintf(buff, sizeof(buff), "%d", dial_prefix_number); linphone_proxy_config_set_dial_prefix(cfg, buff); } - // if (linphone_proxy_config_get_server_addr(cfg) == NULL) - // linphone_proxy_config_set_server_addr(cfg, domain); - // if (linphone_proxy_config_get_route(cfg) == NULL) - // linphone_proxy_config_set_route(cfg, route); + if (linphone_proxy_config_get_server_addr(cfg) == NULL) + linphone_proxy_config_set_server_addr(cfg, domain); + if (linphone_proxy_config_get_route(cfg) == NULL) + linphone_proxy_config_set_route(cfg, route); + linphone_proxy_config_enable_publish(cfg, FALSE); linphone_proxy_config_enable_register(cfg, TRUE); - if (strcmp(linphone_proxy_config_get_realm(creator->proxy_cfg), "sip.linphone.org") == 0) { + if (linphone_proxy_config_get_realm(cfg) != NULL + && strcmp(linphone_proxy_config_get_realm(cfg), "sip.linphone.org") == 0) { linphone_proxy_config_enable_avpf(cfg, TRUE); // If account created on sip.linphone.org, we configure linphone to use TLS by default if (linphone_core_sip_transport_supported(creator->core, LinphoneTransportTls)) { @@ -289,6 +301,8 @@ static void _linphone_account_creator_destroy(LinphoneAccountCreator *creator) { if (creator->email) ms_free(creator->email); if (creator->language) ms_free(creator->language); if (creator->activation_code) ms_free(creator->activation_code); + if (creator->domain) ms_free(creator->domain); + if (creator->route) ms_free(creator->route); } BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreator); @@ -302,11 +316,15 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreator, belle_sip_object_t, LinphoneAccountCreator * linphone_account_creator_new(LinphoneCore *core, const char *xmlrpc_url) { LinphoneAccountCreator *creator; + const char* domain = lp_config_get_string(core->config, "assistant", "domain", NULL); creator = belle_sip_object_new(LinphoneAccountCreator); creator->requests_cbs = linphone_core_get_account_creator_request_engine_cbs(core); creator->responses_cbs = linphone_account_creator_reponses_cbs_new(); creator->core = core; creator->xmlrpc_session = (xmlrpc_url) ? linphone_xml_rpc_session_new(core, xmlrpc_url) : NULL; + if (domain) { + linphone_account_creator_set_domain(creator, domain); + } creator->proxy_cfg = linphone_core_create_proxy_config(core); if (creator->requests_cbs != NULL && linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs) != NULL) linphone_account_creator_requests_cbs_get_constructor_cb(creator->requests_cbs)(creator); @@ -346,7 +364,7 @@ LinphoneUsernameCheck linphone_account_creator_set_username(LinphoneAccountCreat return LinphoneUsernameInvalid; } else if (regex && !is_matching_regex(username, regex)) { return LinphoneUsernameInvalidCharacters; - } else if (validate_uri(creator->core, creator->proxy_cfg, username, NULL) != 0) { + } else if (validate_uri(username, NULL, NULL) != 0) { return LinphoneUsernameInvalid; } @@ -455,7 +473,7 @@ const char * linphone_account_creator_get_language(const LinphoneAccountCreator } LinphoneUsernameCheck linphone_account_creator_set_display_name(LinphoneAccountCreator *creator, const char *display_name) { - if (validate_uri(creator->core, creator->proxy_cfg, NULL, display_name) != 0) { + if (validate_uri(NULL, display_name, NULL) != 0) { return LinphoneUsernameInvalid; } set_string(&creator->display_name, display_name, FALSE); @@ -481,6 +499,31 @@ const char * linphone_account_creator_get_email(const LinphoneAccountCreator *cr return creator->email; } +LinphoneRequestStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain) { + if (domain && validate_uri(NULL, domain, NULL) != 0) { + return LinphoneRequestFailed; + } + + set_string(&creator->domain, domain, TRUE); + return LinphoneRequestOk; + } + +const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator) { + return creator->domain; +} + +LinphoneRequestStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route) { + if (!route || linphone_proxy_config_set_route(creator->proxy_cfg, route) != 0) + return LinphoneRequestFailed; + + set_string(&creator->route, route, TRUE); + return LinphoneRequestOk; +} + +const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator) { + return creator->route; +} + LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator) { return creator->responses_cbs; } @@ -582,6 +625,15 @@ LinphoneRequestStatus linphone_account_creator_update_account(LinphoneAccountCre /************************** Start Account Creator Linphone **************************/ +LinphoneRequestStatus linphone_account_creator_constructor_custom(LinphoneAccountCreator *creator) { + linphone_proxy_config_set_realm(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_route(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_server_addr(creator->proxy_cfg, "sip.linphone.org"); + linphone_proxy_config_set_identity(creator->proxy_cfg, "sip:username@sip.linphone.org"); + + return LinphoneRequestOk; +} + /****************** START OF ACCOUNT USED SECTION *****************************/ static void _is_account_exist_response_cb(LinphoneXmlRpcRequest *request) { LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index aab38ce1a..1b7476749 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2074,7 +2074,7 @@ static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, static void _linphone_core_init_account_creator_request_cbs(LinphoneCore *lc) { LinphoneAccountCreatorRequestCbs *cbs = linphone_account_creator_requests_cbs_new(); - cbs->account_creator_request_constructor_cb = NULL; + cbs->account_creator_request_constructor_cb = linphone_account_creator_constructor_custom; cbs->account_creator_request_destructor_cb = NULL; cbs->create_account_request_cb = linphone_account_creator_create_account_custom; cbs->is_account_exist_request_cb = linphone_account_creator_is_account_exist_custom; @@ -2104,6 +2104,8 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig linphone_task_list_init(&lc->hooks); + _linphone_core_init_account_creator_request_cbs(lc); + linphone_core_cbs_set_notify_received(internal_cbs, linphone_core_internal_notify_received); linphone_core_cbs_set_subscription_state_changed(internal_cbs, linphone_core_internal_subscription_state_changed); _linphone_core_add_callbacks(lc, internal_cbs, TRUE); @@ -2169,8 +2171,6 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL); } // else linphone_core_start will be called after the remote provisioning (see linphone_core_iterate) lc->bw_controller = ms_bandwidth_controller_new(); - - _linphone_core_init_account_creator_request_cbs(lc); } LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata) { diff --git a/coreapi/private.h b/coreapi/private.h index bac7e352f..d0e7a44db 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1460,6 +1460,10 @@ struct _LinphoneAccountCreator { /* Misc */ char *language; /**< User language */ char *activation_code; /**< Account validation code */ + + /* Deprecated */ + char *domain; + char *route; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreator); diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index 8dd5f403c..96d37776d 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -79,7 +79,9 @@ void linphone_gtk_assistant_prepare(GtkWidget *assistant) { check_account_validation(assistant); break; case 9: - linphone_gtk_load_identities(); + if (linphone_account_creator_configure(linphone_gtk_assistant_get_creator(assistant)) != NULL) { + linphone_gtk_load_identities(); + } gtk_assistant_commit(GTK_ASSISTANT(assistant)); break; default: @@ -126,8 +128,12 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { case 2: { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_username")); + GtkEntry *domain_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_domain")); + GtkEntry *proxy_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_proxy")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p2_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); + linphone_account_creator_set_domain(creator, gtk_entry_get_text(domain_entry)); + linphone_account_creator_set_route(creator, gtk_entry_get_text(proxy_entry)); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -137,6 +143,8 @@ static int linphone_gtk_assistant_forward(int curpage, gpointer data) { GtkEntry *username_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_username")); GtkEntry *password_entry = GTK_ENTRY(linphone_gtk_get_widget(w, "p3_entry_password")); linphone_account_creator_set_username(creator, gtk_entry_get_text(username_entry)); + linphone_account_creator_set_domain(creator, "sip.linphone.org"); + linphone_account_creator_set_route(creator, "sip.linphone.org"); linphone_account_creator_set_password(creator, gtk_entry_get_text(password_entry)); curpage = 9; // Go to page_9_finish break; @@ -249,6 +257,8 @@ void linphone_gtk_account_creation_username_changed(GtkEntry *entry) { LinphoneAccountCreator *creator = linphone_gtk_assistant_get_creator(assistant); linphone_account_creator_set_username(creator, gtk_entry_get_text(username)); + linphone_account_creator_set_domain(creator, "sip.linphone.org"); + linphone_account_creator_set_route(creator, "sip.linphone.org"); if (check_username_validity(gtk_entry_get_text(username))) { guint timerID = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(page), "usernameAvailabilityTimerID")); diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index 9e05972b4..fe8b5fed7 100644 --- a/include/linphone/account_creator.h +++ b/include/linphone/account_creator.h @@ -266,6 +266,36 @@ LINPHONE_PUBLIC LinphoneEmailCheck linphone_account_creator_set_email(LinphoneAc **/ LINPHONE_PUBLIC const char * linphone_account_creator_get_email(const LinphoneAccountCreator *creator); +/** + * Set the domain. + * @param[in] creator LinphoneAccountCreator object + * @param[in] domain The domain to set + * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. +**/ +LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator, const char *domain); + +/** + * Get the domain. + * @param[in] creator LinphoneAccountCreator object + * @return The domain of the LinphoneAccountCreator +**/ +LINPHONE_DEPRECATED LINPHONE_PUBLIC const char * linphone_account_creator_get_domain(const LinphoneAccountCreator *creator); + +/** + * Set the route. + * @param[in] creator LinphoneAccountCreator object + * @param[in] route The route to set + * @return LinphoneRequestOk if everything is OK, or a specific error otherwise. +**/ +LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_set_route(LinphoneAccountCreator *creator, const char *route); + +/** + * Get the route. + * @param[in] creator LinphoneAccountCreator object + * @return The route of the LinphoneAccountCreator +**/ +LINPHONE_DEPRECATED LINPHONE_PUBLIC const char * linphone_account_creator_get_route(const LinphoneAccountCreator *creator); + /** * Get the LinphoneAccountCreatorResponseCbs object associated with a LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object @@ -284,6 +314,13 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_ /************************** Start Account Creator Linphone **************************/ +/** + * Account creator custom to set Linphone default values + * @param[in] creator LinphoneAccountCreator object + * @return LinphoneRequestOk if the request has been sent, LinphoneRequestFailed otherwise +**/ +LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_constructor_custom(LinphoneAccountCreator *creator); + /** * Send an XML-RPC request to test the existence of a Linphone account. * @param[in] creator LinphoneAccountCreator object From 927cd5fd683d5b570b145379004d9bdc548f14b3 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Fri, 24 Mar 2017 09:30:07 +0100 Subject: [PATCH 22/32] Add missing function --- coreapi/account_creator_request_engine.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreapi/account_creator_request_engine.c b/coreapi/account_creator_request_engine.c index 9396a629f..fce88ea79 100644 --- a/coreapi/account_creator_request_engine.c +++ b/coreapi/account_creator_request_engine.c @@ -72,6 +72,10 @@ LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_crea return requests_cbs->create_account_request_cb; } +void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb) { + requests_cbs->create_account_request_cb = cb; +} + LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs) { return requests_cbs->is_account_exist_request_cb; } From f19b023f5771353e64f2fc532a344521db5813ca Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Fri, 24 Mar 2017 16:18:25 +0100 Subject: [PATCH 23/32] Fix Update_password function --- coreapi/account_creator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index ac40a7b92..7b0e7d85f 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -1037,7 +1037,7 @@ LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAc char *identity = _get_identity(creator); const char* new_pwd = (const char*)linphone_account_creator_get_user_data(creator); if (!identity || - (!creator->username || !creator->phone_number + ((!creator->username && !creator->phone_number) || !linphone_proxy_config_get_domain(creator->proxy_cfg) || (!creator->password && !creator->ha1) || !new_pwd ) From 86e8c8f9f01f7c920e21b3a262cb747c479b8cea Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 27 Mar 2017 10:30:32 +0200 Subject: [PATCH 24/32] Fix account_creator tests server --- tester/account_creator_tester.c | 716 +++++++++++++++++++----------- tester/rcfiles/account_creator_rc | 5 +- 2 files changed, 456 insertions(+), 265 deletions(-) diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 817d4a0cf..4e1895ee8 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -17,17 +17,43 @@ */ #include "liblinphone_tester.h" +#include "private.h" static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php"; static const int TIMEOUT_REQUEST = 10000; +/////////// INIT ////////////// + +static void init_account_creator_request_cbs(LinphoneCore *lc) { + LinphoneAccountCreatorRequestCbs *cbs = linphone_account_creator_requests_cbs_new(); + linphone_account_creator_requests_cbs_set_constructor_cb(cbs, NULL); + linphone_account_creator_requests_cbs_set_destructor_cb(cbs, NULL); + linphone_account_creator_requests_cbs_set_create_account_cb(cbs, linphone_account_creator_create_account_custom); + linphone_account_creator_requests_cbs_set_is_account_exist_cb(cbs, linphone_account_creator_is_account_exist_custom); + linphone_account_creator_requests_cbs_set_activate_account_cb(cbs, linphone_account_creator_activate_account_custom); + linphone_account_creator_requests_cbs_set_is_account_activated_cb(cbs, linphone_account_creator_is_account_activated_custom); + linphone_account_creator_requests_cbs_set_link_account_cb(cbs, linphone_account_creator_link_phone_number_with_account_custom); + linphone_account_creator_requests_cbs_set_activate_alias_cb(cbs, linphone_account_creator_activate_phone_number_link_custom); + linphone_account_creator_requests_cbs_set_is_alias_used_cb(cbs, linphone_account_creator_is_phone_number_used_custom); + linphone_account_creator_requests_cbs_set_is_account_linked_cb(cbs, linphone_account_creator_is_account_linked_custom); + linphone_account_creator_requests_cbs_set_recover_account_cb(cbs, linphone_account_creator_recover_phone_account_custom); + linphone_account_creator_requests_cbs_set_update_account_cb(cbs, linphone_account_creator_update_password_custom); + linphone_core_set_account_creator_request_engine_cbs(lc, cbs); +} + +static LinphoneAccountCreator * _linphone_account_creator_new(LinphoneCore *lc, const char * url) { + init_account_creator_request_cbs(lc); + LinphoneAccountCreator *creator = linphone_account_creator_new(lc, url); + return creator; +} + /////////// LOCAL TESTS /////////// ////// USERNAME ////// static void local_username_too_short(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, ""), @@ -41,7 +67,7 @@ static void local_username_too_short(void) { static void local_username_too_long(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "usernametoolongforyou"), @@ -55,7 +81,7 @@ static void local_username_too_long(void) { static void local_username_invalid_character(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_username(creator, "use!"), @@ -69,10 +95,10 @@ static void local_username_invalid_character(void) { static void local_username_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_username(creator, "user"), + linphone_account_creator_set_username(creator, "XXXTESTuser_1"), LinphoneUsernameOk, LinphoneUsernameCheck, "%i"); @@ -85,7 +111,7 @@ static void local_username_ok(void) { static void local_password_too_short(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, ""), @@ -99,7 +125,7 @@ static void local_password_too_short(void) { static void local_password_too_long(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, "passwordtoolong"), @@ -113,7 +139,7 @@ static void local_password_too_long(void) { static void local_password_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_password(creator, "pass"), @@ -129,7 +155,7 @@ static void local_password_ok(void) { static void local_email_malformed(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test.linphone.org"), @@ -167,7 +193,7 @@ static void local_email_malformed(void) { static void local_email_invalid_character(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test@linphone.org$"), @@ -181,7 +207,7 @@ static void local_email_invalid_character(void) { static void local_email_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_email(creator, "test@linphone.org"), @@ -209,7 +235,7 @@ static void local_email_ok(void) { static void local_phone_number_too_short(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_phone_number(creator, "0123", "33")&LinphonePhoneNumberTooShort, @@ -223,7 +249,7 @@ static void local_phone_number_too_short(void) { static void local_phone_number_too_long(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_phone_number(creator, "01234567891011", "33")&LinphonePhoneNumberTooLong, @@ -237,7 +263,7 @@ static void local_phone_number_too_long(void) { static void local_phone_number_invalid(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_phone_number(creator, NULL, "33")&LinphonePhoneNumberInvalid, @@ -251,7 +277,7 @@ static void local_phone_number_invalid(void) { static void local_country_code_invalid(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( linphone_account_creator_set_phone_number(creator, "0123", "")&LinphonePhoneNumberCountryCodeInvalid, @@ -265,10 +291,10 @@ static void local_country_code_invalid(void) { static void local_phone_number_ok(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, ""); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, ""); BC_ASSERT_EQUAL( - linphone_account_creator_set_phone_number(creator, "0123456789", "33")&LinphonePhoneNumberOk, + linphone_account_creator_set_phone_number(creator, "000555455", "1")&LinphonePhoneNumberOk, LinphonePhoneNumberOk, LinphonePhoneNumberCheck, "%i"); @@ -294,11 +320,11 @@ static void account_creator_set_cb_done(LinphoneAccountCreatorResponseCbs *cbs) BC_ASSERT_TRUE(stats->cb_done); } -/*static void account_creator_reset_cb_done(LinphoneAccountCreatorCbs *cbs) { - LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs); +static void account_creator_reset_cb_done(LinphoneAccountCreatorResponseCbs *cbs) { + LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_responses_cbs_get_user_data(cbs); stats->cb_done = 0; BC_ASSERT_FALSE(stats->cb_done); -}*/ +} static void account_creator_cb(LinphoneAccountCreator *creator, LinphoneRequestStatus status, const char* resp) { LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); @@ -312,10 +338,170 @@ static void account_creator_cb(LinphoneAccountCreator *creator, LinphoneRequestS account_creator_set_cb_done(cbs); } +static void _get_activation_code_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + LinphoneRequestStatus status = LinphoneRequestFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + if (strstr(resp, "ERROR_") == resp) { + status = LinphoneRequestFailed; + } else { + status = LinphoneRequestOk; + set_string(&creator->activation_code, resp, FALSE); + } + } + account_creator_cb(creator, status, resp); +} + +LinphoneRequestStatus get_activation_code_account_cb(LinphoneAccountCreator *creator) { + LinphoneXmlRpcRequest *request; + if ((!creator->username && !creator->phone_number) || !creator->password) { + return LinphoneRequestMissingArguments; + } + + request = linphone_xml_rpc_request_new_with_args("get_confirmation_key", LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, + LinphoneXmlRpcArgString, creator->password, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), + LinphoneXmlRpcArgNone); + + linphone_xml_rpc_request_set_user_data(request, creator); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_activation_code_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} + +static void _delete_account_cb(LinphoneXmlRpcRequest *request) { + LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request); + LinphoneRequestStatus status = LinphoneRequestFailed; + const char* resp = linphone_xml_rpc_request_get_string_response(request); + if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) { + // We want to delete account from table but it's not an error if it doesn't exist or password doesn't match + if (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp + || strstr(resp, "ERROR_PASSWORD_DOESNT_MATCH") == resp) { + status = LinphoneRequestOk; + } else if (strstr(resp, "ERROR_") == resp) { + status = LinphoneRequestFailed; + } else { + status = LinphoneRequestOk; + } + } + account_creator_cb(creator, status, resp); +} + +LinphoneRequestStatus delete_account_cb(LinphoneAccountCreator *creator) { + LinphoneXmlRpcRequest *request; + if ((!creator->username && !creator->phone_number) || !creator->password) { + return LinphoneRequestMissingArguments; + } + + request = linphone_xml_rpc_request_new_with_args("delete_account", LinphoneXmlRpcArgString, + LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, + LinphoneXmlRpcArgString, creator->password, + LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), + LinphoneXmlRpcArgNone); + + linphone_xml_rpc_request_set_user_data(request, creator); + linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _delete_account_cb); + linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request); + linphone_xml_rpc_request_unref(request); + + return LinphoneRequestOk; +} + +static void get_activation_code(LinphoneAccountCreator *creator, int *cb_done) { + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + + BC_ASSERT_EQUAL( + get_activation_code_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(creator->core, NULL, cb_done, 1, TIMEOUT_REQUEST); +} + +static void server_delete_account_test(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); + LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); + + BC_ASSERT_EQUAL( + delete_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + linphone_account_creator_unref(creator); + + // First attempt with the first password + creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); + cbs = linphone_account_creator_get_responses_cbs(creator); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + account_creator_reset_cb_done(cbs); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + + BC_ASSERT_EQUAL( + delete_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + linphone_account_creator_unref(creator); + + // Second attempt with the second password + creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); + cbs = linphone_account_creator_get_responses_cbs(creator); + + linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + account_creator_reset_cb_done(cbs); + linphone_account_creator_requests_cbs_set_user_data( + linphone_account_creator_get_requests_cbs(creator), + (void*)LinphoneRequestOk); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "newpassword"); + + BC_ASSERT_EQUAL( + delete_account_cb(creator), + LinphoneRequestOk, + LinphoneRequestStatus, + "%i"); + + wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST); + + ms_free(stats); + linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); +} + /****************** Start Is Account Exist ************************/ static void server_account_doesnt_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -341,15 +527,15 @@ static void server_account_doesnt_exist(void) { static void server_account_exist(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotExist); - linphone_account_creator_set_username(creator, "user_exist"); + (void*)LinphoneRequestAccountExist); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_responses_cbs_set_is_account_exist_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -367,7 +553,7 @@ static void server_account_exist(void) { static void server_is_account_exist_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); @@ -383,7 +569,7 @@ static void server_is_account_exist_cb_missing(void) { static void server_is_account_exist_arg_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -406,9 +592,9 @@ static void server_is_account_exist_arg_missing(void) { /****************** End Is Account Exist ************************/ /****************** Start Create Account ************************/ -static void server_account_created_with_email(void) { //TODO synchro server +static void server_account_created_with_email(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -416,7 +602,7 @@ static void server_account_created_with_email(void) { //TODO synchro server linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountCreated); - linphone_account_creator_set_username(creator, "user_1"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_set_email(creator, "user_1@linphone.org"); linphone_account_creator_set_password(creator, "password"); linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); @@ -436,7 +622,7 @@ static void server_account_created_with_email(void) { //TODO synchro server static void server_create_account_already_create_with_email(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -444,8 +630,8 @@ static void server_create_account_already_create_with_email(void) { linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountExist); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_email(creator, "test@bc.com"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); linphone_account_creator_set_password(creator, "password"); linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); @@ -462,9 +648,9 @@ static void server_create_account_already_create_with_email(void) { linphone_core_manager_destroy(marie); } -static void server_account_created_with_phone_number(void) { //TODO synchro server +static void server_account_created_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -472,9 +658,9 @@ static void server_account_created_with_phone_number(void) { //TODO synchro serv linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountCreated); - linphone_account_creator_set_username(creator, "user_1"); - linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -492,7 +678,7 @@ static void server_account_created_with_phone_number(void) { //TODO synchro serv static void server_create_account_already_create_as_account_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -500,9 +686,9 @@ static void server_create_account_already_create_as_account_with_phone_number(vo linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountExist); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_email(creator, "test@bc.com"); - linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555455","1"); linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -520,7 +706,7 @@ static void server_create_account_already_create_as_account_with_phone_number(vo static void server_create_account_already_create_as_alias_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -528,9 +714,10 @@ static void server_create_account_already_create_as_alias_with_phone_number(void linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountExistWithAlias); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_email(creator, "test@bc.com"); - linphone_account_creator_set_phone_number(creator, "01234567","33"); + linphone_account_creator_set_username(creator, "XXXTESTuser_3"); + linphone_account_creator_set_email(creator, "user_2@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_phone_number(creator, "000555456","1"); linphone_account_creator_responses_cbs_set_create_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -548,7 +735,7 @@ static void server_create_account_already_create_as_alias_with_phone_number(void static void server_create_account_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_email(creator, "user_1@linphone.org"); @@ -566,7 +753,7 @@ static void server_create_account_cb_missing(void) { static void server_create_account_with_email_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -592,7 +779,7 @@ static void server_create_account_with_email_arg_username_missing(void) { static void server_create_account_with_email_arg_email_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -618,7 +805,7 @@ static void server_create_account_with_email_arg_email_missing(void) { static void server_create_account_with_email_arg_password_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -644,7 +831,7 @@ static void server_create_account_with_email_arg_password_missing(void) { static void server_create_account_with_phone_number_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -670,7 +857,7 @@ static void server_create_account_with_phone_number_arg_username_missing(void) { static void server_create_account_with_phone_number_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -698,11 +885,11 @@ static void server_create_account_with_phone_number_arg_phone_number_missing(voi /****************** Start Is Account Activated ************************/ static void server_account_not_activated(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( @@ -725,11 +912,11 @@ static void server_account_not_activated(void) { static void server_account_already_activated(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "u_activated"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( @@ -752,7 +939,7 @@ static void server_account_already_activated(void) { static void server_is_account_activated_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); @@ -768,7 +955,7 @@ static void server_is_account_activated_cb_missing(void) { static void server_is_account_activated_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -791,17 +978,19 @@ static void server_is_account_activated_arg_username_missing(void) { /****************** End Is Account Activated ************************/ /****************** Start Activate Account ************************/ -static void server_activate_account_not_activated(void) { //TODO synchro server +static void server_activate_account_not_activated(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_1"); - linphone_account_creator_set_activation_code(creator, "58c93c745df56"); - linphone_account_creator_set_email(creator, "user_1@linphone.org"); - linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountActivated); @@ -820,17 +1009,19 @@ static void server_activate_account_not_activated(void) { //TODO synchro server linphone_core_manager_destroy(marie); } -static void server_activate_account_already_activated(void) { //TODO synchro server +static void server_activate_account_already_activated(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "u_activated"); - linphone_account_creator_set_activation_code(creator, "1234"); - linphone_account_creator_set_email(creator, "test2@bc.com"); - linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + linphone_account_creator_set_password(creator, "password"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), (void*)LinphoneRequestAccountAlreadyActivated); @@ -849,14 +1040,14 @@ static void server_activate_account_already_activated(void) { //TODO synchro ser linphone_core_manager_destroy(marie); } -static void server_activate_non_existent_account(void) { //TODO synchro server +static void server_activate_non_existent_account(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); linphone_account_creator_set_username(creator, "unknown_user"); - linphone_account_creator_set_activation_code(creator, "58c93c745df56"); + linphone_account_creator_set_activation_code(creator, "58c9"); linphone_account_creator_set_email(creator, "user_1@linphone.org"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); @@ -880,7 +1071,7 @@ static void server_activate_non_existent_account(void) { //TODO synchro server static void server_activate_account_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); @@ -896,7 +1087,7 @@ static void server_activate_account_cb_missing(void) { static void server_activate_account_with_email_activated_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -922,7 +1113,7 @@ static void server_activate_account_with_email_activated_arg_username_missing(vo static void server_activate_account_with_email_activated_arg_activation_code_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -948,7 +1139,7 @@ static void server_activate_account_with_email_activated_arg_activation_code_mis static void server_activate_account_with_phone_number_activated_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -974,7 +1165,7 @@ static void server_activate_account_with_phone_number_activated_arg_username_mis static void server_activate_account_with_phone_number_activated_arg_activation_code_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1000,19 +1191,19 @@ static void server_activate_account_with_phone_number_activated_arg_activation_c /****************** End Activate Account ************************/ /****************** Start Link Account ************************/ -static void server_link_account_with_phone_number(void) { //TODO synchro server + phone number +static void server_link_account_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "012345678", "33"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountLinked); + (void*)LinphoneRequestOk); linphone_account_creator_responses_cbs_set_link_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1028,9 +1219,9 @@ static void server_link_account_with_phone_number(void) { //TODO synchro server linphone_core_manager_destroy(marie); } -static void server_link_non_existent_account_with_phone_number(void) { //TODO synchro server + phone number +static void server_link_non_existent_account_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1058,7 +1249,7 @@ static void server_link_non_existent_account_with_phone_number(void) { //TODO sy static void server_link_account_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_phone_number(creator, "0123456", "33"); @@ -1075,7 +1266,7 @@ static void server_link_account_cb_missing(void) { static void server_link_account_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1100,7 +1291,7 @@ static void server_link_account_arg_username_missing(void) { static void server_link_account_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1125,13 +1316,13 @@ static void server_link_account_arg_phone_number_missing(void) { /****************** End Link Account ************************/ /****************** Start Activate Alias ************************/ -static void server_activate_phone_number_for_non_existent_account(void) { //TODO synchro server + phone number +static void server_activate_phone_number_for_non_existent_account(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_username(creator, "unknown_user"); linphone_account_creator_set_phone_number(creator, "012345678", "33"); linphone_account_creator_set_activation_code(creator, "12345679"); linphone_account_creator_set_password(creator, "password"); @@ -1139,7 +1330,7 @@ static void server_activate_phone_number_for_non_existent_account(void) { //TODO linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAccountNotActivated); linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1155,19 +1346,23 @@ static void server_activate_phone_number_for_non_existent_account(void) { //TODO linphone_core_manager_destroy(marie); } -static void server_activate_phone_number_for_account(void) { //TODO synchro server + phone number +static void server_activate_phone_number_for_account(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "unknown_user"); - linphone_account_creator_set_phone_number(creator, "012345678", "33"); - linphone_account_creator_responses_cbs_set_user_data(cbs, stats); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); + linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_email(creator, "user_1@linphone.org"); + get_activation_code(creator, &stats->cb_done); + account_creator_reset_cb_done(creator->responses_cbs); + linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAccountActivated); linphone_account_creator_responses_cbs_set_activate_alias_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1185,7 +1380,7 @@ static void server_activate_phone_number_for_account(void) { //TODO synchro serv static void server_activate_alias_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_phone_number(creator, "012345678", "33"); @@ -1204,7 +1399,7 @@ static void server_activate_alias_cb_missing(void) { static void server_activate_alias_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1231,7 +1426,7 @@ static void server_activate_alias_arg_username_missing(void) { static void server_activate_alias_arg_activation_code_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1258,7 +1453,7 @@ static void server_activate_alias_arg_activation_code_missing(void) { static void server_activate_alias_arg_password_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1285,7 +1480,7 @@ static void server_activate_alias_arg_password_missing(void) { static void server_activate_alias_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1312,18 +1507,18 @@ static void server_activate_alias_arg_phone_number_missing(void) { /****************** End Activate Alias ************************/ /****************** Start Is Alias Used ************************/ -static void server_phone_number_is_used_as_alias(void) { //TODO synchro server + phone number +static void server_phone_number_is_used_as_alias(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_phone_number(creator, "012345678", "33"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAliasExist); linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1339,18 +1534,18 @@ static void server_phone_number_is_used_as_alias(void) { //TODO synchro server + linphone_core_manager_destroy(marie); } -static void server_phone_number_is_used_as_account(void) { //TODO synchro server + phone number +static void server_phone_number_is_used_as_account(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_phone_number(creator, "012345678", "33"); + linphone_account_creator_set_phone_number(creator, "000555455", "1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAliasIsAccount); linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1366,9 +1561,9 @@ static void server_phone_number_is_used_as_account(void) { //TODO synchro server linphone_core_manager_destroy(marie); } -static void server_phone_number_not_used(void) { //TODO synchro server + phone number +static void server_phone_number_not_used(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1377,7 +1572,7 @@ static void server_phone_number_not_used(void) { //TODO synchro server + phone n linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAliasNotExist); linphone_account_creator_responses_cbs_set_is_alias_used_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1395,7 +1590,7 @@ static void server_phone_number_not_used(void) { //TODO synchro server + phone n static void server_is_alias_used_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_phone_number(creator, "012345678", "33"); @@ -1411,7 +1606,7 @@ static void server_is_alias_used_cb_missing(void) { static void server_is_alias_used_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1434,18 +1629,18 @@ static void server_is_alias_used_arg_phone_number_missing(void) { /****************** End Is Alias Used ************************/ /****************** Start Is Account Linked ************************/ -static void server_account_link_with_phone_number(void) { //TODO synchro server + phone number +static void server_account_link_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAccountLinked); linphone_account_creator_responses_cbs_set_is_account_linked_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1461,13 +1656,13 @@ static void server_account_link_with_phone_number(void) { //TODO synchro server linphone_core_manager_destroy(marie); } -static void server_account_not_link_with_phone_number(void) { //TODO synchro server + phone number +static void server_account_not_link_with_phone_number(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( @@ -1490,7 +1685,7 @@ static void server_account_not_link_with_phone_number(void) { //TODO synchro ser static void server_is_account_linked_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); @@ -1506,7 +1701,7 @@ static void server_is_account_linked_cb_missing(void) { static void server_is_account_linked_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1529,18 +1724,18 @@ static void server_is_account_linked_arg_username_missing(void) { /****************** End Is Account Linked ************************/ /****************** Start Recover Account ************************/ -static void server_recover_account_with_phone_number_used(void) { //TODO synchro server + phone number +static void server_recover_account_with_phone_number_used(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_phone_number(creator, "012345678", "33"); + linphone_account_creator_set_phone_number(creator, "000555456", "1"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestOk); linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1556,9 +1751,9 @@ static void server_recover_account_with_phone_number_used(void) { //TODO synchro linphone_core_manager_destroy(marie); } -static void server_recover_account_with_phone_number_not_used(void) { //TODO synchro server + phone number +static void server_recover_account_with_phone_number_not_used(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1567,7 +1762,7 @@ static void server_recover_account_with_phone_number_not_used(void) { //TODO syn linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_responses_cbs_set_recover_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1585,7 +1780,7 @@ static void server_recover_account_with_phone_number_not_used(void) { //TODO syn static void server_recover_account_with_phone_number_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_phone_number(creator, "0123456", "33"); @@ -1601,7 +1796,7 @@ static void server_recover_account_with_phone_number_cb_missing(void) { static void server_recover_account_with_phone_number_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1624,21 +1819,20 @@ static void server_recover_account_with_phone_number_arg_phone_number_missing(vo /****************** End Recover Account ************************/ /****************** Start Update Account ************************/ -static void server_update_account_password_with_wrong_password(void) { //TODO synchro server +static void server_update_account_password_with_wrong_password(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); - linphone_account_creator_set_password(creator, "password"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); + linphone_account_creator_set_password(creator, "pssword"); linphone_account_creator_set_user_data(creator, "newpassword"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestAccountNotExist); linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1654,21 +1848,20 @@ static void server_update_account_password_with_wrong_password(void) { //TODO sy linphone_core_manager_destroy(marie); } -static void server_update_account_password_with_correct_password(void) { //TODO synchro server +static void server_update_account_password_with_correct_password(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_username(creator, "XXXTESTuser_1"); linphone_account_creator_set_password(creator, "password"); linphone_account_creator_set_user_data(creator, "newpassword"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestOk); linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1684,21 +1877,20 @@ static void server_update_account_password_with_correct_password(void) { //TODO linphone_core_manager_destroy(marie); } -static void server_update_account_password_for_non_existent_account(void) { //TODO synchro server +static void server_update_account_password_for_non_existent_account(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); - linphone_account_creator_set_username(creator, "user_exist"); - linphone_account_creator_set_phone_number(creator, "0123456", "33"); + linphone_account_creator_set_username(creator, "unknown_user"); linphone_account_creator_set_password(creator, "password"); linphone_account_creator_set_user_data(creator, "newpassword"); linphone_account_creator_responses_cbs_set_user_data(cbs, stats); linphone_account_creator_requests_cbs_set_user_data( linphone_account_creator_get_requests_cbs(creator), - (void*)LinphoneRequestAccountNotLinked); + (void*)LinphoneRequestErrorServer); linphone_account_creator_responses_cbs_set_update_account_cb(cbs, account_creator_cb); BC_ASSERT_EQUAL( @@ -1716,7 +1908,7 @@ static void server_update_account_password_for_non_existent_account(void) { //TO static void server_update_account_password_cb_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); linphone_account_creator_set_username(creator, "user_exist"); linphone_account_creator_set_phone_number(creator, "0123456", "33"); @@ -1735,7 +1927,7 @@ static void server_update_account_password_cb_missing(void) { static void server_update_account_password_arg_username_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1762,7 +1954,7 @@ static void server_update_account_password_arg_username_missing(void) { static void server_update_account_password_arg_phone_number_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1788,7 +1980,7 @@ static void server_update_account_password_arg_phone_number_missing(void) { static void server_update_account_password_arg_password_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1815,7 +2007,7 @@ static void server_update_account_password_arg_password_missing(void) { static void server_update_account_password_arg_new_password_missing(void) { LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0); - LinphoneAccountCreator *creator = linphone_account_creator_new(marie->lc, XMLRPC_URL); + LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL); LinphoneAccountCreatorResponseCbs *cbs = linphone_account_creator_get_responses_cbs(creator); LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats(); @@ -1902,15 +2094,6 @@ test_t account_creator_tests[] = { "Local - Phone number ok", local_phone_number_ok, "Local"), - - TEST_ONE_TAG( - "Server - Account doesn\'t exist", - server_account_doesnt_exist, - "Server"), - TEST_ONE_TAG( - "Server - Account exist", - server_account_exist, - "Server"), TEST_ONE_TAG( "Local - Is account exist callback missing", server_is_account_exist_cb_missing, @@ -1919,26 +2102,6 @@ test_t account_creator_tests[] = { "Local - Is account exist arguments missing", server_is_account_exist_arg_missing, "Local"), - TEST_ONE_TAG( - "Server - Account created with email", - server_account_created_with_email, - "Server"),//TODO synchro server - TEST_ONE_TAG( - "Server - Account already create with email", - server_create_account_already_create_with_email, - "Server"), - TEST_ONE_TAG( - "Server - Account created with phone number", - server_account_created_with_phone_number, - "Server"),//TODO synchro server - TEST_ONE_TAG( - "Server - Account already created with phone number as account", - server_create_account_already_create_as_account_with_phone_number, - "Server"), - TEST_ONE_TAG( - "Server - Account already created with phone number as alias", - server_create_account_already_create_as_alias_with_phone_number, - "Server"), TEST_ONE_TAG( "Local - Create Account callback missing", server_create_account_cb_missing, @@ -1963,14 +2126,6 @@ test_t account_creator_tests[] = { "Local - Create Account with phone number arguments phone number missing", server_create_account_with_phone_number_arg_phone_number_missing, "Local"), - TEST_ONE_TAG( - "Server - Account not activated", - server_account_not_activated, - "Server"), - TEST_ONE_TAG( - "Server - Account already activated", - server_account_already_activated, - "Server"), TEST_ONE_TAG( "Local - Is account activated callbacks missing", server_is_account_activated_cb_missing, @@ -1979,18 +2134,6 @@ test_t account_creator_tests[] = { "Local - Is account activated arguments username missing", server_is_account_activated_arg_username_missing, "Local"), - TEST_ONE_TAG( - "Server - Activate account", - server_activate_account_not_activated, - "Server"), //TODO synchro server - TEST_ONE_TAG( - "Server - Activate account already activated", - server_activate_account_already_activated, - "Server"), - TEST_ONE_TAG( - "Server - Activate a non existent account", - server_activate_non_existent_account, - "Server"), TEST_ONE_TAG( "Local - Activate account callbacks missing", server_activate_account_cb_missing, @@ -2011,18 +2154,6 @@ test_t account_creator_tests[] = { "Local - Activate account with phone number arguments activation code missing", server_activate_account_with_phone_number_activated_arg_activation_code_missing, "Local"), - TEST_ONE_TAG( - "Server - Link account with phone number", - server_link_account_with_phone_number, - "Server"), //TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Link a non existent account with phone number", - server_link_non_existent_account_with_phone_number, - "Server"), //TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Link a non existent account with phone number", - server_link_non_existent_account_with_phone_number, - "Server"), //TODO synchro server + phone number TEST_ONE_TAG( "Local - Link account callbacks missing", server_link_account_cb_missing, @@ -2035,14 +2166,6 @@ test_t account_creator_tests[] = { "Local - Link account arguments phone number missing", server_link_account_arg_phone_number_missing, "Local"), - TEST_ONE_TAG( - "Server - Activate phone number for an account", - server_activate_phone_number_for_account, - "Server"),//TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Activate phone number for a non existent account", - server_activate_phone_number_for_non_existent_account, - "Server"),//TODO synchro server + phone number TEST_ONE_TAG( "Local - Activate alias callbacks missing", server_activate_alias_cb_missing, @@ -2067,30 +2190,10 @@ test_t account_creator_tests[] = { "Local - Is alias used callbacks missing", server_is_alias_used_cb_missing, "Local"), - TEST_ONE_TAG( - "Server - Phone number is used as alias", - server_phone_number_is_used_as_alias, - "Server"),//TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Phone number is used as account", - server_phone_number_is_used_as_account, - "Server"),//TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Phone number not used", - server_phone_number_not_used, - "Server"),//TODO synchro server + phone number TEST_ONE_TAG( "Local - Is alias used arguments phone number missing", server_is_alias_used_arg_phone_number_missing, "Local"), - TEST_ONE_TAG( - "Server - Account link with phone number", - server_account_link_with_phone_number, - "Server"),//TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Account not link with phone number", - server_account_not_link_with_phone_number, - "Server"),//TODO synchro server + phone number TEST_ONE_TAG( "Local - Is account link callbacks missing", server_is_account_linked_cb_missing, @@ -2099,14 +2202,6 @@ test_t account_creator_tests[] = { "Local - Is account link arguments username missing", server_is_account_linked_arg_username_missing, "Local"), - TEST_ONE_TAG( - "Server - Recover account with phone number used", - server_recover_account_with_phone_number_used, - "Server"),//TODO synchro server + phone number - TEST_ONE_TAG( - "Server - Recover account with phone number not used", - server_recover_account_with_phone_number_not_used, - "Server"),//TODO synchro server + phone number TEST_ONE_TAG( "Local - Recover account with phone number callbacks missing", server_recover_account_with_phone_number_cb_missing, @@ -2115,18 +2210,6 @@ test_t account_creator_tests[] = { "Local - Recover account with phone number arguments phone number missing", server_recover_account_with_phone_number_arg_phone_number_missing, "Local"), - TEST_ONE_TAG( - "Server - Update account password with wrong password ", - server_update_account_password_with_wrong_password, - "Server"),//TODO synchro server - TEST_ONE_TAG( - "Server - Update account password with correct password ", - server_update_account_password_with_correct_password, - "Server"),//TODO synchro server - TEST_ONE_TAG( - "Server - Update account password for a non existent account ", - server_update_account_password_for_non_existent_account, - "Server"),//TODO synchro server TEST_ONE_TAG( "Local - Update account password callbacks missing", server_update_account_password_cb_missing, @@ -2147,6 +2230,115 @@ test_t account_creator_tests[] = { "Local - Update account password arguments new password missing", server_update_account_password_arg_new_password_missing, "Local"), + /* These tests must be carried in a specific order */ + TEST_ONE_TAG( + "Server - Delete accounts test", + server_delete_account_test, + "Server"), + TEST_ONE_TAG( + "Server - Account doesn\'t exist", + server_account_doesnt_exist, + "Server"), + TEST_ONE_TAG( + "Server - Activate a non existent account", + server_activate_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Activate phone number for a non existent account", + server_activate_phone_number_for_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Phone number not used", + server_phone_number_not_used, + "Server"), + TEST_ONE_TAG( + "Server - Update account password for a non existent account", + server_update_account_password_for_non_existent_account, + "Server"), + TEST_ONE_TAG( + "Server - Recover account with phone number not used", + server_recover_account_with_phone_number_not_used, + "Server"), + TEST_ONE_TAG( + "Server - Link a non existent account with phone number", + server_link_non_existent_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Account created with email", + server_account_created_with_email, + "Server"), + TEST_ONE_TAG( + "Server - Account exist", + server_account_exist, + "Server"), + TEST_ONE_TAG( + "Server - Account already create with email", + server_create_account_already_create_with_email, + "Server"), + TEST_ONE_TAG( + "Server - Account created with phone number", + server_account_created_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Account not activated", + server_account_not_activated, + "Server"), + TEST_ONE_TAG( + "Server - Account already created with phone number as account", + server_create_account_already_create_as_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Phone number is used as account", + server_phone_number_is_used_as_account, + "Server"), + TEST_ONE_TAG( + "Server - Account not link with phone number", + server_account_not_link_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Activate account", + server_activate_account_not_activated, + "Server"), + TEST_ONE_TAG( + "Server - Account already activated", + server_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Server - Activate account already activated", + server_activate_account_already_activated, + "Server"), + TEST_ONE_TAG( + "Server - Link account with phone number", + server_link_account_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Activate phone number for an account", + server_activate_phone_number_for_account, + "Server"), + TEST_ONE_TAG( + "Server - Account already created with phone number as alias", + server_create_account_already_create_as_alias_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Phone number is used as alias", + server_phone_number_is_used_as_alias, + "Server"), + TEST_ONE_TAG( + "Server - Account link with phone number", + server_account_link_with_phone_number, + "Server"), + TEST_ONE_TAG( + "Server - Update account password with wrong password", + server_update_account_password_with_wrong_password, + "Server"), + TEST_ONE_TAG( + "Server - Update account password with correct password", + server_update_account_password_with_correct_password, + "Server"), + TEST_ONE_TAG( + "Server - Recover account with phone number used", + server_recover_account_with_phone_number_used, + "Server"), }; test_suite_t account_creator_test_suite = { diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc index 5946e5b27..443827462 100644 --- a/tester/rcfiles/account_creator_rc +++ b/tester/rcfiles/account_creator_rc @@ -1,11 +1,10 @@ [assistant] domain=sip.accounttest.org -password_max_length=8 +password_max_length=12 password_min_length=3 -username_length=4 username_max_length=14 username_min_length=3 -username_regex=^[a-z0-9_.\-]*$ +username_regex=^[A-Za-z0-9_.\-]*$ xmlrpc_url=https://sip2.linphone.org:446/wizard.php [proxy_default_values] From f23b1d3246130cc21974528424621b557a2ccf1e Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 27 Mar 2017 15:00:28 +0200 Subject: [PATCH 25/32] Fix Account creator JNI --- coreapi/linphonecore_jni.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index f0a5e3ec5..29d95f32e 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -8591,7 +8591,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAccountCreatorImpl_getEmail(JN extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_isAccountUsed(JNIEnv *env, jobject thiz, jlong ptr) { LinphoneAccountCreator *account_creator = (LinphoneAccountCreator *)ptr; - return (jint) linphone_account_creator_is_account_linked(account_creator); + return (jint) linphone_account_creator_is_account_exist(account_creator); } extern "C" jint Java_org_linphone_core_LinphoneAccountCreatorImpl_createAccount(JNIEnv *env, jobject thiz, jlong ptr) { From 09f4e2324e31d4577251499150ad11cf4a6bd55d Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 29 Mar 2017 10:52:56 +0200 Subject: [PATCH 26/32] Use correct macro __ios --> TARGET_OS_IPHONE --- coreapi/linphonecore.c | 4 ++-- coreapi/ringtoneplayer.c | 6 +++++- mediastreamer2 | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 1b7476749..ff8d45b20 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1179,7 +1179,7 @@ static void sound_config_read(LinphoneCore *lc) } lc->sound_conf.latency=0; -#ifndef __ios +#if TARGET_OS_IPHONE tmp=TRUE; #else tmp=FALSE; /* on iOS we have builtin echo cancellation.*/ @@ -1687,7 +1687,7 @@ static void video_config_read(LinphoneCore *lc){ linphone_core_set_preferred_framerate(lc,lp_config_get_float(lc->config,"video","framerate",0)); -#if defined(__ANDROID__) || defined(__ios) +#if defined(__ANDROID__) || TARGET_OS_IPHONE automatic_video=0; #endif capture=lp_config_get_int(lc->config,"video","capture",1); diff --git a/coreapi/ringtoneplayer.c b/coreapi/ringtoneplayer.c index c6921c6f1..d3f7ae58b 100644 --- a/coreapi/ringtoneplayer.c +++ b/coreapi/ringtoneplayer.c @@ -21,11 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "private.h" #include +#if __APPLE__ +#include "TargetConditionals.h" +#endif + int linphone_ringtoneplayer_start(MSFactory *factory, LinphoneRingtonePlayer* rp, MSSndCard* card, const char* ringtone, int loop_pause_ms) { return linphone_ringtoneplayer_start_with_cb(factory, rp, card, ringtone, loop_pause_ms, NULL, NULL); } -#ifdef __ios +#if TARGET_OS_IPHONE #include "ringtoneplayer_ios.h" diff --git a/mediastreamer2 b/mediastreamer2 index b937df188..81dd23b31 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b937df188829f73c3f5db35ff0191aa695f27884 +Subproject commit 81dd23b3125568af5aa4a2973105a1c98a153986 From 0878d89d62a52a71c1da1048e44b626db587b1c4 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 29 Mar 2017 11:40:30 +0200 Subject: [PATCH 27/32] Fix android log handler --- coreapi/linphonecore_jni.cc | 51 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 29d95f32e..2eb94f8e1 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -112,33 +112,34 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreFactoryImpl__1setLogHa } static void linphone_android_ortp_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) { - char str[4096]; - const char *levname = "undef"; - vsnprintf(str, sizeof(str) - 1, fmt, args); - str[sizeof(str) - 1] = '\0'; + char* str = bctbx_strdup_vprintf(fmt, args); + const char *levname = "undef"; - int prio; - switch(lev) { - case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; levname="debug"; break; - case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; levname="message"; break; - case ORTP_WARNING: prio = ANDROID_LOG_WARN; levname="warning"; break; - case ORTP_ERROR: prio = ANDROID_LOG_ERROR; levname="error"; break; - case ORTP_FATAL: prio = ANDROID_LOG_FATAL; levname="fatal"; break; - default: prio = ANDROID_LOG_DEFAULT; break; - } + if (str == NULL) return; - if (handler_obj) { - JNIEnv *env = ms_get_jni_env(); - jstring jdomain = env->NewStringUTF(LogDomain); - jstring jlevname = env->NewStringUTF(levname); - jstring jstr = env->NewStringUTF(str); - env->CallVoidMethod(handler_obj, loghandler_id, jdomain, (jint)lev, jlevname, jstr, NULL); - if (jdomain) env->DeleteLocalRef(jdomain); - if (jlevname) env->DeleteLocalRef(jlevname); - if (jstr) env->DeleteLocalRef(jstr); - } else { - linphone_android_log_handler(prio, str); - } + int prio; + switch(lev) { + case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; levname="debug"; break; + case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; levname="message"; break; + case ORTP_WARNING: prio = ANDROID_LOG_WARN; levname="warning"; break; + case ORTP_ERROR: prio = ANDROID_LOG_ERROR; levname="error"; break; + case ORTP_FATAL: prio = ANDROID_LOG_FATAL; levname="fatal"; break; + default: prio = ANDROID_LOG_DEFAULT; break; + } + + if (handler_obj) { + JNIEnv *env = ms_get_jni_env(); + jstring jdomain = env->NewStringUTF(LogDomain); + jstring jlevname = env->NewStringUTF(levname); + jstring jstr = env->NewStringUTF(str); + env->CallVoidMethod(handler_obj, loghandler_id, jdomain, (jint)lev, jlevname, jstr, NULL); + if (jdomain) env->DeleteLocalRef(jdomain); + if (jlevname) env->DeleteLocalRef(jlevname); + if (jstr) env->DeleteLocalRef(jstr); + } else { + linphone_android_log_handler(prio, str); + } + bctbx_free(str); } int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() { From 39c59be2433078ee47bf54cf9c7e215be641abcc Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 29 Mar 2017 13:17:55 +0200 Subject: [PATCH 28/32] fix linphone-daemon printing of RTCP stats --- daemon/daemon.cc | 40 ++++------------------------------------ oRTP | 2 +- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 757276d29..dc1980e60 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -149,43 +149,11 @@ static ostream &printCallStatsHelper(ostream &ostr, const LinphoneCallStats *sta // ostr << prefix << "MaxJitterTs: " << stats->jitter_stats.max_jitter_ts << "\n"; ostr << prefix << "JitterBufferSizeMs: " << stats->jitter_stats.jitter_buffer_size_ms << "\n"; - const report_block_t *rrb = NULL; - if (stats->received_rtcp != NULL) { - if (stats->received_rtcp->b_cont != NULL) - msgpullup(stats->received_rtcp, -1); - if (rtcp_is_SR(stats->received_rtcp)) { - rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0); - } else if (rtcp_is_RR(stats->received_rtcp)) { - rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0); - } - } - if (rrb) { - unsigned int ij; - float flost; - ij = report_block_get_interarrival_jitter(rrb); - flost = (float) (100.0 * report_block_get_fraction_lost(rrb) / 256.0); - ostr << prefix << "Received-InterarrivalJitter: " << ij << "\n"; - ostr << prefix << "Received-FractionLost: " << flost << "\n"; - } + ostr << prefix << "Received-InterarrivalJitter: " << linphone_call_stats_get_receiver_interarrival_jitter(stats) << "\n"; + ostr << prefix << "Received-FractionLost: " << linphone_call_stats_get_receiver_loss_rate(stats) << "\n"; - const report_block_t *srb = NULL; - if (stats->sent_rtcp != NULL) { - if (stats->sent_rtcp->b_cont != NULL) - msgpullup(stats->sent_rtcp, -1); - if (rtcp_is_SR(stats->sent_rtcp)) { - srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0); - } else if (rtcp_is_RR(stats->sent_rtcp)) { - srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0); - } - } - if (srb) { - unsigned int ij; - float flost; - ij = report_block_get_interarrival_jitter(srb); - flost = (float) (100.0 * report_block_get_fraction_lost(srb) / 256.0); - ostr << prefix << "Sent-InterarrivalJitter: " << ij << "\n"; - ostr << prefix << "Sent-FractionLost: " << flost << "\n"; - } + ostr << prefix << "Sent-InterarrivalJitter: " << linphone_call_stats_get_sender_interarrival_jitter(stats) << "\n"; + ostr << prefix << "Sent-FractionLost: " << linphone_call_stats_get_sender_loss_rate(stats) << "\n"; return ostr; } diff --git a/oRTP b/oRTP index 235e5175b..f9099f6b2 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 235e5175b2befa2d3e5f19cd969b0f3bda5b9b4c +Subproject commit f9099f6b2d8f95c6d4237524e66e47b76c26ecca From 2a4a17bffbf6b4aa68e9839faa0e6eb2f540210c Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 29 Mar 2017 13:23:25 +0200 Subject: [PATCH 29/32] Add account_creator_rc file to CMakelists and makefile --- tester/CMakeLists.txt | 1 + tester/Makefile.am | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index cb3d4c129..e90af0224 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -77,6 +77,7 @@ set(CERTIFICATE_CLIENT_FILES set(CERTIFICATE_FILES ${CERTIFICATE_ALT_FILES} ${CERTIFICATE_CN_FILES} ${CERTIFICATE_CLIENT_FILES}) set(RC_FILES + rcfiles/account_creator_rc rcfiles/carddav_rc rcfiles/conference_focus_rc rcfiles/empty_rc diff --git a/tester/Makefile.am b/tester/Makefile.am index 0b3bc0497..f54380a5c 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -34,7 +34,10 @@ CERTIFICATE_CLIENT_FILES = certificates/client/cert.pem \ CERTIFICATE_FILES = $(CERTIFICATE_ALT_FILES) $(CERTIFICATE_CN_FILES) $(CERTIFICATE_CLIENT_FILES) RCFILES = \ + rcfiles/account_creator_rc\ + rcfiles/carddav_rc\ rcfiles/empty_rc\ + rcfiles/friends_rc\ rcfiles/laure_call_logs_rc\ rcfiles/laure_rc_udp\ rcfiles/marie_early_rc\ @@ -75,8 +78,7 @@ RCFILES = \ rcfiles/stun_rc\ rcfiles/upnp_rc\ rcfiles/zero_length_params_rc\ - rcfiles/friends_rc\ - rcfiles/carddav_rc + IMAGE_FILES = images/linphone.svg images/nowebcamCIF.jpg images/nowebcamVGA.jpg From a36cade0849bfe69d67755b17fe6434cde5e2bf8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 29 Mar 2017 14:22:46 +0200 Subject: [PATCH 30/32] Fix build with Clang on Linux. --- coreapi/account_creator.c | 24 ++++++++++++------------ coreapi/xmlrpc.c | 12 ++++++------ include/linphone/xmlrpc.h | 8 ++++---- tester/account_creator_tester.c | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 7b0e7d85f..5c48e7529 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -661,7 +661,7 @@ LinphoneRequestStatus linphone_account_creator_is_account_exist_custom(LinphoneA return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account", LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); @@ -697,7 +697,7 @@ static LinphoneXmlRpcRequest * _create_account_with_phone_custom(LinphoneAccount if (!creator->phone_number) { return NULL; } - request = linphone_xml_rpc_request_new_with_args("create_phone_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_phone_account", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->password ? ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) : "", @@ -713,7 +713,7 @@ static LinphoneXmlRpcRequest * _create_account_with_email_custom(LinphoneAccount if (!creator->username || !creator->email || !creator->password) { return NULL; } - request = linphone_xml_rpc_request_new_with_args("create_email_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "create_email_account", LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->email, LinphoneXmlRpcArgString, ha1_for_passwd(creator->username ? creator->username : creator->phone_number, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password), @@ -775,14 +775,14 @@ LinphoneRequestStatus linphone_account_creator_activate_account_custom(LinphoneA } if (creator->phone_number) { - request = linphone_xml_rpc_request_new_with_args("activate_phone_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_account", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->activation_code, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); } else { - request = linphone_xml_rpc_request_new_with_args("activate_email_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_email_account", LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, linphone_proxy_config_get_domain(creator->proxy_cfg), @@ -819,7 +819,7 @@ LinphoneRequestStatus linphone_account_creator_is_account_activated_custom(Linph } return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("is_account_activated", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_account_activated", LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); @@ -857,7 +857,7 @@ LinphoneRequestStatus linphone_account_creator_is_phone_number_used_custom(Linph } return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("is_phone_number_used", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "is_phone_number_used", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); @@ -892,7 +892,7 @@ LinphoneRequestStatus linphone_account_creator_link_phone_number_with_account_cu } return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("link_phone_number_with_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "link_phone_number_with_account", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), @@ -924,7 +924,7 @@ LinphoneRequestStatus linphone_account_creator_is_account_linked_custom(Linphone if (!creator->username || !linphone_proxy_config_get_domain(creator->proxy_cfg)) { return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("get_phone_number_for_account",LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_phone_number_for_account", LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgNone); @@ -957,7 +957,7 @@ LinphoneRequestStatus linphone_account_creator_activate_phone_number_link_custom } return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("activate_phone_number_link", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "activate_phone_number_link", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, creator->username, LinphoneXmlRpcArgString, creator->activation_code, @@ -1000,7 +1000,7 @@ LinphoneRequestStatus linphone_account_creator_recover_phone_account_custom(Linp } return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("recover_phone_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "recover_phone_account", LinphoneXmlRpcArgString, creator->phone_number, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), LinphoneXmlRpcArgString, creator->language, @@ -1052,7 +1052,7 @@ LinphoneRequestStatus linphone_account_creator_update_password_custom(LinphoneAc const char * ha1 = ms_strdup(creator->ha1 ? creator->ha1 : ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), creator->password) ); const char * new_ha1 = ms_strdup(ha1_for_passwd(username, linphone_proxy_config_get_domain(creator->proxy_cfg), new_pwd)); - request = linphone_xml_rpc_request_new_with_args("update_hash", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "update_hash", LinphoneXmlRpcArgString, username, LinphoneXmlRpcArgString, ha1, LinphoneXmlRpcArgString, new_ha1, diff --git a/coreapi/xmlrpc.c b/coreapi/xmlrpc.c index e65587d91..c7f8b7ea2 100644 --- a/coreapi/xmlrpc.c +++ b/coreapi/xmlrpc.c @@ -251,7 +251,7 @@ static void process_response_from_post_xml_rpc_request(void *data, const belle_h } -static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) { +static LinphoneXmlRpcRequest * _linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method) { LinphoneXmlRpcRequest *request = belle_sip_object_new(LinphoneXmlRpcRequest); request->callbacks = linphone_xml_rpc_request_cbs_new(); request->status = LinphoneXmlRpcStatusPending; @@ -306,18 +306,18 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneXmlRpcSession, belle_sip_object_t, ); -LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type) { - LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type); +LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method) { + LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(return_type, method); format_request(request); return request; } -LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...) { +LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgType return_type, const char *method, ...) { bool_t cont = TRUE; va_list args; LinphoneXmlRpcArgType arg_type; - LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(method, return_type); - va_start(args, return_type); + LinphoneXmlRpcRequest *request = _linphone_xml_rpc_request_new(return_type, method); + va_start(args, method); while (cont) { arg_type = va_arg(args, LinphoneXmlRpcArgType); switch (arg_type) { diff --git a/include/linphone/xmlrpc.h b/include/linphone/xmlrpc.h index efcf50ed1..706105a3e 100644 --- a/include/linphone/xmlrpc.h +++ b/include/linphone/xmlrpc.h @@ -43,19 +43,19 @@ typedef void (*LinphoneXmlRpcRequestCbsResponseCb)(LinphoneXmlRpcRequest *reques /** * Create a new LinphoneXmlRpcRequest object. - * @param[in] method The XML-RPC method to call. * @param[in] return_type The expected XML-RPC response type. + * @param[in] method The XML-RPC method to call. * @return A new LinphoneXmlRpcRequest object. **/ -LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(const char *method, LinphoneXmlRpcArgType return_type); +LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new(LinphoneXmlRpcArgType return_type, const char *method); /** * Create a new LinphoneXmlRpcRequest object giving the arguments to the method call. - * @param[in] method The XML-RPC method to call. * @param[in] return_type The expected XML-RPC response type. + * @param[in] method The XML-RPC method to call. * @return A new LinphoneXmlRpcRequest object. **/ -LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(const char *method, LinphoneXmlRpcArgType return_type, ...); +LINPHONE_PUBLIC LinphoneXmlRpcRequest * linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgType return_type, const char *method, ...); /** * Acquire a reference to the XML-RPC request. diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 4e1895ee8..233258abc 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -359,7 +359,7 @@ LinphoneRequestStatus get_activation_code_account_cb(LinphoneAccountCreator *cre return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("get_confirmation_key", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "get_confirmation_key", LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->password, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), @@ -397,7 +397,7 @@ LinphoneRequestStatus delete_account_cb(LinphoneAccountCreator *creator) { return LinphoneRequestMissingArguments; } - request = linphone_xml_rpc_request_new_with_args("delete_account", LinphoneXmlRpcArgString, + request = linphone_xml_rpc_request_new_with_args(LinphoneXmlRpcArgString, "delete_account", LinphoneXmlRpcArgString, creator->username ? creator->username : creator->phone_number, LinphoneXmlRpcArgString, creator->password, LinphoneXmlRpcArgString, linphone_proxy_config_get_domain(creator->proxy_cfg), From cc00059dcd4815018c76180c3456962223e0c42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 29 Mar 2017 14:39:03 +0200 Subject: [PATCH 31/32] Prevent LinphoneAccountCreatorResponseCbs and LinphoneAccountCreatorRequestsCbs from wrapping --- include/linphone/account_creator.h | 26 +++++++++++++++++ .../linphone/account_creator_request_engine.h | 29 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h index fe8b5fed7..30f48556f 100644 --- a/include/linphone/account_creator.h +++ b/include/linphone/account_creator.h @@ -300,6 +300,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC const char * linphone_account_creator_get_ro * Get the LinphoneAccountCreatorResponseCbs object associated with a LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object * @return The LinphoneAccountCreatorResponseCbs object associated with the LinphoneAccountCreator. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_get_responses_cbs(const LinphoneAccountCreator *creator); @@ -307,6 +308,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_get * Get the LinphoneAccountCreatorRequestCbs object associated with a LinphoneAccountCreator. * @param[in] creator LinphoneAccountCreator object * @return The LinphoneAccountCreatorRequestCbs object associated with the LinphoneAccountCreator. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestCbs * linphone_account_creator_get_requests_cbs(const LinphoneAccountCreator *creator); @@ -400,12 +402,14 @@ LINPHONE_PUBLIC LinphoneRequestStatus linphone_account_creator_update_password_c * Acquire a reference to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The same LinphoneAccountCreatorResponseCbs object. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseCbs * linphone_account_creator_responses_cbs_ref(LinphoneAccountCreatorResponseCbs *responses_cbs); /** * Release a reference to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_unref(LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -413,6 +417,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_unref(LinphoneAccoun * Retrieve the user pointer associated with a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The user pointer associated with the LinphoneAccountCreatorResponseCbs object. + * @donotwrap **/ LINPHONE_PUBLIC void *linphone_account_creator_responses_cbs_get_user_data(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -420,6 +425,7 @@ LINPHONE_PUBLIC void *linphone_account_creator_responses_cbs_get_user_data(const * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorResponseCbs object. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_user_data(LinphoneAccountCreatorResponseCbs *responses_cbs, void *ud); @@ -427,6 +433,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_user_data(Linpho * Get the create account request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current create account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_create_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -434,6 +441,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The create account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_create_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -441,6 +449,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_create_account_c * Get the is account exist request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current is account exist request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -448,6 +457,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The is account exist request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_exist_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -455,6 +465,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_exist * Get the activate account request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current activate account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -462,6 +473,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The activate account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -469,6 +481,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_account * Get the is account activated request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current is account activated request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -476,6 +489,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The is account activated request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_activated_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -483,6 +497,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_activ * Get the link account request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current link account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_link_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -490,6 +505,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The link account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_link_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -497,6 +513,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_link_account_cb( * Get the activate alias request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current link account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_activate_alias_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -504,6 +521,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The activate alias request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_alias_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -511,6 +529,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_activate_alias_c * Get the is alias used request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current is alias used request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -518,6 +537,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The is alias used request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_alias_used_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -525,6 +545,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_alias_used_cb * Get the is account linked request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current is account linked request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -532,6 +553,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The is account linked request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_linked_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -539,6 +561,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_is_account_linke * Get the recover account request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current recover account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_recover_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -546,6 +569,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The recover account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_recover_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); @@ -553,6 +577,7 @@ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_recover_account_ * Get the update account request. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @return The current update account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_responses_cbs_get_update_account_cb(const LinphoneAccountCreatorResponseCbs *responses_cbs); @@ -560,6 +585,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorResponseFunc linphone_account_creator_resp * Assign a user pointer to a LinphoneAccountCreatorResponseCbs object. * @param[in] responses_cbs LinphoneAccountCreatorResponseCbs object. * @param[in] cb The update account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_responses_cbs_set_update_account_cb(LinphoneAccountCreatorResponseCbs *responses_cbs, LinphoneAccountCreatorResponseFunc cb); diff --git a/include/linphone/account_creator_request_engine.h b/include/linphone/account_creator_request_engine.h index a0f4f7236..3094887d9 100644 --- a/include/linphone/account_creator_request_engine.h +++ b/include/linphone/account_creator_request_engine.h @@ -42,6 +42,7 @@ typedef LinphoneRequestStatus (*LinphoneAccountCreatorRequestFunc)(LinphoneAccou /** * Create a new LinphoneAccountCreatorRequestCbs object. * @return a new LinphoneAccountCreatorRequestCbs object. + * @donotwrap **/ LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(void); @@ -49,12 +50,14 @@ LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_new(voi * Acquire a reference to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The same LinphoneAccountCreatorRequestCbs object. + * @donotwrap **/ LinphoneAccountCreatorRequestCbs * linphone_account_creator_requests_cbs_ref(LinphoneAccountCreatorRequestCbs *requests_cbs); /** * Release a reference to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. + * @donotwrap **/ void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -62,6 +65,7 @@ void linphone_account_creator_requests_cbs_unref(LinphoneAccountCreatorRequestCb * Retrieve the user pointer associated with a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The user pointer associated with the LinphoneAccountCreatorRequestCbs object. + * @donotwrap **/ LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -69,6 +73,7 @@ LINPHONE_PUBLIC void *linphone_account_creator_requests_cbs_get_user_data(const * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] ud The user pointer to associate with the LinphoneAccountCreatorRequestCbs object. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(LinphoneAccountCreatorRequestCbs *requests_cbs, void *ud); @@ -76,6 +81,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_user_data(Linphon * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The constructor of account creator requests. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -83,6 +89,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_constructor_cb(Li * Get the constructor of account creator requests. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current constructor of create account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_constructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -90,6 +97,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The destructor. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -97,6 +105,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_destructor_cb(Lin * Get the destructor of create account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current destructor of create account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_destructor_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -104,6 +113,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Get the create account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current create account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_create_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -111,6 +121,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The create account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -118,6 +129,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_create_account_cb * Get the is account exist request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current is account exist request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_exist_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -125,6 +137,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The is account exist request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -132,6 +145,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_exist_ * Get the activate account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current activate account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -139,6 +153,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The activate account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -146,6 +161,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_account_ * Get the is account activated request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current is account activated request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_activated_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -153,6 +169,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The is account activated request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activated_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -160,6 +177,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_activa * Get the link account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current link account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_link_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -167,6 +185,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The link account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -174,6 +193,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_link_account_cb(L * Get the activate alias request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current link account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_activate_alias_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -181,6 +201,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The activate alias request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -188,6 +209,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_activate_alias_cb * Get the is alias used request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current is alias used request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_alias_used_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -195,6 +217,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The is alias used request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -202,6 +225,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_alias_used_cb( * Get the is account linked request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current is account linked request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_is_account_linked_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -209,6 +233,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The is account linked request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -216,6 +241,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_is_account_linked * Get the recover account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current recover account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_recover_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -223,6 +249,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The recover account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); @@ -230,6 +257,7 @@ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_recover_account_c * Get the update account request. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @return The current update account request. + * @donotwrap **/ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_requests_cbs_get_update_account_cb(const LinphoneAccountCreatorRequestCbs *requests_cbs); @@ -237,6 +265,7 @@ LINPHONE_PUBLIC LinphoneAccountCreatorRequestFunc linphone_account_creator_reque * Assign a user pointer to a LinphoneAccountCreatorRequestCbs object. * @param[in] requests_cbs LinphoneAccountCreatorRequestCbs object. * @param[in] cb The update account request to be used. + * @donotwrap **/ LINPHONE_PUBLIC void linphone_account_creator_requests_cbs_set_update_account_cb(LinphoneAccountCreatorRequestCbs *requests_cbs, LinphoneAccountCreatorRequestFunc cb); From a620881569eecd0938bb4101224b4353d029c788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 29 Mar 2017 15:26:21 +0200 Subject: [PATCH 32/32] C++ wrapper: public structure support improvement --- wrappers/cpp/genwrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wrappers/cpp/genwrapper.py b/wrappers/cpp/genwrapper.py index d8e5d5fde..0fb8cd558 100755 --- a/wrappers/cpp/genwrapper.py +++ b/wrappers/cpp/genwrapper.py @@ -291,7 +291,10 @@ class CppTranslator(object): } cExpr = '(::{cPtrType} *)Object::sharedPtrToCPtr(std::static_pointer_cast<{object},{ptrType}>({cppExpr}))'.format(**param) else: - cExpr = '(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) + if exprtype.isref: + cExpr = '(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) + else: + cExpr = '*(const ::{_type} *)({expr}).c_struct()'.format(_type=cPtrType, expr=cppExpr) elif type(exprtype) is AbsApi.ListType: if type(exprtype.containedTypeDesc) is AbsApi.BaseType and exprtype.containedTypeDesc.name == 'string': cExpr = 'StringBctbxListWrapper({0}).c_list()'.format(cppExpr)