From 5859f72627d3366e54cae39d06b9d709e828abaa Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 20 Apr 2018 15:53:33 +0200 Subject: [PATCH 001/143] fix(core): constexpr variables are implicit const --- src/content/content-manager.cpp | 2 +- src/sip-tools/sip-headers.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index ff341bcf2..6040140b8 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -30,7 +30,7 @@ // ============================================================================= namespace { - constexpr const char MultipartBoundary[] = "---------------------------14737809831466499882746641449"; + constexpr char MultipartBoundary[] = "---------------------------14737809831466499882746641449"; } using namespace std; diff --git a/src/sip-tools/sip-headers.h b/src/sip-tools/sip-headers.h index 969735841..788fec285 100644 --- a/src/sip-tools/sip-headers.h +++ b/src/sip-tools/sip-headers.h @@ -29,13 +29,13 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE namespace PriorityHeader { - constexpr const char HeaderName[] = "Priority"; + constexpr char HeaderName[] = "Priority"; // Values - constexpr const char NonUrgent[] = "non-urgent"; - constexpr const char Urgent[] = "urgent"; - constexpr const char Emergency[] = "emergency"; - constexpr const char Normal[] = "normal"; + constexpr char NonUrgent[] = "non-urgent"; + constexpr char Urgent[] = "urgent"; + constexpr char Emergency[] = "emergency"; + constexpr char Normal[] = "normal"; } LINPHONE_END_NAMESPACE From 6df0a4223b942f860527468afe4c700fe2c67208 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 30 Nov 2017 11:34:34 +0100 Subject: [PATCH 002/143] remove useless include --- coreapi/account_creator.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 4a3f16955..4e7575bc8 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -21,11 +21,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphone/core.h" #include "linphone/lpconfig.h" + #include "c-wrapper/c-wrapper.h" #include "dial-plan/dial-plan.h" -#include -#include + +#include "bctoolbox/crypto.h" +#include "bctoolbox/regex.h" // TODO: From coreapi. Remove me later. #include "private.h" From ac2eccd78b6455925be4f666dac448e4be583860 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 23 Apr 2018 10:53:05 +0200 Subject: [PATCH 003/143] feat(c-wrapper): do not clone on setCppPtrFromC when object is clonable --- src/c-wrapper/api/c-address.cpp | 2 +- src/c-wrapper/api/c-call-params.cpp | 6 ++-- src/c-wrapper/api/c-call.cpp | 54 +++++------------------------ src/c-wrapper/internal/c-tools.h | 15 ++------ 4 files changed, 15 insertions(+), 62 deletions(-) diff --git a/src/c-wrapper/api/c-address.cpp b/src/c-wrapper/api/c-address.cpp index cdff96c75..a07fec135 100644 --- a/src/c-wrapper/api/c-address.cpp +++ b/src/c-wrapper/api/c-address.cpp @@ -37,7 +37,7 @@ LinphoneAddress *linphone_address_new (const char *address) { LinphoneAddress *object = L_INIT(Address); L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr); - delete cppPtr; + return object; } diff --git a/src/c-wrapper/api/c-call-params.cpp b/src/c-wrapper/api/c-call-params.cpp index a937e8fdd..cf614024a 100644 --- a/src/c-wrapper/api/c-call-params.cpp +++ b/src/c-wrapper/api/c-call-params.cpp @@ -511,11 +511,9 @@ void linphone_call_params_unref (LinphoneCallParams *cp) { // ============================================================================= LinphoneCallParams *linphone_call_params_new (LinphoneCore *core) { - LinphoneCallParams *params = _linphone_CallParams_init(); - auto mediaSessionParams = new LinphonePrivate::MediaSessionParams(); - L_SET_CPP_PTR_FROM_C_OBJECT(params, mediaSessionParams); + LinphoneCallParams *params = L_INIT(CallParams); + L_SET_CPP_PTR_FROM_C_OBJECT(params, new LinphonePrivate::MediaSessionParams()); L_GET_CPP_PTR_FROM_C_OBJECT(params)->initDefault(L_GET_CPP_PTR_FROM_C_OBJECT(core)); - delete mediaSessionParams; return params; } diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index 0fa450fa5..c3f05d29a 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -43,12 +43,6 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(Call, bctbx_list_t *callbacks; /* A list of LinphoneCallCbs object */ LinphoneCallCbs *currentCbs; /* The current LinphoneCallCbs object used to call a callback */ char *authenticationTokenCache; - LinphoneCallParams *currentParamsCache; - LinphoneCallParams *paramsCache; - LinphoneCallParams *remoteParamsCache; - LinphoneAddress *diversionAddressCache; - LinphoneAddress *remoteAddressCache; - LinphoneAddress *toAddressCache; mutable char *referToCache; char *remoteContactCache; char *remoteUserAgentCache; @@ -59,28 +53,9 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(Call, LinphoneChatRoom *chat_room; ) -static void _linphone_call_constructor (LinphoneCall *call) { - call->currentParamsCache = linphone_call_params_new_for_wrapper(); - call->paramsCache = linphone_call_params_new_for_wrapper(); - call->remoteParamsCache = linphone_call_params_new_for_wrapper(); - call->diversionAddressCache = linphone_address_new(nullptr); - call->remoteAddressCache = linphone_address_new(nullptr); - call->toAddressCache = linphone_address_new(nullptr); -} +static void _linphone_call_constructor (LinphoneCall *call) {} static void _linphone_call_destructor (LinphoneCall *call) { - if (call->currentParamsCache) - linphone_call_params_unref(call->currentParamsCache); - if (call->paramsCache) - linphone_call_params_unref(call->paramsCache); - if (call->remoteParamsCache) - linphone_call_params_unref(call->remoteParamsCache); - if (call->diversionAddressCache) - linphone_address_unref(call->diversionAddressCache); - if (call->remoteAddressCache) - linphone_address_unref(call->remoteAddressCache); - if (call->toAddressCache) - linphone_address_unref(call->toAddressCache); if (call->referToCache) bctbx_free(call->referToCache); if (call->remoteContactCache) @@ -92,7 +67,6 @@ static void _linphone_call_destructor (LinphoneCall *call) { bctbx_list_free_with_data(call->callbacks, (bctbx_list_free_func)linphone_call_cbs_unref); } - // ============================================================================= // TODO: To remove! // ============================================================================= @@ -231,13 +205,11 @@ bool_t linphone_call_asked_to_autoanswer (LinphoneCall *call) { } const LinphoneAddress *linphone_call_get_remote_address (const LinphoneCall *call) { - L_SET_CPP_PTR_FROM_C_OBJECT(call->remoteAddressCache, &L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddress()); - return call->remoteAddressCache; + return L_GET_C_BACK_PTR(&L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteAddress()); } const LinphoneAddress *linphone_call_get_to_address (const LinphoneCall *call) { - L_SET_CPP_PTR_FROM_C_OBJECT(call->toAddressCache, &L_GET_CPP_PTR_FROM_C_OBJECT(call)->getToAddress()); - return call->toAddressCache; + return L_GET_C_BACK_PTR(&L_GET_CPP_PTR_FROM_C_OBJECT(call)->getToAddress()); } const char *linphone_call_get_to_header (const LinphoneCall *call, const char *name) { @@ -255,11 +227,8 @@ char *linphone_call_get_remote_address_as_string (const LinphoneCall *call) { } const LinphoneAddress *linphone_call_get_diversion_address (const LinphoneCall *call) { - LinphonePrivate::Address diversionAddress(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getDiversionAddress()); - if (!diversionAddress.isValid()) - return nullptr; - L_SET_CPP_PTR_FROM_C_OBJECT(call->diversionAddressCache, &diversionAddress); - return call->diversionAddressCache; + const LinphonePrivate::Address &diversionAddress = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getDiversionAddress(); + return diversionAddress.isValid() ? L_GET_C_BACK_PTR(&diversionAddress) : nullptr; } LinphoneCallDir linphone_call_get_dir (const LinphoneCall *call) { @@ -309,17 +278,13 @@ int linphone_call_get_duration (const LinphoneCall *call) { return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getDuration(); } -const LinphoneCallParams *linphone_call_get_current_params(LinphoneCall *call) { - L_SET_CPP_PTR_FROM_C_OBJECT(call->currentParamsCache, L_GET_CPP_PTR_FROM_C_OBJECT(call)->getCurrentParams()); - return call->currentParamsCache; +const LinphoneCallParams *linphone_call_get_current_params (LinphoneCall *call) { + return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getCurrentParams()); } const LinphoneCallParams *linphone_call_get_remote_params(LinphoneCall *call) { const LinphonePrivate::MediaSessionParams *remoteParams = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getRemoteParams(); - if (!remoteParams) - return nullptr; - L_SET_CPP_PTR_FROM_C_OBJECT(call->remoteParamsCache, remoteParams); - return call->remoteParamsCache; + return remoteParams ? L_GET_C_BACK_PTR(remoteParams) : nullptr; } void linphone_call_enable_camera (LinphoneCall *call, bool_t enable) { @@ -645,8 +610,7 @@ void linphone_call_set_params (LinphoneCall *call, const LinphoneCallParams *par } const LinphoneCallParams *linphone_call_get_params (LinphoneCall *call) { - L_SET_CPP_PTR_FROM_C_OBJECT(call->paramsCache, L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams()); - return call->paramsCache; + return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams()); } // ============================================================================= diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 17ec09ff5..776e58f58 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -413,7 +413,7 @@ public: typename CppType = typename CTypeMetaInfo::cppType, typename = typename std::enable_if::value, CppType>::type > - static inline void setCppPtrFromC (CType *cObject, CppType* &&cppObject) { + static inline void setCppPtrFromC (CType *cObject, CppType *cppObject) { CppType **cppObjectAddr = &reinterpret_cast *>(cObject)->cppPtr; if (*cppObjectAddr == cppObject) return; @@ -427,15 +427,6 @@ public: #endif } - template< - typename CType, - typename CppType = typename CTypeMetaInfo::cppType, - typename = typename std::enable_if::value, CppType>::type - > - static inline void setCppPtrFromC (CType *cObject, const CppType *cppObject) { - setCppPtrFromC(cObject, new CppType(*cppObject)); - } - // --------------------------------------------------------------------------- // Get c back ptr resolver helpers. // --------------------------------------------------------------------------- @@ -464,7 +455,7 @@ private: return static_cast(value); RetType *cObject = CppTypeMetaInfo::init(); - setCppPtrFromC(cObject, cppObject); + setCppPtrFromC(cObject, const_cast(cppObject)); return cObject; } @@ -731,7 +722,7 @@ LINPHONE_END_NAMESPACE static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE * object) { \ LinphonePrivate::Wrapper::uninitClonableCppObject(object); \ } \ - static void _linphone_ ## C_TYPE ## _clone(Linphone ## C_TYPE * dest, const Linphone ## C_TYPE * src) { \ + static void _linphone_ ## C_TYPE ## _clone(Linphone ## C_TYPE *dest, const Linphone ## C_TYPE *src) { \ L_ASSERT(src->cppPtr); \ dest->cppPtr = new L_CPP_TYPE_OF_C_TYPE(C_TYPE)(*src->cppPtr); \ } \ From c65fea2420dec54038936d9668131d203cc1971f Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 23 Apr 2018 13:56:26 +0200 Subject: [PATCH 004/143] fix(c-content): use tabs instead spaces --- src/c-wrapper/api/c-content.cpp | 298 ++++++++++++++++---------------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 580c78ca3..4f83fe482 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -37,12 +37,12 @@ using namespace std; L_DECLARE_C_CLONABLE_OBJECT_IMPL(Content, void *cryptoContext; /**< crypto context used to encrypt file for RCS file transfer */ mutable char *name; - mutable char *type; - mutable char *subtype; - mutable char *body; - mutable size_t size; - mutable char *encoding; - mutable char *key; + mutable char *type; + mutable char *subtype; + mutable char *body; + mutable size_t size; + mutable char *encoding; + mutable char *key; ) // ============================================================================= @@ -50,82 +50,82 @@ L_DECLARE_C_CLONABLE_OBJECT_IMPL(Content, // ============================================================================= LinphoneContent * linphone_content_ref(LinphoneContent *content) { - belle_sip_object_ref(content); + belle_sip_object_ref(content); return content; } void linphone_content_unref(LinphoneContent *content) { - belle_sip_object_unref(content); + belle_sip_object_unref(content); } void *linphone_content_get_user_data(const LinphoneContent *content) { - return L_GET_USER_DATA_FROM_C_OBJECT(content); + return L_GET_USER_DATA_FROM_C_OBJECT(content); } void linphone_content_set_user_data(LinphoneContent *content, void *ud) { - return L_SET_USER_DATA_FROM_C_OBJECT(content, ud); + return L_SET_USER_DATA_FROM_C_OBJECT(content, ud); } // ============================================================================= const char * linphone_content_get_type(const LinphoneContent *content) { - if (content->type) ms_free(content->type); - content->type = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType())); - return content->type; + if (content->type) ms_free(content->type); + content->type = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType())); + return content->type; } void linphone_content_set_type(LinphoneContent *content, const char *type) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.setType(L_C_TO_STRING(type)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); + LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + ct.setType(L_C_TO_STRING(type)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); } const char * linphone_content_get_subtype(const LinphoneContent *content) { - if (content->subtype) ms_free(content->subtype); - content->subtype = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType())); - return content->subtype; + if (content->subtype) ms_free(content->subtype); + content->subtype = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType())); + return content->subtype; } void linphone_content_set_subtype(LinphoneContent *content, const char *subtype) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.setSubType(L_C_TO_STRING(subtype)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); + LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + ct.setSubType(L_C_TO_STRING(subtype)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); } void linphone_content_add_content_type_parameter(LinphoneContent *content, const char *name, const char *value) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.addParameter(L_C_TO_STRING(name), L_C_TO_STRING(value)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); + LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + ct.addParameter(L_C_TO_STRING(name), L_C_TO_STRING(value)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); } uint8_t * linphone_content_get_buffer(const LinphoneContent *content) { - return (uint8_t *)linphone_content_get_string_buffer(content); + return (uint8_t *)linphone_content_get_string_buffer(content); } void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer, size_t size) { - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBody(buffer, size); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBody(buffer, size); } const char * linphone_content_get_string_buffer(const LinphoneContent *content) { - if (content->body) ms_free(content->body); - content->body = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); - return content->body; + if (content->body) ms_free(content->body); + content->body = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); + return content->body; } void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer) { - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBodyFromUtf8(L_C_TO_STRING(buffer)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBodyFromUtf8(L_C_TO_STRING(buffer)); } size_t linphone_content_get_size(const LinphoneContent *content) { - size_t size = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getSize(); - if (size == 0) { - size = content->size; - } - return size; + size_t size = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getSize(); + if (size == 0) { + size = content->size; + } + return size; } void linphone_content_set_size(LinphoneContent *content, size_t size) { - content->size = size; + content->size = size; } const char * linphone_content_get_encoding(const LinphoneContent *content) { @@ -133,103 +133,103 @@ const char * linphone_content_get_encoding(const LinphoneContent *content) { } void linphone_content_set_encoding(LinphoneContent *content, const char *encoding) { - if (content->encoding) ms_free(content->encoding); - content->encoding = ms_strdup(encoding); + if (content->encoding) ms_free(content->encoding); + content->encoding = ms_strdup(encoding); } const char * linphone_content_get_name(const LinphoneContent *content) { - const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFile()) { - const LinphonePrivate::FileContent *fc = static_cast(c); - if (content->name) ms_free(content->name); - content->name = ms_strdup(L_STRING_TO_C(fc->getFileName())); - } else if (c->isFileTransfer()) { - const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - if (content->name) ms_free(content->name); - content->name = ms_strdup(L_STRING_TO_C(ftc->getFileName())); - } - return content->name; + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + if (c->isFile()) { + const LinphonePrivate::FileContent *fc = static_cast(c); + if (content->name) ms_free(content->name); + content->name = ms_strdup(L_STRING_TO_C(fc->getFileName())); + } else if (c->isFileTransfer()) { + const LinphonePrivate::FileTransferContent *ftc = static_cast(c); + if (content->name) ms_free(content->name); + content->name = ms_strdup(L_STRING_TO_C(ftc->getFileName())); + } + return content->name; } void linphone_content_set_name(LinphoneContent *content, const char *name) { - if (content->name) ms_free(content->name); + if (content->name) ms_free(content->name); - LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFile()) { - LinphonePrivate::FileContent *fc = static_cast(c); - fc->setFileName(L_C_TO_STRING(name)); - } else if (c->isFileTransfer()) { - LinphonePrivate::FileTransferContent *ftc = static_cast(c); - ftc->setFileName(L_C_TO_STRING(name)); - } + LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + if (c->isFile()) { + LinphonePrivate::FileContent *fc = static_cast(c); + fc->setFileName(L_C_TO_STRING(name)); + } else if (c->isFileTransfer()) { + LinphonePrivate::FileTransferContent *ftc = static_cast(c); + ftc->setFileName(L_C_TO_STRING(name)); + } - content->name = ms_strdup(name); + content->name = ms_strdup(name); } bool_t linphone_content_is_multipart(const LinphoneContent *content) { - return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().isMultipart(); + return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().isMultipart(); } LinphoneContent * linphone_content_get_part(const LinphoneContent *content, int idx) { SalBodyHandler *part_body_handler; SalBodyHandler *body_handler = sal_body_handler_from_content(content); - if (!sal_body_handler_is_multipart(body_handler)) { - sal_body_handler_unref(body_handler); - return NULL; - } + if (!sal_body_handler_is_multipart(body_handler)) { + sal_body_handler_unref(body_handler); + return NULL; + } part_body_handler = sal_body_handler_get_part(body_handler, idx); LinphoneContent *result = linphone_content_from_sal_body_handler(part_body_handler); - sal_body_handler_unref(body_handler); - return result; + sal_body_handler_unref(body_handler); + return result; } LinphoneContent * linphone_content_find_part_by_header(const LinphoneContent *content, const char *header_name, const char *header_value) { SalBodyHandler *part_body_handler; SalBodyHandler *body_handler = sal_body_handler_from_content(content); - if (!sal_body_handler_is_multipart(body_handler)) { - sal_body_handler_unref(body_handler); - return NULL; - } + if (!sal_body_handler_is_multipart(body_handler)) { + sal_body_handler_unref(body_handler); + return NULL; + } part_body_handler = sal_body_handler_find_part_by_header(body_handler, header_name, header_value); - LinphoneContent *result = linphone_content_from_sal_body_handler(part_body_handler); - sal_body_handler_unref(body_handler); - return result; + LinphoneContent *result = linphone_content_from_sal_body_handler(part_body_handler); + sal_body_handler_unref(body_handler); + return result; } const char * linphone_content_get_custom_header(const LinphoneContent *content, const char *header_name) { - SalBodyHandler *body_handler = sal_body_handler_from_content(content); - const char *header = sal_body_handler_get_header(body_handler, header_name); - sal_body_handler_unref(body_handler); - return header; + SalBodyHandler *body_handler = sal_body_handler_from_content(content); + const char *header = sal_body_handler_get_header(body_handler, header_name); + sal_body_handler_unref(body_handler); + return header; } const char *linphone_content_get_key(const LinphoneContent *content) { - if (content->key) ms_free(content->key); + if (content->key) ms_free(content->key); - const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFileTransfer()) { - const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - content->key = ms_strdup(ftc->getFileKeyAsString()); - } - - return content->key; + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + if (c->isFileTransfer()) { + const LinphonePrivate::FileTransferContent *ftc = static_cast(c); + content->key = ms_strdup(ftc->getFileKeyAsString()); + } + + return content->key; } size_t linphone_content_get_key_size(const LinphoneContent *content) { - const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFileTransfer()) { - const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - return ftc->getFileKeySize(); - } - return 0; + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + if (c->isFileTransfer()) { + const LinphonePrivate::FileTransferContent *ftc = static_cast(c); + return ftc->getFileKeySize(); + } + return 0; } void linphone_content_set_key(LinphoneContent *content, const char *key, const size_t keyLength) { - LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFileTransfer()) { - LinphonePrivate::FileTransferContent *ftc = static_cast(c); - ftc->setFileKey(key, keyLength); - } + LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + if (c->isFileTransfer()) { + LinphonePrivate::FileTransferContent *ftc = static_cast(c); + ftc->setFileKey(key, keyLength); + } } // ============================================================================= @@ -238,39 +238,39 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s static LinphoneContent * linphone_content_new_with_body_handler(SalBodyHandler *body_handler) { LinphoneContent *content = L_INIT(Content); - content->cryptoContext = NULL; - LinphonePrivate::Content *c = new LinphonePrivate::Content(); - L_SET_CPP_PTR_FROM_C_OBJECT(content, c); + content->cryptoContext = NULL; + LinphonePrivate::Content *c = new LinphonePrivate::Content(); + L_SET_CPP_PTR_FROM_C_OBJECT(content, c); - if (body_handler != NULL) { - linphone_content_set_type(content, sal_body_handler_get_type(body_handler)); - linphone_content_set_subtype(content, sal_body_handler_get_subtype(body_handler)); - for (const belle_sip_list_t *params = sal_body_handler_get_content_type_parameters_names(body_handler); params; params = params->next) { - const char *paramName = (const char *)(params->data); - const char *paramValue = sal_body_handler_get_content_type_parameter(body_handler, paramName); - linphone_content_add_content_type_parameter(content, paramName, paramValue); - } + if (body_handler != NULL) { + linphone_content_set_type(content, sal_body_handler_get_type(body_handler)); + linphone_content_set_subtype(content, sal_body_handler_get_subtype(body_handler)); + for (const belle_sip_list_t *params = sal_body_handler_get_content_type_parameters_names(body_handler); params; params = params->next) { + const char *paramName = (const char *)(params->data); + const char *paramValue = sal_body_handler_get_content_type_parameter(body_handler, paramName); + linphone_content_add_content_type_parameter(content, paramName, paramValue); + } - if (!linphone_content_is_multipart(content)) { - linphone_content_set_string_buffer(content, (char *)sal_body_handler_get_data(body_handler)); - } else { - belle_sip_multipart_body_handler_t *mpbh = BELLE_SIP_MULTIPART_BODY_HANDLER(body_handler); - char *body = belle_sip_object_to_string(mpbh); - linphone_content_set_string_buffer(content, body); - belle_sip_free(body); - } - - belle_sip_list_t *headers = (belle_sip_list_t *)sal_body_handler_get_headers(body_handler); - while (headers) { - belle_sip_header_t *cHeader = BELLE_SIP_HEADER(headers->data); - LinphonePrivate::Header header = LinphonePrivate::Header(belle_sip_header_get_name(cHeader), belle_sip_header_get_unparsed_value(cHeader)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->addHeader(header); - headers = headers->next; - } - if (sal_body_handler_get_encoding(body_handler)) linphone_content_set_encoding(content, sal_body_handler_get_encoding(body_handler)); + if (!linphone_content_is_multipart(content)) { + linphone_content_set_string_buffer(content, (char *)sal_body_handler_get_data(body_handler)); + } else { + belle_sip_multipart_body_handler_t *mpbh = BELLE_SIP_MULTIPART_BODY_HANDLER(body_handler); + char *body = belle_sip_object_to_string(mpbh); + linphone_content_set_string_buffer(content, body); + belle_sip_free(body); + } + + belle_sip_list_t *headers = (belle_sip_list_t *)sal_body_handler_get_headers(body_handler); + while (headers) { + belle_sip_header_t *cHeader = BELLE_SIP_HEADER(headers->data); + LinphonePrivate::Header header = LinphonePrivate::Header(belle_sip_header_get_name(cHeader), belle_sip_header_get_unparsed_value(cHeader)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->addHeader(header); + headers = headers->next; + } + if (sal_body_handler_get_encoding(body_handler)) linphone_content_set_encoding(content, sal_body_handler_get_encoding(body_handler)); } - return content; + return content; } LinphoneContent * linphone_content_new(void) { @@ -300,32 +300,32 @@ LinphoneContent * linphone_content_from_sal_body_handler(SalBodyHandler *body_ha SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content) { if (content == NULL) return NULL; - SalBodyHandler *body_handler; - LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + SalBodyHandler *body_handler; + LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - if (contentType.isMultipart()) { - size_t size = linphone_content_get_size(content); - char *buffer = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); - const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue()); - belle_sip_multipart_body_handler_t *bh = belle_sip_multipart_body_handler_new_from_buffer(buffer, size, boundary); - body_handler = (SalBodyHandler *)BELLE_SIP_BODY_HANDLER(bh); - } else { - body_handler = sal_body_handler_new(); - sal_body_handler_set_data(body_handler, belle_sip_strdup(linphone_content_get_string_buffer(content))); - } + if (contentType.isMultipart()) { + size_t size = linphone_content_get_size(content); + char *buffer = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); + const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue()); + belle_sip_multipart_body_handler_t *bh = belle_sip_multipart_body_handler_new_from_buffer(buffer, size, boundary); + body_handler = (SalBodyHandler *)BELLE_SIP_BODY_HANDLER(bh); + } else { + body_handler = sal_body_handler_new(); + sal_body_handler_set_data(body_handler, belle_sip_strdup(linphone_content_get_string_buffer(content))); + } - for (const auto &header : L_GET_CPP_PTR_FROM_C_OBJECT(content)->getHeaders()) { - belle_sip_header_t *additionalHeader = belle_sip_header_parse(header.asString().c_str()); - belle_sip_body_handler_add_header(BELLE_SIP_BODY_HANDLER(body_handler), additionalHeader); - } + for (const auto &header : L_GET_CPP_PTR_FROM_C_OBJECT(content)->getHeaders()) { + belle_sip_header_t *additionalHeader = belle_sip_header_parse(header.asString().c_str()); + belle_sip_body_handler_add_header(BELLE_SIP_BODY_HANDLER(body_handler), additionalHeader); + } - sal_body_handler_set_type(body_handler, contentType.getType().c_str()); - sal_body_handler_set_subtype(body_handler, contentType.getSubType().c_str()); - sal_body_handler_set_size(body_handler, linphone_content_get_size(content)); - for (const auto ¶m : contentType.getParameters()) { - sal_body_handler_set_content_type_parameter(body_handler, param.getName().c_str(), param.getValue().c_str()); - } - if (content->encoding) sal_body_handler_set_encoding(body_handler, linphone_content_get_encoding(content)); + sal_body_handler_set_type(body_handler, contentType.getType().c_str()); + sal_body_handler_set_subtype(body_handler, contentType.getSubType().c_str()); + sal_body_handler_set_size(body_handler, linphone_content_get_size(content)); + for (const auto ¶m : contentType.getParameters()) { + sal_body_handler_set_content_type_parameter(body_handler, param.getName().c_str(), param.getValue().c_str()); + } + if (content->encoding) sal_body_handler_set_encoding(body_handler, linphone_content_get_encoding(content)); return body_handler; } From d2a68f458096f59828eee646188292cbb6d87f45 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 23 Apr 2018 14:35:06 +0200 Subject: [PATCH 005/143] feat(c-tools): add one owner on clonable object --- src/c-wrapper/api/c-content.cpp | 3 ++- src/c-wrapper/internal/c-tools.h | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 4f83fe482..1071b5eb1 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -55,7 +55,8 @@ LinphoneContent * linphone_content_ref(LinphoneContent *content) { } void linphone_content_unref(LinphoneContent *content) { - belle_sip_object_unref(content); + // FIXME: Avoid leaks. + // belle_sip_object_unref(content); } void *linphone_content_get_user_data(const LinphoneContent *content) { diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 776e58f58..4cbea191b 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -140,6 +140,9 @@ private: struct WrappedClonableObject { belle_sip_object_t base; CppType *cppPtr; + + // By default: External. + WrappedObjectOwner owner; }; // --------------------------------------------------------------------------- @@ -236,7 +239,7 @@ public: : wrappedObject->cppPtr; if (cppObject) - cppObject->setCBackPtr(nullptr); \ + cppObject->setCBackPtr(nullptr); wrappedObject->cppPtr.~shared_ptr(); wrappedObject->weakCppPtr.~weak_ptr(); @@ -248,7 +251,9 @@ public: typename = typename std::enable_if::value, CppType>::type > static void uninitClonableCppObject (CType *cObject) { - delete reinterpret_cast *>(cObject)->cppPtr; + WrappedClonableObject *wrappedObject = reinterpret_cast *>(cObject); + if (wrappedObject->owner == WrappedObjectOwner::External) + delete wrappedObject->cppPtr; } // --------------------------------------------------------------------------- @@ -417,7 +422,9 @@ public: CppType **cppObjectAddr = &reinterpret_cast *>(cObject)->cppPtr; if (*cppObjectAddr == cppObject) return; - delete *cppObjectAddr; + + if (reinterpret_cast *>(cObject)->owner == WrappedObjectOwner::External) + delete *cppObjectAddr; *cppObjectAddr = cppObject; (*cppObjectAddr)->setCBackPtr(cObject); @@ -455,6 +462,7 @@ private: return static_cast(value); RetType *cObject = CppTypeMetaInfo::init(); + reinterpret_cast *>(cObject)->owner = WrappedObjectOwner::Internal; setCppPtrFromC(cObject, const_cast(cppObject)); return cObject; @@ -491,7 +499,6 @@ public: RetType *cObject = CppTypeMetaInfo::init(); reinterpret_cast *>(cObject)->owner = WrappedObjectOwner::Internal; - setCppPtrFromC(cObject, cppObject); return cObject; @@ -713,6 +720,7 @@ LINPHONE_END_NAMESPACE struct _Linphone ## C_TYPE { \ belle_sip_object_t base; \ L_CPP_TYPE_OF_C_TYPE(C_TYPE) *cppPtr; \ + int owner; \ __VA_ARGS__ \ }; \ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \ From 56a25645a84bc5ce54b54c0b102e255965b1d412 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 23 Apr 2018 16:38:19 +0200 Subject: [PATCH 006/143] fix(c-tools): clone objects in getResolvedCListFromCppList --- src/c-wrapper/internal/c-tools.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 4cbea191b..96bfb4edf 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -559,8 +559,11 @@ public: > static inline bctbx_list_t *getResolvedCListFromCppList (const std::list &cppList) { bctbx_list_t *result = nullptr; - for (const auto &value : cppList) - result = bctbx_list_append(result, getCBackPtr(&value)); + for (const auto &value : cppList) { + auto cValue = getCBackPtr(new CppType(value)); + reinterpret_cast *>(cValue)->owner = WrappedObjectOwner::External; + result = bctbx_list_append(result, cValue); + } return result; } From 8f014cb061701037b967a6e48691663c88762dd7 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 23 Apr 2018 17:01:09 +0200 Subject: [PATCH 007/143] Fixed issues with LIME v1 --- coreapi/lime.c | 2 + src/c-wrapper/api/c-content.cpp | 21 +++-- .../file-transfer-chat-message-modifier.cpp | 88 ++++++++++++++----- .../file-transfer-chat-message-modifier.h | 2 +- 4 files changed, 83 insertions(+), 30 deletions(-) diff --git a/coreapi/lime.c b/coreapi/lime.c index cdf697b95..861830d3d 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -917,8 +917,10 @@ int lime_im_encryption_engine_process_downloading_file_cb(LinphoneImEncryptionEn int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer) { LinphoneContent *content = linphone_chat_message_get_file_transfer_information(msg); + if (!content) return -1; + if (!linphone_content_get_key(content)) { linphone_content_unref(content); return -1; diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 1071b5eb1..b4af8dd30 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -118,11 +118,22 @@ void linphone_content_set_string_buffer(LinphoneContent *content, const char *bu } size_t linphone_content_get_size(const LinphoneContent *content) { - size_t size = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getSize(); - if (size == 0) { - size = content->size; - } - return size; + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + size_t size = 0; + if (c->isFile()) { + const LinphonePrivate::FileContent *fc = static_cast(c); + size = fc->getFileSize(); + } else if (c->isFileTransfer()) { + const LinphonePrivate::FileTransferContent *fc = static_cast(c); + size = fc->getFileSize(); + } + if (size == 0) { + size = c->getSize(); + } + if (size == 0) { + size = content->size; + } + return size; } void linphone_content_set_size(LinphoneContent *content, size_t size) { diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index 6bebbfa0b..e6b7b184a 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -253,12 +253,25 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h is_file_encryption_enabled = is_encryption_enabled_for_file_transfer_cb(imee, L_GET_C_BACK_PTR(message->getChatRoom())); } } + + FileTransferContent *fileTransferContent = new FileTransferContent(); + fileTransferContent->setContentType(ContentType::FileTransfer); + fileTransferContent->setFileSize(currentFileContentToTransfer->getFileSize()); // Copy file size information + message->getPrivate()->addContent(fileTransferContent); + // shall we encrypt the file if (is_file_encryption_enabled && message->getChatRoom()) { // temporary storage for the Content-disposition header value : use a generic filename to not leak it // Actual filename stored in msg->file_transfer_information->name will be set in encrypted msg // sended to the first_part_header = "form-data; name=\"File\"; filename=\"filename.txt\""; + + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb generate_file_transfer_key_cb = + linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(imee_cbs); + if (generate_file_transfer_key_cb) { + generate_file_transfer_key_cb(imee, L_GET_C_BACK_PTR(message->getChatRoom()), L_GET_C_BACK_PTR(message)); + } } else { // temporary storage for the Content-disposition header value first_part_header = "form-data; name=\"File\"; filename=\"" + currentFileContentToTransfer->getFileName() + "\""; @@ -273,6 +286,8 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h // No need to add again the callback for progression, otherwise it will be called twice first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(currentFileContentToTransfer->getFilePath().c_str(), nullptr, this); belle_sip_file_body_handler_set_user_body_handler((belle_sip_file_body_handler_t *)first_part_bh, body_handler); + // Ensure the file size has been set to the correct value + fileTransferContent->setFileSize(belle_sip_file_body_handler_get_file_size((belle_sip_file_body_handler_t *)first_part_bh)); } else if (!currentFileContentToTransfer->isEmpty()) { first_part_bh = (belle_sip_body_handler_t *)belle_sip_memory_body_handler_new_from_buffer( ms_strdup(currentFileContentToTransfer->getBodyAsString().c_str()), @@ -294,30 +309,16 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h uploadFile(); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(httpRequest), BELLE_SIP_BODY_HANDLER(bh)); } else if (code == 200) { // file has been uploaded correctly, get server reply and send it + FileTransferContent *fileTransferContent = nullptr; + for (Content *c : message->getPrivate()->getContents()) { + if (c->isFileTransfer()) { + fileTransferContent = static_cast(c); + break; + } + } + const char *body = belle_sip_message_get_body((belle_sip_message_t *)event->response); if (body && strlen(body) > 0) { - FileTransferContent *fileTransferContent = new FileTransferContent(); - fileTransferContent->setContentType(ContentType::FileTransfer); - - LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(message->getCore()->getCCore()); - bool_t is_file_encryption_enabled = FALSE; - if (imee && message->getChatRoom()) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer_cb = - linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(imee_cbs); - if (is_encryption_enabled_for_file_transfer_cb) { - is_file_encryption_enabled = is_encryption_enabled_for_file_transfer_cb(imee, L_GET_C_BACK_PTR(message->getChatRoom())); - } - } - if (is_file_encryption_enabled && message->getChatRoom()) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb generate_file_transfer_key_cb = - linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(imee_cbs); - if (generate_file_transfer_key_cb) { - generate_file_transfer_key_cb(imee, L_GET_C_BACK_PTR(message->getChatRoom()), L_GET_C_BACK_PTR(message)); - } - } - // if we have an encryption key for the file, we must insert it into the msg and restore the correct filename const char *content_key = fileTransferContent->getFileKeyAsString(); size_t content_key_size = fileTransferContent->getFileKey().size(); @@ -381,7 +382,6 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h fileTransferContent->setFileContent(fileContent); message->getPrivate()->removeContent(fileContent); - message->getPrivate()->addContent(fileTransferContent); message->getPrivate()->setState(ChatMessage::State::FileTransferDone); releaseHttpRequest(); @@ -389,17 +389,44 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h fileUploadEndBackgroundTask(); } else { lWarning() << "Received empty response from server, file transfer failed"; + FileTransferContent *fileTransferContent = nullptr; + for (Content *c : message->getPrivate()->getContents()) { + if (c->isFileTransfer()) { + fileTransferContent = static_cast(c); + message->getPrivate()->removeContent(fileTransferContent); + delete fileTransferContent; + break; + } + } message->getPrivate()->setState(ChatMessage::State::NotDelivered); releaseHttpRequest(); fileUploadEndBackgroundTask(); } } else if (code == 400) { lWarning() << "Received HTTP code response " << code << " for file transfer, probably meaning file is too large"; + FileTransferContent *fileTransferContent = nullptr; + for (Content *c : message->getPrivate()->getContents()) { + if (c->isFileTransfer()) { + fileTransferContent = static_cast(c); + message->getPrivate()->removeContent(fileTransferContent); + delete fileTransferContent; + break; + } + } message->getPrivate()->setState(ChatMessage::State::FileTransferError); releaseHttpRequest(); fileUploadEndBackgroundTask(); } else { lWarning() << "Unhandled HTTP code response " << code << " for file transfer"; + FileTransferContent *fileTransferContent = nullptr; + for (Content *c : message->getPrivate()->getContents()) { + if (c->isFileTransfer()) { + fileTransferContent = static_cast(c); + message->getPrivate()->removeContent(fileTransferContent); + delete fileTransferContent; + break; + } + } message->getPrivate()->setState(ChatMessage::State::NotDelivered); releaseHttpRequest(); fileUploadEndBackgroundTask(); @@ -539,7 +566,6 @@ static void fillFileTransferContentInformationsFromVndGsmaRcsFtHttpXml(FileTrans fileTransferContent->setFileSize(size); xmlFree(fileSizeString); } - if (!xmlStrcmp(cur->name, (const xmlChar *)"file-name")) { xmlChar *filename = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1); fileTransferContent->setFileName((char *)filename); @@ -548,6 +574,20 @@ static void fillFileTransferContentInformationsFromVndGsmaRcsFtHttpXml(FileTrans if (!xmlStrcmp(cur->name, (const xmlChar *)"data")) { fileUrl = xmlGetProp(cur, (const xmlChar *)"url"); } + if (!xmlStrcmp(cur->name, (const xmlChar *)"file-key")) { + // there is a key in the msg: file has been encrypted + // convert the key from base 64 + xmlChar *keyb64 = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1); + size_t keyLength; + bctbx_base64_decode(NULL, &keyLength, (unsigned char *)keyb64, strlen((const char *)keyb64)); + uint8_t *keyBuffer = (uint8_t *)malloc(keyLength); + // decode the key into local key buffer + bctbx_base64_decode(keyBuffer, &keyLength, (unsigned char *)keyb64, strlen((const char *)keyb64)); + fileTransferContent->setFileKey((const char *)keyBuffer, keyLength); + // duplicate key value into the linphone content private structure + xmlFree(keyb64); + free(keyBuffer); + } cur = cur->next; } diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.h b/src/chat/modifier/file-transfer-chat-message-modifier.h index d6d9af736..4c3647cde 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.h +++ b/src/chat/modifier/file-transfer-chat-message-modifier.h @@ -74,7 +74,7 @@ private: void releaseHttpRequest(); std::weak_ptr chatMessage; - FileContent* currentFileContentToTransfer; + FileContent* currentFileContentToTransfer = nullptr; belle_http_request_t *httpRequest = nullptr; belle_http_request_listener_t *httpListener = nullptr; From 4b54286a72394c44f64bcb2be46c5cae1297b334 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 11:49:06 +0200 Subject: [PATCH 008/143] fix(setup-tester): clean a lot of leaks in Setup --- coreapi/friend.c | 4 +- coreapi/friendlist.c | 1 + coreapi/presence.c | 1 + src/CMakeLists.txt | 1 - .../file-transfer-chat-message-modifier.cpp | 2 +- src/search/magic-search.cpp | 41 ++++++---- src/search/search-result-p.h | 42 ---------- src/search/search-result.cpp | 50 ++++++++---- src/search/search-result.h | 28 +++---- tester/setup_tester.c | 78 ++++++++++--------- 10 files changed, 124 insertions(+), 124 deletions(-) delete mode 100644 src/search/search-result-p.h diff --git a/coreapi/friend.c b/coreapi/friend.c index 9c929e225..b865256db 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1779,11 +1779,13 @@ const char * linphone_friend_phone_number_to_sip_uri(LinphoneFriend *lf, const c if(strcmp(normalized_number, phone_number) != 0) { char *old_uri = ms_strdup_printf("sip:%s@%s;user=phone", phone_number, linphone_proxy_config_get_domain(proxy_config)); bctbx_iterator_t *it = bctbx_map_cchar_find_key(lf->friend_list->friends_map_uri, old_uri); - if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(lf->friend_list->friends_map_uri))){ + bctbx_iterator_t *end = bctbx_map_cchar_end(lf->friend_list->friends_map_uri); + if (!bctbx_iterator_cchar_equals(it, end)){ linphone_friend_unref((LinphoneFriend*)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it))); bctbx_map_cchar_erase(lf->friend_list->friends_map_uri, it); } bctbx_iterator_cchar_delete(it); + bctbx_iterator_cchar_delete(end); ms_free(old_uri); } diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 6f196721e..8712bd455 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -577,6 +577,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList * } iterator = bctbx_list_next(iterator); } + bctbx_list_free(phone_numbers); addresses = linphone_friend_get_addresses(lf); iterator = (bctbx_list_t *)addresses; diff --git a/coreapi/presence.c b/coreapi/presence.c index eea5c8980..d8a78ecde 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -357,6 +357,7 @@ LinphoneStatus linphone_presence_model_set_contact(LinphonePresenceModel *model, service = linphone_presence_service_new(NULL, LinphonePresenceBasicStatusClosed, NULL); if (service == NULL) return -1; linphone_presence_model_add_service(model, service); + linphone_presence_service_unref(service); } return linphone_presence_service_set_contact(service, contact); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e8f3751eb..b94bf46a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,7 +155,6 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES sal/sal.h search/magic-search-p.h search/magic-search.h - search/search-result-p.h search/search-result.h utils/background-task.h utils/payload-type-handler.h diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index e6b7b184a..86f67d02c 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -999,7 +999,7 @@ void FileTransferChatMessageModifier::cancelFileTransfer () { ? L_C_TO_STRING(linphone_core_get_file_transfer_server(message->getCore()->getCCore())) : currentFileContentToTransfer->getFilePath().c_str() ); - + } else { lInfo() << "Warning: http request still running for ORPHAN msg: this is a memory leak"; } diff --git a/src/search/magic-search.cpp b/src/search/magic-search.cpp index 6e8a8fa94..a5333c79a 100644 --- a/src/search/magic-search.cpp +++ b/src/search/magic-search.cpp @@ -191,6 +191,8 @@ list *MagicSearch::beginNewSearch(const string &filter, const stri if (addr) { unsigned int weight = searchInAddress(addr, filter, withDomain); if (weight > getMinWeight()) { + // FIXME: Ugly temporary workaround to solve weak. Remove me later. + linphone_address_ref(const_cast(addr)); resultList->push_back(SearchResult(weight, addr, nullptr)); } } @@ -234,17 +236,21 @@ SearchResult MagicSearch::searchInFriend(const LinphoneFriend *lFriend, const st // PHONE NUMBER bctbx_list_t *begin, *phoneNumbers = linphone_friend_get_phone_numbers(lFriend); begin = phoneNumbers; - while (phoneNumbers != nullptr && phoneNumbers->data != nullptr) { + while (phoneNumbers && phoneNumbers->data) { string number = static_cast(phoneNumbers->data); const LinphonePresenceModel *presence = linphone_friend_get_presence_model_for_uri_or_tel(lFriend, number.c_str()); weight += getWeight(number, filter); - if (presence != nullptr) { - weight += getWeight(linphone_presence_model_get_contact(presence), filter) * 2; + if (presence) { + char *contact = linphone_presence_model_get_contact(presence); + weight += getWeight(contact, filter) * 2; + bctbx_free(contact); } phoneNumbers = phoneNumbers->next; } if (begin) bctbx_list_free(begin); + // FIXME: Ugly temporary workaround to solve weak. Remove me later. + if (lAddress) linphone_address_ref(const_cast(lAddress)); return SearchResult(weight, lAddress, lFriend); } @@ -298,22 +304,29 @@ unsigned int MagicSearch::getWeight(const string &stringWords, const string &fil return (weight != string::npos) ? (unsigned int)(weight) : getMinWeight(); } -bool MagicSearch::checkDomain(const LinphoneFriend *lFriend, const LinphoneAddress *lAddress, const string &withDomain) const { +bool MagicSearch::checkDomain (const LinphoneFriend *lFriend, const LinphoneAddress *lAddress, const string &withDomain) const { bool onlySipUri = !withDomain.empty() && withDomain.compare("*") != 0; - const LinphonePresenceModel *presenceModel = (lFriend) ? linphone_friend_get_presence_model(lFriend) : nullptr; - const char *contactPresence = (presenceModel) ? linphone_presence_model_get_contact(presenceModel) : nullptr; - const LinphoneAddress *addrPresence = (contactPresence) ? - linphone_core_create_address(this->getCore()->getCCore(), contactPresence) : nullptr; + const LinphonePresenceModel *presenceModel = lFriend ? linphone_friend_get_presence_model(lFriend) : nullptr; + char *contactPresence = presenceModel ? linphone_presence_model_get_contact(presenceModel) : nullptr; - return ( + LinphoneAddress *addrPresence = nullptr; + if (contactPresence) { + addrPresence = linphone_core_create_address(this->getCore()->getCCore(), contactPresence); + bctbx_free(contactPresence); + } + + bool soFarSoGood = // If we don't want Sip URI only or Address or Presence model - (!onlySipUri || lAddress != nullptr || presenceModel != nullptr) && + (!onlySipUri || lAddress || presenceModel) && // And If we don't want Sip URI only or Address match or Address presence match (!onlySipUri || - (lAddress != nullptr && withDomain.compare(linphone_address_get_domain(lAddress)) == 0) || - (addrPresence != nullptr && withDomain.compare(linphone_address_get_domain(addrPresence)) == 0) - ) - ); + (lAddress && withDomain.compare(linphone_address_get_domain(lAddress)) == 0) || + (addrPresence && withDomain.compare(linphone_address_get_domain(addrPresence)) == 0) + ); + + if (addrPresence) linphone_address_unref(addrPresence); + + return soFarSoGood; } LINPHONE_END_NAMESPACE diff --git a/src/search/search-result-p.h b/src/search/search-result-p.h deleted file mode 100644 index 07830689a..000000000 --- a/src/search/search-result-p.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * search-result-p.h - * Copyright (C) 2010-2018 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 _L_SEARCH_RESULT_P_H_ -#define _L_SEARCH_RESULT_P_H_ - -#include "search-result.h" -#include "object/clonable-object-p.h" - -#include "linphone/types.h" - -LINPHONE_BEGIN_NAMESPACE - -class SearchResultPrivate : public ClonableObjectPrivate { -private: - const LinphoneFriend *mFriend; - const LinphoneAddress *mAddress; - unsigned int mWeight; - - L_DECLARE_PUBLIC(SearchResult); -}; - -LINPHONE_END_NAMESPACE - -#endif //_L_SEARCH_RESULT_P_H_ - diff --git a/src/search/search-result.cpp b/src/search/search-result.cpp index 2c032e76b..8f5b3a10c 100644 --- a/src/search/search-result.cpp +++ b/src/search/search-result.cpp @@ -17,56 +17,72 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "search-result-p.h" -#include "linphone/utils/utils.h" +#include "linphone/api/c-address.h" -using namespace LinphonePrivate; +#include "object/clonable-object-p.h" +#include "search-result.h" + +// ============================================================================= LINPHONE_BEGIN_NAMESPACE -SearchResult::SearchResult(const unsigned int weight, const LinphoneAddress *a, const LinphoneFriend *f) : ClonableObject(*new SearchResultPrivate) { +class SearchResultPrivate : public ClonableObjectPrivate { +private: + const LinphoneFriend *mFriend; + const LinphoneAddress *mAddress; + unsigned int mWeight; + + L_DECLARE_PUBLIC(SearchResult); +}; + +SearchResult::SearchResult (const unsigned int weight, const LinphoneAddress *a, const LinphoneFriend *f) : ClonableObject(*new SearchResultPrivate) { L_D(); d->mWeight = weight; d->mAddress = a; d->mFriend = f; } -SearchResult::SearchResult(const SearchResult &sr) : ClonableObject(*new SearchResultPrivate) { +SearchResult::SearchResult (const SearchResult &sr) : ClonableObject(*new SearchResultPrivate) { L_D(); d->mWeight = sr.getWeight(); d->mAddress = sr.getAddress(); + if (d->mAddress) linphone_address_ref(const_cast(d->mAddress)); d->mFriend = sr.getFriend(); } -SearchResult::~SearchResult() {}; +SearchResult::~SearchResult () { + L_D(); + // FIXME: Ugly temporary workaround to solve weak. Remove me later. + if (d->mAddress) linphone_address_unref(const_cast(d->mAddress)); +}; -bool SearchResult::operator<(const SearchResult& rsr) const{ - return this->getWeight() < rsr.getWeight(); +bool SearchResult::operator< (const SearchResult &other) const { + return getWeight() < other.getWeight(); } -bool SearchResult::operator>(const SearchResult& rsr) const{ - return this->getWeight() > rsr.getWeight(); +bool SearchResult::operator> (const SearchResult &other) const { + return getWeight() > other.getWeight(); } -bool SearchResult::operator>=(const SearchResult& rsr) const{ - return this->getWeight() >= rsr.getWeight(); +bool SearchResult::operator>= (const SearchResult &other) const { + return getWeight() >= other.getWeight(); } -bool SearchResult::operator=(const SearchResult& rsr) const{ - return this->getWeight() == rsr.getWeight(); +bool SearchResult::operator= (const SearchResult &other) const { + return getWeight() == other.getWeight(); } -const LinphoneFriend* SearchResult::getFriend() const { +const LinphoneFriend *SearchResult::getFriend () const { L_D(); return d->mFriend; } -const LinphoneAddress *SearchResult::getAddress() const { +const LinphoneAddress *SearchResult::getAddress () const { L_D(); return d->mAddress; } -unsigned int SearchResult::getWeight() const { +unsigned int SearchResult::getWeight () const { L_D(); return d->mWeight; } diff --git a/src/search/search-result.h b/src/search/search-result.h index d453a273a..e6aa7b56f 100644 --- a/src/search/search-result.h +++ b/src/search/search-result.h @@ -20,10 +20,12 @@ #ifndef _L_SEARCH_RESULT_H_ #define _L_SEARCH_RESULT_H_ -#include "object/clonable-object.h" #include "linphone/utils/general.h" #include "linphone/types.h" -#include "private.h" + +#include "object/clonable-object.h" + +// ============================================================================= LINPHONE_BEGIN_NAMESPACE @@ -31,30 +33,30 @@ class SearchResultPrivate; class LINPHONE_PUBLIC SearchResult : public ClonableObject { public: - SearchResult() = delete; - SearchResult(const unsigned int weight, const LinphoneAddress *a, const LinphoneFriend *f = nullptr); - SearchResult(const SearchResult &sr); - ~SearchResult(); + // TODO: Use C++ Address! Not LinphoneAddress. + SearchResult (const unsigned int weight, const LinphoneAddress *a, const LinphoneFriend *f = nullptr); + SearchResult (const SearchResult &other); + ~SearchResult (); - bool operator<(const SearchResult& rsr) const; - bool operator>(const SearchResult& rsr) const; - bool operator>=(const SearchResult& rsr) const; - bool operator=(const SearchResult& rsr) const; + bool operator< (const SearchResult &other) const; + bool operator> (const SearchResult &other) const; + bool operator>= (const SearchResult &other) const; + bool operator= (const SearchResult &other) const; /** * @return LinphoneFriend associed **/ - const LinphoneFriend* getFriend() const; + const LinphoneFriend *getFriend() const; /** * @return LinphoneAddress associed **/ - const LinphoneAddress* getAddress() const; + const LinphoneAddress *getAddress () const; /** * @return the result weight **/ - unsigned int getWeight() const; + unsigned int getWeight () const; private: L_DECLARE_PRIVATE(SearchResult); diff --git a/tester/setup_tester.c b/tester/setup_tester.c index b10705004..8a2e2ebcc 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -54,7 +54,10 @@ static void _remove_friends_from_list(LinphoneFriendList *list, const char *frie unsigned int i; for (i = 0 ; i < size ; i++) { LinphoneFriend *fr = linphone_friend_list_find_friend_by_uri(list, friends[i]); - if (fr) linphone_friend_list_remove_friend(list, fr); + if (fr) { + linphone_friend_list_remove_friend(list, fr); + linphone_friend_unref(fr); + } } } @@ -91,9 +94,10 @@ static void _check_friend_result_list(LinphoneCore *lc, const bctbx_list_t *resu if (addr) { char *addrUri = linphone_address_as_string_uri_only(addr); if (addrUri && strcmp(addrUri, uri) == 0) { + bctbx_free(addrUri); return; } - if (addrUri) free(addrUri); + if (addrUri) bctbx_free(addrUri); } } } @@ -102,7 +106,9 @@ static void _check_friend_result_list(LinphoneCore *lc, const bctbx_list_t *resu } static void _create_call_log(LinphoneCore *lc, LinphoneAddress *addrFrom, LinphoneAddress *addrTo) { - linphone_core_create_call_log(lc, addrFrom, addrTo, LinphoneCallOutgoing, 100, time(NULL), time(NULL), LinphoneCallSuccess, FALSE, 1.0); + linphone_call_log_unref( + linphone_core_create_call_log(lc, addrFrom, addrTo, LinphoneCallOutgoing, 100, time(NULL), time(NULL), LinphoneCallSuccess, FALSE, 1.0) + ); } static void linphone_version_test(void){ @@ -492,7 +498,7 @@ static void search_friend_all_domains(void) { _check_friend_result_list(manager->lc, resultList, 0, sFriends[2], NULL);//"sip:allo@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, sFriends[3], NULL);//"sip:hello@sip.example.org" _check_friend_result_list(manager->lc, resultList, 2, sFriends[4], NULL);//"sip:hello@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -517,7 +523,7 @@ static void search_friend_one_domain(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, sFriends[2], NULL);//"sip:allo@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, sFriends[3], NULL);//"sip:hello@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -547,7 +553,7 @@ static void search_friend_research_estate(void) { _check_friend_result_list(manager->lc, resultList, 4, sFriends[2], NULL);//"sip:allo@sip.example.org" _check_friend_result_list(manager->lc, resultList, 5, sFriends[3], NULL);//"sip:hello@sip.example.org" _check_friend_result_list(manager->lc, resultList, 6, sFriends[4], NULL);//"sip:hello@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } resultList = linphone_magic_search_get_contact_list_from_filter(magicSearch, "la", ""); @@ -556,7 +562,7 @@ static void search_friend_research_estate(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, sFriends[8], NULL);//"sip:laure@sip.test.org" _check_friend_result_list(manager->lc, resultList, 1, sFriends[6], NULL);//"sip:laura@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -581,7 +587,7 @@ static void search_friend_research_estate_reset(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, sFriends[6], NULL);//"sip:laura@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, sFriends[8], NULL);//"sip:laure@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } linphone_magic_search_reset_search_cache(magicSearch); @@ -597,7 +603,7 @@ static void search_friend_research_estate_reset(void) { _check_friend_result_list(manager->lc, resultList, 4, sFriends[2], NULL);//"sip:allo@sip.example.org" _check_friend_result_list(manager->lc, resultList, 5, sFriends[3], NULL);//"sip:hello@sip.example.org" _check_friend_result_list(manager->lc, resultList, 6, sFriends[4], NULL);//"sip:hello@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -626,7 +632,7 @@ static void search_friend_with_phone_number(void) { _check_friend_result_list(manager->lc, resultList, 0, sFriends[11], NULL);//"sip:+111223344@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, sFriends[10], NULL);//"sip:+33655667788@sip.example.org" _check_friend_result_list(manager->lc, resultList, 2, sFriends[5], NULL);//"sip:marie@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -640,8 +646,8 @@ static void search_friend_with_presence(void) { bctbx_list_t *resultList = NULL; LinphoneCoreManager* manager = linphone_core_manager_create("marie_rc"); LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc); - const char* chloeSipUri = {"sip:chloe@sip.example.org"}; - const char* chloePhoneNumber = {"0633556644"}; + const char *chloeSipUri = "sip:chloe@sip.example.org"; + const char *chloePhoneNumber = "0633556644"; LinphoneFriend *chloeFriend = linphone_core_create_friend(manager->lc); LinphonePresenceModel *chloePresence = linphone_core_create_presence_model(manager->lc); LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(manager->lc); @@ -667,7 +673,7 @@ static void search_friend_with_presence(void) { _check_friend_result_list(manager->lc, resultList, 0, sFriends[11], NULL);//"sip:+111223344@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, chloeSipUri, chloePhoneNumber);//"sip:chloe@sip.example.org" _check_friend_result_list(manager->lc, resultList, 2, sFriends[10], NULL);//"sip:+33655667788@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } linphone_magic_search_reset_search_cache(magicSearch); @@ -678,15 +684,15 @@ static void search_friend_with_presence(void) { // 1 + last address from filter "sip:chloe@sip.example.org" BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, chloeSipUri, chloePhoneNumber);//"sip:chloe@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); - { - LinphoneFriend *fr = linphone_friend_list_find_friend_by_uri(lfl, chloeSipUri); - if (fr != NULL) linphone_friend_list_remove_friend(lfl, fr); - if (chloeFriend) linphone_friend_unref(chloeFriend); - } + + LinphoneFriend *fr = linphone_friend_list_find_friend_by_uri(lfl, chloeSipUri); + linphone_friend_list_remove_friend(lfl, fr); + + if (chloeFriend) linphone_friend_unref(chloeFriend); linphone_magic_search_unref(magicSearch); linphone_core_manager_destroy(manager); @@ -722,7 +728,7 @@ static void search_friend_in_call_log(void) { _check_friend_result_list(manager->lc, resultList, 1, sFriends[1], NULL);//"sip:charette@sip.example.org" _check_friend_result_list(manager->lc, resultList, 2, chloeSipUri, NULL);//"sip:chloe@sip.example.org" _check_friend_result_list(manager->lc, resultList, 3, charlesSipUri, NULL);//"sip:charles@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } linphone_magic_search_reset_search_cache(magicSearch); @@ -733,7 +739,7 @@ static void search_friend_in_call_log(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, sFriends[0], NULL);//"sip:charu@sip.test.org" _check_friend_result_list(manager->lc, resultList, 1, charlesSipUri, NULL);//"sip:charles@sip.test.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -768,9 +774,11 @@ static void search_friend_last_item_is_filter(void) { BC_ASSERT_STRING_EQUAL(linphone_address_get_username(srAddress), "newaddress"); } } - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } + _remove_friends_from_list(lfl, sFriends, sSizeFriend); + linphone_magic_search_unref(magicSearch); linphone_core_manager_destroy(manager); } @@ -811,7 +819,7 @@ static void search_friend_with_name(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, stephanie1SipUri, NULL);//"sip:toto@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, stephanie2SipUri, NULL);//"sip:stephanie@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } linphone_magic_search_reset_search_cache(magicSearch); @@ -822,7 +830,7 @@ static void search_friend_with_name(void) { BC_ASSERT_EQUAL(bctbx_list_size(resultList), 2, int, "%d"); _check_friend_result_list(manager->lc, resultList, 0, stephanie2SipUri, NULL);//"sip:stephanie@sip.example.org" _check_friend_result_list(manager->lc, resultList, 1, stephanie1SipUri, NULL);//"sip:toto@sip.example.org" - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } _remove_friends_from_list(lfl, sFriends, sSizeFriend); @@ -862,7 +870,7 @@ static void search_friend_large_database(void) { if (BC_ASSERT_PTR_NOT_NULL(resultList)) ms_message("List size: %zu", bctbx_list_size(resultList)); - bctbx_list_free(resultList); + bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } } @@ -888,16 +896,16 @@ test_t setup_tests[] = { TEST_NO_TAG("Codec usability", codec_usability_test), TEST_NO_TAG("Codec setup", codec_setup), TEST_NO_TAG("Custom tones setup", custom_tones_setup), - TEST_TWO_TAGS("Search friend from all domains", search_friend_all_domains, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend from one domain", search_friend_one_domain, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Multiple looking for friends with the same cache", search_friend_research_estate, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Multiple looking for friends with cache resetting", search_friend_research_estate_reset, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend with phone number", search_friend_with_phone_number, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend and find it with its presence", search_friend_with_presence, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend in call log", search_friend_in_call_log, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend last item is the filter", search_friend_last_item_is_filter, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend with name", search_friend_with_name, "MagicSearch", "LeaksMemory"), - TEST_TWO_TAGS("Search friend in large friends database", search_friend_large_database, "MagicSearch", "LeaksMemory") + TEST_ONE_TAG("Search friend from all domains", search_friend_all_domains, "MagicSearch"), + TEST_ONE_TAG("Search friend from one domain", search_friend_one_domain, "MagicSearch"), + TEST_ONE_TAG("Multiple looking for friends with the same cache", search_friend_research_estate, "MagicSearch"), + TEST_ONE_TAG("Multiple looking for friends with cache resetting", search_friend_research_estate_reset, "MagicSearch"), + TEST_ONE_TAG("Search friend with phone number", search_friend_with_phone_number, "MagicSearch"), + TEST_ONE_TAG("Search friend and find it with its presence", search_friend_with_presence, "MagicSearch"), + TEST_ONE_TAG("Search friend in call log", search_friend_in_call_log, "MagicSearch"), + TEST_ONE_TAG("Search friend last item is the filter", search_friend_last_item_is_filter, "MagicSearch"), + TEST_ONE_TAG("Search friend with name", search_friend_with_name, "MagicSearch"), + TEST_ONE_TAG("Search friend in large friends database", search_friend_large_database, "MagicSearch") }; test_suite_t setup_test_suite = {"Setup", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From 80e29dd7e6facb2d92114b7eac32908b783e57a1 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 14:52:35 +0200 Subject: [PATCH 009/143] fix(c-content): avoid many memory leaks --- coreapi/lime.c | 62 +++++++++---------- src/c-wrapper/api/c-content.cpp | 37 ++++++----- .../file-transfer-chat-message-modifier.cpp | 6 +- src/content/content-manager.cpp | 4 -- tester/message_tester.c | 24 ++++--- tester/multipart-tester.cpp | 1 - 6 files changed, 58 insertions(+), 76 deletions(-) diff --git a/coreapi/lime.c b/coreapi/lime.c index 861830d3d..d0c07cd89 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -317,7 +317,7 @@ static int lime_deriveKey(limeKey_t *key) { return LIME_UNABLE_TO_DERIVE_KEY; } - /* Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||0x00000100)*/ + /* Derivation is made derived Key = HMAC_SHA256(Key, 0x0000001||"MessageKey"||0x00||SessionId||SessionIndex||0x00000100)*/ /* total data to be hashed is 55 bytes : 4 + 10 + 1 + 32 + 4 + 4 */ inputData[0] = 0x00; inputData[1] = 0x00; @@ -811,7 +811,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn peerUri = linphone_address_as_string_uri_only(linphone_chat_message_get_from_address(msg)); selfUri = linphone_address_as_string_uri_only(linphone_chat_message_get_to_address(msg)); retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)linphone_chat_message_get_text(msg), selfUri, peerUri, &decrypted_body, &decrypted_content_type, - bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0"))); + bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0"))); ms_free(peerUri); ms_free(selfUri); if (retval != 0) { @@ -848,9 +848,9 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn if (linphone_chat_message_get_content_type(msg)) { if (strcmp(linphone_chat_message_get_content_type(msg), "application/vnd.gsma.rcs-ft-http+xml") == 0) { /* It's a file transfer, content type shall be set to application/cipher.vnd.gsma.rcs-ft-http+xml - TODO: As of january 2017, the content type is now included in the encrypted body, this - application/cipher.vnd.gsma.rcs-ft-http+xml is kept for compatibility with previous versions, - but may be dropped in the future to use xml/cipher instead. */ + TODO: As of january 2017, the content type is now included in the encrypted body, this + application/cipher.vnd.gsma.rcs-ft-http+xml is kept for compatibility with previous versions, + but may be dropped in the future to use xml/cipher instead. */ new_content_type = "application/cipher.vnd.gsma.rcs-ft-http+xml"; } else if (strcmp(linphone_chat_message_get_content_type(msg), "application/im-iscomposing+xml") == 0) { /* We don't encrypt composing messages */ @@ -897,22 +897,20 @@ int lime_im_encryption_engine_process_downloading_file_cb(LinphoneImEncryptionEn LinphoneContent *content = linphone_chat_message_get_file_transfer_information(msg); if (!content) return -1; - - if (!linphone_content_get_key(content)) { - linphone_content_unref(content); + + if (!linphone_content_get_key(content)) return -1; - } - if (!buffer || (size == 0)) { - int result = lime_decryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); - linphone_content_unref(content); - return result; - } + if (!buffer || size == 0) + return lime_decryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); - int result = lime_decryptFile(linphone_content_get_cryptoContext_address(content), - (unsigned char *)linphone_content_get_key(content), size, (char *)decrypted_buffer, (char *)buffer); - linphone_content_unref(content); - return result; + return lime_decryptFile( + linphone_content_get_cryptoContext_address(content), + (unsigned char *)linphone_content_get_key(content), + size, + (char *)decrypted_buffer, + (char *)buffer + ); } int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer) { @@ -921,16 +919,11 @@ int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngi if (!content) return -1; - if (!linphone_content_get_key(content)) { - linphone_content_unref(content); + if (!linphone_content_get_key(content)) return -1; - } - if (!buffer || (*size == 0)) { - int result = lime_encryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); - linphone_content_unref(content); - return result; - } + if (!buffer || *size == 0) + return lime_encryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); size_t file_size = linphone_content_get_size(content); if (file_size == 0) { @@ -939,10 +932,13 @@ int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngi *size -= (*size % 16); } - int result = lime_encryptFile(linphone_content_get_cryptoContext_address(content), - (unsigned char *)linphone_content_get_key(content), *size, (char *)buffer, (char *)encrypted_buffer); - linphone_content_unref(content); - return result; + return lime_encryptFile( + linphone_content_get_cryptoContext_address(content), + (unsigned char *)linphone_content_get_key(content), + *size, + (char *)buffer, + (char *)encrypted_buffer + ); } bool_t lime_im_encryption_engine_is_file_encryption_enabled_cb(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room) { @@ -956,10 +952,8 @@ void lime_im_encryption_engine_generate_file_transfer_key_cb(LinphoneImEncryptio * file_transfer_information->key field of the msg */ sal_get_random_bytes((unsigned char *)keyBuffer, FILE_TRANSFER_KEY_SIZE); LinphoneContent *content = linphone_chat_message_get_file_transfer_information(msg); - if (!content) - return; - linphone_content_set_key(content, keyBuffer, FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */ - linphone_content_unref(content); + if (content) + linphone_content_set_key(content, keyBuffer, FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */ } #else /* HAVE_LIME */ diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index b4af8dd30..0d92a6243 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -55,8 +55,7 @@ LinphoneContent * linphone_content_ref(LinphoneContent *content) { } void linphone_content_unref(LinphoneContent *content) { - // FIXME: Avoid leaks. - // belle_sip_object_unref(content); + belle_sip_object_unref(content); } void *linphone_content_get_user_data(const LinphoneContent *content) { @@ -70,8 +69,8 @@ void linphone_content_set_user_data(LinphoneContent *content, void *ud) { // ============================================================================= const char * linphone_content_get_type(const LinphoneContent *content) { - if (content->type) ms_free(content->type); - content->type = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType())); + if (content->type) bctbx_free(content->type); + content->type = bctbx_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType())); return content->type; } @@ -82,8 +81,8 @@ void linphone_content_set_type(LinphoneContent *content, const char *type) { } const char * linphone_content_get_subtype(const LinphoneContent *content) { - if (content->subtype) ms_free(content->subtype); - content->subtype = ms_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType())); + if (content->subtype) bctbx_free(content->subtype); + content->subtype = bctbx_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType())); return content->subtype; } @@ -108,8 +107,8 @@ void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer } const char * linphone_content_get_string_buffer(const LinphoneContent *content) { - if (content->body) ms_free(content->body); - content->body = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); + if (content->body) bctbx_free(content->body); + content->body = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); return content->body; } @@ -145,26 +144,26 @@ const char * linphone_content_get_encoding(const LinphoneContent *content) { } void linphone_content_set_encoding(LinphoneContent *content, const char *encoding) { - if (content->encoding) ms_free(content->encoding); - content->encoding = ms_strdup(encoding); + if (content->encoding) bctbx_free(content->encoding); + content->encoding = bctbx_strdup(encoding); } const char * linphone_content_get_name(const LinphoneContent *content) { const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFile()) { const LinphonePrivate::FileContent *fc = static_cast(c); - if (content->name) ms_free(content->name); - content->name = ms_strdup(L_STRING_TO_C(fc->getFileName())); + if (content->name) bctbx_free(content->name); + content->name = bctbx_strdup(L_STRING_TO_C(fc->getFileName())); } else if (c->isFileTransfer()) { const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - if (content->name) ms_free(content->name); - content->name = ms_strdup(L_STRING_TO_C(ftc->getFileName())); + if (content->name) bctbx_free(content->name); + content->name = bctbx_strdup(L_STRING_TO_C(ftc->getFileName())); } return content->name; } void linphone_content_set_name(LinphoneContent *content, const char *name) { - if (content->name) ms_free(content->name); + if (content->name) bctbx_free(content->name); LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFile()) { @@ -175,7 +174,7 @@ void linphone_content_set_name(LinphoneContent *content, const char *name) { ftc->setFileName(L_C_TO_STRING(name)); } - content->name = ms_strdup(name); + content->name = bctbx_strdup(name); } bool_t linphone_content_is_multipart(const LinphoneContent *content) { @@ -216,12 +215,12 @@ const char * linphone_content_get_custom_header(const LinphoneContent *content, } const char *linphone_content_get_key(const LinphoneContent *content) { - if (content->key) ms_free(content->key); + if (content->key) bctbx_free(content->key); const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFileTransfer()) { const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - content->key = ms_strdup(ftc->getFileKeyAsString()); + content->key = bctbx_strdup(ftc->getFileKeyAsString()); } return content->key; @@ -317,7 +316,7 @@ SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content) { if (contentType.isMultipart()) { size_t size = linphone_content_get_size(content); - char *buffer = ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); + char *buffer = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue()); belle_sip_multipart_body_handler_t *bh = belle_sip_multipart_body_handler_new_from_buffer(buffer, size, boundary); body_handler = (SalBodyHandler *)BELLE_SIP_BODY_HANDLER(bh); diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index 86f67d02c..ad17cfff7 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -116,7 +116,6 @@ void FileTransferChatMessageModifier::fileTransferOnProgress ( // Legacy: call back given by application level. linphone_core_notify_file_transfer_progress_indication(message->getCore()->getCCore(), msg, content, offset, total); } - linphone_content_unref(content); } static int _chat_message_on_send_body ( @@ -173,7 +172,6 @@ int FileTransferChatMessageModifier::onSendBody ( // Legacy linphone_core_notify_file_transfer_send(message->getCore()->getCCore(), msg, content, (char *)buffer, size); } - linphone_content_unref(content); } LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(message->getCore()->getCCore()); @@ -265,7 +263,7 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h // Actual filename stored in msg->file_transfer_information->name will be set in encrypted msg // sended to the first_part_header = "form-data; name=\"File\"; filename=\"filename.txt\""; - + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); LinphoneImEncryptionEngineCbsGenerateFileTransferKeyCb generate_file_transfer_key_cb = linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(imee_cbs); @@ -763,7 +761,6 @@ void FileTransferChatMessageModifier::onRecvBody (belle_sip_user_body_handler_t // Legacy: call back given by application level linphone_core_notify_file_transfer_recv(message->getCore()->getCCore(), msg, content, (const char *)buffer, size); } - linphone_content_unref(content); } } else { lWarning() << "File transfer decrypt failed with code " << (int)retval; @@ -804,7 +801,6 @@ void FileTransferChatMessageModifier::onRecvEnd (belle_sip_user_body_handler_t * // Legacy: call back given by application level linphone_core_notify_file_transfer_recv(message->getCore()->getCCore(), msg, content, nullptr, 0); } - linphone_content_unref(content); } } diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index 6040140b8..0f10cfaa4 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -49,11 +49,9 @@ list ContentManager::multipartToContentList (const Content &content) { LinphoneContent *cContent = linphone_content_from_sal_body_handler(part); Content *cppContent = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); contents.push_back(*cppContent); - linphone_content_unref(cContent); } sal_body_handler_unref(sbh); - linphone_content_unref(cContent); return contents; } @@ -67,7 +65,6 @@ Content ContentManager::contentListToMultipart (const list &contents) LinphoneContent *cContent = L_GET_C_BACK_PTR(content); SalBodyHandler *sbh = sal_body_handler_from_content(cContent); belle_sip_multipart_body_handler_add_part(mpbh, BELLE_SIP_BODY_HANDLER(sbh)); - linphone_content_unref(cContent); } SalBodyHandler *sbh = (SalBodyHandler *)mpbh; @@ -77,7 +74,6 @@ Content ContentManager::contentListToMultipart (const list &contents) LinphoneContent *cContent = linphone_content_from_sal_body_handler(sbh); Content *content = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); Content returnContent = *content; - linphone_content_unref(cContent); belle_sip_object_unref(mpbh); return returnContent; diff --git a/tester/message_tester.c b/tester/message_tester.c index df264123a..17dc41e43 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -66,10 +66,9 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess } counters->last_received_chat_message=linphone_chat_message_ref(msg); LinphoneContent * content = linphone_chat_message_get_file_transfer_information(msg); - if (content) { + if (content) counters->number_of_LinphoneMessageReceivedWithFile++; - linphone_content_unref(content); - } else if (linphone_chat_message_get_external_body_url(msg)) { + else if (linphone_chat_message_get_external_body_url(msg)) { counters->number_of_LinphoneMessageExtBodyReceived++; if (message_external_body_url) { BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(msg),message_external_body_url); @@ -834,12 +833,12 @@ void info_message_base(bool_t with_content) { info=linphone_core_create_info_message(marie->lc); linphone_info_message_add_header(info,"Weather","still bad"); if (with_content) { - LinphoneContent* ct=linphone_core_create_content(marie->lc); - linphone_content_set_type(ct,"application"); - linphone_content_set_subtype(ct,"somexml"); - linphone_content_set_buffer(ct,(const uint8_t *)info_content,strlen(info_content)); - linphone_info_message_set_content(info,ct); - linphone_content_unref(ct); + LinphoneContent* content = linphone_core_create_content(marie->lc); + linphone_content_set_type(content, "application"); + linphone_content_set_subtype(content, "somexml"); + linphone_content_set_buffer(content, (const uint8_t *)info_content, strlen(info_content)); + linphone_info_message_set_content(info, content); + linphone_content_unref(content); } linphone_call_send_info_message(linphone_core_get_current_call(marie->lc),info); linphone_info_message_unref(info); @@ -1442,7 +1441,6 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st BC_ASSERT_PTR_NOT_NULL(linphone_content_get_key(content)); else BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); - linphone_content_unref(content); if (use_file_body_handler_in_download) { linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath); @@ -1647,7 +1645,7 @@ void crash_during_file_transfer(void) { /* Create a new core and check that the message stored in the saved database is in the not delivered state */ linphone_core_manager_restart(pauline, TRUE); linphone_core_set_file_transfer_server(pauline->lc, "https://www.linphone.org:444/lft.php"); - + //BC_ASSERT_TRUE(wait_for(pauline->lc, pauline->lc, &pauline->stat.number_of_LinphoneRegistrationOk, 1)); chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); @@ -1684,9 +1682,9 @@ void crash_during_file_transfer(void) { } } - + bctbx_list_free_with_data(msg_list, (bctbx_list_free_func)linphone_chat_message_unref); - + linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); diff --git a/tester/multipart-tester.cpp b/tester/multipart-tester.cpp index c94dc9a2e..1c54389f2 100644 --- a/tester/multipart-tester.cpp +++ b/tester/multipart-tester.cpp @@ -86,7 +86,6 @@ static void chat_message_multipart_modifier_base(bool first_file_transfer, bool if (first_file_transfer || second_file_transfer) { LinphoneContent *content = linphone_chat_message_get_file_transfer_information(pauline->stat.last_received_chat_message); BC_ASSERT_PTR_NOT_NULL(content); - linphone_content_unref(content); } if (!first_file_transfer || !second_file_transfer) { const char *content = linphone_chat_message_get_text_content(pauline->stat.last_received_chat_message); From 72f5d85a90e48783ac330280edf380492a8c9e00 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 14:53:06 +0200 Subject: [PATCH 010/143] feat(c-wrapper): provide a new L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS macro --- src/c-wrapper/internal/c-tools.h | 92 ++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 96bfb4edf..aef5f9183 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -601,9 +601,9 @@ LINPHONE_END_NAMESPACE #undef L_INTERNAL_WRAPPER_CONSTEXPR -#define L_INTERNAL_C_OBJECT_NO_XTOR(C_OBJECT) +#define L_INTERNAL_C_NO_XTOR(C_OBJECT) -#define L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, CPP_TYPE, ...) \ +#define L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, ...) \ static_assert(LinphonePrivate::CTypeMetaInfo::defined, "Type is not defined."); \ static_assert( \ LinphonePrivate::IsDefinedBaseCppObject< \ @@ -622,13 +622,13 @@ LINPHONE_END_NAMESPACE #define L_INTERNAL_DECLARE_C_OBJECT_FUNCTIONS(C_TYPE, CONSTRUCTOR, DESTRUCTOR) \ BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \ Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init () { \ - Linphone ## C_TYPE * object = belle_sip_object_new(Linphone ## C_TYPE); \ + Linphone ## C_TYPE *object = belle_sip_object_new(Linphone ## C_TYPE); \ new(&object->cppPtr) std::shared_ptr(); \ new(&object->weakCppPtr) std::weak_ptr(); \ CONSTRUCTOR(object); \ return object; \ } \ - static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE *object) { \ + static void _linphone_ ## C_TYPE ## _uninit (Linphone ## C_TYPE *object) { \ DESTRUCTOR(object); \ LinphonePrivate::Wrapper::uninitBaseCppObject(object); \ } \ @@ -644,6 +644,45 @@ LINPHONE_END_NAMESPACE FALSE \ ); +#define L_INTERNAL_DECLARE_C_CLONABLE_OBJECT(C_TYPE, ...) \ + static_assert(LinphonePrivate::CTypeMetaInfo::defined, "Type is not defined."); \ + static_assert( \ + LinphonePrivate::IsDefinedClonableCppObject< \ + LinphonePrivate::CTypeMetaInfo::cppType \ + >::value, \ + "Type is not declared as clonable object." \ + ); \ + struct _Linphone ## C_TYPE { \ + belle_sip_object_t base; \ + L_CPP_TYPE_OF_C_TYPE(C_TYPE) *cppPtr; \ + int owner; \ + __VA_ARGS__ \ + }; \ + +#define L_INTERNAL_DECLARE_C_CLONABLE_OBJECT_FUNCTIONS(C_TYPE, CONSTRUCTOR, DESTRUCTOR) \ + BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \ + Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init () { \ + Linphone ## C_TYPE *object = belle_sip_object_new(Linphone ## C_TYPE); \ + CONSTRUCTOR(object); \ + return object; \ + } \ + static void _linphone_ ## C_TYPE ## _uninit (Linphone ## C_TYPE * object) { \ + DESTRUCTOR(object); \ + LinphonePrivate::Wrapper::uninitClonableCppObject(object); \ + } \ + static void _linphone_ ## C_TYPE ## _clone (Linphone ## C_TYPE *dest, const Linphone ## C_TYPE *src) { \ + L_ASSERT(src->cppPtr); \ + dest->cppPtr = new L_CPP_TYPE_OF_C_TYPE(C_TYPE)(*src->cppPtr); \ + } \ + BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## C_TYPE); \ + BELLE_SIP_INSTANCIATE_VPTR( \ + Linphone ## C_TYPE, belle_sip_object_t, \ + _linphone_ ## C_TYPE ## _uninit, \ + _linphone_ ## C_TYPE ## _clone, \ + NULL, \ + FALSE \ + ); + // ============================================================================= // Public Wrapper API. // ============================================================================= @@ -703,48 +742,23 @@ LINPHONE_END_NAMESPACE // Declare wrapped C object with constructor/destructor. #define L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(C_TYPE, CONSTRUCTOR, DESTRUCTOR, ...) \ - L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, L_CPP_TYPE_OF_C_TYPE(C_TYPE), __VA_ARGS__) \ + L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, __VA_ARGS__) \ L_INTERNAL_DECLARE_C_OBJECT_FUNCTIONS(C_TYPE, CONSTRUCTOR, DESTRUCTOR) // Declare wrapped C object. #define L_DECLARE_C_OBJECT_IMPL(C_TYPE, ...) \ - L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, L_CPP_TYPE_OF_C_TYPE(C_TYPE), __VA_ARGS__) \ - L_INTERNAL_DECLARE_C_OBJECT_FUNCTIONS(C_TYPE, L_INTERNAL_C_OBJECT_NO_XTOR, L_INTERNAL_C_OBJECT_NO_XTOR) + L_INTERNAL_DECLARE_C_OBJECT(C_TYPE, __VA_ARGS__) \ + L_INTERNAL_DECLARE_C_OBJECT_FUNCTIONS(C_TYPE, L_INTERNAL_C_NO_XTOR, L_INTERNAL_C_NO_XTOR) + +// Declare clonable wrapped C object with constructor/destructor. +#define L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS(C_TYPE, CONSTRUCTOR, DESTRUCTOR, ...) \ + L_INTERNAL_DECLARE_C_CLONABLE_OBJECT(C_TYPE, __VA_ARGS__) \ + L_INTERNAL_DECLARE_C_CLONABLE_OBJECT_FUNCTIONS(C_TYPE, CONSTRUCTOR, DESTRUCTOR) // Declare clonable wrapped C object. #define L_DECLARE_C_CLONABLE_OBJECT_IMPL(C_TYPE, ...) \ - static_assert(LinphonePrivate::CTypeMetaInfo::defined, "Type is not defined."); \ - static_assert( \ - LinphonePrivate::IsDefinedClonableCppObject< \ - LinphonePrivate::CTypeMetaInfo::cppType \ - >::value, \ - "Type is not declared as clonable object." \ - ); \ - struct _Linphone ## C_TYPE { \ - belle_sip_object_t base; \ - L_CPP_TYPE_OF_C_TYPE(C_TYPE) *cppPtr; \ - int owner; \ - __VA_ARGS__ \ - }; \ - BELLE_SIP_DECLARE_VPTR_NO_EXPORT(Linphone ## C_TYPE); \ - Linphone ## C_TYPE *_linphone_ ## C_TYPE ## _init() { \ - return belle_sip_object_new(Linphone ## C_TYPE); \ - } \ - static void _linphone_ ## C_TYPE ## _uninit(Linphone ## C_TYPE * object) { \ - LinphonePrivate::Wrapper::uninitClonableCppObject(object); \ - } \ - static void _linphone_ ## C_TYPE ## _clone(Linphone ## C_TYPE *dest, const Linphone ## C_TYPE *src) { \ - L_ASSERT(src->cppPtr); \ - dest->cppPtr = new L_CPP_TYPE_OF_C_TYPE(C_TYPE)(*src->cppPtr); \ - } \ - BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(Linphone ## C_TYPE); \ - BELLE_SIP_INSTANCIATE_VPTR( \ - Linphone ## C_TYPE, belle_sip_object_t, \ - _linphone_ ## C_TYPE ## _uninit, \ - _linphone_ ## C_TYPE ## _clone, \ - NULL, \ - FALSE \ - ); + L_INTERNAL_DECLARE_C_CLONABLE_OBJECT(C_TYPE, __VA_ARGS__) \ + L_INTERNAL_DECLARE_C_CLONABLE_OBJECT_FUNCTIONS(C_TYPE, L_INTERNAL_C_NO_XTOR, L_INTERNAL_C_NO_XTOR) // ----------------------------------------------------------------------------- // Helpers. From 39e7f6eddcee56da850d387a4c6d974af2037d68 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 15:41:24 +0200 Subject: [PATCH 011/143] fix(c-content): avoid memory leaks and better code --- include/linphone/api/c-content.h | 64 ++++---- src/c-wrapper/api/c-address.cpp | 4 +- src/c-wrapper/api/c-chat-message.cpp | 4 +- src/c-wrapper/api/c-content.cpp | 217 +++++++++++++-------------- 4 files changed, 147 insertions(+), 142 deletions(-) diff --git a/include/linphone/api/c-content.h b/include/linphone/api/c-content.h index 6114875a3..214755d5b 100644 --- a/include/linphone/api/c-content.h +++ b/include/linphone/api/c-content.h @@ -38,55 +38,55 @@ * @param[in] content #LinphoneContent object. * @return The same #LinphoneContent object. **/ -LINPHONE_PUBLIC LinphoneContent * linphone_content_ref(LinphoneContent *content); +LINPHONE_PUBLIC LinphoneContent *linphone_content_ref (LinphoneContent *content); /** * Release reference to the content. * @param[in] content #LinphoneContent object. **/ -LINPHONE_PUBLIC void linphone_content_unref(LinphoneContent *content); +LINPHONE_PUBLIC void linphone_content_unref (LinphoneContent *content); /** * Retrieve the user pointer associated with the content. * @param[in] content #LinphoneContent object. * @return The user pointer associated with the content. **/ -LINPHONE_PUBLIC void *linphone_content_get_user_data(const LinphoneContent *content); +LINPHONE_PUBLIC void *linphone_content_get_user_data (const LinphoneContent *content); /** * Assign a user pointer to the content. * @param[in] content #LinphoneContent object. * @param[in] ud The user pointer to associate with the content. **/ -LINPHONE_PUBLIC void linphone_content_set_user_data(LinphoneContent *content, void *ud); +LINPHONE_PUBLIC void linphone_content_set_user_data (LinphoneContent *content, void *user_data); /** * Get the mime type of the content data. * @param[in] content #LinphoneContent object. * @return The mime type of the content data, for example "application". */ -LINPHONE_PUBLIC const char * linphone_content_get_type(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_type (const LinphoneContent *content); /** * Set the mime type of the content data. * @param[in] content #LinphoneContent object. * @param[in] type The mime type of the content data, for example "application". */ -LINPHONE_PUBLIC void linphone_content_set_type(LinphoneContent *content, const char *type); +LINPHONE_PUBLIC void linphone_content_set_type (LinphoneContent *content, const char *type); /** * Get the mime subtype of the content data. * @param[in] content #LinphoneContent object. * @return The mime subtype of the content data, for example "html". */ -LINPHONE_PUBLIC const char * linphone_content_get_subtype(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_subtype (const LinphoneContent *content); /** * Set the mime subtype of the content data. * @param[in] content #LinphoneContent object. * @param[in] subtype The mime subtype of the content data, for example "html". */ -LINPHONE_PUBLIC void linphone_content_set_subtype(LinphoneContent *content, const char *subtype); +LINPHONE_PUBLIC void linphone_content_set_subtype (LinphoneContent *content, const char *subtype); /** * Adds a parameter to the ContentType header. @@ -94,14 +94,18 @@ LINPHONE_PUBLIC void linphone_content_set_subtype(LinphoneContent *content, cons * @param[in] name the name of the parameter to add. * @param[in] value the value of the parameter to add. */ -LINPHONE_PUBLIC void linphone_content_add_content_type_parameter(LinphoneContent *content, const char *name, const char *value); +LINPHONE_PUBLIC void linphone_content_add_content_type_parameter ( + LinphoneContent *content, + const char *name, + const char *value +); /** * Get the content data buffer, usually a string. * @param[in] content #LinphoneContent object. * @return The content data buffer. */ -LINPHONE_PUBLIC uint8_t * linphone_content_get_buffer(const LinphoneContent *content); +LINPHONE_PUBLIC uint8_t *linphone_content_get_buffer (const LinphoneContent *content); /** * Set the content data buffer, usually a string. @@ -109,70 +113,70 @@ LINPHONE_PUBLIC uint8_t * linphone_content_get_buffer(const LinphoneContent *con * @param[in] buffer The content data buffer. * @param[in] size The size of the content data buffer. */ -LINPHONE_PUBLIC void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer, size_t size); +LINPHONE_PUBLIC void linphone_content_set_buffer (LinphoneContent *content, const uint8_t *buffer, size_t size); /** * Get the string content data buffer. * @param[in] content #LinphoneContent object * @return The string content data buffer. */ -LINPHONE_PUBLIC const char * linphone_content_get_string_buffer(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_string_buffer (const LinphoneContent *content); /** * Set the string content data buffer. * @param[in] content #LinphoneContent object. * @param[in] buffer The string content data buffer. */ -LINPHONE_PUBLIC void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer); +LINPHONE_PUBLIC void linphone_content_set_string_buffer (LinphoneContent *content, const char *buffer); /** * Get the content data buffer size, excluding null character despite null character is always set for convenience. * @param[in] content #LinphoneContent object. * @return The content data buffer size. */ -LINPHONE_PUBLIC size_t linphone_content_get_size(const LinphoneContent *content); +LINPHONE_PUBLIC size_t linphone_content_get_size (const LinphoneContent *content); /** * Set the content data size, excluding null character despite null character is always set for convenience. * @param[in] content #LinphoneContent object * @param[in] size The content data buffer size. */ -LINPHONE_PUBLIC void linphone_content_set_size(LinphoneContent *content, size_t size); +LINPHONE_PUBLIC void linphone_content_set_size (LinphoneContent *content, size_t size); /** * Get the encoding of the data buffer, for example "gzip". * @param[in] content #LinphoneContent object. * @return The encoding of the data buffer. */ -LINPHONE_PUBLIC const char * linphone_content_get_encoding(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_encoding (const LinphoneContent *content); /** * Set the encoding of the data buffer, for example "gzip". * @param[in] content #LinphoneContent object. * @param[in] encoding The encoding of the data buffer. */ -LINPHONE_PUBLIC void linphone_content_set_encoding(LinphoneContent *content, const char *encoding); +LINPHONE_PUBLIC void linphone_content_set_encoding (LinphoneContent *content, const char *encoding); /** * Get the name associated with a RCS file transfer message. It is used to store the original filename of the file to be downloaded from server. * @param[in] content #LinphoneContent object. * @return The name of the content. */ -LINPHONE_PUBLIC const char * linphone_content_get_name(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_name (const LinphoneContent *content); /** * Set the name associated with a RCS file transfer message. It is used to store the original filename of the file to be downloaded from server. * @param[in] content #LinphoneContent object. * @param[in] name The name of the content. */ -LINPHONE_PUBLIC void linphone_content_set_name(LinphoneContent *content, const char *name); +LINPHONE_PUBLIC void linphone_content_set_name (LinphoneContent *content, const char *name); /** * Tell whether a content is a multipart content. * @param[in] content #LinphoneContent object. * @return A boolean value telling whether the content is multipart or not. */ -LINPHONE_PUBLIC bool_t linphone_content_is_multipart(const LinphoneContent *content); +LINPHONE_PUBLIC bool_t linphone_content_is_multipart (const LinphoneContent *content); /** * Get a part from a multipart content according to its index. @@ -180,7 +184,7 @@ LINPHONE_PUBLIC bool_t linphone_content_is_multipart(const LinphoneContent *cont * @param[in] idx The index of the part to get. * @return A #LinphoneContent object holding the part if found, NULL otherwise. */ -LINPHONE_PUBLIC LinphoneContent * linphone_content_get_part(const LinphoneContent *content, int idx); +LINPHONE_PUBLIC LinphoneContent *linphone_content_get_part (const LinphoneContent *content, int idx); /** * Find a part from a multipart content looking for a part header with a specified value. @@ -189,7 +193,11 @@ LINPHONE_PUBLIC LinphoneContent * linphone_content_get_part(const LinphoneConten * @param[in] header_value The value of the header to look for. * @return A #LinphoneContent object object the part if found, NULL otherwise. */ -LINPHONE_PUBLIC LinphoneContent * linphone_content_find_part_by_header(const LinphoneContent *content, const char *header_name, const char *header_value); +LINPHONE_PUBLIC LinphoneContent *linphone_content_find_part_by_header ( + const LinphoneContent *content, + const char *header_name, + const char *header_value +); /** * Get a custom header value of a content. @@ -197,29 +205,29 @@ LINPHONE_PUBLIC LinphoneContent * linphone_content_find_part_by_header(const Lin * @param[in] header_name The name of the header to get the value from. * @return The value of the header if found, NULL otherwise. */ -LINPHONE_PUBLIC const char * linphone_content_get_custom_header(const LinphoneContent *content, const char *header_name); +LINPHONE_PUBLIC const char *linphone_content_get_custom_header (const LinphoneContent *content, const char *header_name); /** * Get the key associated with a RCS file transfer message if encrypted * @param[in] content #LinphoneContent object. * @return The key to encrypt/decrypt the file associated to this content. */ -LINPHONE_PUBLIC const char *linphone_content_get_key(const LinphoneContent *content); +LINPHONE_PUBLIC const char *linphone_content_get_key (const LinphoneContent *content); /** * Get the size of key associated with a RCS file transfer message if encrypted * @param[in] content #LinphoneContent object. * @return The key size in bytes */ -LINPHONE_PUBLIC size_t linphone_content_get_key_size(const LinphoneContent *content); +LINPHONE_PUBLIC size_t linphone_content_get_key_size (const LinphoneContent *content); /** * Set the key associated with a RCS file transfer message if encrypted * @param[in] content #LinphoneContent object. * @param[in] key The key to be used to encrypt/decrypt file associated to this content. - * @param[in] keyLength The lengh of the key. + * @param[in] key_length The lengh of the key. */ -LINPHONE_PUBLIC void linphone_content_set_key(LinphoneContent *content, const char *key, const size_t keyLength); +LINPHONE_PUBLIC void linphone_content_set_key (LinphoneContent *content, const char *key, const size_t key_length); /** * @} @@ -229,4 +237,4 @@ LINPHONE_PUBLIC void linphone_content_set_key(LinphoneContent *content, const ch } #endif // ifdef __cplusplus -#endif // ifndef _L_C_CONTENT_H_ \ No newline at end of file +#endif // ifndef _L_C_CONTENT_H_ diff --git a/src/c-wrapper/api/c-address.cpp b/src/c-wrapper/api/c-address.cpp index a07fec135..dbbe793bc 100644 --- a/src/c-wrapper/api/c-address.cpp +++ b/src/c-wrapper/api/c-address.cpp @@ -131,11 +131,11 @@ void linphone_address_clean (LinphoneAddress *address) { } char *linphone_address_as_string (const LinphoneAddress *address) { - return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(address)->asString().c_str()); + return bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(address)->asString().c_str()); } char *linphone_address_as_string_uri_only (const LinphoneAddress *address) { - return ms_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(address)->asStringUriOnly().c_str()); + return bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(address)->asStringUriOnly().c_str()); } bool_t linphone_address_weak_equal (const LinphoneAddress *address1, const LinphoneAddress *address2) { diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index a8e8f923f..12314bf52 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -43,7 +43,9 @@ static void _linphone_chat_message_constructor (LinphoneChatMessage *msg); static void _linphone_chat_message_destructor (LinphoneChatMessage *msg); L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(ChatMessage, - _linphone_chat_message_constructor, _linphone_chat_message_destructor, + _linphone_chat_message_constructor, + _linphone_chat_message_destructor, + LinphoneChatMessageCbs *cbs; LinphoneAddress *from; // cache for shared_ptr
LinphoneAddress *to; // cache for shared_ptr
diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 0d92a6243..a75eda44d 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -21,167 +21,161 @@ #include "linphone/wrapper_utils.h" #include "c-wrapper/c-wrapper.h" - -#include "content/content.h" #include "content/content-type.h" -#include "content/header/header-param.h" -#include "content/header/header.h" -#include "content/content-manager.h" #include "content/file-content.h" #include "content/file-transfer-content.h" +#include "content/header/header-param.h" // ============================================================================= using namespace std; -L_DECLARE_C_CLONABLE_OBJECT_IMPL(Content, - void *cryptoContext; /**< crypto context used to encrypt file for RCS file transfer */ - mutable char *name; - mutable char *type; - mutable char *subtype; - mutable char *body; +static void _linphone_content_constructor (LinphoneContent *content); +static void _linphone_content_destructor (LinphoneContent *content); + +L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS(Content, + _linphone_content_constructor, + _linphone_content_destructor, + + void *cryptoContext; // Used to encrypt file for RCS file transfer. + mutable size_t size; - mutable char *encoding; mutable char *key; + + struct Cache { + string name; + string type; + string subtype; + string encoding; + } mutable cache; ) +static void _linphone_content_constructor (LinphoneContent *content) { + new(&content->cache) LinphoneContent::Cache(); +} + +static void _linphone_content_destructor (LinphoneContent *content) { + content->cache.~Cache(); +} + // ============================================================================= // Reference and user data handling functions. // ============================================================================= -LinphoneContent * linphone_content_ref(LinphoneContent *content) { +LinphoneContent *linphone_content_ref (LinphoneContent *content) { belle_sip_object_ref(content); return content; } -void linphone_content_unref(LinphoneContent *content) { +void linphone_content_unref (LinphoneContent *content) { belle_sip_object_unref(content); } -void *linphone_content_get_user_data(const LinphoneContent *content) { +void *linphone_content_get_user_data (const LinphoneContent *content) { return L_GET_USER_DATA_FROM_C_OBJECT(content); } -void linphone_content_set_user_data(LinphoneContent *content, void *ud) { - return L_SET_USER_DATA_FROM_C_OBJECT(content, ud); +void linphone_content_set_user_data (LinphoneContent *content, void *user_data) { + return L_SET_USER_DATA_FROM_C_OBJECT(content, user_data); } // ============================================================================= -const char * linphone_content_get_type(const LinphoneContent *content) { - if (content->type) bctbx_free(content->type); - content->type = bctbx_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType())); - return content->type; +const char *linphone_content_get_type (const LinphoneContent *content) { + return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getType().c_str(); } -void linphone_content_set_type(LinphoneContent *content, const char *type) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.setType(L_C_TO_STRING(type)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); +void linphone_content_set_type (LinphoneContent *content, const char *type) { + LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + contentType.setType(L_C_TO_STRING(type)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(contentType); } -const char * linphone_content_get_subtype(const LinphoneContent *content) { - if (content->subtype) bctbx_free(content->subtype); - content->subtype = bctbx_strdup(L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType())); - return content->subtype; +const char *linphone_content_get_subtype (const LinphoneContent *content) { + return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().getSubType().c_str(); } -void linphone_content_set_subtype(LinphoneContent *content, const char *subtype) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.setSubType(L_C_TO_STRING(subtype)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); +void linphone_content_set_subtype (LinphoneContent *content, const char *subtype) { + LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + contentType.setSubType(L_C_TO_STRING(subtype)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(contentType); } -void linphone_content_add_content_type_parameter(LinphoneContent *content, const char *name, const char *value) { - LinphonePrivate::ContentType ct = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - ct.addParameter(L_C_TO_STRING(name), L_C_TO_STRING(value)); - L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(ct); +void linphone_content_add_content_type_parameter (LinphoneContent *content, const char *name, const char *value) { + LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); + contentType.addParameter(L_C_TO_STRING(name), L_C_TO_STRING(value)); + L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(contentType); } -uint8_t * linphone_content_get_buffer(const LinphoneContent *content) { +uint8_t *linphone_content_get_buffer (const LinphoneContent *content) { return (uint8_t *)linphone_content_get_string_buffer(content); } -void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer, size_t size) { +void linphone_content_set_buffer (LinphoneContent *content, const uint8_t *buffer, size_t size) { L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBody(buffer, size); } -const char * linphone_content_get_string_buffer(const LinphoneContent *content) { - if (content->body) bctbx_free(content->body); - content->body = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); - return content->body; +const char *linphone_content_get_string_buffer (const LinphoneContent *content) { + return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str(); } -void linphone_content_set_string_buffer(LinphoneContent *content, const char *buffer) { +void linphone_content_set_string_buffer (LinphoneContent *content, const char *buffer) { L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBodyFromUtf8(L_C_TO_STRING(buffer)); } -size_t linphone_content_get_size(const LinphoneContent *content) { - const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - size_t size = 0; - if (c->isFile()) { - const LinphonePrivate::FileContent *fc = static_cast(c); - size = fc->getFileSize(); - } else if (c->isFileTransfer()) { - const LinphonePrivate::FileTransferContent *fc = static_cast(c); - size = fc->getFileSize(); - } - if (size == 0) { - size = c->getSize(); - } - if (size == 0) { - size = content->size; - } - return size; +size_t linphone_content_get_size (const LinphoneContent *content) { + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + size_t size = 0; + if (c->isFile()) + size = static_cast(c)->getFileSize(); + else if (c->isFileTransfer()) + size = static_cast(c)->getFileSize(); + + if (size == 0) { + size = c->getSize(); + } + if (size == 0) { + size = content->size; + } + return size; } -void linphone_content_set_size(LinphoneContent *content, size_t size) { +void linphone_content_set_size (LinphoneContent *content, size_t size) { content->size = size; } -const char * linphone_content_get_encoding(const LinphoneContent *content) { - return content->encoding; +const char *linphone_content_get_encoding (const LinphoneContent *content) { + return content->cache.encoding.c_str(); } -void linphone_content_set_encoding(LinphoneContent *content, const char *encoding) { - if (content->encoding) bctbx_free(content->encoding); - content->encoding = bctbx_strdup(encoding); +void linphone_content_set_encoding (LinphoneContent *content, const char *encoding) { + content->cache.encoding = L_C_TO_STRING(encoding); } -const char * linphone_content_get_name(const LinphoneContent *content) { +const char *linphone_content_get_name (const LinphoneContent *content) { const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFile()) { - const LinphonePrivate::FileContent *fc = static_cast(c); - if (content->name) bctbx_free(content->name); - content->name = bctbx_strdup(L_STRING_TO_C(fc->getFileName())); - } else if (c->isFileTransfer()) { - const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - if (content->name) bctbx_free(content->name); - content->name = bctbx_strdup(L_STRING_TO_C(ftc->getFileName())); - } - return content->name; + if (c->isFile()) + return static_cast(c)->getFileName().c_str(); + if (c->isFileTransfer()) + return static_cast(c)->getFileName().c_str(); + return content->cache.name.c_str(); } -void linphone_content_set_name(LinphoneContent *content, const char *name) { - if (content->name) bctbx_free(content->name); - +void linphone_content_set_name (LinphoneContent *content, const char *name) { LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); - if (c->isFile()) { - LinphonePrivate::FileContent *fc = static_cast(c); - fc->setFileName(L_C_TO_STRING(name)); - } else if (c->isFileTransfer()) { - LinphonePrivate::FileTransferContent *ftc = static_cast(c); - ftc->setFileName(L_C_TO_STRING(name)); - } - - content->name = bctbx_strdup(name); + if (c->isFile()) + static_cast(c)->setFileName(L_C_TO_STRING(name)); + else if (c->isFileTransfer()) + static_cast(c)->setFileName(L_C_TO_STRING(name)); + else + content->cache.name = L_C_TO_STRING(name); } -bool_t linphone_content_is_multipart(const LinphoneContent *content) { +bool_t linphone_content_is_multipart (const LinphoneContent *content) { return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType().isMultipart(); } -LinphoneContent * linphone_content_get_part(const LinphoneContent *content, int idx) { +LinphoneContent *linphone_content_get_part (const LinphoneContent *content, int idx) { SalBodyHandler *part_body_handler; SalBodyHandler *body_handler = sal_body_handler_from_content(content); if (!sal_body_handler_is_multipart(body_handler)) { @@ -194,7 +188,7 @@ LinphoneContent * linphone_content_get_part(const LinphoneContent *content, int return result; } -LinphoneContent * linphone_content_find_part_by_header(const LinphoneContent *content, const char *header_name, const char *header_value) { +LinphoneContent *linphone_content_find_part_by_header (const LinphoneContent *content, const char *header_name, const char *header_value) { SalBodyHandler *part_body_handler; SalBodyHandler *body_handler = sal_body_handler_from_content(content); if (!sal_body_handler_is_multipart(body_handler)) { @@ -207,14 +201,14 @@ LinphoneContent * linphone_content_find_part_by_header(const LinphoneContent *co return result; } -const char * linphone_content_get_custom_header(const LinphoneContent *content, const char *header_name) { +const char *linphone_content_get_custom_header (const LinphoneContent *content, const char *header_name) { SalBodyHandler *body_handler = sal_body_handler_from_content(content); const char *header = sal_body_handler_get_header(body_handler, header_name); sal_body_handler_unref(body_handler); return header; } -const char *linphone_content_get_key(const LinphoneContent *content) { +const char *linphone_content_get_key (const LinphoneContent *content) { if (content->key) bctbx_free(content->key); const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); @@ -226,7 +220,7 @@ const char *linphone_content_get_key(const LinphoneContent *content) { return content->key; } -size_t linphone_content_get_key_size(const LinphoneContent *content) { +size_t linphone_content_get_key_size (const LinphoneContent *content) { const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFileTransfer()) { const LinphonePrivate::FileTransferContent *ftc = static_cast(c); @@ -235,11 +229,11 @@ size_t linphone_content_get_key_size(const LinphoneContent *content) { return 0; } -void linphone_content_set_key(LinphoneContent *content, const char *key, const size_t keyLength) { +void linphone_content_set_key (LinphoneContent *content, const char *key, const size_t key_length) { LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFileTransfer()) { LinphonePrivate::FileTransferContent *ftc = static_cast(c); - ftc->setFileKey(key, keyLength); + ftc->setFileKey(key, key_length); } } @@ -247,7 +241,7 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s // Private functions. // ============================================================================= -static LinphoneContent * linphone_content_new_with_body_handler(SalBodyHandler *body_handler) { +static LinphoneContent *linphone_content_new_with_body_handler (SalBodyHandler *body_handler) { LinphoneContent *content = L_INIT(Content); content->cryptoContext = NULL; LinphonePrivate::Content *c = new LinphonePrivate::Content(); @@ -284,31 +278,32 @@ static LinphoneContent * linphone_content_new_with_body_handler(SalBodyHandler * return content; } -LinphoneContent * linphone_content_new(void) { +LinphoneContent *linphone_content_new (void) { return linphone_content_new_with_body_handler(NULL); } -LinphoneContent * linphone_content_copy(const LinphoneContent *ref) { - return (LinphoneContent *)(belle_sip_object_clone(BELLE_SIP_OBJECT(ref))); +LinphoneContent *linphone_content_copy (const LinphoneContent *ref) { + return (LinphoneContent *)belle_sip_object_clone(BELLE_SIP_OBJECT(ref)); } -LinphoneContent * linphone_core_create_content(LinphoneCore *lc) { +LinphoneContent *linphone_core_create_content (LinphoneCore *lc) { return linphone_content_new(); } -/* crypto context is managed(allocated/freed) by the encryption function, so provide the address of field in the private structure */ -void ** linphone_content_get_cryptoContext_address(LinphoneContent *content) { - return &(content->cryptoContext); +// Crypto context is managed(allocated/freed) by the encryption function, +// so provide the address of field in the private structure. +void **linphone_content_get_cryptoContext_address (LinphoneContent *content) { + return &content->cryptoContext; } -LinphoneContent * linphone_content_from_sal_body_handler(SalBodyHandler *body_handler) { +LinphoneContent *linphone_content_from_sal_body_handler (SalBodyHandler *body_handler) { if (body_handler) { return linphone_content_new_with_body_handler(body_handler); } return NULL; } -SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content) { +SalBodyHandler *sal_body_handler_from_content (const LinphoneContent *content) { if (content == NULL) return NULL; SalBodyHandler *body_handler; @@ -333,10 +328,10 @@ SalBodyHandler * sal_body_handler_from_content(const LinphoneContent *content) { sal_body_handler_set_type(body_handler, contentType.getType().c_str()); sal_body_handler_set_subtype(body_handler, contentType.getSubType().c_str()); sal_body_handler_set_size(body_handler, linphone_content_get_size(content)); - for (const auto ¶m : contentType.getParameters()) { + for (const auto ¶m : contentType.getParameters()) sal_body_handler_set_content_type_parameter(body_handler, param.getName().c_str(), param.getValue().c_str()); - } - if (content->encoding) sal_body_handler_set_encoding(body_handler, linphone_content_get_encoding(content)); + if (!content->cache.encoding.empty()) + sal_body_handler_set_encoding(body_handler, linphone_content_get_encoding(content)); return body_handler; } From aab81fe7edf31f147a1185a8edbe361440f33a4c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 17:04:59 +0200 Subject: [PATCH 012/143] fix(c-wrapper): deal with internal cpp ptr destructions (on clonable) --- src/c-wrapper/internal/c-tools.h | 16 +++++++++++----- src/object/base-object.cpp | 4 +--- src/object/clonable-object.cpp | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index aef5f9183..492cbaccf 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -293,12 +293,22 @@ public: typename CppType, typename = typename std::enable_if::value, CppType>::type > - static void signalCppPtrDestruction (CppType *cppObject) { + static void handleObjectDestruction (CppType *cppObject) { void *value = cppObject->getCBackPtr(); if (value && static_cast *>(value)->owner == WrappedObjectOwner::Internal) belle_sip_object_unref(value); } + template< + typename CppType, + typename = typename std::enable_if::value, CppType>::type + > + static void handleClonableObjectDestruction (CppType *cppObject) { + void *value = cppObject->getCBackPtr(); + if (value && static_cast *>(value)->owner == WrappedObjectOwner::Internal) + belle_sip_object_unref(value); + } + // --------------------------------------------------------------------------- // Get c/cpp ptr helpers. // --------------------------------------------------------------------------- @@ -771,10 +781,6 @@ LINPHONE_END_NAMESPACE // Call the init function of wrapped C object. #define L_INIT(C_TYPE) _linphone_ ## C_TYPE ## _init() -// Signal to wrapper the destruction of cpp base object. -#define L_SIGNAL_CPP_PTR_DESTRUCTION(CPP_OBJECT) \ - LinphonePrivate::Wrapper::signalCppPtrDestruction(CPP_OBJECT); - // Get/set the cpp-ptr of a wrapped C object. #define L_GET_CPP_PTR_FROM_C_OBJECT_1_ARGS(C_OBJECT) \ LinphonePrivate::Wrapper::getCppPtrFromC(C_OBJECT) diff --git a/src/object/base-object.cpp b/src/object/base-object.cpp index ebedc602a..7ef6e2b22 100644 --- a/src/object/base-object.cpp +++ b/src/object/base-object.cpp @@ -19,8 +19,6 @@ #include "base-object-p.h" #include "base-object.h" - -// Necessary for: L_SIGNAL_CPP_PTR_DESTRUCTION. #include "c-wrapper/internal/c-tools.h" // ============================================================================= @@ -34,7 +32,7 @@ BaseObject::BaseObject (BaseObjectPrivate &p) : mPrivate(&p) { } BaseObject::~BaseObject () { - L_SIGNAL_CPP_PTR_DESTRUCTION(this); + Wrapper::handleObjectDestruction(this); delete mPrivate; } diff --git a/src/object/clonable-object.cpp b/src/object/clonable-object.cpp index 38d1bba37..5c6ce7f4a 100644 --- a/src/object/clonable-object.cpp +++ b/src/object/clonable-object.cpp @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "c-wrapper/internal/c-tools.h" #include "clonable-object-p.h" #include "clonable-object.h" @@ -43,6 +44,7 @@ ClonableObject::ClonableObject (ClonableObjectPrivate &p) { } while (false); ClonableObject::~ClonableObject () { + Wrapper::handleClonableObjectDestruction(this); UNREF(); } From 90d98d05dc384128b58cc95631013a6e235b40a1 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 17:05:29 +0200 Subject: [PATCH 013/143] fix(c-content): add a cache to handle getBodyAsString --- src/c-wrapper/api/c-content.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index a75eda44d..f3bc9870b 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -47,6 +47,7 @@ L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS(Content, string type; string subtype; string encoding; + string buffer; } mutable cache; ) @@ -116,7 +117,8 @@ void linphone_content_set_buffer (LinphoneContent *content, const uint8_t *buffe } const char *linphone_content_get_string_buffer (const LinphoneContent *content) { - return L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str(); + content->cache.buffer = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String(); + return content->cache.buffer.c_str(); } void linphone_content_set_string_buffer (LinphoneContent *content, const char *buffer) { From c359665681f497daaf7fdf06f48864f1628ed4c8 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 24 Apr 2018 17:17:16 +0200 Subject: [PATCH 014/143] fix(ChatMessage): avoid memory leak at destruction it it exists file content on one file transfer content --- src/chat/chat-message/chat-message.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 5b42d589c..6048f5439 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -897,9 +897,14 @@ ChatMessage::ChatMessage (const shared_ptr &chatRoom, ChatMess ChatMessage::~ChatMessage () { L_D(); - - for (Content *content : d->contents) + + for (Content *content : d->contents) { + if (content->isFileTransfer()) { + FileTransferContent *fileTransferContent = static_cast(content); + delete fileTransferContent->getFileContent(); + } delete content; + } if (d->salOp) { d->salOp->set_user_pointer(nullptr); From e5354d3a984b6b9f0a6be630cd93c04542b23147 Mon Sep 17 00:00:00 2001 From: Johan Pascal Date: Wed, 31 May 2017 11:32:47 +0200 Subject: [PATCH 015/143] Add tests on ZRTP call : ECDH255, ECDH448, SHA384 --- tester/call_single_tester.c | 6 ++- tester/rcfiles/marie_zrtp_ecdh255_rc | 53 +++++++++++++++++++++++++ tester/rcfiles/marie_zrtp_ecdh448_rc | 54 ++++++++++++++++++++++++++ tester/rcfiles/pauline_zrtp_ecdh255_rc | 52 +++++++++++++++++++++++++ tester/rcfiles/pauline_zrtp_ecdh448_rc | 53 +++++++++++++++++++++++++ 5 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 tester/rcfiles/marie_zrtp_ecdh255_rc create mode 100644 tester/rcfiles/marie_zrtp_ecdh448_rc create mode 100644 tester/rcfiles/pauline_zrtp_ecdh255_rc create mode 100644 tester/rcfiles/pauline_zrtp_ecdh448_rc diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 211a4086f..c70a50925 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -2669,7 +2669,10 @@ static void zrtp_cipher_call(void) { call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_aes256_rc", "pauline_tcp_rc"); } - +static void zrtp_key_agreement_call(void) { + call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_ecdh255_rc", "pauline_zrtp_ecdh255_rc"); + call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_ecdh448_rc", "pauline_zrtp_ecdh448_rc"); +} static void dtls_srtp_call(void) { call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE); @@ -6441,6 +6444,7 @@ test_t call_tests[] = { TEST_NO_TAG("ZRTP silent call", zrtp_silent_call), TEST_NO_TAG("ZRTP SAS call", zrtp_sas_call), TEST_NO_TAG("ZRTP Cipher call", zrtp_cipher_call), + TEST_NO_TAG("ZRTP Key Agreement call", zrtp_key_agreement_call), TEST_NO_TAG("DTLS SRTP call", dtls_srtp_call), TEST_NO_TAG("DTLS SRTP call with media relay", dtls_srtp_call_with_media_realy), TEST_NO_TAG("SRTP call with declined srtp", call_with_declined_srtp), diff --git a/tester/rcfiles/marie_zrtp_ecdh255_rc b/tester/rcfiles/marie_zrtp_ecdh255_rc new file mode 100644 index 000000000..54374fc58 --- /dev/null +++ b/tester/rcfiles/marie_zrtp_ecdh255_rc @@ -0,0 +1,53 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 + +composing_idle_timeout=1 +zrtp_cipher_suites=MS_ZRTP_CIPHER_AES3,MS_ZRTP_CIPHER_AES1 +zrtp_key_agreements_suites=MS_ZRTP_KEY_AGREEMENT_X255 + +[auth_info_0] +username=marie +userid=marie +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sip.example.org;transport=tcp +reg_route=sip.example.org;transport=tcp;lr +reg_identity="Super Marie" +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +[friend_0] +url="Paupoche" +pol=accept +subscribe=0 + + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=28070-38000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general diff --git a/tester/rcfiles/marie_zrtp_ecdh448_rc b/tester/rcfiles/marie_zrtp_ecdh448_rc new file mode 100644 index 000000000..76037ed1d --- /dev/null +++ b/tester/rcfiles/marie_zrtp_ecdh448_rc @@ -0,0 +1,54 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 + +composing_idle_timeout=1 +zrtp_cipher_suites=MS_ZRTP_CIPHER_AES3,MS_ZRTP_CIPHER_AES1 +zrtp_key_agreements_suites=MS_ZRTP_KEY_AGREEMENT_X448 +zrtp_hash_suites=MS_ZRTP_HASH_S384 + +[auth_info_0] +username=marie +userid=marie +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sip.example.org;transport=tcp +reg_route=sip.example.org;transport=tcp;lr +reg_identity="Super Marie" +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +[friend_0] +url="Paupoche" +pol=accept +subscribe=0 + + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=28070-38000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general diff --git a/tester/rcfiles/pauline_zrtp_ecdh255_rc b/tester/rcfiles/pauline_zrtp_ecdh255_rc new file mode 100644 index 000000000..5788c7add --- /dev/null +++ b/tester/rcfiles/pauline_zrtp_ecdh255_rc @@ -0,0 +1,52 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 + +composing_idle_timeout=1 +zrtp_cipher_suites=MS_ZRTP_CIPHER_AES3,MS_ZRTP_CIPHER_AES1 +zrtp_key_agreements_suites=MS_ZRTP_KEY_AGREEMENT_X255 + +[auth_info_0] +username=pauline +userid=pauline +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sip2.linphone.org;transport=tcp +reg_route=sip2.linphone.org;transport=tcp +reg_identity=sip:pauline@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +#[friend_0] +#url="Mariette" +#pol=accept +#subscribe=0 + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=39072-49000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general diff --git a/tester/rcfiles/pauline_zrtp_ecdh448_rc b/tester/rcfiles/pauline_zrtp_ecdh448_rc new file mode 100644 index 000000000..0eaefeac7 --- /dev/null +++ b/tester/rcfiles/pauline_zrtp_ecdh448_rc @@ -0,0 +1,53 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 + +composing_idle_timeout=1 +zrtp_cipher_suites=MS_ZRTP_CIPHER_AES3,MS_ZRTP_CIPHER_AES1 +zrtp_key_agreements_suites=MS_ZRTP_KEY_AGREEMENT_X448 +zrtp_hash_suites=MS_ZRTP_HASH_S384 + +[auth_info_0] +username=pauline +userid=pauline +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sip2.linphone.org;transport=tcp +reg_route=sip2.linphone.org;transport=tcp +reg_identity=sip:pauline@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +#[friend_0] +#url="Mariette" +#pol=accept +#subscribe=0 + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=39072-49000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general From fab2fc3a91157c6993aefeb58a5d005bc9e90570 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 19 Dec 2017 08:20:19 +0100 Subject: [PATCH 016/143] fix flexisip test to avoid crash in case of failure --- tester/flexisip_tester.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index d2bf2bca7..39ed75f78 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -486,18 +486,19 @@ static void call_forking_with_push_notification_single(void){ BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,1000)); /*marie accepts the call*/ - linphone_call_accept(linphone_core_get_current_call(marie->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,5000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - - liblinphone_tester_check_rtcp(pauline,marie); - - linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000)); - + if (BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc))) { + linphone_call_accept(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + + liblinphone_tester_check_rtcp(pauline,marie); + + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000)); + } linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); bctbx_list_free(lcs); From 95cac9b5793ecacdc44fb151db447a09a65d30f5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 19 Dec 2017 15:01:59 +0100 Subject: [PATCH 017/143] fix flexisip tester --- tester/flexisip_tester.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 39ed75f78..fa7f7ea35 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -535,22 +535,23 @@ static void call_forking_with_push_notification_multiple(void){ BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,5000)); /*marie2 accepts the call*/ - linphone_call_accept(linphone_core_get_current_call(marie2->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - - /*call to marie should be cancelled*/ - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); - - liblinphone_tester_check_rtcp(pauline,marie2); - - linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); - - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); - + if (BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie2->lc))) { + linphone_call_accept(linphone_core_get_current_call(marie2->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + + /*call to marie should be cancelled*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); + + liblinphone_tester_check_rtcp(pauline,marie2); + + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); + + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); + } linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); From 03520fcd5285634163abf3ccb985a376fb9c795d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 24 Apr 2018 18:11:20 +0200 Subject: [PATCH 018/143] Fixed group chat's Send File + Text message test --- coreapi/lime.c | 2 +- include/linphone/api/c-content.h | 7 +++++++ src/c-wrapper/api/c-content.cpp | 10 ++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/coreapi/lime.c b/coreapi/lime.c index d0c07cd89..788a6c893 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -925,7 +925,7 @@ int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngi if (!buffer || *size == 0) return lime_encryptFile(linphone_content_get_cryptoContext_address(content), NULL, 0, NULL, NULL); - size_t file_size = linphone_content_get_size(content); + size_t file_size = linphone_content_get_file_size(content); if (file_size == 0) { ms_warning("File size has not been set, encryption will fail if not done in one step (if file is larger than 16K)"); } else if (offset + *size < file_size) { diff --git a/include/linphone/api/c-content.h b/include/linphone/api/c-content.h index 214755d5b..d7fbdc577 100644 --- a/include/linphone/api/c-content.h +++ b/include/linphone/api/c-content.h @@ -136,6 +136,13 @@ LINPHONE_PUBLIC void linphone_content_set_string_buffer (LinphoneContent *conten */ LINPHONE_PUBLIC size_t linphone_content_get_size (const LinphoneContent *content); +/** + * Get the file size if content is either a FileContent or a FileTransferContent. + * @param[in] content #LinphoneContent object. + * @return The represented file size. + */ +LINPHONE_PUBLIC size_t linphone_content_get_file_size(const LinphoneContent *content); + /** * Set the content data size, excluding null character despite null character is always set for convenience. * @param[in] content #LinphoneContent object diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index f3bc9870b..c0d939126 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -125,17 +125,19 @@ void linphone_content_set_string_buffer (LinphoneContent *content, const char *b L_GET_CPP_PTR_FROM_C_OBJECT(content)->setBodyFromUtf8(L_C_TO_STRING(buffer)); } -size_t linphone_content_get_size (const LinphoneContent *content) { +size_t linphone_content_get_file_size(const LinphoneContent *content) { const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); size_t size = 0; if (c->isFile()) size = static_cast(c)->getFileSize(); else if (c->isFileTransfer()) size = static_cast(c)->getFileSize(); + return size; +} - if (size == 0) { - size = c->getSize(); - } +size_t linphone_content_get_size (const LinphoneContent *content) { + const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); + size_t size = c->getSize(); if (size == 0) { size = content->size; } From 402bba9df742fdd2e8be8150b54908278dd09968 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 6 Apr 2018 15:33:13 +0200 Subject: [PATCH 019/143] Use REFER to add a new participant to a client group chat room. --- src/chat/chat-room/client-group-chat-room.cpp | 79 ++++++++++++------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 5a9639621..c36022e94 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -318,22 +318,7 @@ void ClientGroupChatRoom::deleteFromDb () { } void ClientGroupChatRoom::addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) { - list addresses; - addresses.push_back(addr); - addParticipants(addresses, params, hasMedia); -} - -void ClientGroupChatRoom::addParticipants ( - const list &addresses, - const CallSessionParams *params, - bool hasMedia -) { L_D(); - L_D_T(RemoteConference, dConference); - - list addressesList = d->cleanAddressesList(addresses); - if (addressesList.empty()) - return; if ((getState() != ChatRoom::State::Instantiated) && (getState() != ChatRoom::State::Created)) { lError() << "Cannot add participants to the ClientGroupChatRoom in a state other than Instantiated or Created"; @@ -345,6 +330,41 @@ void ClientGroupChatRoom::addParticipants ( return; } + LinphoneCore *cCore = getCore()->getCCore(); + if (getState() == ChatRoom::State::Instantiated) { + list addressesList; + addressesList.push_back(addr); + Content content; + content.setBody(getResourceLists(addressesList)); + content.setContentType(ContentType::ResourceLists); + content.setContentDisposition(ContentDisposition::RecipientList); + + auto session = d->createSession(); + session->startInvite(nullptr, getSubject(), &content); + d->setState(ChatRoom::State::CreationPending); + } else { + SalReferOp *referOp = new SalReferOp(cCore->sal); + LinphoneAddress *lAddr = linphone_address_new(getConferenceAddress().asString().c_str()); + linphone_configure_op(cCore, referOp, lAddr, nullptr, true); + linphone_address_unref(lAddr); + Address referToAddr = addr; + referToAddr.setParam("text"); + referOp->send_refer(referToAddr.getPrivate()->getInternalAddress()); + referOp->unref(); + } +} + +void ClientGroupChatRoom::addParticipants ( + const list &addresses, + const CallSessionParams *params, + bool hasMedia +) { + L_D(); + + list addressesList = d->cleanAddressesList(addresses); + if (addressesList.empty()) + return; + if ((getState() == ChatRoom::State::Instantiated) && (addressesList.size() == 1) && (linphone_config_get_bool(linphone_core_get_config(L_GET_C_BACK_PTR(getCore())), @@ -353,23 +373,22 @@ void ClientGroupChatRoom::addParticipants ( d->capabilities |= ClientGroupChatRoom::Capabilities::OneToOne; } - Content content; - content.setBody(getResourceLists(addressesList)); - content.setContentType(ContentType::ResourceLists); - content.setContentDisposition(ContentDisposition::RecipientList); - // TODO: Activate compression - //if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) - // content.setContentEncoding("deflate"); - // TODO: Activate compression + if (getState() == ChatRoom::State::Instantiated) { + Content content; + content.setBody(getResourceLists(addressesList)); + content.setContentType(ContentType::ResourceLists); + content.setContentDisposition(ContentDisposition::RecipientList); + // TODO: Activate compression + //if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) + // content.setContentEncoding("deflate"); + // TODO: Activate compression - shared_ptr session = dConference->focus->getPrivate()->getSession(); - if (session) - session->update(nullptr, getSubject(), &content); - else { - session = d->createSession(); + auto session = d->createSession(); session->startInvite(nullptr, getSubject(), &content); - if (getState() == ChatRoom::State::Instantiated) - d->setState(ChatRoom::State::CreationPending); + d->setState(ChatRoom::State::CreationPending); + } else { + for (const auto &addr : addresses) + addParticipant(addr, params, hasMedia); } } From 93bfa1e20c37894c824fa380ec1d00e7b577ff3d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 10:26:32 +0200 Subject: [PATCH 020/143] Remove buggy Content-Type header in CPIM messages. --- src/chat/modifier/cpim-chat-message-modifier.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 03c35fed0..3f361b9c9 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -35,13 +35,6 @@ LINPHONE_BEGIN_NAMESPACE ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr &message, int &errorCode) { Cpim::Message cpimMessage; - // TODO: Remove this buggy Content-Type header - Cpim::GenericHeader cpimContentTypeHeader; - cpimContentTypeHeader.setName("Content-Type"); - cpimContentTypeHeader.setValue(ContentType::Cpim.asString()); - cpimMessage.addCpimHeader(cpimContentTypeHeader); - // TODO: Remove this buggy Content-Type header - Cpim::FromHeader cpimFromHeader; cpimFromHeader.setValue(cpimAddressAsString(message->getFromAddress())); cpimMessage.addMessageHeader(cpimFromHeader); @@ -74,14 +67,6 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetBodyAsString(); cpimMessage.setContent(contentBody); - // TODO: Remove this check because of buggy Content-Type header - if (!cpimMessage.isValid()) { - lError() << "[CPIM] Message is invalid: " << contentBody; - errorCode = 500; - return ChatMessageModifier::Result::Error; - } - // TODO: Remove this check because of buggy Content-Type header - Content newContent; newContent.setContentType(ContentType::Cpim); newContent.setBody(cpimMessage.asString()); From ca39d51bcbf30db438bbca88d1fcc67d28435dec Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Apr 2018 11:00:13 +0200 Subject: [PATCH 021/143] Delete client group existing one-to-one chat rooms at start-up to use basic chat rooms instead for the moment. --- src/db/main-db.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index f61f8875a..57fb441d4 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -47,7 +47,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE namespace { - constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 2); + constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 3); constexpr unsigned int ModuleVersionFriends = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyFriendsImport = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyHistoryImport = makeVersion(1, 0, 0); @@ -977,6 +977,8 @@ void MainDbPrivate::updateModuleVersion (const string &name, unsigned int versio } void MainDbPrivate::updateSchema () { + L_Q(); + soci::session *session = dbSession.getBackendSession(); unsigned int version = getModuleVersion("events"); @@ -987,6 +989,15 @@ void MainDbPrivate::updateSchema () { *session << "ALTER TABLE chat_message_participant ADD COLUMN state_change_time" + dbSession.timestampType() + " NOT NULL DEFAULT " + dbSession.currentTimestamp(); } + if (version < makeVersion(1, 0, 3)) { + // Remove client group one-to-one chat rooms for the moment as there are still some issues + // with them and we prefer to keep using basic chat rooms instead + const int &capabilities = ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Conference) + | ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::OneToOne); + *session << "DELETE FROM chat_room WHERE (capabilities & :capabilities1) == :capabilities2", + soci::use(capabilities), soci::use(capabilities); + linphone_config_set_bool(linphone_core_get_config(q->getCore()->getCCore()), "misc", "prefer_basic_chat_room", TRUE); + } } // ----------------------------------------------------------------------------- From 9c461f5fc08b1a067d551c19a3b4fea2b86e173f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Apr 2018 11:30:08 +0200 Subject: [PATCH 022/143] Activate body compression of INVITE used to create a client group chat room. --- src/chat/chat-room/client-group-chat-room.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index c36022e94..1c21542f6 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -378,10 +378,8 @@ void ClientGroupChatRoom::addParticipants ( content.setBody(getResourceLists(addressesList)); content.setContentType(ContentType::ResourceLists); content.setContentDisposition(ContentDisposition::RecipientList); - // TODO: Activate compression - //if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) - // content.setContentEncoding("deflate"); - // TODO: Activate compression + if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate")) + content.setContentEncoding("deflate"); auto session = d->createSession(); session->startInvite(nullptr, getSubject(), &content); From 1548254beaddb5669070a75aa632338e9dac4b7f Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 10:23:59 +0200 Subject: [PATCH 023/143] fix(Utils): getTmAsTimeT must return time_t --- src/utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index eb5ba94d2..897f5dc8f 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -188,7 +188,7 @@ tm Utils::getTimeTAsTm (time_t time) { return *gmtime_r(&time, &result); } -long Utils::getTmAsTimeT (const tm &time) { +time_t Utils::getTmAsTimeT (const tm &time) { return timegm(&const_cast(time)); } From f2924982edcd2a1086971155ceea6367a5844023 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 11:32:18 +0200 Subject: [PATCH 024/143] chore(doc): fix bad doc in many places + set right types when needed --- include/linphone/api/c-address.h | 4 +- include/linphone/api/c-chat-message.h | 223 ++++++++++++++------------ include/linphone/api/c-magic-search.h | 46 +++--- include/linphone/call_params.h | 2 +- include/linphone/callbacks.h | 2 +- include/linphone/core.h | 6 +- include/linphone/factory.h | 11 +- src/c-wrapper/api/c-magic-search.cpp | 80 +++++---- 8 files changed, 201 insertions(+), 173 deletions(-) diff --git a/include/linphone/api/c-address.h b/include/linphone/api/c-address.h index daf59a825..d4716c5b8 100644 --- a/include/linphone/api/c-address.h +++ b/include/linphone/api/c-address.h @@ -188,8 +188,8 @@ LINPHONE_PUBLIC bool_t linphone_address_weak_equal (const LinphoneAddress *addre LINPHONE_PUBLIC bool_t linphone_address_equal (const LinphoneAddress *address1, const LinphoneAddress *address2); /** -* Get the header encoded in the address. -* @param address the address + * Get the header encoded in the address. + * @param header_name the header name **/ LINPHONE_PUBLIC const char *linphone_address_get_header (const LinphoneAddress *address, const char *header_name); diff --git a/include/linphone/api/c-chat-message.h b/include/linphone/api/c-chat-message.h index 3bc7fe062..d37931c74 100644 --- a/include/linphone/api/c-chat-message.h +++ b/include/linphone/api/c-chat-message.h @@ -20,12 +20,12 @@ #ifndef _L_C_CHAT_MESSAGE_H_ #define _L_C_CHAT_MESSAGE_H_ -#include "linphone/api/c-types.h" #include "linphone/api/c-chat-message-cbs.h" +#include "linphone/api/c-types.h" #ifdef SQLITE_STORAGE_ENABLED -#include -#endif + #include +#endif // ifdef SQLITE_STORAGE_ENABLED // ============================================================================= @@ -37,7 +37,7 @@ typedef enum _LinphoneChatMessageDir{ // ============================================================================= #ifdef __cplusplus - extern "C" { + extern "C" { #endif // ifdef __cplusplus /** @@ -47,99 +47,101 @@ typedef enum _LinphoneChatMessageDir{ /** * Acquire a reference to the chat message. - * @param[in] cr The chat message. + * @param[in] msg #LinphoneChatMessage object. * @return The same chat message. -**/ -LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_message_ref(LinphoneChatMessage *msg); + */ +LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_message_ref (LinphoneChatMessage *msg); /** * Release reference to the chat message. - * @param[in] cr The chat message. -**/ -LINPHONE_PUBLIC void linphone_chat_message_unref(LinphoneChatMessage *msg); + * @param[in] msg #LinphoneChatMessage object. + */ +LINPHONE_PUBLIC void linphone_chat_message_unref (LinphoneChatMessage *msg); /** * Retrieve the user pointer associated with the chat message. - * @param[in] cr The chat message. + * @param[in] msg #LinphoneChatMessage object. * @return The user pointer associated with the chat message. -**/ -LINPHONE_PUBLIC void *linphone_chat_message_get_user_data(const LinphoneChatMessage *msg); + */ +LINPHONE_PUBLIC void *linphone_chat_message_get_user_data (const LinphoneChatMessage *msg); /** * Assign a user pointer to the chat message. - * @param[in] cr The chat message. + * @param[in] msg #LinphoneChatMessage object. * @param[in] ud The user pointer to associate with the chat message. -**/ -LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud); + */ +LINPHONE_PUBLIC void linphone_chat_message_set_user_data (LinphoneChatMessage *msg, void *ud); // ============================================================================= -LINPHONE_PUBLIC const char * linphone_chat_message_get_external_body_url(const LinphoneChatMessage *msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_external_body_url (const LinphoneChatMessage *msg); -LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url(LinphoneChatMessage *msg, const char *external_body_url); +LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url (LinphoneChatMessage *msg, const char *external_body_url); /** * Get the time the message was sent. + * @param[in] msg #LinphoneChatMessage object. */ -LINPHONE_PUBLIC time_t linphone_chat_message_get_time(const LinphoneChatMessage* msg); +LINPHONE_PUBLIC time_t linphone_chat_message_get_time (const LinphoneChatMessage *msg); /** * Returns TRUE if the message has been sent, returns FALSE if the message has been received. - * @param message the message -**/ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage* msg); + * @param[in] msg #LinphoneChatMessage object. + */ +LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing (LinphoneChatMessage *msg); /** * Get origin of the message - * @param[in] message #LinphoneChatMessage obj + * @param[in] msg #LinphoneChatMessage object. * @return #LinphoneAddress */ -LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(LinphoneChatMessage* msg); +LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_from_address (LinphoneChatMessage *msg); /** * Get destination of the message - * @param[in] message #LinphoneChatMessage obj + * @param[in] msg #LinphoneChatMessage object. * @return #LinphoneAddress */ -LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(LinphoneChatMessage* msg); +LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_to_address (LinphoneChatMessage *msg); /** * Get the content type of a chat message. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return The content type of the chat message */ -LINPHONE_PUBLIC const char * linphone_chat_message_get_content_type(LinphoneChatMessage *msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_content_type (LinphoneChatMessage *msg); /** * Set the content type of a chat message. * This content type must match a content that is text representable, such as text/plain, text/html or image/svg+xml. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @param[in] content_type The new content type of the chat message */ -LINPHONE_PUBLIC void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type); +LINPHONE_PUBLIC void linphone_chat_message_set_content_type (LinphoneChatMessage *msg, const char *content_type); /** * Get text part of this message + * @param[in] msg #LinphoneChatMessage object. * @return text or NULL if no text. * @deprecated use getTextContent() instead */ -LINPHONE_PUBLIC const char* linphone_chat_message_get_text(LinphoneChatMessage* msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_text (LinphoneChatMessage* msg); /** * Get the message identifier. * It is used to identify a message so that it can be notified as delivered and/or displayed. - * @param[in] cm #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return The message identifier. */ -LINPHONE_PUBLIC const char* linphone_chat_message_get_message_id(const LinphoneChatMessage *msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_message_id (const LinphoneChatMessage *msg); /** * Linphone message has an app-specific field that can store a text. The application might want * to use it for keeping data over restarts, like thumbnail image path. - * @param message #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @return the application-specific data or NULL if none has been stored. */ -LINPHONE_PUBLIC const char* linphone_chat_message_get_appdata(const LinphoneChatMessage* message); +LINPHONE_PUBLIC const char *linphone_chat_message_get_appdata (const LinphoneChatMessage *msg); /** * Linphone message has an app-specific field that can store a text. The application might want @@ -148,244 +150,253 @@ LINPHONE_PUBLIC const char* linphone_chat_message_get_appdata(const LinphoneChat * Invoking this function will attempt to update the message storage to reflect the changeif it is * enabled. * - * @param message #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @param data the data to store into the message */ -LINPHONE_PUBLIC void linphone_chat_message_set_appdata(LinphoneChatMessage* message, const char* data); +LINPHONE_PUBLIC void linphone_chat_message_set_appdata (LinphoneChatMessage *msg, const char *data); /** * Returns the chatroom this message belongs to. -**/ -LINPHONE_PUBLIC LinphoneChatRoom* linphone_chat_message_get_chat_room(const LinphoneChatMessage *msg); + * @param[in] msg #LinphoneChatMessage object. + */ +LINPHONE_PUBLIC LinphoneChatRoom *linphone_chat_message_get_chat_room (const LinphoneChatMessage *msg); /** * Get the path to the file to read from or write to during the file transfer. * @param[in] msg #LinphoneChatMessage object * @return The path to the file to use for the file transfer. */ -LINPHONE_PUBLIC const char * linphone_chat_message_get_file_transfer_filepath(LinphoneChatMessage *msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_file_transfer_filepath (LinphoneChatMessage *msg); // ============================================================================= /** * Get if a chat message is to be stored. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return Whether or not the message is to be stored */ -LINPHONE_PUBLIC bool_t linphone_chat_message_get_to_be_stored(const LinphoneChatMessage *message); +LINPHONE_PUBLIC bool_t linphone_chat_message_get_to_be_stored (const LinphoneChatMessage *msg); /** * Set if a chat message is to be stored. * This content type must match a content that is text representable, such as text/plain, text/html or image/svg+xml. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @param[in] to_be_stored Whether or not the chat message is to be stored */ -LINPHONE_PUBLIC void linphone_chat_message_set_to_be_stored(LinphoneChatMessage *message, bool_t to_be_stored); +LINPHONE_PUBLIC void linphone_chat_message_set_to_be_stored (LinphoneChatMessage *msg, bool_t to_be_stored); -LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *msg); +LINPHONE_PUBLIC unsigned int linphone_chat_message_store (LinphoneChatMessage *msg); /** * Get the state of the message - *@param message #LinphoneChatMessage obj - *@return #LinphoneChatMessageState + * @param[in] msg #LinphoneChatMessage object. + * @return #LinphoneChatMessageState */ -LINPHONE_PUBLIC LinphoneChatMessageState linphone_chat_message_get_state(const LinphoneChatMessage* message); +LINPHONE_PUBLIC LinphoneChatMessageState linphone_chat_message_get_state (const LinphoneChatMessage *msg); /** * Get if the message was encrypted when transfered - * @param[in] message #LinphoneChatMessage obj + * @param[in] msg #LinphoneChatMessage object. * @return whether the message was encrypted when transfered or not */ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_secured(LinphoneChatMessage *msg); +LINPHONE_PUBLIC bool_t linphone_chat_message_is_secured (LinphoneChatMessage *msg); /** * Linphone message can carry external body as defined by rfc2017 - * @param message #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @return external body url or NULL if not present. */ -LINPHONE_PUBLIC const char* linphone_chat_message_get_external_body_url(const LinphoneChatMessage* message); +LINPHONE_PUBLIC const char *linphone_chat_message_get_external_body_url (const LinphoneChatMessage *msg); /** * Linphone message can carry external body as defined by rfc2017 * - * @param message a #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @param url ex: access-type=URL; URL="http://www.foo.com/file" */ -LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url(LinphoneChatMessage* message,const char* url); +LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url (LinphoneChatMessage *msg,const char *url); /** * Get the file_transfer_information (used by call backs to recover informations during a rcs file transfer) * - * @param message #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @return a pointer to the #LinphoneContent structure or NULL if not present. */ -LINPHONE_PUBLIC LinphoneContent* linphone_chat_message_get_file_transfer_information(LinphoneChatMessage* message); +LINPHONE_PUBLIC LinphoneContent *linphone_chat_message_get_file_transfer_information (LinphoneChatMessage *msg); /** * Return whether or not a chat message is a file tranfer. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object * @return Whether or not the message is a file tranfer */ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer(LinphoneChatMessage *message); +LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer (LinphoneChatMessage *msg); /** * Return whether or not a chat message is a text. - * @param[in] message #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return Whether or not the message is a text */ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_text(LinphoneChatMessage *message); +LINPHONE_PUBLIC bool_t linphone_chat_message_is_text (LinphoneChatMessage *msg); /** * Start the download of the file from remote server * - * @param message #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @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); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_start_file_download ( + LinphoneChatMessage *msg, + LinphoneChatMessageStateChangedCb status_cb, + void *ud +); /** * Start the download of the file referenced in a #LinphoneChatMessage from remote server. - * @param[in] message #LinphoneChatMessage object. + * @param[in] msg #LinphoneChatMessage object. */ -LINPHONE_PUBLIC LinphoneStatus linphone_chat_message_download_file(LinphoneChatMessage *message); +LINPHONE_PUBLIC LinphoneStatus linphone_chat_message_download_file (LinphoneChatMessage *msg); /** * Cancel an ongoing file transfer attached to this message.(upload or download) - * @param msg #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. */ -LINPHONE_PUBLIC void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage* msg); +LINPHONE_PUBLIC void linphone_chat_message_cancel_file_transfer (LinphoneChatMessage *msg); /** * Send a chat message. - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. */ LINPHONE_PUBLIC void linphone_chat_message_send (LinphoneChatMessage *msg); /** * Resend a chat message if it is in the 'not delivered' state for whatever reason. - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @deprecated Use linphone_chat_message_send instead. * @donotwrap */ -LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_resend(LinphoneChatMessage *msg); +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_message_resend (LinphoneChatMessage *msg); -LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_peer_address(LinphoneChatMessage *msg); +LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_peer_address (LinphoneChatMessage *msg); /** * Returns the origin address of a message if it was a outgoing message, or the destination address if it was an incoming message. - *@param message #LinphoneChatMessage obj - *@return #LinphoneAddress + * @param[in] msg #LinphoneChatMessage object. + * @return #LinphoneAddress */ -LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_local_address(LinphoneChatMessage* message); +LINPHONE_PUBLIC const LinphoneAddress *linphone_chat_message_get_local_address (LinphoneChatMessage *msg); /** * Add custom headers to the message. - * @param message the message + * @param[in] msg #LinphoneChatMessage object. * @param header_name name of the header * @param header_value header value -**/ -LINPHONE_PUBLIC void linphone_chat_message_add_custom_header(LinphoneChatMessage* message, const char *header_name, const char *header_value); + */ +LINPHONE_PUBLIC void linphone_chat_message_add_custom_header ( + LinphoneChatMessage *msg, + const char *header_name, + const char *header_value +); /** * Retrieve a custom header value given its name. - * @param message the message + * @param[in] msg #LinphoneChatMessage object. * @param header_name header name searched -**/ -LINPHONE_PUBLIC const char * linphone_chat_message_get_custom_header(LinphoneChatMessage* message, const char *header_name); + */ +LINPHONE_PUBLIC const char * linphone_chat_message_get_custom_header (LinphoneChatMessage *msg, const char *header_name); /** * Removes a custom header from the message. - * @param msg the message + * @param[in] msg #LinphoneChatMessage object. * @param header_name name of the header to remove -**/ -LINPHONE_PUBLIC void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name); + */ +LINPHONE_PUBLIC void linphone_chat_message_remove_custom_header (LinphoneChatMessage *msg, const char *header_name); /** * Returns TRUE if the message has been read, otherwise returns FALSE. - * @param message the message -**/ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_read(LinphoneChatMessage* message); + * @param[in] msg #LinphoneChatMessage object. + */ +LINPHONE_PUBLIC bool_t linphone_chat_message_is_read (LinphoneChatMessage *msg); -LINPHONE_PUBLIC LinphoneReason linphone_chat_message_get_reason(LinphoneChatMessage* msg); +LINPHONE_PUBLIC LinphoneReason linphone_chat_message_get_reason (LinphoneChatMessage *msg); /** * Get full details about delivery error of a chat message. - * @param msg a #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @return a #LinphoneErrorInfo describing the details. -**/ -LINPHONE_PUBLIC const LinphoneErrorInfo *linphone_chat_message_get_error_info(const LinphoneChatMessage *msg); + */ +LINPHONE_PUBLIC const LinphoneErrorInfo *linphone_chat_message_get_error_info (const LinphoneChatMessage *msg); /** * Set the path to the file to read from or write to during the file transfer. - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @param[in] filepath The path to the file to use for the file transfer. */ -LINPHONE_PUBLIC void linphone_chat_message_set_file_transfer_filepath(LinphoneChatMessage *msg, const char *filepath); +LINPHONE_PUBLIC void linphone_chat_message_set_file_transfer_filepath (LinphoneChatMessage *msg, const char *filepath); /** * Fulfill a chat message char by char. Message linked to a Real Time Text Call send char in realtime following RFC 4103/T.140 * To commit a message, use #linphone_chat_room_send_message - * @param[in] msg #LinphoneChatMessage + * @param[in] msg #LinphoneChatMessage object. * @param[in] character T.140 char * @returns 0 if succeed. */ -LINPHONE_PUBLIC LinphoneStatus linphone_chat_message_put_char(LinphoneChatMessage *msg,uint32_t character); +LINPHONE_PUBLIC LinphoneStatus linphone_chat_message_put_char (LinphoneChatMessage *msg, uint32_t character); /** * Get the #LinphoneChatMessageCbs object associated with the LinphoneChatMessage. - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return The #LinphoneChatMessageCbs object associated with the LinphoneChatMessage. */ -LINPHONE_PUBLIC LinphoneChatMessageCbs * linphone_chat_message_get_callbacks(const LinphoneChatMessage *msg); +LINPHONE_PUBLIC LinphoneChatMessageCbs *linphone_chat_message_get_callbacks (const LinphoneChatMessage *msg); /** * Adds a content to the ChatMessage - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @param[in] c_content #LinphoneContent object */ -LINPHONE_PUBLIC void linphone_chat_message_add_text_content(LinphoneChatMessage *msg, const char *c_content); +LINPHONE_PUBLIC void linphone_chat_message_add_text_content (LinphoneChatMessage *msg, const char *c_content); /** * Returns true if the chat message has a text content - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return true if it has one, false otherwise */ -LINPHONE_PUBLIC bool_t linphone_chat_message_has_text_content(const LinphoneChatMessage *msg); +LINPHONE_PUBLIC bool_t linphone_chat_message_has_text_content (const LinphoneChatMessage *msg); /** * Gets the text content if available as a string - * @param[in] msg #LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return the #LinphoneContent buffer if available, null otherwise */ -LINPHONE_PUBLIC const char* linphone_chat_message_get_text_content(const LinphoneChatMessage *msg); +LINPHONE_PUBLIC const char *linphone_chat_message_get_text_content (const LinphoneChatMessage *msg); /** * Gets whether or not a file is currently being downloaded or uploaded - * @param[in] msg LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return true if download or upload is in progress, false otherwise */ -LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *msg); +LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer_in_progress (LinphoneChatMessage *msg); /** * Gets the list of participants that displayed this message and the time at which they did. - * @param[in] msg LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return \bctbx_list{LinphoneParticipantImdnState} */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_displayed (const LinphoneChatMessage *msg); /** * Gets the list of participants that did not receive this message. - * @param[in] msg LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return \bctbx_list{LinphoneParticipantImdnState} */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_not_received (const LinphoneChatMessage *msg); /** * Gets the list of participants that received this message and the time at which they did. - * @param[in] msg LinphoneChatMessage object + * @param[in] msg #LinphoneChatMessage object. * @return \bctbx_list{LinphoneParticipantImdnState} */ LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_received (const LinphoneChatMessage *msg); diff --git a/include/linphone/api/c-magic-search.h b/include/linphone/api/c-magic-search.h index e45bc2605..92b667346 100644 --- a/include/linphone/api/c-magic-search.h +++ b/include/linphone/api/c-magic-search.h @@ -22,9 +22,11 @@ #include "linphone/api/c-types.h" +// ============================================================================= + #ifdef __cplusplus -extern "C" { -#endif + extern "C" { +#endif // ifdef __cplusplus /** * @addtogroup misc @@ -34,88 +36,88 @@ extern "C" { /** * Constructs a LinphoneMagicSearch object **/ -LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_new(LinphoneCore *lc); +LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_new (LinphoneCore *lc); /** * Increment reference count of LinphoneMagicSearch object. **/ -LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_ref(LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC LinphoneMagicSearch *linphone_magic_search_ref (LinphoneMagicSearch *magic_search); /** * Decrement reference count of LinphoneMagicSearch object. When dropped to zero, memory is freed. **/ -LINPHONE_PUBLIC void linphone_magic_search_unref(LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC void linphone_magic_search_unref (LinphoneMagicSearch *magic_search); /** * Set the minimum value used to calculate the weight in search * @param[in] weight minimum weight **/ -LINPHONE_PUBLIC void linphone_magic_search_set_min_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight); +LINPHONE_PUBLIC void linphone_magic_search_set_min_weight (LinphoneMagicSearch *magic_search, unsigned int weight); /** * @return the minimum value used to calculate the weight in search **/ -LINPHONE_PUBLIC unsigned int linphone_magic_search_get_min_weight(const LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC unsigned int linphone_magic_search_get_min_weight (const LinphoneMagicSearch *magic_search); /** * Set the maximum value used to calculate the weight in search * @param[in] weight maximum weight **/ -LINPHONE_PUBLIC void linphone_magic_search_set_max_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight); +LINPHONE_PUBLIC void linphone_magic_search_set_max_weight (LinphoneMagicSearch *magic_search, unsigned int weight); /** * @return the maximum value used to calculate the weight in search **/ -LINPHONE_PUBLIC unsigned int linphone_magic_search_get_max_weight(const LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC unsigned int linphone_magic_search_get_max_weight (const LinphoneMagicSearch *magic_search); /** * @return the delimiter used to find matched filter word **/ -LINPHONE_PUBLIC const char *linphone_magic_search_get_delimiter(const LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC const char *linphone_magic_search_get_delimiter (const LinphoneMagicSearch *magic_search); /** * Set the delimiter used to find matched filter word * @param[in] delimiter delimiter (example "-_.,") **/ -LINPHONE_PUBLIC void linphone_magic_search_set_delimiter(LinphoneMagicSearch *magicSearch, const char *delimiter); +LINPHONE_PUBLIC void linphone_magic_search_set_delimiter (LinphoneMagicSearch *magic_search, const char *delimiter); /** * @return if the delimiter search is used **/ -LINPHONE_PUBLIC bool_t linphone_magic_search_get_use_delimiter(LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC bool_t linphone_magic_search_get_use_delimiter (LinphoneMagicSearch *magic_search); /** * Enable or disable the delimiter in search * @param[in] enable **/ -LINPHONE_PUBLIC void linphone_magic_search_set_use_delimiter(LinphoneMagicSearch *magicSearch, bool_t enable); +LINPHONE_PUBLIC void linphone_magic_search_set_use_delimiter (LinphoneMagicSearch *magic_search, bool_t enable); /** * @return the number of the maximum SearchResult which will be return **/ -LINPHONE_PUBLIC unsigned int linphone_magic_search_get_search_limit(const LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC unsigned int linphone_magic_search_get_search_limit (const LinphoneMagicSearch *magic_search); /** * Set the number of the maximum SearchResult which will be return * @param[in] limit **/ -LINPHONE_PUBLIC void linphone_magic_search_set_search_limit(LinphoneMagicSearch *magicSearch, const unsigned int limit); +LINPHONE_PUBLIC void linphone_magic_search_set_search_limit (LinphoneMagicSearch *magic_search, unsigned int limit); /** * @return if the search is limited **/ -LINPHONE_PUBLIC bool_t linphone_magic_search_get_limited_search(const LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC bool_t linphone_magic_search_get_limited_search (const LinphoneMagicSearch *magic_search); /** * Enable or disable the limited search * @param[in] limited **/ -LINPHONE_PUBLIC void linphone_magic_search_set_limited_search(LinphoneMagicSearch *magicSearch, const bool_t limited); +LINPHONE_PUBLIC void linphone_magic_search_set_limited_search (LinphoneMagicSearch *magic_search, bool_t limited); /** * Reset the cache to begin a new search **/ -LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache(LinphoneMagicSearch *magicSearch); +LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache (LinphoneMagicSearch *magic_search); /** * Create a sorted list of SearchResult from SipUri, Contact name, @@ -124,13 +126,17 @@ LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache(LinphoneMagicSearc * During the first search, a cache is created and used for the next search * Use linphone_magic_search_reset_search_cache() to begin a new search * @param[in] filter word we search - * @param[in] withDomain domain which we want to search only + * @param[in] domain domain which we want to search only * - "" for searching in all contact * - "*" for searching in contact with sip SipUri * - "yourdomain" for searching in contact from "yourdomain" domain * @return sorted list of \bctbx_list{LinphoneSearchResult} **/ -LINPHONE_PUBLIC bctbx_list_t* linphone_magic_search_get_contact_list_from_filter(LinphoneMagicSearch *magicSearch, const char *filter, const char *withDomain); +LINPHONE_PUBLIC bctbx_list_t* linphone_magic_search_get_contact_list_from_filter ( + LinphoneMagicSearch *magic_search, + const char *filter, + const char *domain +); /** * @} diff --git a/include/linphone/call_params.h b/include/linphone/call_params.h index 2da8b369e..37cf092dc 100644 --- a/include/linphone/call_params.h +++ b/include/linphone/call_params.h @@ -177,7 +177,7 @@ LINPHONE_PUBLIC float linphone_call_params_get_sent_framerate(const LinphoneCall LINPHONE_PUBLIC const LinphoneVideoDefinition * linphone_call_params_get_sent_video_definition(const LinphoneCallParams *cp); /** - * @biref Gets the size of the video that is sent. + * @brief Gets the size of the video that is sent. * @param[in] cp #LinphoneCalParams object * @return The sent video size or MS_VIDEO_SIZE_UNKNOWN if not available. * @deprecated Use #linphone_call_params_get_sent_video_definition() instead. Deprecated since 2017-03-28. diff --git a/include/linphone/callbacks.h b/include/linphone/callbacks.h index 319a9a4a9..adfdee602 100644 --- a/include/linphone/callbacks.h +++ b/include/linphone/callbacks.h @@ -522,7 +522,7 @@ typedef void (*LinphoneCoreCbsEcCalibrationResultCb)(LinphoneCore *lc, LinphoneE typedef void (*LinphoneCoreCbsEcCalibrationAudioInitCb)(LinphoneCore *lc); /** - * @biref Function prototype used by #linphone_core_cbs_set_ec_calibrator_audio_uninit(). + * @brief Function prototype used by #linphone_core_cbs_set_ec_calibrator_audio_uninit(). * @param lc The core. */ typedef void (*LinphoneCoreCbsEcCalibrationAudioUninitCb)(LinphoneCore *lc); diff --git a/include/linphone/core.h b/include/linphone/core.h index b68a2f362..b439cda8e 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -803,7 +803,7 @@ LINPHONE_PUBLIC char * linphone_core_compress_log_collection(void); LINPHONE_PUBLIC void linphone_core_reset_log_collection(void); /** - * @bref Define a log handler. + * @brief Define a log handler. * @param logfunc The function pointer of the log handler. * @deprecated Use #linphone_logging_service_cbs_set_log_message_written() instead. Deprecated since 2017-10-10. * @donotwrap @@ -1274,7 +1274,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_decline_call(Li LINPHONE_PUBLIC LinphoneStatus linphone_core_terminate_all_calls(LinphoneCore *lc); /** - * @biref Pauses the call. If a music file has been setup using linphone_core_set_play_file(), + * @brief Pauses the call. If a music file has been setup using linphone_core_set_play_file(), * this file will be played to the remote user. * * The only way to resume a paused call is to call linphone_core_resume_call(). @@ -3507,7 +3507,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_preferred_video_size( LINPHONE_PUBLIC void linphone_core_set_preview_video_definition(LinphoneCore *lc, LinphoneVideoDefinition *vdef); /** - * @biref Sets the video size for the captured (preview) video. + * @brief Sets the video size for the captured (preview) video. * * This method is for advanced usage where a video capture must be set independently of the size of the stream actually sent through the call. * This allows for example to have the preview window with HD resolution even if due to bandwidth constraint the sent video size is small. diff --git a/include/linphone/factory.h b/include/linphone/factory.h index 7722ea612..2389b9793 100644 --- a/include/linphone/factory.h +++ b/include/linphone/factory.h @@ -416,7 +416,7 @@ LINPHONE_PUBLIC LinphoneBuffer *linphone_factory_create_buffer_from_string(Linph /** * Creates an object #LinphoneConfig * @param[in] factory the #LinphoneFactory - * @param[in] the path of the config + * @param[in] path the path of the config * @return a #LinphoneConfig */ LINPHONE_PUBLIC LinphoneConfig *linphone_factory_create_config(LinphoneFactory *factory, const char *path); @@ -424,8 +424,8 @@ LINPHONE_PUBLIC LinphoneConfig *linphone_factory_create_config(LinphoneFactory * /** * Creates an object #LinphoneConfig * @param[in] factory the #LinphoneFactory - * @param[in] the path of the config - * @param[in] the path of the factory + * @param[in] path the path of the config + * @param[in] path the path of the factory * @return a #LinphoneConfig */ LINPHONE_PUBLIC LinphoneConfig *linphone_factory_create_config_with_factory(LinphoneFactory *factory, const char *path, const char *factory_path); @@ -433,6 +433,7 @@ LINPHONE_PUBLIC LinphoneConfig *linphone_factory_create_config_with_factory(Linp /** * Creates an object #LinphoneConfig * @param[in] factory the #LinphoneFactory + * @param[in] data the config data * @return a #LinphoneConfig */ LINPHONE_PUBLIC LinphoneConfig *linphone_factory_create_config_from_string(LinphoneFactory *factory, const char *data); @@ -454,14 +455,14 @@ LINPHONE_PUBLIC void linphone_factory_set_user_data(LinphoneFactory *factory, vo /** * Sets the log collection path * @param[in] factory the #LinphoneFactory - * @param[in] the path of the logs + * @param[in] path the path of the logs */ LINPHONE_PUBLIC void linphone_factory_set_log_collection_path(LinphoneFactory *factory, const char *path); /** * Enables or disables log collection * @param[in] factory the #LinphoneFactory - * @param[in] the policy for log collection + * @param[in] state the policy for log collection */ LINPHONE_PUBLIC void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLogCollectionState state); diff --git a/src/c-wrapper/api/c-magic-search.cpp b/src/c-wrapper/api/c-magic-search.cpp index 028a64ba1..f5f9ebebd 100644 --- a/src/c-wrapper/api/c-magic-search.cpp +++ b/src/c-wrapper/api/c-magic-search.cpp @@ -17,15 +17,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "search/magic-search.h" #include "c-wrapper/c-wrapper.h" +#include "search/magic-search.h" + +// ============================================================================= using namespace std; L_DECLARE_C_OBJECT_IMPL(MagicSearch); LinphoneMagicSearch *linphone_core_create_magic_search(LinphoneCore *lc) { - shared_ptr cppPtr = make_shared(L_GET_CPP_PTR_FROM_C_OBJECT(lc)); + shared_ptr cppPtr = make_shared( + L_GET_CPP_PTR_FROM_C_OBJECT(lc) + ); LinphoneMagicSearch *object = L_INIT(MagicSearch); L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr); @@ -36,67 +40,73 @@ LinphoneMagicSearch *linphone_magic_search_new(LinphoneCore *lc) { return linphone_core_create_magic_search(lc); } -LinphoneMagicSearch *linphone_magic_search_ref(LinphoneMagicSearch *magicSearch) { - belle_sip_object_ref(magicSearch); - return magicSearch; +LinphoneMagicSearch *linphone_magic_search_ref (LinphoneMagicSearch *magic_search) { + belle_sip_object_ref(magic_search); + return magic_search; } -void linphone_magic_search_unref(LinphoneMagicSearch *magicSearch) { - belle_sip_object_unref(magicSearch); +void linphone_magic_search_unref (LinphoneMagicSearch *magic_search) { + belle_sip_object_unref(magic_search); } -void linphone_magic_search_set_min_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setMinWeight(weight); +void linphone_magic_search_set_min_weight (LinphoneMagicSearch *magic_search, unsigned int weight) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setMinWeight(weight); } -unsigned int linphone_magic_search_get_min_weight(const LinphoneMagicSearch *magicSearch) { - return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getMinWeight(); +unsigned int linphone_magic_search_get_min_weight (const LinphoneMagicSearch *magic_search) { + return L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getMinWeight(); } -void linphone_magic_search_set_max_weight(LinphoneMagicSearch *magicSearch, const unsigned int weight) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setMaxWeight(weight); +void linphone_magic_search_set_max_weight (LinphoneMagicSearch *magic_search, unsigned int weight) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setMaxWeight(weight); } -unsigned int linphone_magic_search_get_max_weight(const LinphoneMagicSearch *magicSearch) { - return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getMaxWeight(); +unsigned int linphone_magic_search_get_max_weight (const LinphoneMagicSearch *magic_search) { + return L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getMaxWeight(); } -const char *linphone_magic_search_get_delimiter(const LinphoneMagicSearch *magicSearch) { - return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getDelimiter()); +const char *linphone_magic_search_get_delimiter (const LinphoneMagicSearch *magic_search) { + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getDelimiter()); } -void linphone_magic_search_set_delimiter(LinphoneMagicSearch *magicSearch, const char *delimiter) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setDelimiter(L_C_TO_STRING(delimiter)); +void linphone_magic_search_set_delimiter (LinphoneMagicSearch *magic_search, char *delimiter) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setDelimiter(L_C_TO_STRING(delimiter)); } -bool_t linphone_magic_search_get_use_delimiter(LinphoneMagicSearch *magicSearch) { - return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getUseDelimiter(); +bool_t linphone_magic_search_get_use_delimiter (LinphoneMagicSearch *magic_search) { + return L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getUseDelimiter(); } -void linphone_magic_search_set_use_delimiter(LinphoneMagicSearch *magicSearch, bool_t enable) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setUseDelimiter(enable); +void linphone_magic_search_set_use_delimiter (LinphoneMagicSearch *magic_search, bool_t enable) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setUseDelimiter(enable); } -unsigned int linphone_magic_search_get_search_limit(const LinphoneMagicSearch *magicSearch) { - return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getSearchLimit(); +unsigned int linphone_magic_search_get_search_limit (const LinphoneMagicSearch *magic_search) { + return L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getSearchLimit(); } -void linphone_magic_search_set_search_limit(LinphoneMagicSearch *magicSearch, const unsigned int limit) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setSearchLimit(limit); +void linphone_magic_search_set_search_limit (LinphoneMagicSearch *magic_search, unsigned int limit) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setSearchLimit(limit); } -bool_t linphone_magic_search_get_limited_search(const LinphoneMagicSearch *magicSearch) { - return L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getLimitedSearch(); +bool_t linphone_magic_search_get_limited_search (const LinphoneMagicSearch *magic_search) { + return L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getLimitedSearch(); } -void linphone_magic_search_set_limited_search(LinphoneMagicSearch *magicSearch, const bool_t limited) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->setLimitedSearch(limited); +void linphone_magic_search_set_limited_search (LinphoneMagicSearch *magic_search, bool_t limited) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setLimitedSearch(limited); } -void linphone_magic_search_reset_search_cache(LinphoneMagicSearch *magicSearch) { - L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->resetSearchCache(); +void linphone_magic_search_reset_search_cache (LinphoneMagicSearch *magic_search) { + L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->resetSearchCache(); } -bctbx_list_t* linphone_magic_search_get_contact_list_from_filter(LinphoneMagicSearch *magicSearch, const char *filter, const char *withDomain) { - return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(magicSearch)->getContactListFromFilter(L_C_TO_STRING(filter), L_C_TO_STRING(withDomain))); +bctbx_list_t* linphone_magic_search_get_contact_list_from_filter ( + LinphoneMagicSearch *magic_search, + const char *filter, + const char *domain +) { + return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getContactListFromFilter( + L_C_TO_STRING(filter), L_C_TO_STRING(domain) + )); } From 838fdcc342c70288dd0774277ef0864420a3b08a Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 12:01:44 +0200 Subject: [PATCH 025/143] fix(c-magic-search): add missing const on delimiter parameter in linphone_magic_search_set_delimiter --- src/c-wrapper/api/c-magic-search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/c-wrapper/api/c-magic-search.cpp b/src/c-wrapper/api/c-magic-search.cpp index f5f9ebebd..cfdafb1b1 100644 --- a/src/c-wrapper/api/c-magic-search.cpp +++ b/src/c-wrapper/api/c-magic-search.cpp @@ -69,7 +69,7 @@ const char *linphone_magic_search_get_delimiter (const LinphoneMagicSearch *magi return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->getDelimiter()); } -void linphone_magic_search_set_delimiter (LinphoneMagicSearch *magic_search, char *delimiter) { +void linphone_magic_search_set_delimiter (LinphoneMagicSearch *magic_search, const char *delimiter) { L_GET_CPP_PTR_FROM_C_OBJECT(magic_search)->setDelimiter(L_C_TO_STRING(delimiter)); } From db15df1b2d5643d9d481048d53b840e1ee4f6b9d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 12:10:12 +0200 Subject: [PATCH 026/143] fix(MainDb): do not use == in sql query --- src/db/main-db.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 57fb441d4..b153a4e2e 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -994,7 +994,7 @@ void MainDbPrivate::updateSchema () { // with them and we prefer to keep using basic chat rooms instead const int &capabilities = ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Conference) | ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::OneToOne); - *session << "DELETE FROM chat_room WHERE (capabilities & :capabilities1) == :capabilities2", + *session << "DELETE FROM chat_room WHERE (capabilities & :capabilities1) = :capabilities2", soci::use(capabilities), soci::use(capabilities); linphone_config_set_bool(linphone_core_get_config(q->getCore()->getCCore()), "misc", "prefer_basic_chat_room", TRUE); } From 86614b1a15e09205fde5cc8f56557bd377655052 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Apr 2018 14:52:25 +0200 Subject: [PATCH 027/143] Fix handling of file transfer content key. --- src/c-wrapper/api/c-content.cpp | 8 ++------ .../modifier/file-transfer-chat-message-modifier.cpp | 10 +++++----- src/content/file-transfer-content.cpp | 5 ----- src/content/file-transfer-content.h | 1 - 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index c0d939126..0671204ff 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -40,7 +40,6 @@ L_DECLARE_C_CLONABLE_OBJECT_IMPL_WITH_XTORS(Content, void *cryptoContext; // Used to encrypt file for RCS file transfer. mutable size_t size; - mutable char *key; struct Cache { string name; @@ -213,15 +212,12 @@ const char *linphone_content_get_custom_header (const LinphoneContent *content, } const char *linphone_content_get_key (const LinphoneContent *content) { - if (content->key) bctbx_free(content->key); - const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content); if (c->isFileTransfer()) { const LinphonePrivate::FileTransferContent *ftc = static_cast(c); - content->key = bctbx_strdup(ftc->getFileKeyAsString()); + return ftc->getFileKey().data(); } - - return content->key; + return nullptr; } size_t linphone_content_get_key_size (const LinphoneContent *content) { diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index ad17cfff7..f73581c6b 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -318,9 +318,9 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h const char *body = belle_sip_message_get_body((belle_sip_message_t *)event->response); if (body && strlen(body) > 0) { // if we have an encryption key for the file, we must insert it into the msg and restore the correct filename - const char *content_key = fileTransferContent->getFileKeyAsString(); - size_t content_key_size = fileTransferContent->getFileKey().size(); - if (content_key_size > 0) { + const unsigned char *contentKey = reinterpret_cast(fileTransferContent->getFileKey().data()); + size_t contentKeySize = fileTransferContent->getFileKeySize(); + if (contentKeySize > 0) { // parse the msg body xmlDocPtr xmlMessageBody = xmlParseDoc((const xmlChar *)body); @@ -337,11 +337,11 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h xmlNodePtr fileInfoNodeChildren = cur->xmlChildrenNode; // convert key to base64 size_t b64Size; - bctbx_base64_encode(nullptr, &b64Size, (unsigned char *)content_key, content_key_size); + bctbx_base64_encode(nullptr, &b64Size, contentKey, contentKeySize); unsigned char *keyb64 = (unsigned char *)ms_malloc0(b64Size + 1); int xmlStringLength; - bctbx_base64_encode(keyb64, &b64Size, (unsigned char *)content_key, content_key_size); + bctbx_base64_encode(keyb64, &b64Size, contentKey, contentKeySize); keyb64[b64Size] = '\0'; // libxml need a null terminated string // add the node containing the key to the file-info node diff --git a/src/content/file-transfer-content.cpp b/src/content/file-transfer-content.cpp index 2b8e228bb..8bf22f7a0 100644 --- a/src/content/file-transfer-content.cpp +++ b/src/content/file-transfer-content.cpp @@ -164,11 +164,6 @@ const vector &FileTransferContent::getFileKey () const { return d->fileKey; } -const char *FileTransferContent::getFileKeyAsString() const { - L_D(); - return d->fileKey.data(); -} - size_t FileTransferContent::getFileKeySize() const { L_D(); return d->fileKey.size(); diff --git a/src/content/file-transfer-content.h b/src/content/file-transfer-content.h index 1904e11c5..4ae07867b 100644 --- a/src/content/file-transfer-content.h +++ b/src/content/file-transfer-content.h @@ -59,7 +59,6 @@ public: void setFileKey (const char *key, size_t size); const std::vector &getFileKey () const; - const char *getFileKeyAsString () const; size_t getFileKeySize() const; bool isFile () const override; From 4958c62194350d38115011293c2bd4a5f02da348 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 16:18:04 +0200 Subject: [PATCH 028/143] fix(linphonecore): avoid leaks when missing codecs are added --- coreapi/linphonecore.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2a92c87e8..a414450e8 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1597,10 +1597,9 @@ static SalStreamType payload_type_get_stream_type(const PayloadType *pt){ /*this function merges the payload types from the codec default list with the list read from configuration file. * If a new codec becomes supported in Liblinphone or if the list from configuration file is empty or incomplete, all the supported codecs are added - * automatically. This 'l' list is entirely destroyed and rewritten.*/ + * automatically. This 'l' list is entirely rewritten.*/ static bctbx_list_t *add_missing_supported_codecs(LinphoneCore *lc, const bctbx_list_t *default_list, bctbx_list_t *l){ const bctbx_list_t *elem; - bctbx_list_t *newlist; PayloadType *last_seen = NULL; for(elem=default_list; elem!=NULL; elem=elem->next){ @@ -1623,41 +1622,33 @@ static bctbx_list_t *add_missing_supported_codecs(LinphoneCore *lc, const bctbx_ last_seen = (PayloadType*)elem2->data; } } - newlist=bctbx_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); - bctbx_list_free(l); - return newlist; + return l; } /* * This function adds missing codecs, if required by configuration. - * This 'l' list is entirely destroyed and a new list is returned. + * This 'l' list is entirely rewritten if required. */ -static bctbx_list_t *handle_missing_codecs(LinphoneCore *lc, const bctbx_list_t *default_list, bctbx_list_t *l, MSFormatType ft){ +static bctbx_list_t *handle_missing_codecs (LinphoneCore *lc, const bctbx_list_t *default_list, bctbx_list_t *l, MSFormatType ft) { const char *name = "unknown"; - int add_missing; - bctbx_list_t *ret; - switch(ft){ + switch (ft) { case MSAudio: name = "add_missing_audio_codecs"; - break; + break; case MSVideo: name = "add_missing_video_codecs"; - break; + break; case MSText: name = "add_missing_text_codecs"; - break; + break; case MSUnknownMedia: break; } - add_missing = lp_config_get_int(lc->config, "misc", name, 1); - if (add_missing){ - ret = add_missing_supported_codecs(lc, default_list, l); - }else{ - ret = bctbx_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); - bctbx_list_free(l); - } - return ret; + + if (lp_config_get_int(lc->config, "misc", name, 1)) + return add_missing_supported_codecs(lc, default_list, l); + return l; } static bctbx_list_t *codec_append_if_new(bctbx_list_t *l, PayloadType *pt){ @@ -5971,9 +5962,9 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){ static void codecs_config_uninit(LinphoneCore *lc) { _linphone_core_codec_config_write(lc); - bctbx_list_free_with_data(lc->codecs_conf.audio_codecs, (void (*)(void*))payload_type_destroy); - bctbx_list_free_with_data(lc->codecs_conf.video_codecs, (void (*)(void*))payload_type_destroy); - bctbx_list_free_with_data(lc->codecs_conf.text_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free(lc->codecs_conf.audio_codecs); + bctbx_list_free(lc->codecs_conf.video_codecs); + bctbx_list_free(lc->codecs_conf.text_codecs); } void friends_config_uninit(LinphoneCore* lc) From 94abc311722112b7ba9283c7aac00a45f852d812 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 16:25:21 +0200 Subject: [PATCH 029/143] fix(logging): unref correctly in linphone_logging_service_unref --- coreapi/logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/logging.c b/coreapi/logging.c index fd3f12f36..5eef11ce7 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -158,7 +158,7 @@ LinphoneLoggingService *linphone_logging_service_ref(LinphoneLoggingService *ser } void linphone_logging_service_unref(LinphoneLoggingService *service) { - belle_sip_object_ref(service); + belle_sip_object_unref(service); } static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) { From 6fcc907636cfd70d180f2837db73eb00ecdbc45e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 16:45:53 +0200 Subject: [PATCH 030/143] fix(ContentManager): avoid memory leak in contentListToMultipart --- src/content/content-manager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index 0f10cfaa4..fea47e8f6 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -71,12 +71,13 @@ Content ContentManager::contentListToMultipart (const list &contents) sal_body_handler_set_type(sbh, ContentType::Multipart.getType().c_str()); sal_body_handler_set_subtype(sbh, ContentType::Multipart.getSubType().c_str()); sal_body_handler_set_content_type_parameter(sbh, "boundary", MultipartBoundary); + LinphoneContent *cContent = linphone_content_from_sal_body_handler(sbh); - Content *content = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); - Content returnContent = *content; belle_sip_object_unref(mpbh); - return returnContent; + Content content = *L_GET_CPP_PTR_FROM_C_OBJECT(cContent); + linphone_content_unref(cContent); + return content; } LINPHONE_END_NAMESPACE From ab471105682506e5d445816b20e377f9e8e2917f Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 16:54:43 +0200 Subject: [PATCH 031/143] fix(c-content): avoid memory leak in sal_body_handler_from_content --- src/c-wrapper/api/c-content.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 0671204ff..a9fdb1ea5 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -315,6 +315,7 @@ SalBodyHandler *sal_body_handler_from_content (const LinphoneContent *content) { const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue()); belle_sip_multipart_body_handler_t *bh = belle_sip_multipart_body_handler_new_from_buffer(buffer, size, boundary); body_handler = (SalBodyHandler *)BELLE_SIP_BODY_HANDLER(bh); + bctbx_free(buffer); } else { body_handler = sal_body_handler_new(); sal_body_handler_set_data(body_handler, belle_sip_strdup(linphone_content_get_string_buffer(content))); From 19137ae9f7a1e312137cb4bedf0cb6ede0f2c312 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 16:55:05 +0200 Subject: [PATCH 032/143] fix(content-manager): avoid memory leak in multipartToContentList --- src/content/content-manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index fea47e8f6..5d79c7ac7 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -41,7 +41,7 @@ LINPHONE_BEGIN_NAMESPACE list ContentManager::multipartToContentList (const Content &content) { LinphoneContent *cContent = L_GET_C_BACK_PTR(&content); - SalBodyHandler *sbh = sal_body_handler_ref(sal_body_handler_from_content(cContent)); + SalBodyHandler *sbh = sal_body_handler_from_content(cContent); list contents; for (const belle_sip_list_t *parts = sal_body_handler_get_parts(sbh); parts; parts = parts->next) { From ce2b853baeab90fa22ec1410bbdd52d520ba680e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 17:19:06 +0200 Subject: [PATCH 033/143] fix(Logging): free log handler, avoid memory leak --- coreapi/logging.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coreapi/logging.c b/coreapi/logging.c index 5eef11ce7..7c4a213b3 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -127,6 +127,7 @@ static void _log_handler_on_message_written_cb(void *info,const char *domain, Bc static void _log_handler_destroy_cb(bctbx_log_handler_t *handler) { LinphoneLoggingService *service = (LinphoneLoggingService *)bctbx_log_handler_get_user_data(handler); + bctbx_free(service->log_handler); service->log_handler = NULL; } @@ -162,7 +163,8 @@ void linphone_logging_service_unref(LinphoneLoggingService *service) { } static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) { - if (log_service->log_handler) bctbx_remove_log_handler(log_service->log_handler); + if (log_service->log_handler) + bctbx_remove_log_handler(log_service->log_handler); linphone_logging_service_cbs_unref(log_service->cbs); } From a8a5e1ef900f45b8773e0e195880fc2c2d0397a0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 25 Apr 2018 17:20:13 +0200 Subject: [PATCH 034/143] disable test: sequential_forking_with_fallback_route --- tester/flexisip_tester.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index fa7f7ea35..79be0ad9f 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1686,6 +1686,7 @@ void sequential_forking_with_insertion_of_higher_priority(void) { } void sequential_forking_with_fallback_route(void) { +#if 0 //fixme Mickael LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline2 = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie = linphone_core_manager_create("marie_rc"); @@ -1751,6 +1752,9 @@ void sequential_forking_with_fallback_route(void) { linphone_core_manager_destroy(pauline2); linphone_core_manager_destroy(marie); bctbx_list_free(lcs); +#else + ms_error("sequential_forking_with_fallback_route temporaly removed"); +#endif } test_t flexisip_tests[] = { From 89fb96837bae55855da83d86a359e7cc3ad03997 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 17:24:04 +0200 Subject: [PATCH 035/143] fix(content-manager): avoid memory leak in multipartToContentList --- src/content/content-manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index 5d79c7ac7..d4d07cf70 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -47,8 +47,8 @@ list ContentManager::multipartToContentList (const Content &content) { for (const belle_sip_list_t *parts = sal_body_handler_get_parts(sbh); parts; parts = parts->next) { SalBodyHandler *part = (SalBodyHandler *)parts->data; LinphoneContent *cContent = linphone_content_from_sal_body_handler(part); - Content *cppContent = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); - contents.push_back(*cppContent); + contents.push_back(*L_GET_CPP_PTR_FROM_C_OBJECT(cContent)); + linphone_content_unref(cContent); } sal_body_handler_unref(sbh); From ea2e4f75cca9640f67dc70163883d6422e1959be Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 25 Apr 2018 17:45:22 +0200 Subject: [PATCH 036/143] fix(cpim-tester): avoid memory leaks + invalid reads --- tester/cpim-tester.cpp | 43 +++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 66cc661d8..83a45430e 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -48,7 +48,8 @@ static void parse_minimal_message () { const string str2 = message->asString(); BC_ASSERT_STRING_EQUAL(str2.c_str(), str.c_str()); - BC_ASSERT_STRING_EQUAL(message->getContent().c_str(), ""); + const string content = message->getContent(); + BC_ASSERT_STRING_EQUAL(content.c_str(), ""); } static void set_generic_header_name () { @@ -389,21 +390,33 @@ static void build_message () { BC_ASSERT_STRING_EQUAL(strMessage.c_str(), expectedMessage.c_str()); } -static int fake_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg) { - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), ContentType::Cpim.asString().c_str()); // Encryption is the first receiving step, so this message should be CPIM +static int fake_im_encryption_engine_process_incoming_message_cb ( + LinphoneImEncryptionEngine *engine, + LinphoneChatRoom *room, + LinphoneChatMessage *msg +) { + // Encryption is the first receiving step, so this message should be CPIM. + const string expected = ContentType::Cpim.asString(); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), expected.c_str()); return -1; } -static int fake_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEngine *engine, LinphoneChatRoom *room, LinphoneChatMessage *msg) { - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), ContentType::Cpim.asString().c_str()); // Encryption is the last sending step, so this message should be CPIM +static int fake_im_encryption_engine_process_outgoing_message_cb ( + LinphoneImEncryptionEngine *engine, + LinphoneChatRoom *room, + LinphoneChatMessage *msg +) { + // Encryption is the last sending step, so this message should be CPIM. + const string expected = ContentType::Cpim.asString(); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(msg), expected.c_str()); return -1; } -static void cpim_chat_message_modifier_base(bool_t use_multipart) { +static void cpim_chat_message_modifier_base (bool useMultipart) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - // We use a fake encryption engine just to check the internal content type during the sending/receiving process + // We use a fake encryption engine just to check the internal content type during the sending/receiving process. LinphoneImEncryptionEngine *marie_imee = linphone_im_encryption_engine_new(); LinphoneImEncryptionEngineCbs *marie_cbs = linphone_im_encryption_engine_get_callbacks(marie_imee); LinphoneImEncryptionEngine *pauline_imee = linphone_im_encryption_engine_new(); @@ -413,12 +426,15 @@ static void cpim_chat_message_modifier_base(bool_t use_multipart) { linphone_core_set_im_encryption_engine(marie->lc, marie_imee); linphone_core_set_im_encryption_engine(pauline->lc, pauline_imee); - IdentityAddress paulineAddress(linphone_address_as_string_uri_only(pauline->identity)); + char *paulineUri = linphone_address_as_string_uri_only(pauline->identity); + IdentityAddress paulineAddress(paulineUri); + bctbx_free(paulineUri); + shared_ptr marieRoom = marie->lc->cppPtr->getOrCreateBasicChatRoom(paulineAddress); marieRoom->allowCpim(true); shared_ptr marieMessage = marieRoom->createChatMessage("Hello CPIM"); - if (use_multipart) { + if (useMultipart) { marieRoom->allowMultipart(true); Content *content = new Content(); content->setContentType(ContentType::PlainText); @@ -433,7 +449,8 @@ static void cpim_chat_message_modifier_base(bool_t use_multipart) { BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message); if (pauline->stat.last_received_chat_message != NULL) { BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline->stat.last_received_chat_message), "Hello CPIM"); - BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), ContentType::PlainText.asString().c_str()); + const string expected = ContentType::PlainText.asString(); + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), expected.c_str()); } linphone_im_encryption_engine_unref(marie_imee); @@ -443,11 +460,11 @@ static void cpim_chat_message_modifier_base(bool_t use_multipart) { linphone_core_manager_destroy(pauline); } -static void cpim_chat_message_modifier(void) { +static void cpim_chat_message_modifier () { cpim_chat_message_modifier_base(FALSE); } -static void cpim_chat_message_modifier_with_multipart_body(void) { +static void cpim_chat_message_modifier_with_multipart_body () { cpim_chat_message_modifier_base(TRUE); } @@ -462,7 +479,7 @@ test_t cpim_tests[] = { TEST_NO_TAG("Parse Message with generic header parameters", parse_message_with_generic_header_parameters), TEST_NO_TAG("Build Message", build_message), TEST_NO_TAG("CPIM chat message modifier", cpim_chat_message_modifier), - TEST_NO_TAG("CPIM chat message modifier with multipart body", cpim_chat_message_modifier_with_multipart_body), + TEST_NO_TAG("CPIM chat message modifier with multipart body", cpim_chat_message_modifier_with_multipart_body) }; test_suite_t cpim_test_suite = { From 5ab6c928f2ecb6407d243e0a0bf2f42a609a01f6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 26 Apr 2018 10:33:13 +0200 Subject: [PATCH 037/143] add missing rc file to CMakeLists.txt --- tester/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index e07217934..10df74697 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -132,6 +132,8 @@ set(RC_FILES rcfiles/pauline_zrtp_aes256_rc rcfiles/pauline_zrtp_b256_rc rcfiles/pauline_zrtp_srtpsuite_aes256_rc + rcfiles/pauline_zrtp_ecdh255_rc + rcfiles/pauline_zrtp_ecdh448_rc rcfiles/remote_zero_length_params_rc rcfiles/stun_rc rcfiles/zero_length_params_rc From 94e53a4e22601e20c45a06514a4abb6f5a70ab6b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 12 Apr 2018 11:02:31 +0200 Subject: [PATCH 038/143] Add Content-Disposition header for IMDN messages. --- src/chat/chat-message/chat-message-p.h | 2 +- src/chat/chat-message/chat-message.cpp | 22 ++++++------ src/chat/chat-room/server-group-chat-room-p.h | 2 +- .../modifier/cpim-chat-message-modifier.cpp | 14 ++++++-- src/content/content-disposition.cpp | 1 + src/content/content-disposition.h | 1 + src/sal/call-op.cpp | 9 ++--- src/sal/call-op.h | 2 +- src/sal/message-op-interface.h | 36 +++++++++++++++++-- src/sal/message-op.cpp | 18 ++-------- src/sal/message-op.h | 2 +- src/sal/op.cpp | 2 +- 12 files changed, 71 insertions(+), 40 deletions(-) diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index 919bae443..7ffe61832 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -26,8 +26,8 @@ #include "chat/chat-room/chat-room-id.h" #include "chat/modifier/file-transfer-chat-message-modifier.h" #include "chat/notification/imdn.h" -#include "content/content-type.h" #include "content/content.h" +#include "content/content-type.h" #include "content/file-content.h" #include "content/file-transfer-content.h" #include "db/main-db.h" diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 6048f5439..6010dadbb 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -33,17 +33,15 @@ #include "chat/chat-room/real-time-text-chat-room.h" #include "chat/modifier/cpim-chat-message-modifier.h" #include "chat/modifier/encryption-chat-message-modifier.h" -#include "chat/modifier/file-transfer-chat-message-modifier.h" #include "chat/modifier/multipart-chat-message-modifier.h" +#include "chat/notification/imdn.h" #include "conference/participant.h" #include "conference/participant-imdn-state.h" -#include "content/file-content.h" +#include "content/content-disposition.h" #include "content/header/header-param.h" -#include "content/content.h" #include "core/core.h" #include "core/core-p.h" #include "logger/logger.h" -#include "chat/notification/imdn.h" #include "sip-tools/sip-headers.h" #include "ortp/b64.h" @@ -462,6 +460,7 @@ void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) { shared_ptr msg = q->getChatRoom()->createChatMessage(); Content *content = new Content(); + content->setContentDisposition(ContentDisposition::Notification); content->setContentType(ContentType::Imdn); content->setBody(Imdn::createXml(imdnId, time, imdnType, reason)); msg->addContent(content); @@ -773,13 +772,16 @@ void ChatMessagePrivate::send () { auto msgOp = dynamic_cast(op); if (!externalBodyUrl.empty()) { - char *content_type = ms_strdup_printf("message/external-body;access-type=URL;URL=\"%s\"", externalBodyUrl.c_str()); - msgOp->send_message(content_type, NULL); - ms_free(content_type); - } else if (internalContent.getContentType().isValid()) { - msgOp->send_message(internalContent.getContentType().asString().c_str(), internalContent.getBodyAsUtf8String().c_str()); + Content content; + ContentType contentType(ContentType::ExternalBody); + contentType.addParameter("access-type", "URL"); + contentType.addParameter("URL", "\"" + externalBodyUrl + "\""); + content.setContentType(contentType); + msgOp->sendMessage(content); } else { - msgOp->send_message(ContentType::PlainText.asString().c_str(), internalContent.getBodyAsUtf8String().c_str()); + if (!internalContent.getContentType().isValid()) + internalContent.setContentType(ContentType::PlainText); + msgOp->sendMessage(internalContent); } // Restore FileContents and remove FileTransferContents diff --git a/src/chat/chat-room/server-group-chat-room-p.h b/src/chat/chat-room/server-group-chat-room-p.h index 0ddcbdd48..daa8ae629 100644 --- a/src/chat/chat-room/server-group-chat-room-p.h +++ b/src/chat/chat-room/server-group-chat-room-p.h @@ -69,7 +69,7 @@ public: private: struct Message { Message (const std::string &from, const ContentType &contentType, const std::string &text, const SalCustomHeader *salCustomHeaders) - : fromAddr(from) + : fromAddr(from) { content.setContentType(contentType); if (!text.empty()) diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 3f361b9c9..af207fff5 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -20,8 +20,9 @@ #include "address/address.h" #include "chat/chat-message/chat-message-p.h" #include "chat/cpim/cpim.h" -#include "content/content-type.h" #include "content/content.h" +#include "content/content-disposition.h" +#include "content/content-type.h" #include "logger/logger.h" #include "cpim-chat-message-modifier.h" @@ -59,6 +60,12 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetContents().front(); } + if (content->getContentDisposition().isValid()) { + Cpim::GenericHeader contentDispositionHeader; + contentDispositionHeader.setName("Content-Disposition"); + contentDispositionHeader.setValue(content->getContentDisposition().asString()); + cpimMessage.addContentHeader(contentDispositionHeader); + } Cpim::GenericHeader contentTypeHeader; contentTypeHeader.setName("Content-Type"); contentTypeHeader.setValue(content->getContentType().asString()); @@ -100,10 +107,11 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetContentHeaders(); if (l) { for (const auto &header : *l.get()) { - if (header->getName() == "Content-Type") { + if (header->getName() == "Content-Disposition") { + newContent.setContentDisposition(ContentDisposition(header->getValue())); + } else if (header->getName() == "Content-Type") { contentTypeFound = true; newContent.setContentType(ContentType(header->getValue())); - break; } } } diff --git a/src/content/content-disposition.cpp b/src/content/content-disposition.cpp index 1a14d9bd7..b7c6c9f16 100644 --- a/src/content/content-disposition.cpp +++ b/src/content/content-disposition.cpp @@ -38,6 +38,7 @@ public: // ----------------------------------------------------------------------------- +const ContentDisposition ContentDisposition::Notification("notification"); const ContentDisposition ContentDisposition::RecipientList("recipient-list"); const ContentDisposition ContentDisposition::RecipientListHistory("recipient-list-history; handling=optional"); diff --git a/src/content/content-disposition.h b/src/content/content-disposition.h index 9021f0e2c..e01b289bb 100644 --- a/src/content/content-disposition.h +++ b/src/content/content-disposition.h @@ -52,6 +52,7 @@ public: std::string asString () const; + static const ContentDisposition Notification; static const ContentDisposition RecipientList; static const ContentDisposition RecipientListHistory; diff --git a/src/sal/call-op.cpp b/src/sal/call-op.cpp index f28a096fa..3773585d3 100644 --- a/src/sal/call-op.cpp +++ b/src/sal/call-op.cpp @@ -1530,10 +1530,11 @@ void SalCallOp::process_notify(const belle_sip_request_event_t *event, belle_sip } } -int SalCallOp::send_message(const char* content_type, const char *msg) { - if (!this->dialog) return -1; - belle_sip_request_t* req=belle_sip_dialog_create_queued_request(this->dialog,"MESSAGE"); - prepare_message_request(req, content_type, msg); +int SalCallOp::sendMessage (const Content &content) { + if (!this->dialog) + return -1; + belle_sip_request_t *req = belle_sip_dialog_create_queued_request(this->dialog, "MESSAGE"); + prepareMessageRequest(req, content); return send_request(req); } diff --git a/src/sal/call-op.h b/src/sal/call-op.h index fea958e6d..8c1a484e3 100644 --- a/src/sal/call-op.h +++ b/src/sal/call-op.h @@ -66,7 +66,7 @@ public: void set_sdp_handling(SalOpSDPHandling handling); // Implementation of SalMessageOpInterface - int send_message(const char* content_type, const char *msg) override; + int sendMessage (const Content &content) override; int reply(SalReason reason) override {return SalOp::reply_message(reason);} private: diff --git a/src/sal/message-op-interface.h b/src/sal/message-op-interface.h index acc5ea49c..ea00bdc6a 100644 --- a/src/sal/message-op-interface.h +++ b/src/sal/message-op-interface.h @@ -20,17 +20,49 @@ #ifndef _L_SAL_MESSAGE_OP_INTERFACE_H_ #define _L_SAL_MESSAGE_OP_INTERFACE_H_ +#include + +#include "content/content.h" +#include "content/content-type.h" + LINPHONE_BEGIN_NAMESPACE class SalMessageOpInterface { public: virtual ~SalMessageOpInterface() = default; - virtual int send_message(const char* content_type, const char *msg) = 0; + virtual int sendMessage (const Content &content) = 0; virtual int reply(SalReason reason) = 0; protected: - void prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg); + void prepareMessageRequest (belle_sip_request_t *req, const Content &content) { + time_t curtime = std::time(nullptr); + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime)) + ); + const ContentType &contentType = content.getContentType(); + std::string contentTypeStr = std::string(BELLE_SIP_CONTENT_TYPE ": ") + contentType.asString(); + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + BELLE_SIP_HEADER(belle_sip_header_content_type_parse(contentTypeStr.c_str())) + ); + if (content.isEmpty()) { + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + BELLE_SIP_HEADER(belle_sip_header_content_length_create(0)) + ); + } else { + std::string body = content.getBodyAsUtf8String(); + size_t contentLength = body.size(); + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + BELLE_SIP_HEADER(belle_sip_header_content_length_create(contentLength)) + ); + belle_sip_message_set_body(BELLE_SIP_MESSAGE(req), body.c_str(), contentLength); + } + } + }; LINPHONE_END_NAMESPACE diff --git a/src/sal/message-op.cpp b/src/sal/message-op.cpp index 090f5f50e..29acdab93 100644 --- a/src/sal/message-op.cpp +++ b/src/sal/message-op.cpp @@ -77,27 +77,13 @@ void SalMessageOp::fill_cbs() { this->type=Type::Message; } -void SalMessageOpInterface::prepare_message_request(belle_sip_request_t *req, const char* content_type, const char *msg) { - char content_type_raw[256]; - size_t content_length = msg?strlen(msg):0; - time_t curtime = ms_time(NULL); - snprintf(content_type_raw,sizeof(content_type_raw),BELLE_SIP_CONTENT_TYPE ": %s",content_type); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_type_parse(content_type_raw))); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_length))); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime))); - if (msg){ - /*don't call set_body() with null argument because it resets content type and content length*/ - belle_sip_message_set_body(BELLE_SIP_MESSAGE(req), msg, content_length); - } -} - -int SalMessageOp::send_message(const char* content_type, const char *msg) { +int SalMessageOp::sendMessage (const Content &content) { fill_cbs(); this->dir = Dir::Outgoing; belle_sip_request_t *req = build_request("MESSAGE"); if (!req) return -1; - prepare_message_request(req, content_type, msg); + prepareMessageRequest(req, content); return send_request(req); } diff --git a/src/sal/message-op.h b/src/sal/message-op.h index 9c1527ba8..922cc0381 100644 --- a/src/sal/message-op.h +++ b/src/sal/message-op.h @@ -29,7 +29,7 @@ class SalMessageOp: public SalOp, public SalMessageOpInterface { public: SalMessageOp(Sal *sal): SalOp(sal) {} - int send_message(const char* content_type, const char *msg) override; + int sendMessage (const Content &content) override; int reply(SalReason reason) override {return SalOp::reply_message(reason);} private: diff --git a/src/sal/op.cpp b/src/sal/op.cpp index 497a7a99b..33a641906 100644 --- a/src/sal/op.cpp +++ b/src/sal/op.cpp @@ -1040,7 +1040,7 @@ void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { salmsg.url = ms_strdup(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")+1); /* skip first "*/ ((char*)salmsg.url)[url_length-2]='\0'; /*remove trailing "*/ } - + salmsg.message_id=message_id; salmsg.time=date ? belle_sip_header_date_get_time(date) : time(NULL); this->root->callbacks.message_received(this,&salmsg); From 9c80965f1ec2a7ca81db21f2e79fc5dbbe655565 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 10:49:07 +0200 Subject: [PATCH 039/143] Add missing Content-Length header in CPIM. --- src/chat/modifier/cpim-chat-message-modifier.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index af207fff5..1cc8f8b5b 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -60,6 +60,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetContents().front(); } + const string contentBody = content->getBodyAsString(); if (content->getContentDisposition().isValid()) { Cpim::GenericHeader contentDispositionHeader; contentDispositionHeader.setName("Content-Disposition"); @@ -70,8 +71,10 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetContentType().asString()); cpimMessage.addContentHeader(contentTypeHeader); - - const string contentBody = content->getBodyAsString(); + Cpim::GenericHeader contentLengthHeader; + contentLengthHeader.setName("Content-Length"); + contentLengthHeader.setValue(to_string(contentBody.size())); + cpimMessage.addContentHeader(contentLengthHeader); cpimMessage.setContent(contentBody); Content newContent; From f4f642a4d52e05e63417e6bfb019066ba0b8d44a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 11:35:42 +0200 Subject: [PATCH 040/143] Add utility method to join a vector of strings into a single string. --- include/linphone/utils/utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linphone/utils/utils.h b/include/linphone/utils/utils.h index e13c89889..0714e9a06 100644 --- a/include/linphone/utils/utils.h +++ b/include/linphone/utils/utils.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -107,6 +108,15 @@ namespace Utils { return str ? str : ""; } + template + LINPHONE_PUBLIC std::string join (const std::vector& elems, const S& delim) { + std::stringstream ss; + auto e = elems.begin(); + ss << *e++; + for (; e != elems.end(); ++e) + ss << delim << *e; + return ss.str(); + } LINPHONE_PUBLIC std::string trim (const std::string &str); template From d1dc2238982ee2c97e882c77090723da4fe5fe3e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 17:11:41 +0200 Subject: [PATCH 041/143] Handle imdn namespace and Disposition-Notification header in CPIM. --- src/CMakeLists.txt | 2 + src/chat/chat-message/chat-message-p.h | 26 ++++++-- src/chat/chat-message/chat-message.cpp | 12 ++-- src/chat/chat-message/chat-message.h | 7 +- .../chat-message/notification-message.cpp | 55 ++++++++++++++++ src/chat/chat-message/notification-message.h | 50 ++++++++++++++ src/chat/chat-room/chat-room-p.h | 1 + src/chat/chat-room/chat-room.cpp | 26 ++++---- .../modifier/cpim-chat-message-modifier.cpp | 65 +++++++++++++++++-- 9 files changed, 210 insertions(+), 34 deletions(-) create mode 100644 src/chat/chat-message/notification-message.cpp create mode 100644 src/chat/chat-message/notification-message.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b94bf46a5..adf89688f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES call/remote-conference-call.h chat/chat-message/chat-message-p.h chat/chat-message/chat-message.h + chat/chat-message/notification-message.h chat/chat-room/abstract-chat-room-p.h chat/chat-room/abstract-chat-room.h chat/chat-room/basic-chat-room-p.h @@ -190,6 +191,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES call/local-conference-call.cpp call/remote-conference-call.cpp chat/chat-message/chat-message.cpp + chat/chat-message/notification-message.cpp chat/chat-room/abstract-chat-room.cpp chat/chat-room/basic-chat-room.cpp chat/chat-room/basic-to-client-group-chat-room.cpp diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index 7ffe61832..2e620bb4a 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -44,6 +44,7 @@ class ChatMessagePrivate : public ObjectPrivate { friend class CpimChatMessageModifier; friend class EncryptionChatMessageModifier; friend class MultipartChatMessageModifier; + friend class NotificationMessagePrivate; public: enum Step { @@ -99,6 +100,13 @@ public: SalOp *getSalOp () const; void setSalOp (SalOp *op); + bool getDisplayNotificationRequired () const { return displayNotificationRequired; } + bool getNegativeDeliveryNotificationRequired () const { return negativeDeliveryNotificationRequired; } + bool getPositiveDeliveryNotificationRequired () const { return positiveDeliveryNotificationRequired; } + virtual void setDisplayNotificationRequired (bool value) { displayNotificationRequired = value; } + virtual void setNegativeDeliveryNotificationRequired (bool value) { negativeDeliveryNotificationRequired = value; } + virtual void setPositiveDeliveryNotificationRequired (bool value) { positiveDeliveryNotificationRequired = value; } + SalCustomHeader *getSalCustomHeaders () const; void setSalCustomHeaders (SalCustomHeader *headers); @@ -156,11 +164,20 @@ public: void updateInDb (); private: - ChatMessagePrivate(const std::shared_ptr &cr, ChatMessage::Direction dir); - + static bool validStateTransition (ChatMessage::State currentState, ChatMessage::State newState); +public: + mutable MainDbChatMessageKey dbKey; + +protected: + bool displayNotificationRequired = true; + bool negativeDeliveryNotificationRequired = true; + bool positiveDeliveryNotificationRequired = true; + bool toBeStored = true; + +private: // TODO: Clean attributes. time_t time = ::ms_time(0); // TODO: Change me in all files. std::string imdnId; @@ -189,10 +206,6 @@ private: // TODO: Remove my comment. VARIABLES OK. // Do not expose. -public: - mutable MainDbChatMessageKey dbKey; - -private: std::weak_ptr chatRoom; ChatRoomId chatRoomId; IdentityAddress fromAddress; @@ -204,7 +217,6 @@ private: std::list contents; bool encryptionPrevented = false; - bool toBeStored = true; mutable bool contentsNotLoadedFromDatabase = false; L_DECLARE_PUBLIC(ChatMessage); }; diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 6010dadbb..cb76692e6 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -457,7 +457,8 @@ void ChatMessagePrivate::setChatRoom (const shared_ptr &cr) { void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) { L_Q(); - shared_ptr msg = q->getChatRoom()->createChatMessage(); + auto chatRoomPrivate = static_cast(q->getChatRoom()->getPrivate()); + shared_ptr msg = chatRoomPrivate->createNotificationMessage(ChatMessage::Direction::Outgoing); Content *content = new Content(); content->setContentDisposition(ContentDisposition::Notification); @@ -468,7 +469,6 @@ void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) { if (reason != LinphoneReasonNone) msg->getPrivate()->setEncryptionPrevented(true); - msg->setToBeStored(false); msg->getPrivate()->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); msg->getPrivate()->send(); @@ -523,9 +523,8 @@ void ChatMessagePrivate::notifyReceiving () { // Legacy q->getChatRoom()->getPrivate()->notifyChatMessageReceived(q->getSharedFromThis()); - if ((getContentType() != ContentType::Imdn) && (getContentType() != ContentType::ImIsComposing)) { + if (getPositiveDeliveryNotificationRequired()) q->sendDeliveryNotification(LinphoneReasonNone); - } } LinphoneReason ChatMessagePrivate::receive () { @@ -894,7 +893,10 @@ bool ChatMessagePrivate::validStateTransition (ChatMessage::State currentState, // ----------------------------------------------------------------------------- ChatMessage::ChatMessage (const shared_ptr &chatRoom, ChatMessage::Direction direction) : - Object(*new ChatMessagePrivate(chatRoom,direction)), CoreAccessor(chatRoom->getCore()) { + Object(*new ChatMessagePrivate(chatRoom, direction)), CoreAccessor(chatRoom->getCore()) { +} + +ChatMessage::ChatMessage (ChatMessagePrivate &p) : Object(p), CoreAccessor(p.getPublic()->getChatRoom()->getCore()) { } ChatMessage::~ChatMessage () { diff --git a/src/chat/chat-message/chat-message.h b/src/chat/chat-message/chat-message.h index 633b379b3..d6dfc3296 100644 --- a/src/chat/chat-message/chat-message.h +++ b/src/chat/chat-message/chat-message.h @@ -61,7 +61,7 @@ public: L_DECLARE_ENUM(State, L_ENUM_VALUES_CHAT_MESSAGE_STATE); L_DECLARE_ENUM(Direction, L_ENUM_VALUES_CHAT_MESSAGE_DIRECTION); - ~ChatMessage (); + virtual ~ChatMessage (); // ----- TODO: Remove me. void cancelFileTransfer (); @@ -93,7 +93,7 @@ public: bool isReadOnly () const; bool getToBeStored () const; - void setToBeStored (bool value); + virtual void setToBeStored (bool value); std::list getParticipantsThatHaveDisplayed () const; std::list getParticipantsThatHaveReceived () const; @@ -114,6 +114,9 @@ public: bool downloadFile (FileTransferContent *content); bool isFileTransferInProgress(); +protected: + explicit ChatMessage (ChatMessagePrivate &p); + private: ChatMessage (const std::shared_ptr &chatRoom, ChatMessage::Direction direction); diff --git a/src/chat/chat-message/notification-message.cpp b/src/chat/chat-message/notification-message.cpp new file mode 100644 index 000000000..8471c1484 --- /dev/null +++ b/src/chat/chat-message/notification-message.cpp @@ -0,0 +1,55 @@ +/* + * notification-message.cpp + * Copyright (C) 2010-2018 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 "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/notification-message.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +class NotificationMessagePrivate : public ChatMessagePrivate { +private: + NotificationMessagePrivate(const std::shared_ptr &cr, ChatMessage::Direction dir) + : ChatMessagePrivate(cr, dir) {} + + void setDisplayNotificationRequired (bool value) override {} + void setNegativeDeliveryNotificationRequired (bool value) override {} + void setPositiveDeliveryNotificationRequired (bool value) override {} + + L_DECLARE_PUBLIC(NotificationMessage); +}; + +// ----------------------------------------------------------------------------- + +NotificationMessage::NotificationMessage (const shared_ptr &chatRoom, ChatMessage::Direction direction) : + ChatMessage(*new NotificationMessagePrivate(chatRoom, direction)) { + L_D(); + d->displayNotificationRequired = false; + d->negativeDeliveryNotificationRequired = false; + d->positiveDeliveryNotificationRequired = false; + d->toBeStored = false; +} + +void NotificationMessage::setToBeStored (bool value) { +} + +LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/notification-message.h b/src/chat/chat-message/notification-message.h new file mode 100644 index 000000000..4870788c1 --- /dev/null +++ b/src/chat/chat-message/notification-message.h @@ -0,0 +1,50 @@ +/* + * notification-message.h + * Copyright (C) 2010-2018 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 _L_NOTIFICATION_MESSAGE_H_ +#define _L_NOTIFICATION_MESSAGE_H_ + +#include "chat/chat-message/chat-message.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class NotificationMessagePrivate; + +class LINPHONE_PUBLIC NotificationMessage : public ChatMessage { +public: + friend class ChatRoomPrivate; + + L_OVERRIDE_SHARED_FROM_THIS(NotificationMessage); + + virtual ~NotificationMessage () = default; + + void setToBeStored (bool value) override; + +private: + NotificationMessage (const std::shared_ptr &chatRoom, ChatMessage::Direction direction); + + L_DECLARE_PRIVATE(NotificationMessage); + L_DISABLE_COPY(NotificationMessage); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_NOTIFICATION_MESSAGE_H_ diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 4d177d845..0da5cc137 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -54,6 +54,7 @@ public: void removeTransientEvent (const std::shared_ptr &eventLog) override; std::shared_ptr createChatMessage (ChatMessage::Direction direction); + std::shared_ptr createNotificationMessage (ChatMessage::Direction direction); std::list> findChatMessages (const std::string &messageId) const; void notifyChatMessageReceived (const std::shared_ptr &chatMessage) override; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 72705d157..e57bef564 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -23,6 +23,7 @@ #include "c-wrapper/c-wrapper.h" #include "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/notification-message.h" #include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" #include "sip-tools/sip-headers.h" @@ -84,8 +85,7 @@ void ChatRoomPrivate::sendIsComposingNotification () { content->setContentType(ContentType::ImIsComposing); content->setBody(payload); - shared_ptr chatMessage = createChatMessage(ChatMessage::Direction::Outgoing); - chatMessage->setToBeStored(false); + shared_ptr chatMessage = createNotificationMessage(ChatMessage::Direction::Outgoing); chatMessage->addContent(content); chatMessage->getPrivate()->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); chatMessage->getPrivate()->addSalCustomHeader("Expires", "0"); @@ -121,6 +121,11 @@ shared_ptr ChatRoomPrivate::createChatMessage (ChatMessage::Directi return shared_ptr(new ChatMessage(q->getSharedFromThis(), direction)); } +shared_ptr ChatRoomPrivate::createNotificationMessage (ChatMessage::Direction direction) { + L_Q(); + return shared_ptr(new NotificationMessage(q->getSharedFromThis(), direction)); +} + list> ChatRoomPrivate::findChatMessages (const string &messageId) const { L_Q(); return q->getCore()->getPrivate()->mainDb->findChatMessages(q->getChatRoomId(), messageId); @@ -214,26 +219,21 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag reason = msg->getPrivate()->receive(); if (reason == LinphoneReasonNotAcceptable || reason == LinphoneReasonUnknown) { - /* Return LinphoneReasonNone to avoid flexisip resending us a message we can't decrypt */ - reason = LinphoneReasonNone; - goto end; + // Return LinphoneReasonNone to avoid flexisip resending us a message we can't decrypt + return LinphoneReasonNone; } if (msg->getPrivate()->getContentType() == ContentType::ImIsComposing) { onIsComposingReceived(msg->getFromAddress(), msg->getPrivate()->getText()); - if (lp_config_get_int(linphone_core_get_config(cCore), "sip", "deliver_imdn", 0) != 1) { - goto end; - } + if (lp_config_get_int(linphone_core_get_config(cCore), "sip", "deliver_imdn", 0) != 1) + return reason; } else if (msg->getPrivate()->getContentType() == ContentType::Imdn) { onImdnReceived(msg); - if (lp_config_get_int(linphone_core_get_config(cCore), "sip", "deliver_imdn", 0) != 1) { - goto end; - } + if (lp_config_get_int(linphone_core_get_config(cCore), "sip", "deliver_imdn", 0) != 1) + return reason; } onChatMessageReceived(msg); - -end: return reason; } diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 1cc8f8b5b..5f2865ee9 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "linphone/utils/utils.h" + #include "address/address.h" #include "chat/chat-message/chat-message-p.h" #include "chat/cpim/cpim.h" @@ -42,12 +44,33 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetToAddress())); cpimMessage.addMessageHeader(cpimToHeader); - char token[13]; - belle_sip_random_token(token, sizeof(token)); - Cpim::MessageIdHeader cpimMessageIdHeader; - cpimMessageIdHeader.setValue(token); - cpimMessage.addMessageHeader(cpimMessageIdHeader); - message->getPrivate()->setImdnMessageId(token); + + if (message->getPrivate()->getPositiveDeliveryNotificationRequired() + || message->getPrivate()->getDisplayNotificationRequired() + ) { + const string imdnNamespace = "imdn"; + Cpim::NsHeader cpimNsHeader; + cpimNsHeader.setValue(imdnNamespace + " "); + cpimMessage.addMessageHeader(cpimNsHeader); + + char token[13]; + belle_sip_random_token(token, sizeof(token)); + Cpim::GenericHeader cpimMessageIdHeader; + cpimMessageIdHeader.setName("Message-ID"); // TODO: Replace by imdnNamespace + ".Message-ID"); + cpimMessageIdHeader.setValue(token); + cpimMessage.addMessageHeader(cpimMessageIdHeader); + message->getPrivate()->setImdnMessageId(token); + + Cpim::GenericHeader dispositionNotificationHeader; + dispositionNotificationHeader.setName(imdnNamespace + ".Disposition-Notification"); + vector dispositionNotificationValues; + if (message->getPrivate()->getPositiveDeliveryNotificationRequired()) + dispositionNotificationValues.emplace_back("positive-delivery"); + if (message->getPrivate()->getDisplayNotificationRequired()) + dispositionNotificationValues.emplace_back("display"); + dispositionNotificationHeader.setValue(Utils::join(dispositionNotificationValues, ", ")); + cpimMessage.addMessageHeader(dispositionNotificationHeader); + } const Content *content; if (!message->getInternalContent().isEmpty()) { @@ -125,17 +148,45 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetContent()); + message->getPrivate()->setPositiveDeliveryNotificationRequired(false); + message->getPrivate()->setNegativeDeliveryNotificationRequired(false); + message->getPrivate()->setDisplayNotificationRequired(false); + Address cpimFromAddress; Address cpimToAddress; l = cpimMessage->getMessageHeaders(); if (l) { + string imdnNamespace = ""; + for (const auto &header : *l.get()) { + if (header->getName() == "NS") { + string val = header->getValue(); + size_t startPos = 0; + startPos = val.find("<", startPos); + if (startPos == string::npos) + break; + size_t endPos = 0; + endPos = val.find(">", startPos); + if (endPos == string::npos) + break; + if (val.substr(startPos, endPos) == "") + imdnNamespace = Utils::trim(val.substr(0, startPos)); + } + } for (const auto &header : *l.get()) { if (header->getName() == "From") cpimFromAddress = Address(header->getValue()); else if (header->getName() == "To") cpimToAddress = Address(header->getValue()); - else if (header->getName() == "Message-ID") + else if ((header->getName() == "Message-ID") || (header->getName() == (imdnNamespace + ".Message-ID"))) message->getPrivate()->setImdnMessageId(header->getValue()); + else if ((header->getName() == (imdnNamespace + ".Disposition-Notification"))) { + vector values = Utils::split(header->getValue(), ", "); + for (const auto &value : values) + if (value == "positive-delivery") + message->getPrivate()->setPositiveDeliveryNotificationRequired(true); + else if (value == "display") + message->getPrivate()->setDisplayNotificationRequired(true); + } } } From dfde23f205de533e1147e3a958b1b6ee64dff64d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 17:43:20 +0200 Subject: [PATCH 042/143] Handle IMDN negative-delivery. --- src/chat/chat-message/chat-message.cpp | 8 ++++++-- src/chat/modifier/cpim-chat-message-modifier.cpp | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index cb76692e6..9d6ec11a2 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -548,7 +548,9 @@ LinphoneReason ChatMessagePrivate::receive () { /* Unable to decrypt message */ chatRoom->getPrivate()->notifyUndecryptableChatMessageReceived(q->getSharedFromThis()); reason = linphone_error_code_to_reason(errorCode); - q->sendDeliveryNotification(reason); + if (getNegativeDeliveryNotificationRequired()) { + q->sendDeliveryNotification(reason); + } return reason; } else if (result == ChatMessageModifier::Result::Suspended) { currentRecvStep |= ChatMessagePrivate::Step::Encryption; @@ -632,7 +634,9 @@ LinphoneReason ChatMessagePrivate::receive () { if (errorCode > 0) { reason = linphone_error_code_to_reason(errorCode); - q->sendDeliveryNotification(reason); + if (getNegativeDeliveryNotificationRequired()) { + q->sendDeliveryNotification(reason); + } return reason; } diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 5f2865ee9..9c7d48f6b 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -46,6 +46,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetPrivate()->getPositiveDeliveryNotificationRequired() + || message->getPrivate()->getNegativeDeliveryNotificationRequired() || message->getPrivate()->getDisplayNotificationRequired() ) { const string imdnNamespace = "imdn"; @@ -66,6 +67,8 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr dispositionNotificationValues; if (message->getPrivate()->getPositiveDeliveryNotificationRequired()) dispositionNotificationValues.emplace_back("positive-delivery"); + if (message->getPrivate()->getNegativeDeliveryNotificationRequired()) + dispositionNotificationValues.emplace_back("negative-delivery"); if (message->getPrivate()->getDisplayNotificationRequired()) dispositionNotificationValues.emplace_back("display"); dispositionNotificationHeader.setValue(Utils::join(dispositionNotificationValues, ", ")); @@ -184,6 +187,8 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetPrivate()->setPositiveDeliveryNotificationRequired(true); + else if (value == "negative-delivery") + message->getPrivate()->setNegativeDeliveryNotificationRequired(true); else if (value == "display") message->getPrivate()->setDisplayNotificationRequired(true); } From 536d4d324ab6b7528e79326d29776d4ade51c349 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 17:27:01 +0200 Subject: [PATCH 043/143] Remove Message-ID header specific parsing in cpim grammar. --- share/cpim_grammar | Bin 5239 -> 5158 bytes src/chat/cpim/header/cpim-core-headers.cpp | 1 - src/chat/cpim/header/cpim-core-headers.h | 1 - src/chat/cpim/parser/cpim-parser.cpp | 7 ------- src/chat/cpim/parser/cpim-parser.h | 3 --- src/chat/cpim/parser/cpim-rules | 2 -- 6 files changed, 14 deletions(-) diff --git a/share/cpim_grammar b/share/cpim_grammar index 6f8b36d954a126b6509342fa2bd3096c72aa2c24..7ea914ca5fe9dc16205704b241c8649960421b6c 100644 GIT binary patch delta 12 Tcmeyau}ot_3g_mnoQJpoC8`BT delta 93 zcmZ3c@m*s>3TFUIZfbFHVtT4>W{Pe`YGO)i5d#n~vw%o0Mh0I-Mut=%E{5VnAe{~s c(*@F=K }, { "cc", &HeaderNode::createCoreHeader }, { "DateTime", &HeaderNode::createCoreHeader }, - { "Message-ID", &HeaderNode::createCoreHeader }, { "Subject", &HeaderNode::createCoreHeader }, { "NS", &HeaderNode::createCoreHeader }, { "Require", &HeaderNode::createCoreHeader } @@ -420,12 +419,6 @@ bool Cpim::Parser::coreHeaderIsValid (const string &header return true; } -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "Message-ID", headerValue); -} - template<> bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { L_D(); diff --git a/src/chat/cpim/parser/cpim-parser.h b/src/chat/cpim/parser/cpim-parser.h index 46864274a..bdb32f7e4 100644 --- a/src/chat/cpim/parser/cpim-parser.h +++ b/src/chat/cpim/parser/cpim-parser.h @@ -70,9 +70,6 @@ namespace Cpim { template<> bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - template<> bool Parser::coreHeaderIsValid(const std::string &headerValue) const; diff --git a/src/chat/cpim/parser/cpim-rules b/src/chat/cpim/parser/cpim-rules index a0b866fee..bba8e019c 100644 --- a/src/chat/cpim/parser/cpim-rules +++ b/src/chat/cpim/parser/cpim-rules @@ -25,8 +25,6 @@ To-header-value = [ Formal-name ] "<" URI ">" DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value DateTime-header-value = date-time -Message-ID-header = %d77.101.115.115.97.103.101.45.73.68 ": " Token - cc-header = %d99.99 ": " cc-header-value cc-header-value = [ Formal-name ] "<" URI ">" From 75c981df03223f7c1b6b3989cb8791791189fc6e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 17:24:36 +0200 Subject: [PATCH 044/143] Add IsComposingMessage class. --- src/CMakeLists.txt | 3 ++ .../chat-message/is-composing-message.cpp | 46 +++++++++++++++++ src/chat/chat-message/is-composing-message.h | 51 +++++++++++++++++++ .../chat-message/notification-message-p.h | 46 +++++++++++++++++ .../chat-message/notification-message.cpp | 20 ++------ src/chat/chat-message/notification-message.h | 3 ++ src/chat/chat-room/chat-room-p.h | 1 + src/chat/chat-room/chat-room.cpp | 23 +++------ 8 files changed, 163 insertions(+), 30 deletions(-) create mode 100644 src/chat/chat-message/is-composing-message.cpp create mode 100644 src/chat/chat-message/is-composing-message.h create mode 100644 src/chat/chat-message/notification-message-p.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index adf89688f..c4141b33f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,7 +35,9 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES call/remote-conference-call.h chat/chat-message/chat-message-p.h chat/chat-message/chat-message.h + chat/chat-message/is-composing-message.h chat/chat-message/notification-message.h + chat/chat-message/notification-message-p.h chat/chat-room/abstract-chat-room-p.h chat/chat-room/abstract-chat-room.h chat/chat-room/basic-chat-room-p.h @@ -191,6 +193,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES call/local-conference-call.cpp call/remote-conference-call.cpp chat/chat-message/chat-message.cpp + chat/chat-message/is-composing-message.cpp chat/chat-message/notification-message.cpp chat/chat-room/abstract-chat-room.cpp chat/chat-room/basic-chat-room.cpp diff --git a/src/chat/chat-message/is-composing-message.cpp b/src/chat/chat-message/is-composing-message.cpp new file mode 100644 index 000000000..13177e92e --- /dev/null +++ b/src/chat/chat-message/is-composing-message.cpp @@ -0,0 +1,46 @@ +/* + * is-composing-message.cpp + * Copyright (C) 2010-2018 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 "chat/chat-message/notification-message-p.h" +#include "chat/chat-message/is-composing-message.h" +#include "sip-tools/sip-headers.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +// ----------------------------------------------------------------------------- + +IsComposingMessage::IsComposingMessage ( + const shared_ptr &chatRoom, + IsComposing &isComposingHandler, + bool isComposing +) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) { + L_D(); + Content *content = new Content(); + content->setContentType(ContentType::ImIsComposing); + content->setBody(isComposingHandler.marshal(isComposing)); + addContent(content); + d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); + d->addSalCustomHeader("Expires", "0"); +} + +LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/is-composing-message.h b/src/chat/chat-message/is-composing-message.h new file mode 100644 index 000000000..41f2a8c7f --- /dev/null +++ b/src/chat/chat-message/is-composing-message.h @@ -0,0 +1,51 @@ +/* + * is-composing-message.h + * Copyright (C) 2010-2018 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 _L_IS_COMPOSING_MESSAGE_H_ +#define _L_IS_COMPOSING_MESSAGE_H_ + +#include "chat/chat-message/notification-message.h" +#include "chat/notification/is-composing.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class LINPHONE_PUBLIC IsComposingMessage : public NotificationMessage { +public: + friend class ChatRoomPrivate; + + L_OVERRIDE_SHARED_FROM_THIS(IsComposingMessage); + + virtual ~IsComposingMessage () = default; + +private: + IsComposingMessage ( + const std::shared_ptr &chatRoom, + IsComposing &isComposingHandler, + bool isComposing + ); + + L_DECLARE_PRIVATE(NotificationMessage); + L_DISABLE_COPY(IsComposingMessage); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_IS_COMPOSING_MESSAGE_H_ diff --git a/src/chat/chat-message/notification-message-p.h b/src/chat/chat-message/notification-message-p.h new file mode 100644 index 000000000..122086529 --- /dev/null +++ b/src/chat/chat-message/notification-message-p.h @@ -0,0 +1,46 @@ +/* + * notification-message-p.h + * Copyright (C) 2010-2018 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 _L_NOTIFICATION_MESSAGE_P_H_ +#define _L_NOTIFICATION_MESSAGE_P_H_ + +#include "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/notification-message.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class NotificationMessagePrivate : public ChatMessagePrivate { + friend class IsComposingMessage; + +private: + NotificationMessagePrivate(const std::shared_ptr &cr, ChatMessage::Direction dir) + : ChatMessagePrivate(cr, dir) {} + + void setDisplayNotificationRequired (bool value) override {} + void setNegativeDeliveryNotificationRequired (bool value) override {} + void setPositiveDeliveryNotificationRequired (bool value) override {} + + L_DECLARE_PUBLIC(NotificationMessage); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_NOTIFICATION_MESSAGE_P_H_ diff --git a/src/chat/chat-message/notification-message.cpp b/src/chat/chat-message/notification-message.cpp index 8471c1484..eefcdaf20 100644 --- a/src/chat/chat-message/notification-message.cpp +++ b/src/chat/chat-message/notification-message.cpp @@ -17,8 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "chat/chat-message/chat-message-p.h" -#include "chat/chat-message/notification-message.h" +#include "chat/chat-message/notification-message-p.h" // ============================================================================= @@ -26,22 +25,13 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -class NotificationMessagePrivate : public ChatMessagePrivate { -private: - NotificationMessagePrivate(const std::shared_ptr &cr, ChatMessage::Direction dir) - : ChatMessagePrivate(cr, dir) {} - - void setDisplayNotificationRequired (bool value) override {} - void setNegativeDeliveryNotificationRequired (bool value) override {} - void setPositiveDeliveryNotificationRequired (bool value) override {} - - L_DECLARE_PUBLIC(NotificationMessage); -}; - // ----------------------------------------------------------------------------- NotificationMessage::NotificationMessage (const shared_ptr &chatRoom, ChatMessage::Direction direction) : - ChatMessage(*new NotificationMessagePrivate(chatRoom, direction)) { + NotificationMessage(*new NotificationMessagePrivate(chatRoom, direction)) { +} + +NotificationMessage::NotificationMessage (NotificationMessagePrivate &p) : ChatMessage(p) { L_D(); d->displayNotificationRequired = false; d->negativeDeliveryNotificationRequired = false; diff --git a/src/chat/chat-message/notification-message.h b/src/chat/chat-message/notification-message.h index 4870788c1..f818a009f 100644 --- a/src/chat/chat-message/notification-message.h +++ b/src/chat/chat-message/notification-message.h @@ -38,6 +38,9 @@ public: void setToBeStored (bool value) override; +protected: + explicit NotificationMessage (NotificationMessagePrivate &p); + private: NotificationMessage (const std::shared_ptr &chatRoom, ChatMessage::Direction direction); diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 0da5cc137..c884ffda6 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -54,6 +54,7 @@ public: void removeTransientEvent (const std::shared_ptr &eventLog) override; std::shared_ptr createChatMessage (ChatMessage::Direction direction); + std::shared_ptr createIsComposingMessage (); std::shared_ptr createNotificationMessage (ChatMessage::Direction direction); std::list> findChatMessages (const std::string &messageId) const; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index e57bef564..dcacd666e 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -23,10 +23,10 @@ #include "c-wrapper/c-wrapper.h" #include "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/is-composing-message.h" #include "chat/chat-message/notification-message.h" #include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" -#include "sip-tools/sip-headers.h" #include "logger/logger.h" // ============================================================================= @@ -77,20 +77,8 @@ void ChatRoomPrivate::sendIsComposingNotification () { if (!linphone_im_notif_policy_get_send_is_composing(policy)) return; - string payload = isComposingHandler->marshal(isComposing); - if (payload.empty()) - return; - - Content *content = new Content(); - content->setContentType(ContentType::ImIsComposing); - content->setBody(payload); - - shared_ptr chatMessage = createNotificationMessage(ChatMessage::Direction::Outgoing); - chatMessage->addContent(content); - chatMessage->getPrivate()->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); - chatMessage->getPrivate()->addSalCustomHeader("Expires", "0"); - - chatMessage->getPrivate()->send(); + auto isComposingMsg = createIsComposingMessage(); + isComposingMsg->getPrivate()->send(); } // ----------------------------------------------------------------------------- @@ -121,6 +109,11 @@ shared_ptr ChatRoomPrivate::createChatMessage (ChatMessage::Directi return shared_ptr(new ChatMessage(q->getSharedFromThis(), direction)); } +shared_ptr ChatRoomPrivate::createIsComposingMessage () { + L_Q(); + return shared_ptr(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing)); +} + shared_ptr ChatRoomPrivate::createNotificationMessage (ChatMessage::Direction direction) { L_Q(); return shared_ptr(new NotificationMessage(q->getSharedFromThis(), direction)); From 2888e84392afe90dfbb2ed8a85404c9a2df5fde6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 17:44:39 +0200 Subject: [PATCH 045/143] Add ImdnMessage class. --- src/CMakeLists.txt | 2 + src/chat/chat-message/chat-message-p.h | 2 - src/chat/chat-message/chat-message.cpp | 50 +++--------- src/chat/chat-message/chat-message.h | 2 - src/chat/chat-message/imdn-message.cpp | 76 ++++++++++++++++++ src/chat/chat-message/imdn-message.h | 54 +++++++++++++ .../chat-message/notification-message-p.h | 1 + src/chat/chat-room/chat-room-p.h | 12 ++- src/chat/chat-room/chat-room.cpp | 46 +++++++++-- src/chat/chat-room/chat-room.h | 1 + src/chat/notification/imdn.cpp | 80 ++++++++++++++++++- src/chat/notification/imdn.h | 27 +++++++ 12 files changed, 300 insertions(+), 53 deletions(-) create mode 100644 src/chat/chat-message/imdn-message.cpp create mode 100644 src/chat/chat-message/imdn-message.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4141b33f..a6f4568cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES call/remote-conference-call.h chat/chat-message/chat-message-p.h chat/chat-message/chat-message.h + chat/chat-message/imdn-message.h chat/chat-message/is-composing-message.h chat/chat-message/notification-message.h chat/chat-message/notification-message-p.h @@ -193,6 +194,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES call/local-conference-call.cpp call/remote-conference-call.cpp chat/chat-message/chat-message.cpp + chat/chat-message/imdn-message.cpp chat/chat-message/is-composing-message.cpp chat/chat-message/notification-message.cpp chat/chat-room/abstract-chat-room.cpp diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index 2e620bb4a..a8e9ae60f 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -154,8 +154,6 @@ public: bool downloadFile (); - void sendImdn (Imdn::Type imdnType, LinphoneReason reason); - void notifyReceiving (); LinphoneReason receive (); void send (); diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 9d6ec11a2..22321eda6 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -179,7 +179,7 @@ void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) { if (state == ChatMessage::State::FileTransferDone && !hasFileTransferContent()) { // We wait until the file has been downloaded to send the displayed IMDN - q->sendDisplayNotification(); + static_cast(q->getChatRoom()->getPrivate())->sendDisplayNotification(q->getSharedFromThis()); setState(ChatMessage::State::Displayed); } else { updateInDb(); @@ -454,26 +454,6 @@ void ChatMessagePrivate::setChatRoom (const shared_ptr &cr) { // ----------------------------------------------------------------------------- -void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) { - L_Q(); - - auto chatRoomPrivate = static_cast(q->getChatRoom()->getPrivate()); - shared_ptr msg = chatRoomPrivate->createNotificationMessage(ChatMessage::Direction::Outgoing); - - Content *content = new Content(); - content->setContentDisposition(ContentDisposition::Notification); - content->setContentType(ContentType::Imdn); - content->setBody(Imdn::createXml(imdnId, time, imdnType, reason)); - msg->addContent(content); - - if (reason != LinphoneReasonNone) - msg->getPrivate()->setEncryptionPrevented(true); - - msg->getPrivate()->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); - - msg->getPrivate()->send(); -} - static void forceUtf8Content (Content &content) { // TODO: Deal with other content type in the future. ContentType contentType = content.getContentType(); @@ -524,7 +504,7 @@ void ChatMessagePrivate::notifyReceiving () { q->getChatRoom()->getPrivate()->notifyChatMessageReceived(q->getSharedFromThis()); if (getPositiveDeliveryNotificationRequired()) - q->sendDeliveryNotification(LinphoneReasonNone); + static_cast(q->getChatRoom()->getPrivate())->sendDeliveryNotification(q->getSharedFromThis()); } LinphoneReason ChatMessagePrivate::receive () { @@ -549,7 +529,10 @@ LinphoneReason ChatMessagePrivate::receive () { chatRoom->getPrivate()->notifyUndecryptableChatMessageReceived(q->getSharedFromThis()); reason = linphone_error_code_to_reason(errorCode); if (getNegativeDeliveryNotificationRequired()) { - q->sendDeliveryNotification(reason); + static_cast(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification( + q->getSharedFromThis(), + reason + ); } return reason; } else if (result == ChatMessageModifier::Result::Suspended) { @@ -635,7 +618,10 @@ LinphoneReason ChatMessagePrivate::receive () { if (errorCode > 0) { reason = linphone_error_code_to_reason(errorCode); if (getNegativeDeliveryNotificationRequired()) { - q->sendDeliveryNotification(reason); + static_cast(q->getChatRoom()->getPrivate())->sendDeliveryErrorNotification( + q->getSharedFromThis(), + reason + ); } return reason; } @@ -1123,22 +1109,6 @@ void ChatMessage::send () { getChatRoom()->getPrivate()->sendChatMessage(getSharedFromThis()); } -void ChatMessage::sendDeliveryNotification (LinphoneReason reason) { - L_D(); - - LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(getCore()->getCCore()); - if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) - d->sendImdn(Imdn::Type::Delivery, reason); -} - -void ChatMessage::sendDisplayNotification () { - L_D(); - - LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(getCore()->getCCore()); - if (linphone_im_notif_policy_get_send_imdn_displayed(policy)) - d->sendImdn(Imdn::Type::Display, LinphoneReasonNone); -} - bool ChatMessage::downloadFile(FileTransferContent *fileTransferContent) { L_D(); return d->fileTransferChatMessageModifier.downloadFile(getSharedFromThis(), fileTransferContent); diff --git a/src/chat/chat-message/chat-message.h b/src/chat/chat-message/chat-message.h index d6dfc3296..2893fd6ed 100644 --- a/src/chat/chat-message/chat-message.h +++ b/src/chat/chat-message/chat-message.h @@ -66,8 +66,6 @@ public: // ----- TODO: Remove me. void cancelFileTransfer (); int putCharacter (uint32_t character); - void sendDeliveryNotification (LinphoneReason reason); - void sendDisplayNotification (); void setIsSecured (bool isSecured); // ----- TODO: Remove me. diff --git a/src/chat/chat-message/imdn-message.cpp b/src/chat/chat-message/imdn-message.cpp new file mode 100644 index 000000000..eb70de34d --- /dev/null +++ b/src/chat/chat-message/imdn-message.cpp @@ -0,0 +1,76 @@ +/* + * imdn-message.cpp + * Copyright (C) 2010-2018 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 "chat/chat-message/notification-message-p.h" +#include "chat/chat-message/imdn-message.h" +#include "content/content-disposition.h" +#include "sip-tools/sip-headers.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +// ----------------------------------------------------------------------------- + +ImdnMessage::ImdnMessage ( + const shared_ptr &chatRoom, + const list> &deliveredMessages, + const list> &displayedMessages +) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) { + L_D(); + + for (const auto &message : deliveredMessages) { + Content *content = new Content(); + content->setContentDisposition(ContentDisposition::Notification); + content->setContentType(ContentType::Imdn); + content->setBody(Imdn::createXml(message->getImdnMessageId(), message->getTime(), Imdn::Type::Delivery, LinphoneReasonNone)); + addContent(content); + } + for (const auto &message : displayedMessages) { + Content *content = new Content(); + content->setContentDisposition(ContentDisposition::Notification); + content->setContentType(ContentType::Imdn); + content->setBody(Imdn::createXml(message->getImdnMessageId(), message->getTime(), Imdn::Type::Display, LinphoneReasonNone)); + addContent(content); + } + + d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); +} + +ImdnMessage::ImdnMessage ( + const shared_ptr &chatRoom, + const list &nonDeliveredMessages +) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) { + L_D(); + + for (const auto &mr : nonDeliveredMessages) { + Content *content = new Content(); + content->setContentDisposition(ContentDisposition::Notification); + content->setContentType(ContentType::Imdn); + content->setBody(Imdn::createXml(mr.message->getImdnMessageId(), mr.message->getTime(), Imdn::Type::Delivery, mr.reason)); + addContent(content); + } + + d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); + d->setEncryptionPrevented(true); +} + +LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/imdn-message.h b/src/chat/chat-message/imdn-message.h new file mode 100644 index 000000000..a7aa026ca --- /dev/null +++ b/src/chat/chat-message/imdn-message.h @@ -0,0 +1,54 @@ +/* + * imdn-message.h + * Copyright (C) 2010-2018 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 _L_IMDN_MESSAGE_H_ +#define _L_IMDN_MESSAGE_H_ + +#include "chat/chat-message/notification-message.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class LINPHONE_PUBLIC ImdnMessage : public NotificationMessage { +public: + friend class ChatRoomPrivate; + + L_OVERRIDE_SHARED_FROM_THIS(ImdnMessage); + + virtual ~ImdnMessage () = default; + +private: + ImdnMessage ( + const std::shared_ptr &chatRoom, + const std::list> &deliveredMessages, + const std::list> &displayedMessages + ); + ImdnMessage ( + const std::shared_ptr &chatRoom, + const std::list &nonDeliveredMessages + ); + + L_DECLARE_PRIVATE(NotificationMessage); + L_DISABLE_COPY(ImdnMessage); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_IMDN_MESSAGE_H_ diff --git a/src/chat/chat-message/notification-message-p.h b/src/chat/chat-message/notification-message-p.h index 122086529..259d7da02 100644 --- a/src/chat/chat-message/notification-message-p.h +++ b/src/chat/chat-message/notification-message-p.h @@ -28,6 +28,7 @@ LINPHONE_BEGIN_NAMESPACE class NotificationMessagePrivate : public ChatMessagePrivate { + friend class ImdnMessage; friend class IsComposingMessage; private: diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index c884ffda6..438f08a5e 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -25,6 +25,7 @@ #include "abstract-chat-room-p.h" #include "chat-room-id.h" #include "chat-room.h" +#include "chat/notification/imdn.h" #include "chat/notification/is-composing.h" // ============================================================================= @@ -54,10 +55,18 @@ public: void removeTransientEvent (const std::shared_ptr &eventLog) override; std::shared_ptr createChatMessage (ChatMessage::Direction direction); + std::shared_ptr createImdnMessage ( + const std::list> &deliveredMessages, + const std::list> &displayedMessages + ); + std::shared_ptr createImdnMessage (const std::list &nonDeliveredMessages); std::shared_ptr createIsComposingMessage (); - std::shared_ptr createNotificationMessage (ChatMessage::Direction direction); std::list> findChatMessages (const std::string &messageId) const; + void sendDeliveryErrorNotification (const std::shared_ptr &message, LinphoneReason reason); + void sendDeliveryNotification (const std::shared_ptr &message); + void sendDisplayNotification (const std::shared_ptr &message); + void notifyChatMessageReceived (const std::shared_ptr &chatMessage) override; void notifyIsComposingReceived (const Address &remoteAddress, bool isComposing); void notifyStateChanged (); @@ -86,6 +95,7 @@ private: time_t creationTime = std::time(nullptr); time_t lastUpdateTime = std::time(nullptr); + std::unique_ptr imdnHandler; std::unique_ptr isComposingHandler; bool isComposing = false; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index dcacd666e..ed0762922 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -23,8 +23,8 @@ #include "c-wrapper/c-wrapper.h" #include "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/imdn-message.h" #include "chat/chat-message/is-composing-message.h" -#include "chat/chat-message/notification-message.h" #include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" #include "logger/logger.h" @@ -109,16 +109,24 @@ shared_ptr ChatRoomPrivate::createChatMessage (ChatMessage::Directi return shared_ptr(new ChatMessage(q->getSharedFromThis(), direction)); } +shared_ptr ChatRoomPrivate::createImdnMessage ( + const list> &deliveredMessages, + const list> &displayedMessages +) { + L_Q(); + return shared_ptr(new ImdnMessage(q->getSharedFromThis(), deliveredMessages, displayedMessages)); +} + +shared_ptr ChatRoomPrivate::createImdnMessage (const list &nonDeliveredMessages) { + L_Q(); + return shared_ptr(new ImdnMessage(q->getSharedFromThis(), nonDeliveredMessages)); +} + shared_ptr ChatRoomPrivate::createIsComposingMessage () { L_Q(); return shared_ptr(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing)); } -shared_ptr ChatRoomPrivate::createNotificationMessage (ChatMessage::Direction direction) { - L_Q(); - return shared_ptr(new NotificationMessage(q->getSharedFromThis(), direction)); -} - list> ChatRoomPrivate::findChatMessages (const string &messageId) const { L_Q(); return q->getCore()->getPrivate()->mainDb->findChatMessages(q->getChatRoomId(), messageId); @@ -126,6 +134,29 @@ list> ChatRoomPrivate::findChatMessages (const string &m // ----------------------------------------------------------------------------- +void ChatRoomPrivate::sendDeliveryErrorNotification (const shared_ptr &message, LinphoneReason reason) { + L_Q(); + LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); + if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) + imdnHandler->notifyDeliveryError(message, reason); +} + +void ChatRoomPrivate::sendDeliveryNotification (const shared_ptr &message) { + L_Q(); + LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); + if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) + imdnHandler->notifyDelivery(message); +} + +void ChatRoomPrivate::sendDisplayNotification (const shared_ptr &message) { + L_Q(); + LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); + if (linphone_im_notif_policy_get_send_imdn_displayed(policy)) + imdnHandler->notifyDisplay(message); +} + +// ----------------------------------------------------------------------------- + void ChatRoomPrivate::notifyChatMessageReceived (const shared_ptr &chatMessage) { L_Q(); LinphoneChatRoom *cr = getCChatRoom(); @@ -279,6 +310,7 @@ ChatRoom::ChatRoom (ChatRoomPrivate &p, const shared_ptr &core, const Chat L_D(); d->chatRoomId = chatRoomId; + d->imdnHandler.reset(new Imdn(this)); d->isComposingHandler.reset(new IsComposing(core->getCCore(), d)); } @@ -440,7 +472,7 @@ void ChatRoom::markAsRead () { for (auto &chatMessage : dCore->mainDb->getUnreadChatMessages(d->chatRoomId)) { // Do not send display notification for file transfer until it has been downloaded (it won't have a file transfer content anymore) if (!chatMessage->getPrivate()->hasFileTransferContent()) { - chatMessage->sendDisplayNotification(); + d->sendDisplayNotification(chatMessage); chatMessage->getPrivate()->setState(ChatMessage::State::Displayed, true); // True will ensure the setState won't update the database so it will be done below by the markChatMessagesAsRead } } diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index bbdb34e2d..db261a90f 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -31,6 +31,7 @@ class ChatRoomPrivate; class LINPHONE_PUBLIC ChatRoom : public AbstractChatRoom { public: friend class ChatMessagePrivate; + friend class Imdn; friend class ProxyChatRoomPrivate; L_OVERRIDE_SHARED_FROM_THIS(ChatRoom); diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index f74afa848..da89e9810 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -17,8 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + #include "chat/chat-message/chat-message-p.h" -#include "chat/chat-room/chat-room.h" +#include "chat/chat-room/chat-room-p.h" #include "core/core.h" #include "logger/logger.h" @@ -32,6 +34,46 @@ LINPHONE_BEGIN_NAMESPACE const string Imdn::imdnPrefix = "/imdn:imdn"; +// ----------------------------------------------------------------------------- + +Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) {} + +Imdn::~Imdn () { + stopTimer(); +} + +// ----------------------------------------------------------------------------- + +void Imdn::notifyDelivery (const shared_ptr &message) { + if (find(deliveredMessages.begin(), deliveredMessages.end(), message) == deliveredMessages.end()) { + deliveredMessages.push_back(message); + startTimer(); + } +} + +void Imdn::notifyDeliveryError (const shared_ptr &message, LinphoneReason reason) { + auto it = find_if(nonDeliveredMessages.begin(), nonDeliveredMessages.end(), [message](const MessageReason mr) { + return message == mr.message; + }); + if (it == nonDeliveredMessages.end()) { + nonDeliveredMessages.emplace_back(message, reason); + startTimer(); + } +} + +void Imdn::notifyDisplay (const shared_ptr &message) { + auto it = find(deliveredMessages.begin(), deliveredMessages.end(), message); + if (it != deliveredMessages.end()) + deliveredMessages.erase(it); + + if (find(displayedMessages.begin(), displayedMessages.end(), message) == displayedMessages.end()) { + displayedMessages.push_back(message); + startTimer(); + } +} + +// ----------------------------------------------------------------------------- + string Imdn::createXml (const string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason) { xmlBufferPtr buf; xmlTextWriterPtr writer; @@ -144,6 +186,8 @@ void Imdn::parse (const shared_ptr &chatMessage) { linphone_xmlparsing_context_destroy(xmlCtx); } +// ----------------------------------------------------------------------------- + void Imdn::parse (const shared_ptr &imdnMessage, xmlparsing_context_t *xmlCtx) { char xpathStr[MAX_XPATH_LENGTH]; char *messageIdStr = nullptr; @@ -208,4 +252,38 @@ void Imdn::parse (const shared_ptr &imdnMessage, xmlparsing_context linphone_free_xml_text_content(datetimeStr); } +int Imdn::timerExpired (void *data, unsigned int revents) { + Imdn *d = reinterpret_cast(data); + d->stopTimer(); + d->send(); + return BELLE_SIP_STOP; +} + +// ----------------------------------------------------------------------------- + +void Imdn::send () { + if (!deliveredMessages.empty() || !displayedMessages.empty()) + chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages)->send(); + if (!nonDeliveredMessages.empty()) + chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages)->send(); +} + +void Imdn::startTimer () { + unsigned int duration = 500; + if (!timer) + timer = chatRoom->getCore()->getCCore()->sal->create_timer(timerExpired, this, duration, "imdn timeout"); + else + belle_sip_source_set_timeout(timer, duration); +} + +void Imdn::stopTimer () { + if (timer) { + auto core = chatRoom->getCore()->getCCore(); + if (core && core->sal) + core->sal->cancel_timer(timer); + belle_sip_object_unref(timer); + timer = nullptr; + } +} + LINPHONE_END_NAMESPACE diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index e6eea4766..63927ab52 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -28,6 +28,7 @@ LINPHONE_BEGIN_NAMESPACE +class ChatMessage; class ChatRoom; class Imdn { @@ -37,14 +38,40 @@ public: Display }; + struct MessageReason { + MessageReason (const std::shared_ptr &message, LinphoneReason reason) + : message(message), reason(reason) {} + + const std::shared_ptr message; + LinphoneReason reason; + }; + + Imdn (ChatRoom *chatRoom); + ~Imdn (); + + void notifyDelivery (const std::shared_ptr &message); + void notifyDeliveryError (const std::shared_ptr &message, LinphoneReason reason); + void notifyDisplay (const std::shared_ptr &message); + static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason); static void parse (const std::shared_ptr &chatMessage); private: static void parse (const std::shared_ptr &chatMessage, xmlparsing_context_t *xmlCtx); + static int timerExpired (void *data, unsigned int revents); + + void send (); + void startTimer (); + void stopTimer (); private: static const std::string imdnPrefix; + + ChatRoom *chatRoom = nullptr; + std::list> deliveredMessages; + std::list> displayedMessages; + std::list nonDeliveredMessages; + belle_sip_source_t *timer = nullptr; }; LINPHONE_END_NAMESPACE From 035503cd533407a3fc0ac47e0a66896fbbc75e8f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 Apr 2018 15:53:49 +0200 Subject: [PATCH 046/143] Add new imdn in group chat tester. --- tester/group_chat_tester.c | 77 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index a8d29303c..d5c5b427b 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -3062,9 +3062,6 @@ static void imdn_for_group_chat_room (void) { linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(marie->lc)); linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(pauline->lc)); linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(chloe->lc)); - linphone_config_set_bool(linphone_core_get_config(marie->lc), "misc", "enable_simple_group_chat_message_state", FALSE); - linphone_config_set_bool(linphone_core_get_config(pauline->lc), "misc", "enable_simple_group_chat_message_state", FALSE); - linphone_config_set_bool(linphone_core_get_config(chloe->lc), "misc", "enable_simple_group_chat_message_state", FALSE); // Marie creates a new group chat room const char *initialSubject = "Colleagues"; @@ -3147,6 +3144,79 @@ end: linphone_core_manager_destroy(chloe); } +static void aggregated_imdn_for_group_chat_room (void) { + LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); + LinphoneCoreManager *chloe = linphone_core_manager_create("chloe_rc"); + bctbx_list_t *coresManagerList = NULL; + bctbx_list_t *participantsAddresses = NULL; + coresManagerList = bctbx_list_append(coresManagerList, marie); + coresManagerList = bctbx_list_append(coresManagerList, pauline); + coresManagerList = bctbx_list_append(coresManagerList, chloe); + bctbx_list_t *coresList = init_core_for_conference(coresManagerList); + start_core_for_conference(coresManagerList); + participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc))); + participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(chloe->lc))); + stats initialMarieStats = marie->stat; + stats initialPaulineStats = pauline->stat; + stats initialChloeStats = chloe->stat; + + // Enable IMDN + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(marie->lc)); + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(pauline->lc)); + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(chloe->lc)); + + // Marie creates a new group chat room + const char *initialSubject = "Colleagues"; + LinphoneChatRoom *marieCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject, -1); + const LinphoneAddress *confAddr = linphone_chat_room_get_conference_address(marieCr); + + // Check that the chat room is correctly created on Pauline's side and that the participants are added + LinphoneChatRoom *paulineCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 2, FALSE); + + // Check that the chat room is correctly created on Chloe's side and that the participants are added + LinphoneChatRoom *chloeCr = check_creation_chat_room_client_side(coresList, chloe, &initialChloeStats, confAddr, initialSubject, 2, FALSE); + + // Chloe begins composing a message + const char *chloeTextMessage = "Hello"; + const char *chloeTextMessage2 = "Long time no talk"; + const char *chloeTextMessage3 = "How are you?"; + LinphoneChatMessage *chloeMessage = _send_message(chloeCr, chloeTextMessage); + LinphoneChatMessage *chloeMessage2 = _send_message(chloeCr, chloeTextMessage2); + LinphoneChatMessage *chloeMessage3 = _send_message(chloeCr, chloeTextMessage3); + BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, initialMarieStats.number_of_LinphoneMessageReceived + 3, 3000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 3, 3000)); + LinphoneChatMessage *marieLastMsg = marie->stat.last_received_chat_message; + if (!BC_ASSERT_PTR_NOT_NULL(marieLastMsg)) + goto end; + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marieLastMsg), chloeTextMessage3); + LinphoneAddress *chloeAddr = linphone_address_new(linphone_core_get_identity(chloe->lc)); + BC_ASSERT_TRUE(linphone_address_weak_equal(chloeAddr, linphone_chat_message_get_from_address(marieLastMsg))); + linphone_address_unref(chloeAddr); + + // Mark the messages as read on Marie's and Pauline's sides + linphone_chat_room_mark_as_read(marieCr); + linphone_chat_room_mark_as_read(paulineCr); + BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 1000)); + BC_ASSERT_EQUAL(chloe->stat.number_of_LinphoneMessageDeliveredToUser, 0, int, "%d"); + + linphone_chat_message_unref(chloeMessage3); + linphone_chat_message_unref(chloeMessage2); + linphone_chat_message_unref(chloeMessage); + +end: + // Clean db from chat room + linphone_core_manager_delete_chat_room(marie, marieCr, coresList); + linphone_core_manager_delete_chat_room(chloe, chloeCr, coresList); + linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList); + + bctbx_list_free(coresList); + bctbx_list_free(coresManagerList); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(chloe); +} + static void find_one_to_one_chat_room (void) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); @@ -3333,6 +3403,7 @@ test_t group_chat_tests[] = { TEST_NO_TAG("New unique one-to-one chatroom after both participants left", group_chat_room_new_unique_one_to_one_chat_room_after_both_participants_left), TEST_NO_TAG("Unique one-to-one chatroom re-created from the party that deleted it, with inactive devices", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2), TEST_NO_TAG("IMDN for group chat room", imdn_for_group_chat_room), + TEST_NO_TAG("Aggregated IMDN for group chat room", aggregated_imdn_for_group_chat_room), TEST_NO_TAG("Find one to one chat room", find_one_to_one_chat_room), TEST_NO_TAG("New device after group chat room creation", group_chat_room_new_device_after_creation) }; From d0a8b3f15c440cbb5b3f88ef1c8d7af36cad454f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 Apr 2018 15:54:07 +0200 Subject: [PATCH 047/143] Correctly set Content-Disposition header on multipart content. --- src/content/content-manager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index d4d07cf70..c82b4d432 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -23,6 +23,7 @@ #include "linphone/api/c-content.h" +#include "content-disposition.h" #include "content-manager.h" #include "content-type.h" #include "content/content.h" @@ -47,7 +48,10 @@ list ContentManager::multipartToContentList (const Content &content) { for (const belle_sip_list_t *parts = sal_body_handler_get_parts(sbh); parts; parts = parts->next) { SalBodyHandler *part = (SalBodyHandler *)parts->data; LinphoneContent *cContent = linphone_content_from_sal_body_handler(part); - contents.push_back(*L_GET_CPP_PTR_FROM_C_OBJECT(cContent)); + Content *cppContent = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); + if (content.getContentDisposition().isValid()) + cppContent->setContentDisposition(content.getContentDisposition()); + contents.push_back(*cppContent); linphone_content_unref(cContent); } @@ -61,7 +65,12 @@ Content ContentManager::contentListToMultipart (const list &contents) ); mpbh = (belle_sip_multipart_body_handler_t *)belle_sip_object_ref(mpbh); + ContentDisposition disposition; for (Content *content : contents) { + // Is this content-disposition stuff generic or only valid for notification content-disposition? + if (content->getContentDisposition().isValid()) + disposition = content->getContentDisposition(); + LinphoneContent *cContent = L_GET_C_BACK_PTR(content); SalBodyHandler *sbh = sal_body_handler_from_content(cContent); belle_sip_multipart_body_handler_add_part(mpbh, BELLE_SIP_BODY_HANDLER(sbh)); @@ -76,6 +85,8 @@ Content ContentManager::contentListToMultipart (const list &contents) belle_sip_object_unref(mpbh); Content content = *L_GET_CPP_PTR_FROM_C_OBJECT(cContent); + if (disposition.isValid()) + content.setContentDisposition(disposition); linphone_content_unref(cContent); return content; } From 41259c585abc15258e6bdec8749a6ea9db8f1f64 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 Apr 2018 16:47:59 +0200 Subject: [PATCH 048/143] Compress body of imdn and is-composing messages. --- src/chat/chat-message/chat-message-p.h | 1 + src/chat/chat-message/chat-message.cpp | 2 ++ src/chat/chat-message/notification-message.cpp | 1 + src/sal/message-op-interface.h | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index a8e9ae60f..464ed8077 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -174,6 +174,7 @@ protected: bool negativeDeliveryNotificationRequired = true; bool positiveDeliveryNotificationRequired = true; bool toBeStored = true; + std::string contentEncoding; private: // TODO: Clean attributes. diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 22321eda6..a8e0855cc 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -770,6 +770,8 @@ void ChatMessagePrivate::send () { } else { if (!internalContent.getContentType().isValid()) internalContent.setContentType(ContentType::PlainText); + if (!contentEncoding.empty()) + internalContent.setContentEncoding(contentEncoding); msgOp->sendMessage(internalContent); } diff --git a/src/chat/chat-message/notification-message.cpp b/src/chat/chat-message/notification-message.cpp index eefcdaf20..16c649d13 100644 --- a/src/chat/chat-message/notification-message.cpp +++ b/src/chat/chat-message/notification-message.cpp @@ -37,6 +37,7 @@ NotificationMessage::NotificationMessage (NotificationMessagePrivate &p) : ChatM d->negativeDeliveryNotificationRequired = false; d->positiveDeliveryNotificationRequired = false; d->toBeStored = false; + d->contentEncoding = "deflate"; } void NotificationMessage::setToBeStored (bool value) { diff --git a/src/sal/message-op-interface.h b/src/sal/message-op-interface.h index ea00bdc6a..981f20e1d 100644 --- a/src/sal/message-op-interface.h +++ b/src/sal/message-op-interface.h @@ -41,6 +41,12 @@ protected: BELLE_SIP_MESSAGE(req), BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime)) ); + std::string contentEncoding = content.getContentEncoding(); + if (!contentEncoding.empty()) + belle_sip_message_add_header( + BELLE_SIP_MESSAGE(req), + belle_sip_header_create("Content-Encoding", contentEncoding.c_str()) + ); const ContentType &contentType = content.getContentType(); std::string contentTypeStr = std::string(BELLE_SIP_CONTENT_TYPE ": ") + contentType.asString(); belle_sip_message_add_header( From 9c4cd6cd60ce366772456593184df1d232ec5130 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 17 Apr 2018 11:43:12 +0200 Subject: [PATCH 049/143] Use xsd for imdn xml handling. --- src/CMakeLists.txt | 4 + src/chat/notification/imdn.cpp | 235 +-- src/chat/notification/imdn.h | 3 - src/xml/conference-info.cpp | 90 +- src/xml/conference-info.h | 62 +- src/xml/epilogue.txt | 3 + src/xml/generate.py | 6 + src/xml/imdn.cpp | 3440 ++++++++++++++++++++++++++++++++ src/xml/imdn.h | 1730 ++++++++++++++++ src/xml/imdn.xsd | 158 ++ src/xml/linphone-imdn.cpp | 717 +++++++ src/xml/linphone-imdn.h | 592 ++++++ src/xml/linphone-imdn.xsd | 15 + src/xml/prologue.txt | 5 +- src/xml/resource-lists.cpp | 52 +- src/xml/resource-lists.h | 40 +- src/xml/xml.cpp | 44 +- src/xml/xml.h | 10 +- tester/group_chat_tester.c | 10 +- 19 files changed, 6942 insertions(+), 274 deletions(-) create mode 100644 src/xml/imdn.cpp create mode 100644 src/xml/imdn.h create mode 100644 src/xml/imdn.xsd create mode 100644 src/xml/linphone-imdn.cpp create mode 100644 src/xml/linphone-imdn.h create mode 100644 src/xml/linphone-imdn.xsd diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6f4568cd..f5617ed65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -164,6 +164,8 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES utils/payload-type-handler.h variant/variant.h xml/conference-info.h + xml/imdn.h + xml/linphone-imdn.h xml/resource-lists.h xml/xml.h ) @@ -286,6 +288,8 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES utils/utils.cpp variant/variant.cpp xml/conference-info.cpp + xml/imdn.cpp + xml/linphone-imdn.cpp xml/resource-lists.cpp xml/xml.cpp ) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index da89e9810..203eb7846 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -23,6 +23,8 @@ #include "chat/chat-room/chat-room-p.h" #include "core/core.h" #include "logger/logger.h" +#include "xml/imdn.h" +#include "xml/linphone-imdn.h" #include "imdn.h" @@ -32,8 +34,6 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -const string Imdn::imdnPrefix = "/imdn:imdn"; - // ----------------------------------------------------------------------------- Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) {} @@ -74,184 +74,75 @@ void Imdn::notifyDisplay (const shared_ptr &message) { // ----------------------------------------------------------------------------- -string Imdn::createXml (const string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason) { - xmlBufferPtr buf; - xmlTextWriterPtr writer; - int err; - string content; - char *datetime = nullptr; - - // Check that the chat message has a message id. - if (id.empty()) - return content; - - buf = xmlBufferCreate(); - if (buf == nullptr) { - lError() << "Error creating the XML buffer"; - return content; - } - writer = xmlNewTextWriterMemory(buf, 0); - if (writer == nullptr) { - lError() << "Error creating the XML writer"; - return content; - } - - datetime = linphone_timestamp_to_rfc3339_string(time); - err = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", nullptr); - if (err >= 0) { - err = xmlTextWriterStartElementNS(writer, nullptr, (const xmlChar *)"imdn", - (const xmlChar *)"urn:ietf:params:xml:ns:imdn"); - } - if ((err >= 0) && (reason != LinphoneReasonNone)) { - err = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)"xmlns", (const xmlChar *)"linphoneimdn", nullptr, (const xmlChar *)"http://www.linphone.org/xsds/imdn.xsd"); - } - if (err >= 0) { - err = xmlTextWriterWriteElement(writer, (const xmlChar *)"message-id", (const xmlChar *)id.c_str()); - } - if (err >= 0) { - err = xmlTextWriterWriteElement(writer, (const xmlChar *)"datetime", (const xmlChar *)datetime); - } - if (err >= 0) { - if (imdnType == Imdn::Type::Delivery) { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivery-notification"); - } else { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"display-notification"); - } - } - if (err >= 0) { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"status"); - } - if (err >= 0) { - if (reason == LinphoneReasonNone) { - if (imdnType == Imdn::Type::Delivery) { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"delivered"); - } else { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"displayed"); - } - } else { - err = xmlTextWriterStartElement(writer, (const xmlChar *)"error"); - } - } - if (err >= 0) { - // Close the "delivered", "displayed" or "error" element. - err = xmlTextWriterEndElement(writer); - } - if ((err >= 0) && (reason != LinphoneReasonNone)) { - err = xmlTextWriterStartElementNS(writer, (const xmlChar *)"linphoneimdn", (const xmlChar *)"reason", nullptr); - if (err >= 0) { - char codestr[16]; - snprintf(codestr, 16, "%d", linphone_reason_to_error_code(reason)); - err = xmlTextWriterWriteAttribute(writer, (const xmlChar *)"code", (const xmlChar *)codestr); - } - if (err >= 0) { - err = xmlTextWriterWriteString(writer, (const xmlChar *)linphone_reason_to_string(reason)); - } - if (err >= 0) { - err = xmlTextWriterEndElement(writer); - } - } - if (err >= 0) { - // Close the "status" element. - err = xmlTextWriterEndElement(writer); - } - if (err >= 0) { - // Close the "delivery-notification" or "display-notification" element. - err = xmlTextWriterEndElement(writer); - } - if (err >= 0) { - // Close the "imdn" element. - err = xmlTextWriterEndElement(writer); - } - if (err >= 0) { - err = xmlTextWriterEndDocument(writer); - } - if (err > 0) { - // xmlTextWriterEndDocument returns the size of the content. - content = string((char *)buf->content); - } - xmlFreeTextWriter(writer); - xmlBufferFree(buf); +string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, LinphoneReason reason) { + char *datetime = linphone_timestamp_to_rfc3339_string(timestamp); + Xsd::Imdn::Imdn imdn(id, datetime); ms_free(datetime); - return content; + if (imdnType == Imdn::Type::Delivery) { + Xsd::Imdn::Status status; + if (reason == LinphoneReasonNone) { + auto delivered = Xsd::Imdn::Delivered(); + status.setDelivered(delivered); + } else { + auto failed = Xsd::Imdn::Failed(); + status.setFailed(failed); + Xsd::LinphoneImdn::ImdnReason imdnReason(linphone_reason_to_string(reason)); + imdnReason.setCode(linphone_reason_to_error_code(reason)); + status.setReason(imdnReason); + } + Xsd::Imdn::DeliveryNotification deliveryNotification(status); + imdn.setDeliveryNotification(deliveryNotification); + } else if (imdnType == Imdn::Type::Display) { + Xsd::Imdn::Status1 status; + auto displayed = Xsd::Imdn::Displayed(); + status.setDisplayed(displayed); + Xsd::Imdn::DisplayNotification displayNotification(status); + imdn.setDisplayNotification(displayNotification); + } + + stringstream ss; + Xsd::XmlSchema::NamespaceInfomap map; + map[""].name = "urn:ietf:params:xml:ns:imdn"; + map["imdn"].name = "http://www.linphone.org/xsds/imdn.xsd"; + Xsd::Imdn::serializeImdn(ss, imdn, map); + return ss.str(); } void Imdn::parse (const shared_ptr &chatMessage) { - xmlparsing_context_t *xmlCtx = linphone_xmlparsing_context_new(); - xmlSetGenericErrorFunc(xmlCtx, linphone_xmlparsing_genericxml_error); - xmlCtx->doc = xmlReadDoc((const unsigned char *)chatMessage->getPrivate()->getText().c_str(), 0, nullptr, 0); - if (xmlCtx->doc) - parse(chatMessage, xmlCtx); - else - lWarning() << "Wrongly formatted IMDN XML: " << xmlCtx->errorBuffer; - linphone_xmlparsing_context_destroy(xmlCtx); + shared_ptr cr = chatMessage->getChatRoom(); + for (const auto &content : chatMessage->getPrivate()->getContents()) { + istringstream data(content->getBodyAsString()); + unique_ptr imdn(Xsd::Imdn::parseImdn(data, Xsd::XmlSchema::Flags::dont_validate)); + if (!imdn) + continue; + shared_ptr cm = cr->findChatMessage(imdn->getMessageId()); + if (!cm) { + lWarning() << "Received IMDN for unknown message " << imdn->getMessageId(); + } else { + auto policy = linphone_core_get_im_notif_policy(cr->getCore()->getCCore()); + time_t imdnTime = chatMessage->getTime(); + const IdentityAddress &participantAddress = chatMessage->getFromAddress().getAddressWithoutGruu(); + auto &deliveryNotification = imdn->getDeliveryNotification(); + auto &displayNotification = imdn->getDisplayNotification(); + if (deliveryNotification.present()) { + auto &status = deliveryNotification.get().getStatus(); + if (status.getDelivered().present() && linphone_im_notif_policy_get_recv_imdn_delivered(policy)) + cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::DeliveredToUser, imdnTime); + else if ((status.getFailed().present() || status.getError().present()) + && linphone_im_notif_policy_get_recv_imdn_delivered(policy) + ) + cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::NotDelivered, imdnTime); + } else if (displayNotification.present()) { + auto &status = displayNotification.get().getStatus(); + if (status.getDisplayed().present() && linphone_im_notif_policy_get_recv_imdn_displayed(policy)) + cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::Displayed, imdnTime); + } + } + } } // ----------------------------------------------------------------------------- -void Imdn::parse (const shared_ptr &imdnMessage, xmlparsing_context_t *xmlCtx) { - char xpathStr[MAX_XPATH_LENGTH]; - char *messageIdStr = nullptr; - char *datetimeStr = nullptr; - if (linphone_create_xml_xpath_context(xmlCtx) < 0) - return; - - xmlXPathRegisterNs(xmlCtx->xpath_ctx, (const xmlChar *)"imdn", (const xmlChar *)"urn:ietf:params:xml:ns:imdn"); - xmlXPathObjectPtr imdnObject = linphone_get_xml_xpath_object_for_node_list(xmlCtx, imdnPrefix.c_str()); - if (imdnObject) { - if (imdnObject->nodesetval && (imdnObject->nodesetval->nodeNr >= 1)) { - snprintf(xpathStr, sizeof(xpathStr), "%s[1]/imdn:message-id", imdnPrefix.c_str()); - messageIdStr = linphone_get_xml_text_content(xmlCtx, xpathStr); - snprintf(xpathStr, sizeof(xpathStr), "%s[1]/imdn:datetime", imdnPrefix.c_str()); - datetimeStr = linphone_get_xml_text_content(xmlCtx, xpathStr); - } - xmlXPathFreeObject(imdnObject); - } - - if (messageIdStr && datetimeStr) { - shared_ptr cr = imdnMessage->getChatRoom(); - shared_ptr cm = cr->findChatMessage(messageIdStr); - const IdentityAddress &participantAddress = imdnMessage->getFromAddress().getAddressWithoutGruu(); - if (!cm) { - lWarning() << "Received IMDN for unknown message " << messageIdStr; - } else { - time_t imdnTime = imdnMessage->getTime(); - LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(cr->getCore()->getCCore()); - snprintf(xpathStr, sizeof(xpathStr), "%s[1]/imdn:delivery-notification/imdn:status", imdnPrefix.c_str()); - xmlXPathObjectPtr deliveryStatusObject = linphone_get_xml_xpath_object_for_node_list(xmlCtx, xpathStr); - snprintf(xpathStr, sizeof(xpathStr), "%s[1]/imdn:display-notification/imdn:status", imdnPrefix.c_str()); - xmlXPathObjectPtr displayStatusObject = linphone_get_xml_xpath_object_for_node_list(xmlCtx, xpathStr); - if (deliveryStatusObject && linphone_im_notif_policy_get_recv_imdn_delivered(policy)) { - if (deliveryStatusObject->nodesetval && (deliveryStatusObject->nodesetval->nodeNr >= 1)) { - xmlNodePtr node = deliveryStatusObject->nodesetval->nodeTab[0]; - if (node->children && node->children->name) { - if (strcmp((const char *)node->children->name, "delivered") == 0) { - cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::DeliveredToUser, imdnTime); - } else if (strcmp((const char *)node->children->name, "error") == 0) { - cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::NotDelivered, imdnTime); - } - } - } - xmlXPathFreeObject(deliveryStatusObject); - } - if (displayStatusObject && linphone_im_notif_policy_get_recv_imdn_displayed(policy)) { - if (displayStatusObject->nodesetval && (displayStatusObject->nodesetval->nodeNr >= 1)) { - xmlNodePtr node = displayStatusObject->nodesetval->nodeTab[0]; - if (node->children && node->children->name) { - if (strcmp((const char *)node->children->name, "displayed") == 0) { - cm->getPrivate()->setParticipantState(participantAddress, ChatMessage::State::Displayed, imdnTime); - } - } - } - xmlXPathFreeObject(displayStatusObject); - } - } - } - if (messageIdStr) - linphone_free_xml_text_content(messageIdStr); - if (datetimeStr) - linphone_free_xml_text_content(datetimeStr); -} - int Imdn::timerExpired (void *data, unsigned int revents) { Imdn *d = reinterpret_cast(data); d->stopTimer(); diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index 63927ab52..ca5095319 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -57,7 +57,6 @@ public: static void parse (const std::shared_ptr &chatMessage); private: - static void parse (const std::shared_ptr &chatMessage, xmlparsing_context_t *xmlCtx); static int timerExpired (void *data, unsigned int revents); void send (); @@ -65,8 +64,6 @@ private: void stopTimer (); private: - static const std::string imdnPrefix; - ChatRoom *chatRoom = nullptr; std::list> deliveredMessages; std::list> displayedMessages; diff --git a/src/xml/conference-info.cpp b/src/xml/conference-info.cpp index 5089051d7..fc2f8aac3 100644 --- a/src/xml/conference-info.cpp +++ b/src/xml/conference-info.cpp @@ -36,9 +36,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -54,7 +55,7 @@ namespace LinphonePrivate namespace ConferenceInfo { // ConferenceType - // + // const ConferenceType::ConferenceDescriptionOptional& ConferenceType:: getConferenceDescription () const @@ -376,7 +377,7 @@ namespace LinphonePrivate // StateType - // + // StateType:: StateType (Value v) @@ -413,7 +414,7 @@ namespace LinphonePrivate StateType& StateType:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_StateType_literals_[v]); return *this; @@ -421,7 +422,7 @@ namespace LinphonePrivate // ConferenceDescriptionType - // + // const ConferenceDescriptionType::DisplayTextOptional& ConferenceDescriptionType:: getDisplayText () const @@ -707,7 +708,7 @@ namespace LinphonePrivate // HostType - // + // const HostType::DisplayTextOptional& HostType:: getDisplayText () const @@ -849,7 +850,7 @@ namespace LinphonePrivate // ConferenceStateType - // + // const ConferenceStateType::UserCountOptional& ConferenceStateType:: getUserCount () const @@ -973,7 +974,7 @@ namespace LinphonePrivate // ConferenceMediaType - // + // const ConferenceMediaType::EntrySequence& ConferenceMediaType:: getEntry () const @@ -1025,7 +1026,7 @@ namespace LinphonePrivate // ConferenceMediumType - // + // const ConferenceMediumType::DisplayTextOptional& ConferenceMediumType:: getDisplayText () const @@ -1197,7 +1198,7 @@ namespace LinphonePrivate // UrisType - // + // const UrisType::EntrySequence& UrisType:: getEntry () const @@ -1285,7 +1286,7 @@ namespace LinphonePrivate // UriType - // + // const UriType::UriType1& UriType:: getUri () const @@ -1481,7 +1482,7 @@ namespace LinphonePrivate } // UsersType - // + // const UsersType::UserSequence& UsersType:: getUser () const @@ -1587,7 +1588,7 @@ namespace LinphonePrivate // UserType - // + // const UserType::DisplayTextOptional& UserType:: getDisplayText () const @@ -1873,7 +1874,7 @@ namespace LinphonePrivate // UserRolesType - // + // const UserRolesType::EntrySequence& UserRolesType:: getEntry () const @@ -1949,7 +1950,7 @@ namespace LinphonePrivate } // EndpointType - // + // const EndpointType::DisplayTextOptional& EndpointType:: getDisplayText () const @@ -2325,7 +2326,7 @@ namespace LinphonePrivate // EndpointStatusType - // + // EndpointStatusType:: EndpointStatusType (Value v) @@ -2362,7 +2363,7 @@ namespace LinphonePrivate EndpointStatusType& EndpointStatusType:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_EndpointStatusType_literals_[v]); return *this; @@ -2370,7 +2371,7 @@ namespace LinphonePrivate // JoiningType - // + // JoiningType:: JoiningType (Value v) @@ -2407,7 +2408,7 @@ namespace LinphonePrivate JoiningType& JoiningType:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_JoiningType_literals_[v]); return *this; @@ -2415,7 +2416,7 @@ namespace LinphonePrivate // DisconnectionType - // + // DisconnectionType:: DisconnectionType (Value v) @@ -2452,7 +2453,7 @@ namespace LinphonePrivate DisconnectionType& DisconnectionType:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_DisconnectionType_literals_[v]); return *this; @@ -2460,7 +2461,7 @@ namespace LinphonePrivate // ExecutionType - // + // const ExecutionType::WhenOptional& ExecutionType:: getWhen () const @@ -2584,7 +2585,7 @@ namespace LinphonePrivate // CallType - // + // const CallType::SipOptional& CallType:: getSip () const @@ -2666,7 +2667,7 @@ namespace LinphonePrivate // SipDialogIdType - // + // const SipDialogIdType::DisplayTextOptional& SipDialogIdType:: getDisplayText () const @@ -2838,7 +2839,7 @@ namespace LinphonePrivate // MediaType - // + // const MediaType::DisplayTextOptional& MediaType:: getDisplayText () const @@ -3070,7 +3071,7 @@ namespace LinphonePrivate // MediaStatusType - // + // MediaStatusType:: MediaStatusType (Value v) @@ -3107,7 +3108,7 @@ namespace LinphonePrivate MediaStatusType& MediaStatusType:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_MediaStatusType_literals_[v]); return *this; @@ -3115,7 +3116,7 @@ namespace LinphonePrivate // SidebarsByValType - // + // const SidebarsByValType::EntrySequence& SidebarsByValType:: getEntry () const @@ -3208,6 +3209,15 @@ namespace LinphonePrivate #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -6779,6 +6789,15 @@ namespace LinphonePrivate #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -7563,6 +7582,15 @@ namespace LinphonePrivate #include #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -9304,8 +9332,12 @@ namespace LinphonePrivate // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif // // End epilogue. + diff --git a/src/xml/conference-info.h b/src/xml/conference-info.h index 79e9e19c3..cc7c48a96 100644 --- a/src/xml/conference-info.h +++ b/src/xml/conference-info.h @@ -51,9 +51,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -240,6 +241,8 @@ namespace LinphonePrivate typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; typedef ::xsd::cxx::tree::serialization< char > Serialization; // Error handler callback interface. @@ -573,7 +576,7 @@ namespace LinphonePrivate ConferenceType& operator= (const ConferenceType& x); - virtual + virtual ~ConferenceType (); // Implementation. @@ -882,7 +885,7 @@ namespace LinphonePrivate ConferenceDescriptionType& operator= (const ConferenceDescriptionType& x); - virtual + virtual ~ConferenceDescriptionType (); // Implementation. @@ -1030,7 +1033,7 @@ namespace LinphonePrivate HostType& operator= (const HostType& x); - virtual + virtual ~HostType (); // Implementation. @@ -1164,7 +1167,7 @@ namespace LinphonePrivate ConferenceStateType& operator= (const ConferenceStateType& x); - virtual + virtual ~ConferenceStateType (); // Implementation. @@ -1246,7 +1249,7 @@ namespace LinphonePrivate ConferenceMediaType& operator= (const ConferenceMediaType& x); - virtual + virtual ~ConferenceMediaType (); // Implementation. @@ -1406,7 +1409,7 @@ namespace LinphonePrivate ConferenceMediumType& operator= (const ConferenceMediumType& x); - virtual + virtual ~ConferenceMediumType (); // Implementation. @@ -1512,7 +1515,7 @@ namespace LinphonePrivate UrisType& operator= (const UrisType& x); - virtual + virtual ~UrisType (); // Implementation. @@ -1674,7 +1677,7 @@ namespace LinphonePrivate UriType& operator= (const UriType& x); - virtual + virtual ~UriType (); // Implementation. @@ -1730,7 +1733,7 @@ namespace LinphonePrivate _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; - virtual + virtual ~KeywordsType (); }; @@ -1834,7 +1837,7 @@ namespace LinphonePrivate UsersType& operator= (const UsersType& x); - virtual + virtual ~UsersType (); // Implementation. @@ -2080,7 +2083,7 @@ namespace LinphonePrivate UserType& operator= (const UserType& x); - virtual + virtual ~UserType (); // Implementation. @@ -2168,7 +2171,7 @@ namespace LinphonePrivate UserRolesType& operator= (const UserRolesType& x); - virtual + virtual ~UserRolesType (); // Implementation. @@ -2220,7 +2223,7 @@ namespace LinphonePrivate _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; - virtual + virtual ~UserLanguagesType (); }; @@ -2513,7 +2516,7 @@ namespace LinphonePrivate EndpointType& operator= (const EndpointType& x); - virtual + virtual ~EndpointType (); // Implementation. @@ -2828,7 +2831,7 @@ namespace LinphonePrivate ExecutionType& operator= (const ExecutionType& x); - virtual + virtual ~ExecutionType (); // Implementation. @@ -2928,7 +2931,7 @@ namespace LinphonePrivate CallType& operator= (const CallType& x); - virtual + virtual ~CallType (); // Implementation. @@ -3089,7 +3092,7 @@ namespace LinphonePrivate SipDialogIdType& operator= (const SipDialogIdType& x); - virtual + virtual ~SipDialogIdType (); // Implementation. @@ -3295,7 +3298,7 @@ namespace LinphonePrivate MediaType& operator= (const MediaType& x); - virtual + virtual ~MediaType (); // Implementation. @@ -3461,7 +3464,7 @@ namespace LinphonePrivate SidebarsByValType& operator= (const SidebarsByValType& x); - virtual + virtual ~SidebarsByValType (); // Implementation. @@ -3708,14 +3711,14 @@ namespace LinphonePrivate void serializeConferenceInfo (::std::ostream& os, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); void serializeConferenceInfo (::std::ostream& os, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -3723,7 +3726,7 @@ namespace LinphonePrivate void serializeConferenceInfo (::std::ostream& os, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, ::xercesc::DOMErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -3734,14 +3737,14 @@ namespace LinphonePrivate void serializeConferenceInfo (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); void serializeConferenceInfo (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -3749,7 +3752,7 @@ namespace LinphonePrivate void serializeConferenceInfo (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, ::xercesc::DOMErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -3767,7 +3770,7 @@ namespace LinphonePrivate // ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > - serializeConferenceInfo (const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, + serializeConferenceInfo (const ::LinphonePrivate::Xsd::ConferenceInfo::ConferenceType& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); @@ -3899,6 +3902,9 @@ namespace LinphonePrivate // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif diff --git a/src/xml/epilogue.txt b/src/xml/epilogue.txt index ebe68c888..b4e4ec06e 100644 --- a/src/xml/epilogue.txt +++ b/src/xml/epilogue.txt @@ -1,3 +1,6 @@ +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif diff --git a/src/xml/generate.py b/src/xml/generate.py index 0046c4b05..c2fb8075a 100755 --- a/src/xml/generate.py +++ b/src/xml/generate.py @@ -51,6 +51,7 @@ def generate(name): "--generate-serialization", "--generate-ostream", "--generate-detach", + "--generate-polymorphic", "--std", "c++11", "--type-naming", "java", "--function-naming", "java", @@ -62,6 +63,7 @@ def generate(name): "--show-sloc", "--prologue-file", prologue_file, "--epilogue-file", epilogue_file, + "--root-element-first", "--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-([^,-]+)-?([^,-]*)%\\u$1\\u$2\\u$3\\u$4%", "--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-?([^,-]*)%\\u$1\\u$2\\u$3%", "--type-regex", "%(?:[^ ]* )?([^,-]+)-?([^,-]*)%\\u$1\\u$2%", @@ -90,6 +92,8 @@ def generate(name): "--serializer-regex", "%([^-]+)-?([^-]*)%serialize\\u$1\\u$2%", "--namespace-map", "http://www.w3.org/2001/XMLSchema=LinphonePrivate::Xsd::XmlSchema", "--namespace-map", "urn:ietf:params:xml:ns:conference-info=LinphonePrivate::Xsd::ConferenceInfo", + "--namespace-map", "urn:ietf:params:xml:ns:imdn=LinphonePrivate::Xsd::Imdn", + "--namespace-map", "http://www.linphone.org/xsds/imdn.xsd=LinphonePrivate::Xsd::LinphoneImdn", "--namespace-map", "urn:ietf:params:xml:ns:resource-lists=LinphonePrivate::Xsd::ResourceLists", source_file ], shell=False) @@ -100,6 +104,8 @@ def generate(name): def main(argv = None): generate("xml") generate("conference-info") + generate("imdn") + generate("linphone-imdn") generate("resource-lists") if __name__ == "__main__": diff --git a/src/xml/imdn.cpp b/src/xml/imdn.cpp new file mode 100644 index 000000000..d180b9078 --- /dev/null +++ b/src/xml/imdn.cpp @@ -0,0 +1,3440 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#include "imdn.h" + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + // Imdn + // + + const Imdn::MessageIdType& Imdn:: + getMessageId () const + { + return this->message_id_.get (); + } + + Imdn::MessageIdType& Imdn:: + getMessageId () + { + return this->message_id_.get (); + } + + void Imdn:: + setMessageId (const MessageIdType& x) + { + this->message_id_.set (x); + } + + void Imdn:: + setMessageId (::std::unique_ptr< MessageIdType > x) + { + this->message_id_.set (std::move (x)); + } + + ::std::unique_ptr< Imdn::MessageIdType > Imdn:: + setDetachMessage_id () + { + return this->message_id_.detach (); + } + + const Imdn::DatetimeType& Imdn:: + getDatetime () const + { + return this->datetime_.get (); + } + + Imdn::DatetimeType& Imdn:: + getDatetime () + { + return this->datetime_.get (); + } + + void Imdn:: + setDatetime (const DatetimeType& x) + { + this->datetime_.set (x); + } + + void Imdn:: + setDatetime (::std::unique_ptr< DatetimeType > x) + { + this->datetime_.set (std::move (x)); + } + + ::std::unique_ptr< Imdn::DatetimeType > Imdn:: + setDetachDatetime () + { + return this->datetime_.detach (); + } + + const Imdn::RecipientUriOptional& Imdn:: + getRecipientUri () const + { + return this->recipient_uri_; + } + + Imdn::RecipientUriOptional& Imdn:: + getRecipientUri () + { + return this->recipient_uri_; + } + + void Imdn:: + setRecipientUri (const RecipientUriType& x) + { + this->recipient_uri_.set (x); + } + + void Imdn:: + setRecipientUri (const RecipientUriOptional& x) + { + this->recipient_uri_ = x; + } + + void Imdn:: + setRecipientUri (::std::unique_ptr< RecipientUriType > x) + { + this->recipient_uri_.set (std::move (x)); + } + + const Imdn::OriginalRecipientUriOptional& Imdn:: + getOriginalRecipientUri () const + { + return this->original_recipient_uri_; + } + + Imdn::OriginalRecipientUriOptional& Imdn:: + getOriginalRecipientUri () + { + return this->original_recipient_uri_; + } + + void Imdn:: + setOriginalRecipientUri (const OriginalRecipientUriType& x) + { + this->original_recipient_uri_.set (x); + } + + void Imdn:: + setOriginalRecipientUri (const OriginalRecipientUriOptional& x) + { + this->original_recipient_uri_ = x; + } + + void Imdn:: + setOriginalRecipientUri (::std::unique_ptr< OriginalRecipientUriType > x) + { + this->original_recipient_uri_.set (std::move (x)); + } + + const Imdn::SubjectOptional& Imdn:: + getSubject () const + { + return this->subject_; + } + + Imdn::SubjectOptional& Imdn:: + getSubject () + { + return this->subject_; + } + + void Imdn:: + setSubject (const SubjectType& x) + { + this->subject_.set (x); + } + + void Imdn:: + setSubject (const SubjectOptional& x) + { + this->subject_ = x; + } + + void Imdn:: + setSubject (::std::unique_ptr< SubjectType > x) + { + this->subject_.set (std::move (x)); + } + + const Imdn::DeliveryNotificationOptional& Imdn:: + getDeliveryNotification () const + { + return this->delivery_notification_; + } + + Imdn::DeliveryNotificationOptional& Imdn:: + getDeliveryNotification () + { + return this->delivery_notification_; + } + + void Imdn:: + setDeliveryNotification (const DeliveryNotificationType& x) + { + this->delivery_notification_.set (x); + } + + void Imdn:: + setDeliveryNotification (const DeliveryNotificationOptional& x) + { + this->delivery_notification_ = x; + } + + void Imdn:: + setDeliveryNotification (::std::unique_ptr< DeliveryNotificationType > x) + { + this->delivery_notification_.set (std::move (x)); + } + + const Imdn::DisplayNotificationOptional& Imdn:: + getDisplayNotification () const + { + return this->display_notification_; + } + + Imdn::DisplayNotificationOptional& Imdn:: + getDisplayNotification () + { + return this->display_notification_; + } + + void Imdn:: + setDisplayNotification (const DisplayNotificationType& x) + { + this->display_notification_.set (x); + } + + void Imdn:: + setDisplayNotification (const DisplayNotificationOptional& x) + { + this->display_notification_ = x; + } + + void Imdn:: + setDisplayNotification (::std::unique_ptr< DisplayNotificationType > x) + { + this->display_notification_.set (std::move (x)); + } + + const Imdn::ProcessingNotificationOptional& Imdn:: + getProcessingNotification () const + { + return this->processing_notification_; + } + + Imdn::ProcessingNotificationOptional& Imdn:: + getProcessingNotification () + { + return this->processing_notification_; + } + + void Imdn:: + setProcessingNotification (const ProcessingNotificationType& x) + { + this->processing_notification_.set (x); + } + + void Imdn:: + setProcessingNotification (const ProcessingNotificationOptional& x) + { + this->processing_notification_ = x; + } + + void Imdn:: + setProcessingNotification (::std::unique_ptr< ProcessingNotificationType > x) + { + this->processing_notification_.set (std::move (x)); + } + + const Imdn::AnySequence& Imdn:: + getAny () const + { + return this->any_; + } + + Imdn::AnySequence& Imdn:: + getAny () + { + return this->any_; + } + + void Imdn:: + setAny (const AnySequence& s) + { + this->any_ = s; + } + + const ::xercesc::DOMDocument& Imdn:: + getDomDocument () const + { + return *this->dom_document_; + } + + ::xercesc::DOMDocument& Imdn:: + getDomDocument () + { + return *this->dom_document_; + } + + + // DeliveryNotification + // + + const DeliveryNotification::StatusType& DeliveryNotification:: + getStatus () const + { + return this->status_.get (); + } + + DeliveryNotification::StatusType& DeliveryNotification:: + getStatus () + { + return this->status_.get (); + } + + void DeliveryNotification:: + setStatus (const StatusType& x) + { + this->status_.set (x); + } + + void DeliveryNotification:: + setStatus (::std::unique_ptr< StatusType > x) + { + this->status_.set (std::move (x)); + } + + ::std::unique_ptr< DeliveryNotification::StatusType > DeliveryNotification:: + setDetachStatus () + { + return this->status_.detach (); + } + + + // Delivered + // + + + // Failed + // + + + // DisplayNotification + // + + const DisplayNotification::StatusType& DisplayNotification:: + getStatus () const + { + return this->status_.get (); + } + + DisplayNotification::StatusType& DisplayNotification:: + getStatus () + { + return this->status_.get (); + } + + void DisplayNotification:: + setStatus (const StatusType& x) + { + this->status_.set (x); + } + + void DisplayNotification:: + setStatus (::std::unique_ptr< StatusType > x) + { + this->status_.set (std::move (x)); + } + + ::std::unique_ptr< DisplayNotification::StatusType > DisplayNotification:: + setDetachStatus () + { + return this->status_.detach (); + } + + + // Displayed + // + + + // ProcessingNotification + // + + const ProcessingNotification::StatusType& ProcessingNotification:: + getStatus () const + { + return this->status_.get (); + } + + ProcessingNotification::StatusType& ProcessingNotification:: + getStatus () + { + return this->status_.get (); + } + + void ProcessingNotification:: + setStatus (const StatusType& x) + { + this->status_.set (x); + } + + void ProcessingNotification:: + setStatus (::std::unique_ptr< StatusType > x) + { + this->status_.set (std::move (x)); + } + + ::std::unique_ptr< ProcessingNotification::StatusType > ProcessingNotification:: + setDetachStatus () + { + return this->status_.detach (); + } + + + // Processed + // + + + // Stored + // + + + // Forbidden + // + + + // Error + // + + + // Status + // + + const Status::DeliveredOptional& Status:: + getDelivered () const + { + return this->delivered_; + } + + Status::DeliveredOptional& Status:: + getDelivered () + { + return this->delivered_; + } + + void Status:: + setDelivered (const DeliveredType& x) + { + this->delivered_.set (x); + } + + void Status:: + setDelivered (const DeliveredOptional& x) + { + this->delivered_ = x; + } + + void Status:: + setDelivered (::std::unique_ptr< DeliveredType > x) + { + this->delivered_.set (std::move (x)); + } + + const Status::FailedOptional& Status:: + getFailed () const + { + return this->failed_; + } + + Status::FailedOptional& Status:: + getFailed () + { + return this->failed_; + } + + void Status:: + setFailed (const FailedType& x) + { + this->failed_.set (x); + } + + void Status:: + setFailed (const FailedOptional& x) + { + this->failed_ = x; + } + + void Status:: + setFailed (::std::unique_ptr< FailedType > x) + { + this->failed_.set (std::move (x)); + } + + const Status::ForbiddenOptional& Status:: + getForbidden () const + { + return this->forbidden_; + } + + Status::ForbiddenOptional& Status:: + getForbidden () + { + return this->forbidden_; + } + + void Status:: + setForbidden (const ForbiddenType& x) + { + this->forbidden_.set (x); + } + + void Status:: + setForbidden (const ForbiddenOptional& x) + { + this->forbidden_ = x; + } + + void Status:: + setForbidden (::std::unique_ptr< ForbiddenType > x) + { + this->forbidden_.set (std::move (x)); + } + + const Status::ErrorOptional& Status:: + getError () const + { + return this->error_; + } + + Status::ErrorOptional& Status:: + getError () + { + return this->error_; + } + + void Status:: + setError (const ErrorType& x) + { + this->error_.set (x); + } + + void Status:: + setError (const ErrorOptional& x) + { + this->error_ = x; + } + + void Status:: + setError (::std::unique_ptr< ErrorType > x) + { + this->error_.set (std::move (x)); + } + + const Status::ReasonOptional& Status:: + getReason () const + { + return this->reason_; + } + + Status::ReasonOptional& Status:: + getReason () + { + return this->reason_; + } + + void Status:: + setReason (const ReasonType& x) + { + this->reason_.set (x); + } + + void Status:: + setReason (const ReasonOptional& x) + { + this->reason_ = x; + } + + void Status:: + setReason (::std::unique_ptr< ReasonType > x) + { + this->reason_.set (std::move (x)); + } + + + // Status1 + // + + const Status1::DisplayedOptional& Status1:: + getDisplayed () const + { + return this->displayed_; + } + + Status1::DisplayedOptional& Status1:: + getDisplayed () + { + return this->displayed_; + } + + void Status1:: + setDisplayed (const DisplayedType& x) + { + this->displayed_.set (x); + } + + void Status1:: + setDisplayed (const DisplayedOptional& x) + { + this->displayed_ = x; + } + + void Status1:: + setDisplayed (::std::unique_ptr< DisplayedType > x) + { + this->displayed_.set (std::move (x)); + } + + const Status1::ForbiddenOptional& Status1:: + getForbidden () const + { + return this->forbidden_; + } + + Status1::ForbiddenOptional& Status1:: + getForbidden () + { + return this->forbidden_; + } + + void Status1:: + setForbidden (const ForbiddenType& x) + { + this->forbidden_.set (x); + } + + void Status1:: + setForbidden (const ForbiddenOptional& x) + { + this->forbidden_ = x; + } + + void Status1:: + setForbidden (::std::unique_ptr< ForbiddenType > x) + { + this->forbidden_.set (std::move (x)); + } + + const Status1::ErrorOptional& Status1:: + getError () const + { + return this->error_; + } + + Status1::ErrorOptional& Status1:: + getError () + { + return this->error_; + } + + void Status1:: + setError (const ErrorType& x) + { + this->error_.set (x); + } + + void Status1:: + setError (const ErrorOptional& x) + { + this->error_ = x; + } + + void Status1:: + setError (::std::unique_ptr< ErrorType > x) + { + this->error_.set (std::move (x)); + } + + const Status1::AnySequence& Status1:: + getAny () const + { + return this->any_; + } + + Status1::AnySequence& Status1:: + getAny () + { + return this->any_; + } + + void Status1:: + setAny (const AnySequence& s) + { + this->any_ = s; + } + + const ::xercesc::DOMDocument& Status1:: + getDomDocument () const + { + return *this->dom_document_; + } + + ::xercesc::DOMDocument& Status1:: + getDomDocument () + { + return *this->dom_document_; + } + + + // Status2 + // + + const Status2::ProcessedOptional& Status2:: + getProcessed () const + { + return this->processed_; + } + + Status2::ProcessedOptional& Status2:: + getProcessed () + { + return this->processed_; + } + + void Status2:: + setProcessed (const ProcessedType& x) + { + this->processed_.set (x); + } + + void Status2:: + setProcessed (const ProcessedOptional& x) + { + this->processed_ = x; + } + + void Status2:: + setProcessed (::std::unique_ptr< ProcessedType > x) + { + this->processed_.set (std::move (x)); + } + + const Status2::StoredOptional& Status2:: + getStored () const + { + return this->stored_; + } + + Status2::StoredOptional& Status2:: + getStored () + { + return this->stored_; + } + + void Status2:: + setStored (const StoredType& x) + { + this->stored_.set (x); + } + + void Status2:: + setStored (const StoredOptional& x) + { + this->stored_ = x; + } + + void Status2:: + setStored (::std::unique_ptr< StoredType > x) + { + this->stored_.set (std::move (x)); + } + + const Status2::ForbiddenOptional& Status2:: + getForbidden () const + { + return this->forbidden_; + } + + Status2::ForbiddenOptional& Status2:: + getForbidden () + { + return this->forbidden_; + } + + void Status2:: + setForbidden (const ForbiddenType& x) + { + this->forbidden_.set (x); + } + + void Status2:: + setForbidden (const ForbiddenOptional& x) + { + this->forbidden_ = x; + } + + void Status2:: + setForbidden (::std::unique_ptr< ForbiddenType > x) + { + this->forbidden_.set (std::move (x)); + } + + const Status2::ErrorOptional& Status2:: + getError () const + { + return this->error_; + } + + Status2::ErrorOptional& Status2:: + getError () + { + return this->error_; + } + + void Status2:: + setError (const ErrorType& x) + { + this->error_.set (x); + } + + void Status2:: + setError (const ErrorOptional& x) + { + this->error_ = x; + } + + void Status2:: + setError (::std::unique_ptr< ErrorType > x) + { + this->error_.set (std::move (x)); + } + + const Status2::AnySequence& Status2:: + getAny () const + { + return this->any_; + } + + Status2::AnySequence& Status2:: + getAny () + { + return this->any_; + } + + void Status2:: + setAny (const AnySequence& s) + { + this->any_ = s; + } + + const ::xercesc::DOMDocument& Status2:: + getDomDocument () const + { + return *this->dom_document_; + } + + ::xercesc::DOMDocument& Status2:: + getDomDocument () + { + return *this->dom_document_; + } + } + } +} + +#include + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + // Imdn + // + + Imdn:: + Imdn (const MessageIdType& message_id, + const DatetimeType& datetime) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + message_id_ (message_id, this), + datetime_ (datetime, this), + recipient_uri_ (this), + original_recipient_uri_ (this), + subject_ (this), + delivery_notification_ (this), + display_notification_ (this), + processing_notification_ (this), + any_ (this->getDomDocument ()) + { + } + + Imdn:: + Imdn (const Imdn& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + message_id_ (x.message_id_, f, this), + datetime_ (x.datetime_, f, this), + recipient_uri_ (x.recipient_uri_, f, this), + original_recipient_uri_ (x.original_recipient_uri_, f, this), + subject_ (x.subject_, f, this), + delivery_notification_ (x.delivery_notification_, f, this), + display_notification_ (x.display_notification_, f, this), + processing_notification_ (x.processing_notification_, f, this), + any_ (x.any_, this->getDomDocument ()) + { + } + + Imdn:: + Imdn (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + message_id_ (this), + datetime_ (this), + recipient_uri_ (this), + original_recipient_uri_ (this), + subject_ (this), + delivery_notification_ (this), + display_notification_ (this), + processing_notification_ (this), + any_ (this->getDomDocument ()) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void Imdn:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // message-id + // + if (n.name () == "message-id" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< MessageIdType > r ( + MessageIdTraits::create (i, f, this)); + + if (!message_id_.present ()) + { + this->message_id_.set (::std::move (r)); + continue; + } + } + + // datetime + // + if (n.name () == "datetime" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< DatetimeType > r ( + DatetimeTraits::create (i, f, this)); + + if (!datetime_.present ()) + { + this->datetime_.set (::std::move (r)); + continue; + } + } + + // recipient-uri + // + if (n.name () == "recipient-uri" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< RecipientUriType > r ( + RecipientUriTraits::create (i, f, this)); + + if (!this->recipient_uri_) + { + this->recipient_uri_.set (::std::move (r)); + continue; + } + } + + // original-recipient-uri + // + if (n.name () == "original-recipient-uri" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< OriginalRecipientUriType > r ( + OriginalRecipientUriTraits::create (i, f, this)); + + if (!this->original_recipient_uri_) + { + this->original_recipient_uri_.set (::std::move (r)); + continue; + } + } + + // subject + // + if (n.name () == "subject" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< SubjectType > r ( + SubjectTraits::create (i, f, this)); + + if (!this->subject_) + { + this->subject_.set (::std::move (r)); + continue; + } + } + + // delivery-notification + // + if (n.name () == "delivery-notification" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< DeliveryNotificationType > r ( + DeliveryNotificationTraits::create (i, f, this)); + + if (!this->delivery_notification_) + { + this->delivery_notification_.set (::std::move (r)); + continue; + } + } + + // display-notification + // + if (n.name () == "display-notification" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< DisplayNotificationType > r ( + DisplayNotificationTraits::create (i, f, this)); + + if (!this->display_notification_) + { + this->display_notification_.set (::std::move (r)); + continue; + } + } + + // processing-notification + // + if (n.name () == "processing-notification" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ProcessingNotificationType > r ( + ProcessingNotificationTraits::create (i, f, this)); + + if (!this->processing_notification_) + { + this->processing_notification_.set (::std::move (r)); + continue; + } + } + + // any + // + if ((!n.namespace_ ().empty () && n.namespace_ () != "urn:ietf:params:xml:ns:imdn")) + { + ::xercesc::DOMElement* r ( + static_cast< ::xercesc::DOMElement* > ( + this->getDomDocument ().importNode ( + const_cast< ::xercesc::DOMElement* > (&i), true))); + this->any_.push_back (r); + continue; + } + + break; + } + + if (!message_id_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "message-id", + "urn:ietf:params:xml:ns:imdn"); + } + + if (!datetime_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "datetime", + "urn:ietf:params:xml:ns:imdn"); + } + } + + Imdn* Imdn:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Imdn (*this, f, c); + } + + Imdn& Imdn:: + operator= (const Imdn& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->message_id_ = x.message_id_; + this->datetime_ = x.datetime_; + this->recipient_uri_ = x.recipient_uri_; + this->original_recipient_uri_ = x.original_recipient_uri_; + this->subject_ = x.subject_; + this->delivery_notification_ = x.delivery_notification_; + this->display_notification_ = x.display_notification_; + this->processing_notification_ = x.processing_notification_; + this->any_ = x.any_; + } + + return *this; + } + + Imdn:: + ~Imdn () + { + } + + // DeliveryNotification + // + + DeliveryNotification:: + DeliveryNotification (const StatusType& status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (status, this) + { + } + + DeliveryNotification:: + DeliveryNotification (::std::unique_ptr< StatusType > status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (std::move (status), this) + { + } + + DeliveryNotification:: + DeliveryNotification (const DeliveryNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + status_ (x.status_, f, this) + { + } + + DeliveryNotification:: + DeliveryNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + status_ (this) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void DeliveryNotification:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // status + // + if (n.name () == "status" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< StatusType > r ( + StatusTraits::create (i, f, this)); + + if (!status_.present ()) + { + this->status_.set (::std::move (r)); + continue; + } + } + + break; + } + + if (!status_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "status", + "urn:ietf:params:xml:ns:imdn"); + } + } + + DeliveryNotification* DeliveryNotification:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class DeliveryNotification (*this, f, c); + } + + DeliveryNotification& DeliveryNotification:: + operator= (const DeliveryNotification& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->status_ = x.status_; + } + + return *this; + } + + DeliveryNotification:: + ~DeliveryNotification () + { + } + + // Delivered + // + + Delivered:: + Delivered () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Delivered:: + Delivered (const Delivered& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Delivered:: + Delivered (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Delivered:: + Delivered (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Delivered:: + Delivered (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Delivered* Delivered:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Delivered (*this, f, c); + } + + Delivered:: + ~Delivered () + { + } + + // Failed + // + + Failed:: + Failed () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Failed:: + Failed (const Failed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Failed:: + Failed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Failed:: + Failed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Failed:: + Failed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Failed* Failed:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Failed (*this, f, c); + } + + Failed:: + ~Failed () + { + } + + // DisplayNotification + // + + DisplayNotification:: + DisplayNotification (const StatusType& status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (status, this) + { + } + + DisplayNotification:: + DisplayNotification (::std::unique_ptr< StatusType > status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (std::move (status), this) + { + } + + DisplayNotification:: + DisplayNotification (const DisplayNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + status_ (x.status_, f, this) + { + } + + DisplayNotification:: + DisplayNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + status_ (this) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void DisplayNotification:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // status + // + if (n.name () == "status" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< StatusType > r ( + StatusTraits::create (i, f, this)); + + if (!status_.present ()) + { + this->status_.set (::std::move (r)); + continue; + } + } + + break; + } + + if (!status_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "status", + "urn:ietf:params:xml:ns:imdn"); + } + } + + DisplayNotification* DisplayNotification:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class DisplayNotification (*this, f, c); + } + + DisplayNotification& DisplayNotification:: + operator= (const DisplayNotification& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->status_ = x.status_; + } + + return *this; + } + + DisplayNotification:: + ~DisplayNotification () + { + } + + // Displayed + // + + Displayed:: + Displayed () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Displayed:: + Displayed (const Displayed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Displayed:: + Displayed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Displayed:: + Displayed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Displayed:: + Displayed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Displayed* Displayed:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Displayed (*this, f, c); + } + + Displayed:: + ~Displayed () + { + } + + // ProcessingNotification + // + + ProcessingNotification:: + ProcessingNotification (const StatusType& status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (status, this) + { + } + + ProcessingNotification:: + ProcessingNotification (::std::unique_ptr< StatusType > status) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + status_ (std::move (status), this) + { + } + + ProcessingNotification:: + ProcessingNotification (const ProcessingNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + status_ (x.status_, f, this) + { + } + + ProcessingNotification:: + ProcessingNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + status_ (this) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void ProcessingNotification:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // status + // + if (n.name () == "status" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< StatusType > r ( + StatusTraits::create (i, f, this)); + + if (!status_.present ()) + { + this->status_.set (::std::move (r)); + continue; + } + } + + break; + } + + if (!status_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "status", + "urn:ietf:params:xml:ns:imdn"); + } + } + + ProcessingNotification* ProcessingNotification:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class ProcessingNotification (*this, f, c); + } + + ProcessingNotification& ProcessingNotification:: + operator= (const ProcessingNotification& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->status_ = x.status_; + } + + return *this; + } + + ProcessingNotification:: + ~ProcessingNotification () + { + } + + // Processed + // + + Processed:: + Processed () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Processed:: + Processed (const Processed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Processed:: + Processed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Processed:: + Processed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Processed:: + Processed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Processed* Processed:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Processed (*this, f, c); + } + + Processed:: + ~Processed () + { + } + + // Stored + // + + Stored:: + Stored () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Stored:: + Stored (const Stored& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Stored:: + Stored (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Stored:: + Stored (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Stored:: + Stored (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Stored* Stored:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Stored (*this, f, c); + } + + Stored:: + ~Stored () + { + } + + // Forbidden + // + + Forbidden:: + Forbidden () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Forbidden:: + Forbidden (const Forbidden& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Forbidden:: + Forbidden (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Forbidden:: + Forbidden (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Forbidden:: + Forbidden (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Forbidden* Forbidden:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Forbidden (*this, f, c); + } + + Forbidden:: + ~Forbidden () + { + } + + // Error + // + + Error:: + Error () + : ::LinphonePrivate::Xsd::XmlSchema::Type () + { + } + + Error:: + Error (const Error& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c) + { + } + + Error:: + Error (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f, c) + { + } + + Error:: + Error (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (a, f, c) + { + } + + Error:: + Error (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (s, e, f, c) + { + } + + Error* Error:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Error (*this, f, c); + } + + Error:: + ~Error () + { + } + + // Status + // + + Status:: + Status () + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + delivered_ (this), + failed_ (this), + forbidden_ (this), + error_ (this), + reason_ (this) + { + } + + Status:: + Status (const Status& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + delivered_ (x.delivered_, f, this), + failed_ (x.failed_, f, this), + forbidden_ (x.forbidden_, f, this), + error_ (x.error_, f, this), + reason_ (x.reason_, f, this) + { + } + + Status:: + Status (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + delivered_ (this), + failed_ (this), + forbidden_ (this), + error_ (this), + reason_ (this) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void Status:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // delivered + // + if (n.name () == "delivered" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< DeliveredType > r ( + DeliveredTraits::create (i, f, this)); + + if (!this->delivered_) + { + this->delivered_.set (::std::move (r)); + continue; + } + } + + // failed + // + if (n.name () == "failed" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< FailedType > r ( + FailedTraits::create (i, f, this)); + + if (!this->failed_) + { + this->failed_.set (::std::move (r)); + continue; + } + } + + // forbidden + // + if (n.name () == "forbidden" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ForbiddenType > r ( + ForbiddenTraits::create (i, f, this)); + + if (!this->forbidden_) + { + this->forbidden_.set (::std::move (r)); + continue; + } + } + + // error + // + if (n.name () == "error" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ErrorType > r ( + ErrorTraits::create (i, f, this)); + + if (!this->error_) + { + this->error_.set (::std::move (r)); + continue; + } + } + + // reason + // + if (n.name () == "reason" && n.namespace_ () == "http://www.linphone.org/xsds/imdn.xsd") + { + ::std::unique_ptr< ReasonType > r ( + ReasonTraits::create (i, f, this)); + + if (!this->reason_) + { + this->reason_.set (::std::move (r)); + continue; + } + } + + break; + } + } + + Status* Status:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Status (*this, f, c); + } + + Status& Status:: + operator= (const Status& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->delivered_ = x.delivered_; + this->failed_ = x.failed_; + this->forbidden_ = x.forbidden_; + this->error_ = x.error_; + this->reason_ = x.reason_; + } + + return *this; + } + + Status:: + ~Status () + { + } + + // Status1 + // + + Status1:: + Status1 () + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + displayed_ (this), + forbidden_ (this), + error_ (this), + any_ (this->getDomDocument ()) + { + } + + Status1:: + Status1 (const Status1& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + displayed_ (x.displayed_, f, this), + forbidden_ (x.forbidden_, f, this), + error_ (x.error_, f, this), + any_ (x.any_, this->getDomDocument ()) + { + } + + Status1:: + Status1 (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + displayed_ (this), + forbidden_ (this), + error_ (this), + any_ (this->getDomDocument ()) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void Status1:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // displayed + // + if (n.name () == "displayed" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< DisplayedType > r ( + DisplayedTraits::create (i, f, this)); + + if (!this->displayed_) + { + this->displayed_.set (::std::move (r)); + continue; + } + } + + // forbidden + // + if (n.name () == "forbidden" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ForbiddenType > r ( + ForbiddenTraits::create (i, f, this)); + + if (!this->forbidden_) + { + this->forbidden_.set (::std::move (r)); + continue; + } + } + + // error + // + if (n.name () == "error" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ErrorType > r ( + ErrorTraits::create (i, f, this)); + + if (!this->error_) + { + this->error_.set (::std::move (r)); + continue; + } + } + + // any + // + if ((!n.namespace_ ().empty () && n.namespace_ () != "urn:ietf:params:xml:ns:imdn")) + { + ::xercesc::DOMElement* r ( + static_cast< ::xercesc::DOMElement* > ( + this->getDomDocument ().importNode ( + const_cast< ::xercesc::DOMElement* > (&i), true))); + this->any_.push_back (r); + continue; + } + + break; + } + } + + Status1* Status1:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Status1 (*this, f, c); + } + + Status1& Status1:: + operator= (const Status1& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->displayed_ = x.displayed_; + this->forbidden_ = x.forbidden_; + this->error_ = x.error_; + this->any_ = x.any_; + } + + return *this; + } + + Status1:: + ~Status1 () + { + } + + // Status2 + // + + Status2:: + Status2 () + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + processed_ (this), + stored_ (this), + forbidden_ (this), + error_ (this), + any_ (this->getDomDocument ()) + { + } + + Status2:: + Status2 (const Status2& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + processed_ (x.processed_, f, this), + stored_ (x.stored_, f, this), + forbidden_ (x.forbidden_, f, this), + error_ (x.error_, f, this), + any_ (x.any_, this->getDomDocument ()) + { + } + + Status2:: + Status2 (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + processed_ (this), + stored_ (this), + forbidden_ (this), + error_ (this), + any_ (this->getDomDocument ()) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void Status2:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // processed + // + if (n.name () == "processed" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ProcessedType > r ( + ProcessedTraits::create (i, f, this)); + + if (!this->processed_) + { + this->processed_.set (::std::move (r)); + continue; + } + } + + // stored + // + if (n.name () == "stored" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< StoredType > r ( + StoredTraits::create (i, f, this)); + + if (!this->stored_) + { + this->stored_.set (::std::move (r)); + continue; + } + } + + // forbidden + // + if (n.name () == "forbidden" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ForbiddenType > r ( + ForbiddenTraits::create (i, f, this)); + + if (!this->forbidden_) + { + this->forbidden_.set (::std::move (r)); + continue; + } + } + + // error + // + if (n.name () == "error" && n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ErrorType > r ( + ErrorTraits::create (i, f, this)); + + if (!this->error_) + { + this->error_.set (::std::move (r)); + continue; + } + } + + // any + // + if ((!n.namespace_ ().empty () && n.namespace_ () != "urn:ietf:params:xml:ns:imdn")) + { + ::xercesc::DOMElement* r ( + static_cast< ::xercesc::DOMElement* > ( + this->getDomDocument ().importNode ( + const_cast< ::xercesc::DOMElement* > (&i), true))); + this->any_.push_back (r); + continue; + } + + break; + } + } + + Status2* Status2:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class Status2 (*this, f, c); + } + + Status2& Status2:: + operator= (const Status2& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->processed_ = x.processed_; + this->stored_ = x.stored_; + this->forbidden_ = x.forbidden_; + this->error_ = x.error_; + this->any_ = x.any_; + } + + return *this; + } + + Status2:: + ~Status2 () + { + } + } + } +} + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + ::std::ostream& + operator<< (::std::ostream& o, const Imdn& i) + { + o << ::std::endl << "message-id: " << i.getMessageId (); + o << ::std::endl << "datetime: " << i.getDatetime (); + if (i.getRecipientUri ()) + { + o << ::std::endl << "recipient-uri: " << *i.getRecipientUri (); + } + + if (i.getOriginalRecipientUri ()) + { + o << ::std::endl << "original-recipient-uri: " << *i.getOriginalRecipientUri (); + } + + if (i.getSubject ()) + { + o << ::std::endl << "subject: " << *i.getSubject (); + } + + if (i.getDeliveryNotification ()) + { + o << ::std::endl << "delivery-notification: " << *i.getDeliveryNotification (); + } + + if (i.getDisplayNotification ()) + { + o << ::std::endl << "display-notification: " << *i.getDisplayNotification (); + } + + if (i.getProcessingNotification ()) + { + o << ::std::endl << "processing-notification: " << *i.getProcessingNotification (); + } + + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const DeliveryNotification& i) + { + o << ::std::endl << "status: " << i.getStatus (); + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Delivered&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Failed&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const DisplayNotification& i) + { + o << ::std::endl << "status: " << i.getStatus (); + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Displayed&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const ProcessingNotification& i) + { + o << ::std::endl << "status: " << i.getStatus (); + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Processed&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Stored&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Forbidden&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Error&) + { + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Status& i) + { + if (i.getDelivered ()) + { + o << ::std::endl << "delivered: " << *i.getDelivered (); + } + + if (i.getFailed ()) + { + o << ::std::endl << "failed: " << *i.getFailed (); + } + + if (i.getForbidden ()) + { + o << ::std::endl << "forbidden: " << *i.getForbidden (); + } + + if (i.getError ()) + { + o << ::std::endl << "error: " << *i.getError (); + } + + if (i.getReason ()) + { + o << ::std::endl << "reason: " << *i.getReason (); + } + + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Status1& i) + { + if (i.getDisplayed ()) + { + o << ::std::endl << "displayed: " << *i.getDisplayed (); + } + + if (i.getForbidden ()) + { + o << ::std::endl << "forbidden: " << *i.getForbidden (); + } + + if (i.getError ()) + { + o << ::std::endl << "error: " << *i.getError (); + } + + return o; + } + + ::std::ostream& + operator<< (::std::ostream& o, const Status2& i) + { + if (i.getProcessed ()) + { + o << ::std::endl << "processed: " << *i.getProcessed (); + } + + if (i.getStored ()) + { + o << ::std::endl << "stored: " << *i.getStored (); + } + + if (i.getForbidden ()) + { + o << ::std::endl << "forbidden: " << *i.getForbidden (); + } + + if (i.getError ()) + { + o << ::std::endl << "error: " << *i.getError (); + } + + return o; + } + } + } +} + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& u, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& sid, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::Imdn::parseImdn (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& i, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::xercesc::DOMDocument& doc, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + static_cast< ::xercesc::DOMDocument* > (doc.cloneNode (true))); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > ( + ::LinphonePrivate::Xsd::Imdn::parseImdn ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "imdn" && + n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::Imdn::Imdn, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "imdn", + "urn:ietf:params:xml:ns:imdn"); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties&) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > c ( + ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) && + !(f & ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom)) + ? static_cast< ::xercesc::DOMDocument* > (d->cloneNode (true)) + : 0); + + ::xercesc::DOMDocument& doc (c.get () ? *c : *d); + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + doc.setUserData (::LinphonePrivate::Xsd::XmlSchema::dom::treeNodeKey, + (c.get () ? &c : &d), + 0); + + if (n.name () == "imdn" && + n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::Imdn::Imdn, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "imdn", + "urn:ietf:params:xml:ns:imdn"); + } + } + } +} + +#include +#include +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + void + serializeImdn (::std::ostream& o, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeImdn (::std::ostream& o, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeImdn (::std::ostream& o, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeImdn (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeImdn (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeImdn (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::Imdn::serializeImdn (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeImdn (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + ::LinphonePrivate::Xsd::XmlSchema::Flags) + { + ::xercesc::DOMElement& e (*d.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "imdn" && + n.namespace_ () == "urn:ietf:params:xml:ns:imdn") + { + e << s; + } + else + { + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "imdn", + "urn:ietf:params:xml:ns:imdn"); + } + } + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeImdn (const ::LinphonePrivate::Xsd::Imdn::Imdn& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::serialize< char > ( + "imdn", + "urn:ietf:params:xml:ns:imdn", + m, f)); + + ::LinphonePrivate::Xsd::Imdn::serializeImdn (*d, s, f); + return d; + } + + void + operator<< (::xercesc::DOMElement& e, const Imdn& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // message-id + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "message-id", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << i.getMessageId (); + } + + // datetime + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "datetime", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << i.getDatetime (); + } + + // recipient-uri + // + if (i.getRecipientUri ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "recipient-uri", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getRecipientUri (); + } + + // original-recipient-uri + // + if (i.getOriginalRecipientUri ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "original-recipient-uri", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getOriginalRecipientUri (); + } + + // subject + // + if (i.getSubject ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "subject", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getSubject (); + } + + // delivery-notification + // + if (i.getDeliveryNotification ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "delivery-notification", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getDeliveryNotification (); + } + + // display-notification + // + if (i.getDisplayNotification ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "display-notification", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getDisplayNotification (); + } + + // processing-notification + // + if (i.getProcessingNotification ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "processing-notification", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getProcessingNotification (); + } + + // any + // + for (Imdn::AnyConstIterator + b (i.getAny ().begin ()), n (i.getAny ().end ()); + b != n; ++b) + { + e.appendChild ( + e.getOwnerDocument ()->importNode ( + const_cast< ::xercesc::DOMElement* > (&(*b)), true)); + } + } + + void + operator<< (::xercesc::DOMElement& e, const DeliveryNotification& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // status + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "status", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << i.getStatus (); + } + } + + void + operator<< (::xercesc::DOMElement& e, const Delivered& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Delivered&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Delivered&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const Failed& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Failed&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Failed&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const DisplayNotification& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // status + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "status", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << i.getStatus (); + } + } + + void + operator<< (::xercesc::DOMElement& e, const Displayed& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Displayed&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Displayed&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const ProcessingNotification& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // status + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "status", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << i.getStatus (); + } + } + + void + operator<< (::xercesc::DOMElement& e, const Processed& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Processed&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Processed&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const Stored& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Stored&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Stored&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const Forbidden& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Forbidden&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Forbidden&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const Error& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + } + + void + operator<< (::xercesc::DOMAttr&, const Error&) + { + } + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Error&) + { + } + + void + operator<< (::xercesc::DOMElement& e, const Status& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // delivered + // + if (i.getDelivered ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "delivered", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getDelivered (); + } + + // failed + // + if (i.getFailed ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "failed", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getFailed (); + } + + // forbidden + // + if (i.getForbidden ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "forbidden", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getForbidden (); + } + + // error + // + if (i.getError ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "error", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getError (); + } + + // reason + // + if (i.getReason ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "reason", + "http://www.linphone.org/xsds/imdn.xsd", + e)); + + s << *i.getReason (); + } + } + + void + operator<< (::xercesc::DOMElement& e, const Status1& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // displayed + // + if (i.getDisplayed ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "displayed", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getDisplayed (); + } + + // forbidden + // + if (i.getForbidden ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "forbidden", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getForbidden (); + } + + // error + // + if (i.getError ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "error", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getError (); + } + + // any + // + for (Status1::AnyConstIterator + b (i.getAny ().begin ()), n (i.getAny ().end ()); + b != n; ++b) + { + e.appendChild ( + e.getOwnerDocument ()->importNode ( + const_cast< ::xercesc::DOMElement* > (&(*b)), true)); + } + } + + void + operator<< (::xercesc::DOMElement& e, const Status2& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // processed + // + if (i.getProcessed ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "processed", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getProcessed (); + } + + // stored + // + if (i.getStored ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "stored", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getStored (); + } + + // forbidden + // + if (i.getForbidden ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "forbidden", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getForbidden (); + } + + // error + // + if (i.getError ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "error", + "urn:ietf:params:xml:ns:imdn", + e)); + + s << *i.getError (); + } + + // any + // + for (Status2::AnyConstIterator + b (i.getAny ().begin ()), n (i.getAny ().end ()); + b != n; ++b) + { + e.appendChild ( + e.getOwnerDocument ()->importNode ( + const_cast< ::xercesc::DOMElement* > (&(*b)), true)); + } + } + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + diff --git a/src/xml/imdn.h b/src/xml/imdn.h new file mode 100644 index 000000000..687f80533 --- /dev/null +++ b/src/xml/imdn.h @@ -0,0 +1,1730 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +#ifndef XML_IMDN_H +#define XML_IMDN_H + +#ifndef XSD_CXX11 +#define XSD_CXX11 +#endif + +#ifndef XSD_USE_CHAR +#define XSD_USE_CHAR +#endif + +#ifndef XSD_CXX_TREE_USE_CHAR +#define XSD_CXX_TREE_USE_CHAR +#endif + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#if (XSD_INT_VERSION != 4000000L) +#error XSD runtime version mismatch +#endif + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace XmlSchema + { + // anyType and anySimpleType. + // + typedef ::xsd::cxx::tree::type Type; + typedef ::xsd::cxx::tree::simple_type< char, Type > SimpleType; + typedef ::xsd::cxx::tree::type Container; + + // 8-bit + // + typedef signed char Byte; + typedef unsigned char UnsignedByte; + + // 16-bit + // + typedef short Short; + typedef unsigned short UnsignedShort; + + // 32-bit + // + typedef int Int; + typedef unsigned int UnsignedInt; + + // 64-bit + // + typedef long long Long; + typedef unsigned long long UnsignedLong; + + // Supposed to be arbitrary-length integral types. + // + typedef long long Integer; + typedef long long NonPositiveInteger; + typedef unsigned long long NonNegativeInteger; + typedef unsigned long long PositiveInteger; + typedef long long NegativeInteger; + + // Boolean. + // + typedef bool Boolean; + + // Floating-point types. + // + typedef float Float; + typedef double Double; + typedef double Decimal; + + // String types. + // + typedef ::xsd::cxx::tree::string< char, SimpleType > String; + typedef ::xsd::cxx::tree::normalized_string< char, String > NormalizedString; + typedef ::xsd::cxx::tree::token< char, NormalizedString > Token; + typedef ::xsd::cxx::tree::name< char, Token > Name; + typedef ::xsd::cxx::tree::nmtoken< char, Token > Nmtoken; + typedef ::xsd::cxx::tree::nmtokens< char, SimpleType, Nmtoken > Nmtokens; + typedef ::xsd::cxx::tree::ncname< char, Name > Ncname; + typedef ::xsd::cxx::tree::language< char, Token > Language; + + // ID/IDREF. + // + typedef ::xsd::cxx::tree::id< char, Ncname > Id; + typedef ::xsd::cxx::tree::idref< char, Ncname, Type > Idref; + typedef ::xsd::cxx::tree::idrefs< char, SimpleType, Idref > Idrefs; + + // URI. + // + typedef ::xsd::cxx::tree::uri< char, SimpleType > Uri; + + // Qualified name. + // + typedef ::xsd::cxx::tree::qname< char, SimpleType, Uri, Ncname > Qname; + + // Binary. + // + typedef ::xsd::cxx::tree::buffer< char > Buffer; + typedef ::xsd::cxx::tree::base64_binary< char, SimpleType > Base64Binary; + typedef ::xsd::cxx::tree::hex_binary< char, SimpleType > HexBinary; + + // Date/time. + // + typedef ::xsd::cxx::tree::time_zone TimeZone; + typedef ::xsd::cxx::tree::date< char, SimpleType > Date; + typedef ::xsd::cxx::tree::date_time< char, SimpleType > DateTime; + typedef ::xsd::cxx::tree::duration< char, SimpleType > Duration; + typedef ::xsd::cxx::tree::gday< char, SimpleType > Gday; + typedef ::xsd::cxx::tree::gmonth< char, SimpleType > Gmonth; + typedef ::xsd::cxx::tree::gmonth_day< char, SimpleType > GmonthDay; + typedef ::xsd::cxx::tree::gyear< char, SimpleType > Gyear; + typedef ::xsd::cxx::tree::gyear_month< char, SimpleType > GyearMonth; + typedef ::xsd::cxx::tree::time< char, SimpleType > Time; + + // Entity. + // + typedef ::xsd::cxx::tree::entity< char, Ncname > Entity; + typedef ::xsd::cxx::tree::entities< char, SimpleType, Entity > Entities; + + typedef ::xsd::cxx::tree::content_order ContentOrder; + // Namespace information and list stream. Used in + // serialization functions. + // + typedef ::xsd::cxx::xml::dom::namespace_info< char > NamespaceInfo; + typedef ::xsd::cxx::xml::dom::namespace_infomap< char > NamespaceInfomap; + typedef ::xsd::cxx::tree::list_stream< char > ListStream; + typedef ::xsd::cxx::tree::as_double< Double > AsDouble; + typedef ::xsd::cxx::tree::as_decimal< Decimal > AsDecimal; + typedef ::xsd::cxx::tree::facet Facet; + + // Flags and properties. + // + typedef ::xsd::cxx::tree::flags Flags; + typedef ::xsd::cxx::tree::properties< char > Properties; + + // Parsing/serialization diagnostics. + // + typedef ::xsd::cxx::tree::severity Severity; + typedef ::xsd::cxx::tree::error< char > Error; + typedef ::xsd::cxx::tree::diagnostics< char > Diagnostics; + + // Exceptions. + // + typedef ::xsd::cxx::tree::exception< char > Exception; + typedef ::xsd::cxx::tree::bounds< char > Bounds; + typedef ::xsd::cxx::tree::duplicate_id< char > DuplicateId; + typedef ::xsd::cxx::tree::parsing< char > Parsing; + typedef ::xsd::cxx::tree::expected_element< char > ExpectedElement; + typedef ::xsd::cxx::tree::unexpected_element< char > UnexpectedElement; + typedef ::xsd::cxx::tree::expected_attribute< char > ExpectedAttribute; + typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; + typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; + typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; + typedef ::xsd::cxx::tree::serialization< char > Serialization; + + // Error handler callback interface. + // + typedef ::xsd::cxx::xml::error_handler< char > ErrorHandler; + + // DOM interaction. + // + namespace dom + { + // Automatic pointer for DOMDocument. + // + using ::xsd::cxx::xml::dom::unique_ptr; + +#ifndef XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA +#define XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA + // DOM user data key for back pointers to tree nodes. + // + const XMLCh* const treeNodeKey = ::xsd::cxx::tree::user_data_keys::node; +#endif + } + } + } +} + +// Forward declarations. +// +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + class Imdn; + class DeliveryNotification; + class Delivered; + class Failed; + class DisplayNotification; + class Displayed; + class ProcessingNotification; + class Processed; + class Stored; + class Forbidden; + class Error; + class Status; + class Status1; + class Status2; + } + } +} + + +#include // ::std::unique_ptr +#include // std::numeric_limits +#include // std::binary_search +#include // std::move + +#include + +#include +#include +#include +#include + +#include + +#include + +#include "linphone-imdn.h" + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + class Imdn: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // message-id + // + typedef ::LinphonePrivate::Xsd::XmlSchema::Token MessageIdType; + typedef ::xsd::cxx::tree::traits< MessageIdType, char > MessageIdTraits; + + const MessageIdType& + getMessageId () const; + + MessageIdType& + getMessageId (); + + void + setMessageId (const MessageIdType& x); + + void + setMessageId (::std::unique_ptr< MessageIdType > p); + + ::std::unique_ptr< MessageIdType > + setDetachMessage_id (); + + // datetime + // + typedef ::LinphonePrivate::Xsd::XmlSchema::String DatetimeType; + typedef ::xsd::cxx::tree::traits< DatetimeType, char > DatetimeTraits; + + const DatetimeType& + getDatetime () const; + + DatetimeType& + getDatetime (); + + void + setDatetime (const DatetimeType& x); + + void + setDatetime (::std::unique_ptr< DatetimeType > p); + + ::std::unique_ptr< DatetimeType > + setDetachDatetime (); + + // recipient-uri + // + typedef ::LinphonePrivate::Xsd::XmlSchema::Uri RecipientUriType; + typedef ::xsd::cxx::tree::optional< RecipientUriType > RecipientUriOptional; + typedef ::xsd::cxx::tree::traits< RecipientUriType, char > RecipientUriTraits; + + const RecipientUriOptional& + getRecipientUri () const; + + RecipientUriOptional& + getRecipientUri (); + + void + setRecipientUri (const RecipientUriType& x); + + void + setRecipientUri (const RecipientUriOptional& x); + + void + setRecipientUri (::std::unique_ptr< RecipientUriType > p); + + // original-recipient-uri + // + typedef ::LinphonePrivate::Xsd::XmlSchema::Uri OriginalRecipientUriType; + typedef ::xsd::cxx::tree::optional< OriginalRecipientUriType > OriginalRecipientUriOptional; + typedef ::xsd::cxx::tree::traits< OriginalRecipientUriType, char > OriginalRecipientUriTraits; + + const OriginalRecipientUriOptional& + getOriginalRecipientUri () const; + + OriginalRecipientUriOptional& + getOriginalRecipientUri (); + + void + setOriginalRecipientUri (const OriginalRecipientUriType& x); + + void + setOriginalRecipientUri (const OriginalRecipientUriOptional& x); + + void + setOriginalRecipientUri (::std::unique_ptr< OriginalRecipientUriType > p); + + // subject + // + typedef ::LinphonePrivate::Xsd::XmlSchema::String SubjectType; + typedef ::xsd::cxx::tree::optional< SubjectType > SubjectOptional; + typedef ::xsd::cxx::tree::traits< SubjectType, char > SubjectTraits; + + const SubjectOptional& + getSubject () const; + + SubjectOptional& + getSubject (); + + void + setSubject (const SubjectType& x); + + void + setSubject (const SubjectOptional& x); + + void + setSubject (::std::unique_ptr< SubjectType > p); + + // delivery-notification + // + typedef ::LinphonePrivate::Xsd::Imdn::DeliveryNotification DeliveryNotificationType; + typedef ::xsd::cxx::tree::optional< DeliveryNotificationType > DeliveryNotificationOptional; + typedef ::xsd::cxx::tree::traits< DeliveryNotificationType, char > DeliveryNotificationTraits; + + const DeliveryNotificationOptional& + getDeliveryNotification () const; + + DeliveryNotificationOptional& + getDeliveryNotification (); + + void + setDeliveryNotification (const DeliveryNotificationType& x); + + void + setDeliveryNotification (const DeliveryNotificationOptional& x); + + void + setDeliveryNotification (::std::unique_ptr< DeliveryNotificationType > p); + + // display-notification + // + typedef ::LinphonePrivate::Xsd::Imdn::DisplayNotification DisplayNotificationType; + typedef ::xsd::cxx::tree::optional< DisplayNotificationType > DisplayNotificationOptional; + typedef ::xsd::cxx::tree::traits< DisplayNotificationType, char > DisplayNotificationTraits; + + const DisplayNotificationOptional& + getDisplayNotification () const; + + DisplayNotificationOptional& + getDisplayNotification (); + + void + setDisplayNotification (const DisplayNotificationType& x); + + void + setDisplayNotification (const DisplayNotificationOptional& x); + + void + setDisplayNotification (::std::unique_ptr< DisplayNotificationType > p); + + // processing-notification + // + typedef ::LinphonePrivate::Xsd::Imdn::ProcessingNotification ProcessingNotificationType; + typedef ::xsd::cxx::tree::optional< ProcessingNotificationType > ProcessingNotificationOptional; + typedef ::xsd::cxx::tree::traits< ProcessingNotificationType, char > ProcessingNotificationTraits; + + const ProcessingNotificationOptional& + getProcessingNotification () const; + + ProcessingNotificationOptional& + getProcessingNotification (); + + void + setProcessingNotification (const ProcessingNotificationType& x); + + void + setProcessingNotification (const ProcessingNotificationOptional& x); + + void + setProcessingNotification (::std::unique_ptr< ProcessingNotificationType > p); + + // any + // + typedef ::xsd::cxx::tree::element_sequence AnySequence; + typedef AnySequence::iterator AnyIterator; + typedef AnySequence::const_iterator AnyConstIterator; + + const AnySequence& + getAny () const; + + AnySequence& + getAny (); + + void + setAny (const AnySequence& s); + + // DOMDocument for wildcard content. + // + const ::xercesc::DOMDocument& + getDomDocument () const; + + ::xercesc::DOMDocument& + getDomDocument (); + + // Constructors. + // + Imdn (const MessageIdType&, + const DatetimeType&); + + Imdn (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Imdn (const Imdn& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Imdn* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + Imdn& + operator= (const Imdn& x); + + virtual + ~Imdn (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > dom_document_; + + ::xsd::cxx::tree::one< MessageIdType > message_id_; + ::xsd::cxx::tree::one< DatetimeType > datetime_; + RecipientUriOptional recipient_uri_; + OriginalRecipientUriOptional original_recipient_uri_; + SubjectOptional subject_; + DeliveryNotificationOptional delivery_notification_; + DisplayNotificationOptional display_notification_; + ProcessingNotificationOptional processing_notification_; + AnySequence any_; + }; + + class DeliveryNotification: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // status + // + typedef ::LinphonePrivate::Xsd::Imdn::Status StatusType; + typedef ::xsd::cxx::tree::traits< StatusType, char > StatusTraits; + + const StatusType& + getStatus () const; + + StatusType& + getStatus (); + + void + setStatus (const StatusType& x); + + void + setStatus (::std::unique_ptr< StatusType > p); + + ::std::unique_ptr< StatusType > + setDetachStatus (); + + // Constructors. + // + DeliveryNotification (const StatusType&); + + DeliveryNotification (::std::unique_ptr< StatusType >); + + DeliveryNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + DeliveryNotification (const DeliveryNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual DeliveryNotification* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + DeliveryNotification& + operator= (const DeliveryNotification& x); + + virtual + ~DeliveryNotification (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::xsd::cxx::tree::one< StatusType > status_; + }; + + class Delivered: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Delivered (); + + Delivered (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Delivered (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Delivered (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Delivered (const Delivered& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Delivered* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Delivered (); + }; + + class Failed: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Failed (); + + Failed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Failed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Failed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Failed (const Failed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Failed* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Failed (); + }; + + class DisplayNotification: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // status + // + typedef ::LinphonePrivate::Xsd::Imdn::Status1 StatusType; + typedef ::xsd::cxx::tree::traits< StatusType, char > StatusTraits; + + const StatusType& + getStatus () const; + + StatusType& + getStatus (); + + void + setStatus (const StatusType& x); + + void + setStatus (::std::unique_ptr< StatusType > p); + + ::std::unique_ptr< StatusType > + setDetachStatus (); + + // Constructors. + // + DisplayNotification (const StatusType&); + + DisplayNotification (::std::unique_ptr< StatusType >); + + DisplayNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + DisplayNotification (const DisplayNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual DisplayNotification* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + DisplayNotification& + operator= (const DisplayNotification& x); + + virtual + ~DisplayNotification (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::xsd::cxx::tree::one< StatusType > status_; + }; + + class Displayed: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Displayed (); + + Displayed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Displayed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Displayed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Displayed (const Displayed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Displayed* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Displayed (); + }; + + class ProcessingNotification: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // status + // + typedef ::LinphonePrivate::Xsd::Imdn::Status2 StatusType; + typedef ::xsd::cxx::tree::traits< StatusType, char > StatusTraits; + + const StatusType& + getStatus () const; + + StatusType& + getStatus (); + + void + setStatus (const StatusType& x); + + void + setStatus (::std::unique_ptr< StatusType > p); + + ::std::unique_ptr< StatusType > + setDetachStatus (); + + // Constructors. + // + ProcessingNotification (const StatusType&); + + ProcessingNotification (::std::unique_ptr< StatusType >); + + ProcessingNotification (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + ProcessingNotification (const ProcessingNotification& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual ProcessingNotification* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + ProcessingNotification& + operator= (const ProcessingNotification& x); + + virtual + ~ProcessingNotification (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::xsd::cxx::tree::one< StatusType > status_; + }; + + class Processed: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Processed (); + + Processed (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Processed (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Processed (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Processed (const Processed& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Processed* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Processed (); + }; + + class Stored: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Stored (); + + Stored (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Stored (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Stored (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Stored (const Stored& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Stored* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Stored (); + }; + + class Forbidden: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Forbidden (); + + Forbidden (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Forbidden (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Forbidden (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Forbidden (const Forbidden& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Forbidden* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Forbidden (); + }; + + class Error: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // Constructors. + // + Error (); + + Error (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Error (const ::xercesc::DOMAttr& a, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Error (const ::std::string& s, + const ::xercesc::DOMElement* e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Error (const Error& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Error* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + virtual + ~Error (); + }; + + class Status: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // delivered + // + typedef ::LinphonePrivate::Xsd::Imdn::Delivered DeliveredType; + typedef ::xsd::cxx::tree::optional< DeliveredType > DeliveredOptional; + typedef ::xsd::cxx::tree::traits< DeliveredType, char > DeliveredTraits; + + const DeliveredOptional& + getDelivered () const; + + DeliveredOptional& + getDelivered (); + + void + setDelivered (const DeliveredType& x); + + void + setDelivered (const DeliveredOptional& x); + + void + setDelivered (::std::unique_ptr< DeliveredType > p); + + // failed + // + typedef ::LinphonePrivate::Xsd::Imdn::Failed FailedType; + typedef ::xsd::cxx::tree::optional< FailedType > FailedOptional; + typedef ::xsd::cxx::tree::traits< FailedType, char > FailedTraits; + + const FailedOptional& + getFailed () const; + + FailedOptional& + getFailed (); + + void + setFailed (const FailedType& x); + + void + setFailed (const FailedOptional& x); + + void + setFailed (::std::unique_ptr< FailedType > p); + + // forbidden + // + typedef ::LinphonePrivate::Xsd::Imdn::Forbidden ForbiddenType; + typedef ::xsd::cxx::tree::optional< ForbiddenType > ForbiddenOptional; + typedef ::xsd::cxx::tree::traits< ForbiddenType, char > ForbiddenTraits; + + const ForbiddenOptional& + getForbidden () const; + + ForbiddenOptional& + getForbidden (); + + void + setForbidden (const ForbiddenType& x); + + void + setForbidden (const ForbiddenOptional& x); + + void + setForbidden (::std::unique_ptr< ForbiddenType > p); + + // error + // + typedef ::LinphonePrivate::Xsd::Imdn::Error ErrorType; + typedef ::xsd::cxx::tree::optional< ErrorType > ErrorOptional; + typedef ::xsd::cxx::tree::traits< ErrorType, char > ErrorTraits; + + const ErrorOptional& + getError () const; + + ErrorOptional& + getError (); + + void + setError (const ErrorType& x); + + void + setError (const ErrorOptional& x); + + void + setError (::std::unique_ptr< ErrorType > p); + + // reason + // + typedef ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason ReasonType; + typedef ::xsd::cxx::tree::optional< ReasonType > ReasonOptional; + typedef ::xsd::cxx::tree::traits< ReasonType, char > ReasonTraits; + + const ReasonOptional& + getReason () const; + + ReasonOptional& + getReason (); + + void + setReason (const ReasonType& x); + + void + setReason (const ReasonOptional& x); + + void + setReason (::std::unique_ptr< ReasonType > p); + + // Constructors. + // + Status (); + + Status (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Status (const Status& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Status* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + Status& + operator= (const Status& x); + + virtual + ~Status (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + DeliveredOptional delivered_; + FailedOptional failed_; + ForbiddenOptional forbidden_; + ErrorOptional error_; + ReasonOptional reason_; + }; + + class Status1: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // displayed + // + typedef ::LinphonePrivate::Xsd::Imdn::Displayed DisplayedType; + typedef ::xsd::cxx::tree::optional< DisplayedType > DisplayedOptional; + typedef ::xsd::cxx::tree::traits< DisplayedType, char > DisplayedTraits; + + const DisplayedOptional& + getDisplayed () const; + + DisplayedOptional& + getDisplayed (); + + void + setDisplayed (const DisplayedType& x); + + void + setDisplayed (const DisplayedOptional& x); + + void + setDisplayed (::std::unique_ptr< DisplayedType > p); + + // forbidden + // + typedef ::LinphonePrivate::Xsd::Imdn::Forbidden ForbiddenType; + typedef ::xsd::cxx::tree::optional< ForbiddenType > ForbiddenOptional; + typedef ::xsd::cxx::tree::traits< ForbiddenType, char > ForbiddenTraits; + + const ForbiddenOptional& + getForbidden () const; + + ForbiddenOptional& + getForbidden (); + + void + setForbidden (const ForbiddenType& x); + + void + setForbidden (const ForbiddenOptional& x); + + void + setForbidden (::std::unique_ptr< ForbiddenType > p); + + // error + // + typedef ::LinphonePrivate::Xsd::Imdn::Error ErrorType; + typedef ::xsd::cxx::tree::optional< ErrorType > ErrorOptional; + typedef ::xsd::cxx::tree::traits< ErrorType, char > ErrorTraits; + + const ErrorOptional& + getError () const; + + ErrorOptional& + getError (); + + void + setError (const ErrorType& x); + + void + setError (const ErrorOptional& x); + + void + setError (::std::unique_ptr< ErrorType > p); + + // any + // + typedef ::xsd::cxx::tree::element_sequence AnySequence; + typedef AnySequence::iterator AnyIterator; + typedef AnySequence::const_iterator AnyConstIterator; + + const AnySequence& + getAny () const; + + AnySequence& + getAny (); + + void + setAny (const AnySequence& s); + + // DOMDocument for wildcard content. + // + const ::xercesc::DOMDocument& + getDomDocument () const; + + ::xercesc::DOMDocument& + getDomDocument (); + + // Constructors. + // + Status1 (); + + Status1 (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Status1 (const Status1& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Status1* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + Status1& + operator= (const Status1& x); + + virtual + ~Status1 (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > dom_document_; + + DisplayedOptional displayed_; + ForbiddenOptional forbidden_; + ErrorOptional error_; + AnySequence any_; + }; + + class Status2: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // processed + // + typedef ::LinphonePrivate::Xsd::Imdn::Processed ProcessedType; + typedef ::xsd::cxx::tree::optional< ProcessedType > ProcessedOptional; + typedef ::xsd::cxx::tree::traits< ProcessedType, char > ProcessedTraits; + + const ProcessedOptional& + getProcessed () const; + + ProcessedOptional& + getProcessed (); + + void + setProcessed (const ProcessedType& x); + + void + setProcessed (const ProcessedOptional& x); + + void + setProcessed (::std::unique_ptr< ProcessedType > p); + + // stored + // + typedef ::LinphonePrivate::Xsd::Imdn::Stored StoredType; + typedef ::xsd::cxx::tree::optional< StoredType > StoredOptional; + typedef ::xsd::cxx::tree::traits< StoredType, char > StoredTraits; + + const StoredOptional& + getStored () const; + + StoredOptional& + getStored (); + + void + setStored (const StoredType& x); + + void + setStored (const StoredOptional& x); + + void + setStored (::std::unique_ptr< StoredType > p); + + // forbidden + // + typedef ::LinphonePrivate::Xsd::Imdn::Forbidden ForbiddenType; + typedef ::xsd::cxx::tree::optional< ForbiddenType > ForbiddenOptional; + typedef ::xsd::cxx::tree::traits< ForbiddenType, char > ForbiddenTraits; + + const ForbiddenOptional& + getForbidden () const; + + ForbiddenOptional& + getForbidden (); + + void + setForbidden (const ForbiddenType& x); + + void + setForbidden (const ForbiddenOptional& x); + + void + setForbidden (::std::unique_ptr< ForbiddenType > p); + + // error + // + typedef ::LinphonePrivate::Xsd::Imdn::Error ErrorType; + typedef ::xsd::cxx::tree::optional< ErrorType > ErrorOptional; + typedef ::xsd::cxx::tree::traits< ErrorType, char > ErrorTraits; + + const ErrorOptional& + getError () const; + + ErrorOptional& + getError (); + + void + setError (const ErrorType& x); + + void + setError (const ErrorOptional& x); + + void + setError (::std::unique_ptr< ErrorType > p); + + // any + // + typedef ::xsd::cxx::tree::element_sequence AnySequence; + typedef AnySequence::iterator AnyIterator; + typedef AnySequence::const_iterator AnyConstIterator; + + const AnySequence& + getAny () const; + + AnySequence& + getAny (); + + void + setAny (const AnySequence& s); + + // DOMDocument for wildcard content. + // + const ::xercesc::DOMDocument& + getDomDocument () const; + + ::xercesc::DOMDocument& + getDomDocument (); + + // Constructors. + // + Status2 (); + + Status2 (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + Status2 (const Status2& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual Status2* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + Status2& + operator= (const Status2& x); + + virtual + ~Status2 (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > dom_document_; + + ProcessedOptional processed_; + StoredOptional stored_; + ForbiddenOptional forbidden_; + ErrorOptional error_; + AnySequence any_; + }; + } + } +} + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + ::std::ostream& + operator<< (::std::ostream&, const Imdn&); + + ::std::ostream& + operator<< (::std::ostream&, const DeliveryNotification&); + + ::std::ostream& + operator<< (::std::ostream&, const Delivered&); + + ::std::ostream& + operator<< (::std::ostream&, const Failed&); + + ::std::ostream& + operator<< (::std::ostream&, const DisplayNotification&); + + ::std::ostream& + operator<< (::std::ostream&, const Displayed&); + + ::std::ostream& + operator<< (::std::ostream&, const ProcessingNotification&); + + ::std::ostream& + operator<< (::std::ostream&, const Processed&); + + ::std::ostream& + operator<< (::std::ostream&, const Stored&); + + ::std::ostream& + operator<< (::std::ostream&, const Forbidden&); + + ::std::ostream& + operator<< (::std::ostream&, const Error&); + + ::std::ostream& + operator<< (::std::ostream&, const Status&); + + ::std::ostream& + operator<< (::std::ostream&, const Status1&); + + ::std::ostream& + operator<< (::std::ostream&, const Status2&); + } + } +} + +#include + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + // Parse a URI or a local file. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::std::string& uri, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse std::istream. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::std::istream& is, + const ::std::string& id, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::InputSource. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::xercesc::InputSource& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::DOMDocument. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (const ::xercesc::DOMDocument& d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::Imdn::Imdn > + parseImdn (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + } + } +} + +#include + +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace Imdn + { + // Serialize to std::ostream. + // + + void + serializeImdn (::std::ostream& os, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeImdn (::std::ostream& os, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeImdn (::std::ostream& os, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to xercesc::XMLFormatTarget. + // + + void + serializeImdn (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeImdn (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeImdn (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to an existing xercesc::DOMDocument. + // + + void + serializeImdn (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to a new xercesc::DOMDocument. + // + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeImdn (const ::LinphonePrivate::Xsd::Imdn::Imdn& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + operator<< (::xercesc::DOMElement&, const Imdn&); + + void + operator<< (::xercesc::DOMElement&, const DeliveryNotification&); + + void + operator<< (::xercesc::DOMElement&, const Delivered&); + + void + operator<< (::xercesc::DOMAttr&, const Delivered&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Delivered&); + + void + operator<< (::xercesc::DOMElement&, const Failed&); + + void + operator<< (::xercesc::DOMAttr&, const Failed&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Failed&); + + void + operator<< (::xercesc::DOMElement&, const DisplayNotification&); + + void + operator<< (::xercesc::DOMElement&, const Displayed&); + + void + operator<< (::xercesc::DOMAttr&, const Displayed&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Displayed&); + + void + operator<< (::xercesc::DOMElement&, const ProcessingNotification&); + + void + operator<< (::xercesc::DOMElement&, const Processed&); + + void + operator<< (::xercesc::DOMAttr&, const Processed&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Processed&); + + void + operator<< (::xercesc::DOMElement&, const Stored&); + + void + operator<< (::xercesc::DOMAttr&, const Stored&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Stored&); + + void + operator<< (::xercesc::DOMElement&, const Forbidden&); + + void + operator<< (::xercesc::DOMAttr&, const Forbidden&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Forbidden&); + + void + operator<< (::xercesc::DOMElement&, const Error&); + + void + operator<< (::xercesc::DOMAttr&, const Error&); + + void + operator<< (::LinphonePrivate::Xsd::XmlSchema::ListStream&, + const Error&); + + void + operator<< (::xercesc::DOMElement&, const Status&); + + void + operator<< (::xercesc::DOMElement&, const Status1&); + + void + operator<< (::xercesc::DOMElement&, const Status2&); + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + +#endif // XML_IMDN_H diff --git a/src/xml/imdn.xsd b/src/xml/imdn.xsd new file mode 100644 index 000000000..f69675f60 --- /dev/null +++ b/src/xml/imdn.xsd @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/xml/linphone-imdn.cpp b/src/xml/linphone-imdn.cpp new file mode 100644 index 000000000..d54b05414 --- /dev/null +++ b/src/xml/linphone-imdn.cpp @@ -0,0 +1,717 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#include "linphone-imdn.h" + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + // ImdnReason + // + + const ImdnReason::CodeType& ImdnReason:: + getCode () const + { + return this->code_.get (); + } + + ImdnReason::CodeType& ImdnReason:: + getCode () + { + return this->code_.get (); + } + + void ImdnReason:: + setCode (const CodeType& x) + { + this->code_.set (x); + } + + ImdnReason::CodeType ImdnReason:: + getCodeDefaultValue () + { + return CodeType (200); + } + } + } +} + +#include + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + // ImdnReason + // + + ImdnReason:: + ImdnReason () + : ::LinphonePrivate::Xsd::XmlSchema::String (), + code_ (getCodeDefaultValue (), this) + { + } + + ImdnReason:: + ImdnReason (const char* _xsd_String_base) + : ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_String_base), + code_ (getCodeDefaultValue (), this) + { + } + + ImdnReason:: + ImdnReason (const ::std::string& _xsd_String_base) + : ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_String_base), + code_ (getCodeDefaultValue (), this) + { + } + + ImdnReason:: + ImdnReason (const ::LinphonePrivate::Xsd::XmlSchema::String& _xsd_String_base) + : ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_String_base), + code_ (getCodeDefaultValue (), this) + { + } + + ImdnReason:: + ImdnReason (const ImdnReason& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::String (x, f, c), + code_ (x.code_, f, this) + { + } + + ImdnReason:: + ImdnReason (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::String (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + code_ (this) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, false, false, true); + this->parse (p, f); + } + } + + void ImdnReason:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + while (p.more_attributes ()) + { + const ::xercesc::DOMAttr& i (p.next_attribute ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + if (n.name () == "code" && n.namespace_ ().empty ()) + { + this->code_.set (CodeTraits::create (i, f, this)); + continue; + } + } + + if (!code_.present ()) + { + this->code_.set (getCodeDefaultValue ()); + } + } + + ImdnReason* ImdnReason:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class ImdnReason (*this, f, c); + } + + ImdnReason& ImdnReason:: + operator= (const ImdnReason& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = x; + this->code_ = x.code_; + } + + return *this; + } + + ImdnReason:: + ~ImdnReason () + { + } + } + } +} + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + ::std::ostream& + operator<< (::std::ostream& o, const ImdnReason& i) + { + o << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::String& > (i); + + o << ::std::endl << "code: " << i.getCode (); + return o; + } + } + } +} + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& u, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& sid, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::LinphoneImdn::parseReason (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& i, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::xercesc::DOMDocument& doc, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + static_cast< ::xercesc::DOMDocument* > (doc.cloneNode (true))); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > ( + ::LinphonePrivate::Xsd::LinphoneImdn::parseReason ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "reason" && + n.namespace_ () == "http://www.linphone.org/xsds/imdn.xsd") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "reason", + "http://www.linphone.org/xsds/imdn.xsd"); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties&) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > c ( + ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) && + !(f & ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom)) + ? static_cast< ::xercesc::DOMDocument* > (d->cloneNode (true)) + : 0); + + ::xercesc::DOMDocument& doc (c.get () ? *c : *d); + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + doc.setUserData (::LinphonePrivate::Xsd::XmlSchema::dom::treeNodeKey, + (c.get () ? &c : &d), + 0); + + if (n.name () == "reason" && + n.namespace_ () == "http://www.linphone.org/xsds/imdn.xsd") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "reason", + "http://www.linphone.org/xsds/imdn.xsd"); + } + } + } +} + +#include +#include +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + void + serializeReason (::std::ostream& o, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeReason (::std::ostream& o, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeReason (::std::ostream& o, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeReason (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeReason (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeReason (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeReason (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + ::LinphonePrivate::Xsd::XmlSchema::Flags) + { + ::xercesc::DOMElement& e (*d.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "reason" && + n.namespace_ () == "http://www.linphone.org/xsds/imdn.xsd") + { + e << s; + } + else + { + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "reason", + "http://www.linphone.org/xsds/imdn.xsd"); + } + } + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeReason (const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::serialize< char > ( + "reason", + "http://www.linphone.org/xsds/imdn.xsd", + m, f)); + + ::LinphonePrivate::Xsd::LinphoneImdn::serializeReason (*d, s, f); + return d; + } + + void + operator<< (::xercesc::DOMElement& e, const ImdnReason& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::String& > (i); + + // code + // + { + ::xercesc::DOMAttr& a ( + ::xsd::cxx::xml::dom::create_attribute ( + "code", + e)); + + a << i.getCode (); + } + } + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + diff --git a/src/xml/linphone-imdn.h b/src/xml/linphone-imdn.h new file mode 100644 index 000000000..42e1327a6 --- /dev/null +++ b/src/xml/linphone-imdn.h @@ -0,0 +1,592 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +#ifndef XML_LINPHONE_IMDN_H +#define XML_LINPHONE_IMDN_H + +#ifndef XSD_CXX11 +#define XSD_CXX11 +#endif + +#ifndef XSD_USE_CHAR +#define XSD_USE_CHAR +#endif + +#ifndef XSD_CXX_TREE_USE_CHAR +#define XSD_CXX_TREE_USE_CHAR +#endif + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#if (XSD_INT_VERSION != 4000000L) +#error XSD runtime version mismatch +#endif + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace XmlSchema + { + // anyType and anySimpleType. + // + typedef ::xsd::cxx::tree::type Type; + typedef ::xsd::cxx::tree::simple_type< char, Type > SimpleType; + typedef ::xsd::cxx::tree::type Container; + + // 8-bit + // + typedef signed char Byte; + typedef unsigned char UnsignedByte; + + // 16-bit + // + typedef short Short; + typedef unsigned short UnsignedShort; + + // 32-bit + // + typedef int Int; + typedef unsigned int UnsignedInt; + + // 64-bit + // + typedef long long Long; + typedef unsigned long long UnsignedLong; + + // Supposed to be arbitrary-length integral types. + // + typedef long long Integer; + typedef long long NonPositiveInteger; + typedef unsigned long long NonNegativeInteger; + typedef unsigned long long PositiveInteger; + typedef long long NegativeInteger; + + // Boolean. + // + typedef bool Boolean; + + // Floating-point types. + // + typedef float Float; + typedef double Double; + typedef double Decimal; + + // String types. + // + typedef ::xsd::cxx::tree::string< char, SimpleType > String; + typedef ::xsd::cxx::tree::normalized_string< char, String > NormalizedString; + typedef ::xsd::cxx::tree::token< char, NormalizedString > Token; + typedef ::xsd::cxx::tree::name< char, Token > Name; + typedef ::xsd::cxx::tree::nmtoken< char, Token > Nmtoken; + typedef ::xsd::cxx::tree::nmtokens< char, SimpleType, Nmtoken > Nmtokens; + typedef ::xsd::cxx::tree::ncname< char, Name > Ncname; + typedef ::xsd::cxx::tree::language< char, Token > Language; + + // ID/IDREF. + // + typedef ::xsd::cxx::tree::id< char, Ncname > Id; + typedef ::xsd::cxx::tree::idref< char, Ncname, Type > Idref; + typedef ::xsd::cxx::tree::idrefs< char, SimpleType, Idref > Idrefs; + + // URI. + // + typedef ::xsd::cxx::tree::uri< char, SimpleType > Uri; + + // Qualified name. + // + typedef ::xsd::cxx::tree::qname< char, SimpleType, Uri, Ncname > Qname; + + // Binary. + // + typedef ::xsd::cxx::tree::buffer< char > Buffer; + typedef ::xsd::cxx::tree::base64_binary< char, SimpleType > Base64Binary; + typedef ::xsd::cxx::tree::hex_binary< char, SimpleType > HexBinary; + + // Date/time. + // + typedef ::xsd::cxx::tree::time_zone TimeZone; + typedef ::xsd::cxx::tree::date< char, SimpleType > Date; + typedef ::xsd::cxx::tree::date_time< char, SimpleType > DateTime; + typedef ::xsd::cxx::tree::duration< char, SimpleType > Duration; + typedef ::xsd::cxx::tree::gday< char, SimpleType > Gday; + typedef ::xsd::cxx::tree::gmonth< char, SimpleType > Gmonth; + typedef ::xsd::cxx::tree::gmonth_day< char, SimpleType > GmonthDay; + typedef ::xsd::cxx::tree::gyear< char, SimpleType > Gyear; + typedef ::xsd::cxx::tree::gyear_month< char, SimpleType > GyearMonth; + typedef ::xsd::cxx::tree::time< char, SimpleType > Time; + + // Entity. + // + typedef ::xsd::cxx::tree::entity< char, Ncname > Entity; + typedef ::xsd::cxx::tree::entities< char, SimpleType, Entity > Entities; + + typedef ::xsd::cxx::tree::content_order ContentOrder; + // Namespace information and list stream. Used in + // serialization functions. + // + typedef ::xsd::cxx::xml::dom::namespace_info< char > NamespaceInfo; + typedef ::xsd::cxx::xml::dom::namespace_infomap< char > NamespaceInfomap; + typedef ::xsd::cxx::tree::list_stream< char > ListStream; + typedef ::xsd::cxx::tree::as_double< Double > AsDouble; + typedef ::xsd::cxx::tree::as_decimal< Decimal > AsDecimal; + typedef ::xsd::cxx::tree::facet Facet; + + // Flags and properties. + // + typedef ::xsd::cxx::tree::flags Flags; + typedef ::xsd::cxx::tree::properties< char > Properties; + + // Parsing/serialization diagnostics. + // + typedef ::xsd::cxx::tree::severity Severity; + typedef ::xsd::cxx::tree::error< char > Error; + typedef ::xsd::cxx::tree::diagnostics< char > Diagnostics; + + // Exceptions. + // + typedef ::xsd::cxx::tree::exception< char > Exception; + typedef ::xsd::cxx::tree::bounds< char > Bounds; + typedef ::xsd::cxx::tree::duplicate_id< char > DuplicateId; + typedef ::xsd::cxx::tree::parsing< char > Parsing; + typedef ::xsd::cxx::tree::expected_element< char > ExpectedElement; + typedef ::xsd::cxx::tree::unexpected_element< char > UnexpectedElement; + typedef ::xsd::cxx::tree::expected_attribute< char > ExpectedAttribute; + typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; + typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; + typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; + typedef ::xsd::cxx::tree::serialization< char > Serialization; + + // Error handler callback interface. + // + typedef ::xsd::cxx::xml::error_handler< char > ErrorHandler; + + // DOM interaction. + // + namespace dom + { + // Automatic pointer for DOMDocument. + // + using ::xsd::cxx::xml::dom::unique_ptr; + +#ifndef XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA +#define XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA + // DOM user data key for back pointers to tree nodes. + // + const XMLCh* const treeNodeKey = ::xsd::cxx::tree::user_data_keys::node; +#endif + } + } + } +} + +// Forward declarations. +// +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + class ImdnReason; + } + } +} + + +#include // ::std::unique_ptr +#include // std::numeric_limits +#include // std::binary_search +#include // std::move + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + class ImdnReason: public ::LinphonePrivate::Xsd::XmlSchema::String + { + public: + // code + // + typedef ::LinphonePrivate::Xsd::XmlSchema::Int CodeType; + typedef ::xsd::cxx::tree::traits< CodeType, char > CodeTraits; + + const CodeType& + getCode () const; + + CodeType& + getCode (); + + void + setCode (const CodeType& x); + + static CodeType + getCodeDefaultValue (); + + // Constructors. + // + ImdnReason (); + + ImdnReason (const char*); + + ImdnReason (const ::std::string&); + + ImdnReason (const ::LinphonePrivate::Xsd::XmlSchema::String&); + + ImdnReason (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + ImdnReason (const ImdnReason& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual ImdnReason* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + ImdnReason& + operator= (const ImdnReason& x); + + virtual + ~ImdnReason (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::xsd::cxx::tree::one< CodeType > code_; + }; + } + } +} + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + ::std::ostream& + operator<< (::std::ostream&, const ImdnReason&); + } + } +} + +#include + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + // Parse a URI or a local file. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::std::string& uri, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse std::istream. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::std::istream& is, + const ::std::string& id, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::InputSource. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::xercesc::InputSource& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::DOMDocument. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (const ::xercesc::DOMDocument& d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason > + parseReason (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + } + } +} + +#include + +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace LinphoneImdn + { + // Serialize to std::ostream. + // + + void + serializeReason (::std::ostream& os, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeReason (::std::ostream& os, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeReason (::std::ostream& os, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to xercesc::XMLFormatTarget. + // + + void + serializeReason (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeReason (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeReason (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to an existing xercesc::DOMDocument. + // + + void + serializeReason (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to a new xercesc::DOMDocument. + // + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeReason (const ::LinphonePrivate::Xsd::LinphoneImdn::ImdnReason& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + operator<< (::xercesc::DOMElement&, const ImdnReason&); + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + +#endif // XML_LINPHONE_IMDN_H diff --git a/src/xml/linphone-imdn.xsd b/src/xml/linphone-imdn.xsd new file mode 100644 index 000000000..6a6136a0d --- /dev/null +++ b/src/xml/linphone-imdn.xsd @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/xml/prologue.txt b/src/xml/prologue.txt index f2a7bf6f0..23e94d03a 100644 --- a/src/xml/prologue.txt +++ b/src/xml/prologue.txt @@ -1,7 +1,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#ifndef __ANDROID__ +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-override" #endif -#endif diff --git a/src/xml/resource-lists.cpp b/src/xml/resource-lists.cpp index 5d42e0137..79f90d384 100644 --- a/src/xml/resource-lists.cpp +++ b/src/xml/resource-lists.cpp @@ -36,9 +36,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -54,7 +55,7 @@ namespace LinphonePrivate namespace ResourceLists { // ListType - // + // const ListType::DisplayNameOptional& ListType:: getDisplayName () const @@ -238,7 +239,7 @@ namespace LinphonePrivate // EntryType - // + // const EntryType::DisplayNameOptional& EntryType:: getDisplayName () const @@ -350,7 +351,7 @@ namespace LinphonePrivate // EntryRefType - // + // const EntryRefType::DisplayNameOptional& EntryRefType:: getDisplayName () const @@ -462,7 +463,7 @@ namespace LinphonePrivate // ExternalType - // + // const ExternalType::DisplayNameOptional& ExternalType:: getDisplayName () const @@ -574,7 +575,7 @@ namespace LinphonePrivate // DisplayNameType - // + // const DisplayNameType::LangOptional& DisplayNameType:: getLang () const @@ -608,15 +609,15 @@ namespace LinphonePrivate // List - // + // // DisplayName - // + // // ResourceLists - // + // const ResourceLists::ListSequence& ResourceLists:: getList () const @@ -643,6 +644,15 @@ namespace LinphonePrivate #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -1558,6 +1568,15 @@ namespace LinphonePrivate #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -1976,6 +1995,15 @@ namespace LinphonePrivate #include #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + namespace LinphonePrivate { namespace Xsd @@ -2483,8 +2511,12 @@ namespace LinphonePrivate // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif // // End epilogue. + diff --git a/src/xml/resource-lists.h b/src/xml/resource-lists.h index 1062cfb31..4494881c4 100644 --- a/src/xml/resource-lists.h +++ b/src/xml/resource-lists.h @@ -51,9 +51,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -240,6 +241,8 @@ namespace LinphonePrivate typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; typedef ::xsd::cxx::tree::serialization< char > Serialization; // Error handler callback interface. @@ -480,7 +483,7 @@ namespace LinphonePrivate ListType& operator= (const ListType& x); - virtual + virtual ~ListType (); // Implementation. @@ -604,7 +607,7 @@ namespace LinphonePrivate EntryType& operator= (const EntryType& x); - virtual + virtual ~EntryType (); // Implementation. @@ -724,7 +727,7 @@ namespace LinphonePrivate EntryRefType& operator= (const EntryRefType& x); - virtual + virtual ~EntryRefType (); // Implementation. @@ -845,7 +848,7 @@ namespace LinphonePrivate ExternalType& operator= (const ExternalType& x); - virtual + virtual ~ExternalType (); // Implementation. @@ -913,7 +916,7 @@ namespace LinphonePrivate DisplayNameType& operator= (const DisplayNameType& x); - virtual + virtual ~DisplayNameType (); // Implementation. @@ -946,7 +949,7 @@ namespace LinphonePrivate _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; - virtual + virtual ~List (); }; @@ -975,7 +978,7 @@ namespace LinphonePrivate _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; - virtual + virtual ~DisplayName (); }; @@ -1018,7 +1021,7 @@ namespace LinphonePrivate ResourceLists& operator= (const ResourceLists& x); - virtual + virtual ~ResourceLists (); // Implementation. @@ -1209,14 +1212,14 @@ namespace LinphonePrivate void serializeResourceLists (::std::ostream& os, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); void serializeResourceLists (::std::ostream& os, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -1224,7 +1227,7 @@ namespace LinphonePrivate void serializeResourceLists (::std::ostream& os, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, ::xercesc::DOMErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -1235,14 +1238,14 @@ namespace LinphonePrivate void serializeResourceLists (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); void serializeResourceLists (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -1250,7 +1253,7 @@ namespace LinphonePrivate void serializeResourceLists (::xercesc::XMLFormatTarget& ft, - const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, ::xercesc::DOMErrorHandler& eh, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), const ::std::string& e = "UTF-8", @@ -1268,7 +1271,7 @@ namespace LinphonePrivate // ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > - serializeResourceLists (const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, + serializeResourceLists (const ::LinphonePrivate::Xsd::ResourceLists::ResourceLists& x, const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); @@ -1291,6 +1294,9 @@ namespace LinphonePrivate // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index b8c204909..f052e7f5a 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -36,9 +36,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -73,7 +74,7 @@ namespace namespace_ } // Space - // + // Space:: Space (Value v) @@ -110,7 +111,7 @@ namespace namespace_ Space& Space:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::Ncname& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Ncname& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::Ncname (_xsd_Space_literals_[v]); return *this; @@ -118,7 +119,7 @@ namespace namespace_ // Lang_member - // + // Lang_member:: Lang_member (Value v) @@ -155,7 +156,7 @@ namespace namespace_ Lang_member& Lang_member:: operator= (Value v) { - static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = + static_cast< ::LinphonePrivate::Xsd::XmlSchema::String& > (*this) = ::LinphonePrivate::Xsd::XmlSchema::String (_xsd_Lang_member_literals_[v]); return *this; @@ -166,6 +167,15 @@ namespace namespace_ #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + namespace namespace_ { // Lang @@ -344,6 +354,15 @@ namespace namespace_ #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + namespace namespace_ { ::std::ostream& @@ -389,6 +408,15 @@ namespace namespace_ #include #include +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + namespace namespace_ { void @@ -453,8 +481,12 @@ namespace namespace_ // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif // // End epilogue. + diff --git a/src/xml/xml.h b/src/xml/xml.h index af3c3c3a2..681dc279d 100644 --- a/src/xml/xml.h +++ b/src/xml/xml.h @@ -51,9 +51,10 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" -#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) - #pragma GCC diagnostic ignored "-Wsuggest-override" #endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif // // End prologue. @@ -240,6 +241,8 @@ namespace LinphonePrivate typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; typedef ::xsd::cxx::tree::serialization< char > Serialization; // Error handler callback interface. @@ -510,6 +513,9 @@ namespace namespace_ // Begin epilogue. // +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic pop #endif diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index d5c5b427b..ca6eed11d 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -3077,8 +3077,8 @@ static void imdn_for_group_chat_room (void) { // Chloe begins composing a message const char *chloeTextMessage = "Hello"; LinphoneChatMessage *chloeMessage = _send_message(chloeCr, chloeTextMessage); - BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, initialMarieStats.number_of_LinphoneMessageReceived + 1, 10000)); - BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 10000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, initialMarieStats.number_of_LinphoneMessageReceived + 1, 3000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 3000)); LinphoneChatMessage *marieLastMsg = marie->stat.last_received_chat_message; if (!BC_ASSERT_PTR_NOT_NULL(marieLastMsg)) goto end; @@ -3088,7 +3088,7 @@ static void imdn_for_group_chat_room (void) { linphone_address_unref(chloeAddr); // Check that the message has been delivered to Marie and Pauline - BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 1000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 3000)); BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_displayed(chloeMessage)); bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_that_have_received(chloeMessage); if (BC_ASSERT_PTR_NOT_NULL(participantsThatReceivedChloeMessage)) { @@ -3105,7 +3105,7 @@ static void imdn_for_group_chat_room (void) { // Marie marks the message as read, check that the state is not yet displayed on Chloe's side linphone_chat_room_mark_as_read(marieCr); - BC_ASSERT_FALSE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 1000)); + BC_ASSERT_FALSE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 3000)); bctbx_list_t *participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_that_have_displayed(chloeMessage); if (BC_ASSERT_PTR_NOT_NULL(participantsThatDisplayedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatDisplayedChloeMessage), 1, int, "%d"); @@ -3120,7 +3120,7 @@ static void imdn_for_group_chat_room (void) { // Pauline also marks the message as read, check that the state is now displayed on Chloe's side linphone_chat_room_mark_as_read(paulineCr); - BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 1000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 3000)); participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_that_have_displayed(chloeMessage); if (BC_ASSERT_PTR_NOT_NULL(participantsThatDisplayedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatDisplayedChloeMessage), 2, int, "%d"); From 9c673a435ce0072ebd69093fdf4ce3282868d42a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 17 Apr 2018 17:53:12 +0200 Subject: [PATCH 050/143] Use xsd for is-composing xml handling. --- src/CMakeLists.txt | 2 + .../chat-message/is-composing-message.cpp | 2 +- src/chat/notification/is-composing.cpp | 132 +-- src/chat/notification/is-composing.h | 6 +- src/xml/generate.py | 2 + src/xml/is-composing.cpp | 962 ++++++++++++++++++ src/xml/is-composing.h | 678 ++++++++++++ src/xml/is-composing.xsd | 18 + 8 files changed, 1693 insertions(+), 109 deletions(-) create mode 100644 src/xml/is-composing.cpp create mode 100644 src/xml/is-composing.h create mode 100644 src/xml/is-composing.xsd diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5617ed65..90bb71e2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -165,6 +165,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES variant/variant.h xml/conference-info.h xml/imdn.h + xml/is-composing.h xml/linphone-imdn.h xml/resource-lists.h xml/xml.h @@ -289,6 +290,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES variant/variant.cpp xml/conference-info.cpp xml/imdn.cpp + xml/is-composing.cpp xml/linphone-imdn.cpp xml/resource-lists.cpp xml/xml.cpp diff --git a/src/chat/chat-message/is-composing-message.cpp b/src/chat/chat-message/is-composing-message.cpp index 13177e92e..9797e9e9e 100644 --- a/src/chat/chat-message/is-composing-message.cpp +++ b/src/chat/chat-message/is-composing-message.cpp @@ -37,7 +37,7 @@ IsComposingMessage::IsComposingMessage ( L_D(); Content *content = new Content(); content->setContentType(ContentType::ImIsComposing); - content->setBody(isComposingHandler.marshal(isComposing)); + content->setBody(isComposingHandler.createXml(isComposing)); addContent(content); d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); d->addSalCustomHeader("Expires", "0"); diff --git a/src/chat/notification/is-composing.cpp b/src/chat/notification/is-composing.cpp index c567bd3b8..e6e6c70ae 100644 --- a/src/chat/notification/is-composing.cpp +++ b/src/chat/notification/is-composing.cpp @@ -24,6 +24,7 @@ #include "chat/chat-room/chat-room-p.h" #include "chat/notification/is-composing.h" #include "logger/logger.h" +#include "xml/is-composing.h" // ============================================================================= @@ -42,10 +43,6 @@ struct IsRemoteComposingData { // ----------------------------------------------------------------------------- -const string IsComposing::isComposingPrefix = "/xsi:isComposing"; - -// ----------------------------------------------------------------------------- - IsComposing::IsComposing (LinphoneCore *core, IsComposingListener *listener) : core(core), listener(listener) {} @@ -55,66 +52,34 @@ IsComposing::~IsComposing () { // ----------------------------------------------------------------------------- -string IsComposing::marshal (bool isComposing) { - string content; +string IsComposing::createXml (bool isComposing) { + Xsd::IsComposing::IsComposing node(isComposing ? "active" : "idle"); + if (isComposing) + node.setRefresh(static_cast(lp_config_get_int(core->config, "sip", "composing_refresh_timeout", defaultRefreshTimeout))); - xmlBufferPtr buf = xmlBufferCreate(); - if (!buf) { - lError() << "Error creating the XML buffer"; - return content; - } - xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0); - if (!writer) { - lError() << "Error creating the XML writer"; - return content; - } - - int err = xmlTextWriterStartDocument(writer, "1.0", "UTF-8", nullptr); - if (err >= 0) { - err = xmlTextWriterStartElementNS(writer, nullptr, (const xmlChar *)"isComposing", - (const xmlChar *)"urn:ietf:params:xml:ns:im-iscomposing"); - } - if (err >= 0) { - err = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)"xmlns", (const xmlChar *)"xsi", nullptr, - (const xmlChar *)"http://www.w3.org/2001/XMLSchema-instance"); - } - if (err >= 0) { - err = xmlTextWriterWriteAttributeNS(writer, (const xmlChar *)"xsi", (const xmlChar *)"schemaLocation", nullptr, - (const xmlChar *)"urn:ietf:params:xml:ns:im-composing iscomposing.xsd"); - } - if (err >= 0) { - err = xmlTextWriterWriteElement(writer, (const xmlChar *)"state", - isComposing ? (const xmlChar *)"active" : (const xmlChar *)"idle"); - } - if ((err >= 0) && isComposing) { - int refreshTimeout = lp_config_get_int(core->config, "sip", "composing_refresh_timeout", defaultRefreshTimeout); - err = xmlTextWriterWriteElement(writer, (const xmlChar *)"refresh", (const xmlChar *)Utils::toString(refreshTimeout).c_str()); - } - if (err >= 0) { - /* Close the "isComposing" element. */ - err = xmlTextWriterEndElement(writer); - } - if (err >= 0) { - err = xmlTextWriterEndDocument(writer); - } - if (err > 0) { - /* xmlTextWriterEndDocument returns the size of the content. */ - content = (char *)buf->content; - } - xmlFreeTextWriter(writer); - xmlBufferFree(buf); - return content; + stringstream ss; + Xsd::XmlSchema::NamespaceInfomap map; + map[""].name = "urn:ietf:params:xml:ns:im-iscomposing"; + Xsd::IsComposing::serializeIsComposing(ss, node, map); + return ss.str(); } void IsComposing::parse (const Address &remoteAddr, const string &text) { - xmlparsing_context_t *xmlCtx = linphone_xmlparsing_context_new(); - xmlSetGenericErrorFunc(xmlCtx, linphone_xmlparsing_genericxml_error); - xmlCtx->doc = xmlReadDoc((const unsigned char *)text.c_str(), 0, nullptr, 0); - if (xmlCtx->doc) - parse(xmlCtx, remoteAddr); - else - lWarning() << "Wrongly formatted presence XML: " << xmlCtx->errorBuffer; - linphone_xmlparsing_context_destroy(xmlCtx); + istringstream data(text); + unique_ptr node(Xsd::IsComposing::parseIsComposing(data, Xsd::XmlSchema::Flags::dont_validate)); + if (!node) + return; + + if (node->getState() == "active") { + unsigned long long refresh = 0; + if (node->getRefresh().present()) + refresh = node->getRefresh().get(); + startRemoteRefreshTimer(remoteAddr.asStringUriOnly(), refresh); + listener->onIsRemoteComposingStateChanged(remoteAddr, true); + } else if (node->getState() == "idle") { + stopRemoteRefreshTimer(remoteAddr.asStringUriOnly()); + listener->onIsRemoteComposingStateChanged(remoteAddr, false); + } } void IsComposing::startIdleTimer () { @@ -186,47 +151,6 @@ unsigned int IsComposing::getRemoteRefreshTimerDuration () { return remoteRefreshTimerDuration < 0 ? 0 : static_cast(remoteRefreshTimerDuration); } -void IsComposing::parse (xmlparsing_context_t *xmlCtx, const Address &remoteAddr) { - char xpathStr[MAX_XPATH_LENGTH]; - char *stateStr = nullptr; - char *refreshStr = nullptr; - int i; - bool state = false; - - if (linphone_create_xml_xpath_context(xmlCtx) < 0) - return; - - xmlXPathRegisterNs(xmlCtx->xpath_ctx, (const xmlChar *)"xsi", (const xmlChar *)"urn:ietf:params:xml:ns:im-iscomposing"); - xmlXPathObjectPtr isComposingObject = linphone_get_xml_xpath_object_for_node_list(xmlCtx, isComposingPrefix.c_str()); - if (isComposingObject) { - if (isComposingObject->nodesetval) { - for (i = 1; i <= isComposingObject->nodesetval->nodeNr; i++) { - snprintf(xpathStr, sizeof(xpathStr), "%s[%i]/xsi:state", isComposingPrefix.c_str(), i); - stateStr = linphone_get_xml_text_content(xmlCtx, xpathStr); - if (!stateStr) - continue; - snprintf(xpathStr, sizeof(xpathStr), "%s[%i]/xsi:refresh", isComposingPrefix.c_str(), i); - refreshStr = linphone_get_xml_text_content(xmlCtx, xpathStr); - } - } - xmlXPathFreeObject(isComposingObject); - } - - if (stateStr) { - if (strcmp(stateStr, "active") == 0) { - state = true; - startRemoteRefreshTimer(remoteAddr.asStringUriOnly(), refreshStr); - } else { - stopRemoteRefreshTimer(remoteAddr.asStringUriOnly()); - } - - listener->onIsRemoteComposingStateChanged(remoteAddr, state); - linphone_free_xml_text_content(stateStr); - } - if (refreshStr) - linphone_free_xml_text_content(refreshStr); -} - int IsComposing::idleTimerExpired () { stopRefreshTimer(); stopIdleTimer(); @@ -245,10 +169,10 @@ int IsComposing::remoteRefreshTimerExpired (const string &uri) { return BELLE_SIP_STOP; } -void IsComposing::startRemoteRefreshTimer (const string &uri, const char *refreshStr) { +void IsComposing::startRemoteRefreshTimer (const string &uri, unsigned long long refresh) { unsigned int duration = getRemoteRefreshTimerDuration(); - if (refreshStr) - duration = static_cast(Utils::stoi(refreshStr)); + if (refresh != 0) + duration = static_cast(refresh); auto it = remoteRefreshTimers.find(uri); if (it == remoteRefreshTimers.end()) { IsRemoteComposingData *data = new IsRemoteComposingData(this, uri); diff --git a/src/chat/notification/is-composing.h b/src/chat/notification/is-composing.h index 5722537d5..b556dffef 100644 --- a/src/chat/notification/is-composing.h +++ b/src/chat/notification/is-composing.h @@ -38,7 +38,7 @@ public: IsComposing (LinphoneCore *core, IsComposingListener *listener); ~IsComposing (); - std::string marshal (bool isComposing); + std::string createXml (bool isComposing); void parse (const Address &remoteAddr, const std::string &content); void startIdleTimer (); void startRefreshTimer (); @@ -51,11 +51,10 @@ private: unsigned int getIdleTimerDuration (); unsigned int getRefreshTimerDuration (); unsigned int getRemoteRefreshTimerDuration (); - void parse (xmlparsing_context_t *xmlCtx, const Address &remoteAddr); int idleTimerExpired (); int refreshTimerExpired (); int remoteRefreshTimerExpired (const std::string &uri); - void startRemoteRefreshTimer (const std::string &uri, const char *refreshStr); + void startRemoteRefreshTimer (const std::string &uri, unsigned long long refresh); void stopAllRemoteRefreshTimers (); std::unordered_map::iterator stopRemoteRefreshTimer (const std::unordered_map::const_iterator it); @@ -67,7 +66,6 @@ private: static const int defaultIdleTimeout = 15; static const int defaultRefreshTimeout = 60; static const int defaultRemoteRefreshTimeout = 120; - static const std::string isComposingPrefix; LinphoneCore *core = nullptr; IsComposingListener *listener = nullptr; diff --git a/src/xml/generate.py b/src/xml/generate.py index c2fb8075a..60c2f73d0 100755 --- a/src/xml/generate.py +++ b/src/xml/generate.py @@ -93,6 +93,7 @@ def generate(name): "--namespace-map", "http://www.w3.org/2001/XMLSchema=LinphonePrivate::Xsd::XmlSchema", "--namespace-map", "urn:ietf:params:xml:ns:conference-info=LinphonePrivate::Xsd::ConferenceInfo", "--namespace-map", "urn:ietf:params:xml:ns:imdn=LinphonePrivate::Xsd::Imdn", + "--namespace-map", "urn:ietf:params:xml:ns:im-iscomposing=LinphonePrivate::Xsd::IsComposing", "--namespace-map", "http://www.linphone.org/xsds/imdn.xsd=LinphonePrivate::Xsd::LinphoneImdn", "--namespace-map", "urn:ietf:params:xml:ns:resource-lists=LinphonePrivate::Xsd::ResourceLists", source_file @@ -105,6 +106,7 @@ def main(argv = None): generate("xml") generate("conference-info") generate("imdn") + generate("is-composing") generate("linphone-imdn") generate("resource-lists") diff --git a/src/xml/is-composing.cpp b/src/xml/is-composing.cpp new file mode 100644 index 000000000..24002401b --- /dev/null +++ b/src/xml/is-composing.cpp @@ -0,0 +1,962 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#include "is-composing.h" + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + // IsComposing + // + + const IsComposing::StateType& IsComposing:: + getState () const + { + return this->state_.get (); + } + + IsComposing::StateType& IsComposing:: + getState () + { + return this->state_.get (); + } + + void IsComposing:: + setState (const StateType& x) + { + this->state_.set (x); + } + + void IsComposing:: + setState (::std::unique_ptr< StateType > x) + { + this->state_.set (std::move (x)); + } + + ::std::unique_ptr< IsComposing::StateType > IsComposing:: + setDetachState () + { + return this->state_.detach (); + } + + const IsComposing::LastactiveOptional& IsComposing:: + getLastactive () const + { + return this->lastactive_; + } + + IsComposing::LastactiveOptional& IsComposing:: + getLastactive () + { + return this->lastactive_; + } + + void IsComposing:: + setLastactive (const LastactiveType& x) + { + this->lastactive_.set (x); + } + + void IsComposing:: + setLastactive (const LastactiveOptional& x) + { + this->lastactive_ = x; + } + + void IsComposing:: + setLastactive (::std::unique_ptr< LastactiveType > x) + { + this->lastactive_.set (std::move (x)); + } + + const IsComposing::ContenttypeOptional& IsComposing:: + getContenttype () const + { + return this->contenttype_; + } + + IsComposing::ContenttypeOptional& IsComposing:: + getContenttype () + { + return this->contenttype_; + } + + void IsComposing:: + setContenttype (const ContenttypeType& x) + { + this->contenttype_.set (x); + } + + void IsComposing:: + setContenttype (const ContenttypeOptional& x) + { + this->contenttype_ = x; + } + + void IsComposing:: + setContenttype (::std::unique_ptr< ContenttypeType > x) + { + this->contenttype_.set (std::move (x)); + } + + const IsComposing::RefreshOptional& IsComposing:: + getRefresh () const + { + return this->refresh_; + } + + IsComposing::RefreshOptional& IsComposing:: + getRefresh () + { + return this->refresh_; + } + + void IsComposing:: + setRefresh (const RefreshType& x) + { + this->refresh_.set (x); + } + + void IsComposing:: + setRefresh (const RefreshOptional& x) + { + this->refresh_ = x; + } + + const IsComposing::AnySequence& IsComposing:: + getAny () const + { + return this->any_; + } + + IsComposing::AnySequence& IsComposing:: + getAny () + { + return this->any_; + } + + void IsComposing:: + setAny (const AnySequence& s) + { + this->any_ = s; + } + + const ::xercesc::DOMDocument& IsComposing:: + getDomDocument () const + { + return *this->dom_document_; + } + + ::xercesc::DOMDocument& IsComposing:: + getDomDocument () + { + return *this->dom_document_; + } + } + } +} + +#include + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_factory_plate< 0, char > + type_factory_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + // IsComposing + // + + IsComposing:: + IsComposing (const StateType& state) + : ::LinphonePrivate::Xsd::XmlSchema::Type (), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + state_ (state, this), + lastactive_ (this), + contenttype_ (this), + refresh_ (this), + any_ (this->getDomDocument ()) + { + } + + IsComposing:: + IsComposing (const IsComposing& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (x, f, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + state_ (x.state_, f, this), + lastactive_ (x.lastactive_, f, this), + contenttype_ (x.contenttype_, f, this), + refresh_ (x.refresh_, f, this), + any_ (x.any_, this->getDomDocument ()) + { + } + + IsComposing:: + IsComposing (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) + : ::LinphonePrivate::Xsd::XmlSchema::Type (e, f | ::LinphonePrivate::Xsd::XmlSchema::Flags::base, c), + dom_document_ (::xsd::cxx::xml::dom::create_document< char > ()), + state_ (this), + lastactive_ (this), + contenttype_ (this), + refresh_ (this), + any_ (this->getDomDocument ()) + { + if ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::base) == 0) + { + ::xsd::cxx::xml::dom::parser< char > p (e, true, false, false); + this->parse (p, f); + } + } + + void IsComposing:: + parse (::xsd::cxx::xml::dom::parser< char >& p, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + for (; p.more_content (); p.next_content (false)) + { + const ::xercesc::DOMElement& i (p.cur_element ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (i)); + + // state + // + if (n.name () == "state" && n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + ::std::unique_ptr< StateType > r ( + StateTraits::create (i, f, this)); + + if (!state_.present ()) + { + this->state_.set (::std::move (r)); + continue; + } + } + + // lastactive + // + if (n.name () == "lastactive" && n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + ::std::unique_ptr< LastactiveType > r ( + LastactiveTraits::create (i, f, this)); + + if (!this->lastactive_) + { + this->lastactive_.set (::std::move (r)); + continue; + } + } + + // contenttype + // + if (n.name () == "contenttype" && n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + ::std::unique_ptr< ContenttypeType > r ( + ContenttypeTraits::create (i, f, this)); + + if (!this->contenttype_) + { + this->contenttype_.set (::std::move (r)); + continue; + } + } + + // refresh + // + if (n.name () == "refresh" && n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + if (!this->refresh_) + { + this->refresh_.set (RefreshTraits::create (i, f, this)); + continue; + } + } + + // any + // + if ((!n.namespace_ ().empty () && n.namespace_ () != "urn:ietf:params:xml:ns:im-iscomposing")) + { + ::xercesc::DOMElement* r ( + static_cast< ::xercesc::DOMElement* > ( + this->getDomDocument ().importNode ( + const_cast< ::xercesc::DOMElement* > (&i), true))); + this->any_.push_back (r); + continue; + } + + break; + } + + if (!state_.present ()) + { + throw ::xsd::cxx::tree::expected_element< char > ( + "state", + "urn:ietf:params:xml:ns:im-iscomposing"); + } + } + + IsComposing* IsComposing:: + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f, + ::LinphonePrivate::Xsd::XmlSchema::Container* c) const + { + return new class IsComposing (*this, f, c); + } + + IsComposing& IsComposing:: + operator= (const IsComposing& x) + { + if (this != &x) + { + static_cast< ::LinphonePrivate::Xsd::XmlSchema::Type& > (*this) = x; + this->state_ = x.state_; + this->lastactive_ = x.lastactive_; + this->contenttype_ = x.contenttype_; + this->refresh_ = x.refresh_; + this->any_ = x.any_; + } + + return *this; + } + + IsComposing:: + ~IsComposing () + { + } + } + } +} + +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::std_ostream_plate< 0, char > + std_ostream_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + ::std::ostream& + operator<< (::std::ostream& o, const IsComposing& i) + { + o << ::std::endl << "state: " << i.getState (); + if (i.getLastactive ()) + { + o << ::std::endl << "lastactive: " << *i.getLastactive (); + } + + if (i.getContenttype ()) + { + o << ::std::endl << "contenttype: " << *i.getContenttype (); + } + + if (i.getRefresh ()) + { + o << ::std::endl << "refresh: " << *i.getRefresh (); + } + + return o; + } + } + } +} + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& u, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& u, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + u, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& sid, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0, + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& sid, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::xml::sax::std_input_source isrc (is, sid); + return ::LinphonePrivate::Xsd::IsComposing::parseIsComposing (isrc, h, f, p); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::xsd::cxx::tree::error_handler< char > h; + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing< char > > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& i, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& i, + ::xercesc::DOMErrorHandler& h, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::parse< char > ( + i, h, p, f)); + + if (!d.get ()) + throw ::xsd::cxx::tree::parsing< char > (); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::xercesc::DOMDocument& doc, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p) + { + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + static_cast< ::xercesc::DOMDocument* > (doc.cloneNode (true))); + + return ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > ( + ::LinphonePrivate::Xsd::IsComposing::parseIsComposing ( + std::move (d), f | ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom, p)); + } + + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "isComposing" && + n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::IsComposing::IsComposing, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "isComposing", + "urn:ietf:params:xml:ns:im-iscomposing"); + } + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f, + const ::LinphonePrivate::Xsd::XmlSchema::Properties&) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > c ( + ((f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) && + !(f & ::LinphonePrivate::Xsd::XmlSchema::Flags::own_dom)) + ? static_cast< ::xercesc::DOMDocument* > (d->cloneNode (true)) + : 0); + + ::xercesc::DOMDocument& doc (c.get () ? *c : *d); + const ::xercesc::DOMElement& e (*doc.getDocumentElement ()); + + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::keep_dom) + doc.setUserData (::LinphonePrivate::Xsd::XmlSchema::dom::treeNodeKey, + (c.get () ? &c : &d), + 0); + + if (n.name () == "isComposing" && + n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > r ( + ::xsd::cxx::tree::traits< ::LinphonePrivate::Xsd::IsComposing::IsComposing, char >::create ( + e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "isComposing", + "urn:ietf:params:xml:ns:im-iscomposing"); + } + } + } +} + +#include +#include +#include + +#include + +namespace _xsd +{ + static + const ::xsd::cxx::tree::type_serializer_plate< 0, char > + type_serializer_plate_init; +} + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + void + serializeIsComposing (::std::ostream& o, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeIsComposing (::std::ostream& o, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::xsd::cxx::xml::auto_initializer i ( + (f & ::LinphonePrivate::Xsd::XmlSchema::Flags::dont_initialize) == 0); + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeIsComposing (::std::ostream& o, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t (o); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeIsComposing (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + + ::xsd::cxx::tree::error_handler< char > h; + + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + h.throw_if_failed< ::xsd::cxx::tree::serialization< char > > (); + } + } + + void + serializeIsComposing (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeIsComposing (::xercesc::XMLFormatTarget& t, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + ::xercesc::DOMErrorHandler& h, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + const ::std::string& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (s, m, f)); + if (!::xsd::cxx::xml::dom::serialize (t, *d, e, h, f)) + { + throw ::xsd::cxx::tree::serialization< char > (); + } + } + + void + serializeIsComposing (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + ::LinphonePrivate::Xsd::XmlSchema::Flags) + { + ::xercesc::DOMElement& e (*d.getDocumentElement ()); + const ::xsd::cxx::xml::qualified_name< char > n ( + ::xsd::cxx::xml::dom::name< char > (e)); + + if (n.name () == "isComposing" && + n.namespace_ () == "urn:ietf:params:xml:ns:im-iscomposing") + { + e << s; + } + else + { + throw ::xsd::cxx::tree::unexpected_element < char > ( + n.name (), + n.namespace_ (), + "isComposing", + "urn:ietf:params:xml:ns:im-iscomposing"); + } + } + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeIsComposing (const ::LinphonePrivate::Xsd::IsComposing::IsComposing& s, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m, + ::LinphonePrivate::Xsd::XmlSchema::Flags f) + { + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d ( + ::xsd::cxx::xml::dom::serialize< char > ( + "isComposing", + "urn:ietf:params:xml:ns:im-iscomposing", + m, f)); + + ::LinphonePrivate::Xsd::IsComposing::serializeIsComposing (*d, s, f); + return d; + } + + void + operator<< (::xercesc::DOMElement& e, const IsComposing& i) + { + e << static_cast< const ::LinphonePrivate::Xsd::XmlSchema::Type& > (i); + + // state + // + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "state", + "urn:ietf:params:xml:ns:im-iscomposing", + e)); + + s << i.getState (); + } + + // lastactive + // + if (i.getLastactive ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "lastactive", + "urn:ietf:params:xml:ns:im-iscomposing", + e)); + + s << *i.getLastactive (); + } + + // contenttype + // + if (i.getContenttype ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "contenttype", + "urn:ietf:params:xml:ns:im-iscomposing", + e)); + + s << *i.getContenttype (); + } + + // refresh + // + if (i.getRefresh ()) + { + ::xercesc::DOMElement& s ( + ::xsd::cxx::xml::dom::create_element ( + "refresh", + "urn:ietf:params:xml:ns:im-iscomposing", + e)); + + s << *i.getRefresh (); + } + + // any + // + for (IsComposing::AnyConstIterator + b (i.getAny ().begin ()), n (i.getAny ().end ()); + b != n; ++b) + { + e.appendChild ( + e.getOwnerDocument ()->importNode ( + const_cast< ::xercesc::DOMElement* > (&(*b)), true)); + } + } + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + diff --git a/src/xml/is-composing.h b/src/xml/is-composing.h new file mode 100644 index 000000000..1d7025245 --- /dev/null +++ b/src/xml/is-composing.h @@ -0,0 +1,678 @@ +// Copyright (c) 2005-2014 Code Synthesis Tools CC +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// 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 St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis Tools CC gives +// permission to link this program with the Xerces-C++ library (or with +// modified versions of Xerces-C++ that use the same license as Xerces-C++), +// and distribute linked combinations including the two. You must obey +// the GNU General Public License version 2 in all respects for all of +// the code used other than Xerces-C++. If you modify this copy of the +// program, you may extend this exception to your version of the program, +// but you are not obligated to do so. If you do not wish to do so, delete +// this exception statement from your version. +// +// Furthermore, Code Synthesis Tools CC makes a special exception for +// the Free/Libre and Open Source Software (FLOSS) which is described +// in the accompanying FLOSSE file. +// + +#ifndef XML_IS_COMPOSING_H +#define XML_IS_COMPOSING_H + +#ifndef XSD_CXX11 +#define XSD_CXX11 +#endif + +#ifndef XSD_USE_CHAR +#define XSD_USE_CHAR +#endif + +#ifndef XSD_CXX_TREE_USE_CHAR +#define XSD_CXX_TREE_USE_CHAR +#endif + +// Begin prologue. +// +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-override" +#endif +// +// End prologue. + +#include + +#if (XSD_INT_VERSION != 4000000L) +#error XSD runtime version mismatch +#endif + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace XmlSchema + { + // anyType and anySimpleType. + // + typedef ::xsd::cxx::tree::type Type; + typedef ::xsd::cxx::tree::simple_type< char, Type > SimpleType; + typedef ::xsd::cxx::tree::type Container; + + // 8-bit + // + typedef signed char Byte; + typedef unsigned char UnsignedByte; + + // 16-bit + // + typedef short Short; + typedef unsigned short UnsignedShort; + + // 32-bit + // + typedef int Int; + typedef unsigned int UnsignedInt; + + // 64-bit + // + typedef long long Long; + typedef unsigned long long UnsignedLong; + + // Supposed to be arbitrary-length integral types. + // + typedef long long Integer; + typedef long long NonPositiveInteger; + typedef unsigned long long NonNegativeInteger; + typedef unsigned long long PositiveInteger; + typedef long long NegativeInteger; + + // Boolean. + // + typedef bool Boolean; + + // Floating-point types. + // + typedef float Float; + typedef double Double; + typedef double Decimal; + + // String types. + // + typedef ::xsd::cxx::tree::string< char, SimpleType > String; + typedef ::xsd::cxx::tree::normalized_string< char, String > NormalizedString; + typedef ::xsd::cxx::tree::token< char, NormalizedString > Token; + typedef ::xsd::cxx::tree::name< char, Token > Name; + typedef ::xsd::cxx::tree::nmtoken< char, Token > Nmtoken; + typedef ::xsd::cxx::tree::nmtokens< char, SimpleType, Nmtoken > Nmtokens; + typedef ::xsd::cxx::tree::ncname< char, Name > Ncname; + typedef ::xsd::cxx::tree::language< char, Token > Language; + + // ID/IDREF. + // + typedef ::xsd::cxx::tree::id< char, Ncname > Id; + typedef ::xsd::cxx::tree::idref< char, Ncname, Type > Idref; + typedef ::xsd::cxx::tree::idrefs< char, SimpleType, Idref > Idrefs; + + // URI. + // + typedef ::xsd::cxx::tree::uri< char, SimpleType > Uri; + + // Qualified name. + // + typedef ::xsd::cxx::tree::qname< char, SimpleType, Uri, Ncname > Qname; + + // Binary. + // + typedef ::xsd::cxx::tree::buffer< char > Buffer; + typedef ::xsd::cxx::tree::base64_binary< char, SimpleType > Base64Binary; + typedef ::xsd::cxx::tree::hex_binary< char, SimpleType > HexBinary; + + // Date/time. + // + typedef ::xsd::cxx::tree::time_zone TimeZone; + typedef ::xsd::cxx::tree::date< char, SimpleType > Date; + typedef ::xsd::cxx::tree::date_time< char, SimpleType > DateTime; + typedef ::xsd::cxx::tree::duration< char, SimpleType > Duration; + typedef ::xsd::cxx::tree::gday< char, SimpleType > Gday; + typedef ::xsd::cxx::tree::gmonth< char, SimpleType > Gmonth; + typedef ::xsd::cxx::tree::gmonth_day< char, SimpleType > GmonthDay; + typedef ::xsd::cxx::tree::gyear< char, SimpleType > Gyear; + typedef ::xsd::cxx::tree::gyear_month< char, SimpleType > GyearMonth; + typedef ::xsd::cxx::tree::time< char, SimpleType > Time; + + // Entity. + // + typedef ::xsd::cxx::tree::entity< char, Ncname > Entity; + typedef ::xsd::cxx::tree::entities< char, SimpleType, Entity > Entities; + + typedef ::xsd::cxx::tree::content_order ContentOrder; + // Namespace information and list stream. Used in + // serialization functions. + // + typedef ::xsd::cxx::xml::dom::namespace_info< char > NamespaceInfo; + typedef ::xsd::cxx::xml::dom::namespace_infomap< char > NamespaceInfomap; + typedef ::xsd::cxx::tree::list_stream< char > ListStream; + typedef ::xsd::cxx::tree::as_double< Double > AsDouble; + typedef ::xsd::cxx::tree::as_decimal< Decimal > AsDecimal; + typedef ::xsd::cxx::tree::facet Facet; + + // Flags and properties. + // + typedef ::xsd::cxx::tree::flags Flags; + typedef ::xsd::cxx::tree::properties< char > Properties; + + // Parsing/serialization diagnostics. + // + typedef ::xsd::cxx::tree::severity Severity; + typedef ::xsd::cxx::tree::error< char > Error; + typedef ::xsd::cxx::tree::diagnostics< char > Diagnostics; + + // Exceptions. + // + typedef ::xsd::cxx::tree::exception< char > Exception; + typedef ::xsd::cxx::tree::bounds< char > Bounds; + typedef ::xsd::cxx::tree::duplicate_id< char > DuplicateId; + typedef ::xsd::cxx::tree::parsing< char > Parsing; + typedef ::xsd::cxx::tree::expected_element< char > ExpectedElement; + typedef ::xsd::cxx::tree::unexpected_element< char > UnexpectedElement; + typedef ::xsd::cxx::tree::expected_attribute< char > ExpectedAttribute; + typedef ::xsd::cxx::tree::unexpected_enumerator< char > UnexpectedEnumerator; + typedef ::xsd::cxx::tree::expected_text_content< char > ExpectedTextContent; + typedef ::xsd::cxx::tree::no_prefix_mapping< char > NoPrefixMapping; + typedef ::xsd::cxx::tree::no_type_info< char > NoTypeInfo; + typedef ::xsd::cxx::tree::not_derived< char > NotDerived; + typedef ::xsd::cxx::tree::serialization< char > Serialization; + + // Error handler callback interface. + // + typedef ::xsd::cxx::xml::error_handler< char > ErrorHandler; + + // DOM interaction. + // + namespace dom + { + // Automatic pointer for DOMDocument. + // + using ::xsd::cxx::xml::dom::unique_ptr; + +#ifndef XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA +#define XSD_CXX_TREE_TREE_NODE_KEY__LINPHONEPRIVATE__XSD__XMLSCHEMA + // DOM user data key for back pointers to tree nodes. + // + const XMLCh* const treeNodeKey = ::xsd::cxx::tree::user_data_keys::node; +#endif + } + } + } +} + +// Forward declarations. +// +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + class IsComposing; + } + } +} + + +#include // ::std::unique_ptr +#include // std::numeric_limits +#include // std::binary_search +#include // std::move + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + class IsComposing: public ::LinphonePrivate::Xsd::XmlSchema::Type + { + public: + // state + // + typedef ::LinphonePrivate::Xsd::XmlSchema::String StateType; + typedef ::xsd::cxx::tree::traits< StateType, char > StateTraits; + + const StateType& + getState () const; + + StateType& + getState (); + + void + setState (const StateType& x); + + void + setState (::std::unique_ptr< StateType > p); + + ::std::unique_ptr< StateType > + setDetachState (); + + // lastactive + // + typedef ::LinphonePrivate::Xsd::XmlSchema::DateTime LastactiveType; + typedef ::xsd::cxx::tree::optional< LastactiveType > LastactiveOptional; + typedef ::xsd::cxx::tree::traits< LastactiveType, char > LastactiveTraits; + + const LastactiveOptional& + getLastactive () const; + + LastactiveOptional& + getLastactive (); + + void + setLastactive (const LastactiveType& x); + + void + setLastactive (const LastactiveOptional& x); + + void + setLastactive (::std::unique_ptr< LastactiveType > p); + + // contenttype + // + typedef ::LinphonePrivate::Xsd::XmlSchema::String ContenttypeType; + typedef ::xsd::cxx::tree::optional< ContenttypeType > ContenttypeOptional; + typedef ::xsd::cxx::tree::traits< ContenttypeType, char > ContenttypeTraits; + + const ContenttypeOptional& + getContenttype () const; + + ContenttypeOptional& + getContenttype (); + + void + setContenttype (const ContenttypeType& x); + + void + setContenttype (const ContenttypeOptional& x); + + void + setContenttype (::std::unique_ptr< ContenttypeType > p); + + // refresh + // + typedef ::LinphonePrivate::Xsd::XmlSchema::PositiveInteger RefreshType; + typedef ::xsd::cxx::tree::optional< RefreshType > RefreshOptional; + typedef ::xsd::cxx::tree::traits< RefreshType, char > RefreshTraits; + + const RefreshOptional& + getRefresh () const; + + RefreshOptional& + getRefresh (); + + void + setRefresh (const RefreshType& x); + + void + setRefresh (const RefreshOptional& x); + + // any + // + typedef ::xsd::cxx::tree::element_sequence AnySequence; + typedef AnySequence::iterator AnyIterator; + typedef AnySequence::const_iterator AnyConstIterator; + + const AnySequence& + getAny () const; + + AnySequence& + getAny (); + + void + setAny (const AnySequence& s); + + // DOMDocument for wildcard content. + // + const ::xercesc::DOMDocument& + getDomDocument () const; + + ::xercesc::DOMDocument& + getDomDocument (); + + // Constructors. + // + IsComposing (const StateType&); + + IsComposing (const ::xercesc::DOMElement& e, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + IsComposing (const IsComposing& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0); + + virtual IsComposing* + _clone (::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + ::LinphonePrivate::Xsd::XmlSchema::Container* c = 0) const; + + IsComposing& + operator= (const IsComposing& x); + + virtual + ~IsComposing (); + + // Implementation. + // + protected: + void + parse (::xsd::cxx::xml::dom::parser< char >&, + ::LinphonePrivate::Xsd::XmlSchema::Flags); + + protected: + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > dom_document_; + + ::xsd::cxx::tree::one< StateType > state_; + LastactiveOptional lastactive_; + ContenttypeOptional contenttype_; + RefreshOptional refresh_; + AnySequence any_; + }; + } + } +} + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + ::std::ostream& + operator<< (::std::ostream&, const IsComposing&); + } + } +} + +#include + +#include +#include +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + // Parse a URI or a local file. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& uri, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::std::string& uri, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse std::istream. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& id, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::std::istream& is, + const ::std::string& id, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::InputSource. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& is, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::xercesc::InputSource& is, + ::xercesc::DOMErrorHandler& eh, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + // Parse xercesc::DOMDocument. + // + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (const ::xercesc::DOMDocument& d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + + ::std::unique_ptr< ::LinphonePrivate::Xsd::IsComposing::IsComposing > + parseIsComposing (::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > d, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0, + const ::LinphonePrivate::Xsd::XmlSchema::Properties& p = ::LinphonePrivate::Xsd::XmlSchema::Properties ()); + } + } +} + +#include + +#include +#include +#include + +#include + +namespace LinphonePrivate +{ + namespace Xsd + { + namespace IsComposing + { + // Serialize to std::ostream. + // + + void + serializeIsComposing (::std::ostream& os, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeIsComposing (::std::ostream& os, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeIsComposing (::std::ostream& os, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to xercesc::XMLFormatTarget. + // + + void + serializeIsComposing (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeIsComposing (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + ::LinphonePrivate::Xsd::XmlSchema::ErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + serializeIsComposing (::xercesc::XMLFormatTarget& ft, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + ::xercesc::DOMErrorHandler& eh, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + const ::std::string& e = "UTF-8", + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to an existing xercesc::DOMDocument. + // + + void + serializeIsComposing (::xercesc::DOMDocument& d, + const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + // Serialize to a new xercesc::DOMDocument. + // + + ::LinphonePrivate::Xsd::XmlSchema::dom::unique_ptr< ::xercesc::DOMDocument > + serializeIsComposing (const ::LinphonePrivate::Xsd::IsComposing::IsComposing& x, + const ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap& m = ::LinphonePrivate::Xsd::XmlSchema::NamespaceInfomap (), + ::LinphonePrivate::Xsd::XmlSchema::Flags f = 0); + + void + operator<< (::xercesc::DOMElement&, const IsComposing&); + } + } +} + +#include + +// Begin epilogue. +// +#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) + #pragma GCC diagnostic pop +#endif +#if __clang__ || __GNUC__ >= 4 + #pragma GCC diagnostic pop +#endif +// +// End epilogue. + +#endif // XML_IS_COMPOSING_H diff --git a/src/xml/is-composing.xsd b/src/xml/is-composing.xsd new file mode 100644 index 000000000..7cf4a8b70 --- /dev/null +++ b/src/xml/is-composing.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + From aedd2dd2c1668145f16becea0f6844b1a3ea1e18 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 17 Apr 2018 18:01:40 +0200 Subject: [PATCH 051/143] Start a background task during the imdn timeout. --- src/chat/notification/imdn.cpp | 2 ++ src/chat/notification/imdn.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 203eb7846..27b4776b0 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -165,6 +165,7 @@ void Imdn::startTimer () { timer = chatRoom->getCore()->getCCore()->sal->create_timer(timerExpired, this, duration, "imdn timeout"); else belle_sip_source_set_timeout(timer, duration); + bgTask.start(chatRoom->getCore(), 1); } void Imdn::stopTimer () { @@ -175,6 +176,7 @@ void Imdn::stopTimer () { belle_sip_object_unref(timer); timer = nullptr; } + bgTask.stop(); } LINPHONE_END_NAMESPACE diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index ca5095319..e9b8c633b 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -22,6 +22,8 @@ #include "linphone/utils/general.h" +#include "utils/background-task.h" + #include "private.h" // ============================================================================= @@ -69,6 +71,7 @@ private: std::list> displayedMessages; std::list nonDeliveredMessages; belle_sip_source_t *timer = nullptr; + BackgroundTask bgTask { "IMDN sending" }; }; LINPHONE_END_NAMESPACE From 13b9f38e328e7a133d5740c3d29d766021626b28 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 17:34:48 +0200 Subject: [PATCH 052/143] Wait for the delivery of IMDN messages before storing the messages' states in DB. --- src/CMakeLists.txt | 1 + src/chat/chat-message/chat-message-p.h | 2 +- src/chat/chat-message/chat-message.cpp | 5 +- src/chat/chat-message/chat-message.h | 1 + src/chat/chat-message/imdn-message-p.h | 44 ++++++++++++++++ src/chat/chat-message/imdn-message.cpp | 51 ++++++++++++------- src/chat/chat-message/imdn-message.h | 27 ++++++++-- .../chat-message/notification-message-p.h | 5 +- src/chat/chat-room/chat-room-p.h | 17 ++++--- src/chat/chat-room/chat-room.cpp | 35 ++++++++----- src/chat/chat-room/chat-room.h | 1 + src/chat/notification/imdn.cpp | 27 ++++++++-- src/chat/notification/imdn.h | 8 ++- 13 files changed, 173 insertions(+), 51 deletions(-) create mode 100644 src/chat/chat-message/imdn-message-p.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90bb71e2d..4208e1479 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,6 +36,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES chat/chat-message/chat-message-p.h chat/chat-message/chat-message.h chat/chat-message/imdn-message.h + chat/chat-message/imdn-message-p.h chat/chat-message/is-composing-message.h chat/chat-message/notification-message.h chat/chat-message/notification-message-p.h diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index 464ed8077..b013e9b96 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -62,7 +62,7 @@ public: std::list getParticipantsByImdnState (MainDb::ParticipantStateRetrievalFunc func) const; void setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState, time_t stateChangeTime); - void setState (ChatMessage::State newState, bool force = false); + virtual void setState (ChatMessage::State newState, bool force = false); void setTime (time_t time); diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index a8e0855cc..12bae8983 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -179,8 +179,9 @@ void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) { if (state == ChatMessage::State::FileTransferDone && !hasFileTransferContent()) { // We wait until the file has been downloaded to send the displayed IMDN - static_cast(q->getChatRoom()->getPrivate())->sendDisplayNotification(q->getSharedFromThis()); - setState(ChatMessage::State::Displayed); + bool doNotStoreInDb = static_cast(q->getChatRoom()->getPrivate())->sendDisplayNotification(q->getSharedFromThis()); + // Force the state so it is stored directly in DB, but when the IMDN has successfully been delivered + setState(ChatMessage::State::Displayed, doNotStoreInDb); } else { updateInDb(); } diff --git a/src/chat/chat-message/chat-message.h b/src/chat/chat-message/chat-message.h index 2893fd6ed..7b5af855a 100644 --- a/src/chat/chat-message/chat-message.h +++ b/src/chat/chat-message/chat-message.h @@ -50,6 +50,7 @@ class LINPHONE_PUBLIC ChatMessage : public Object, public CoreAccessor { friend class CpimChatMessageModifier; friend class FileTransferChatMessageModifier; friend class Imdn; + friend class ImdnMessagePrivate; friend class MainDb; friend class MainDbPrivate; friend class RealTimeTextChatRoomPrivate; diff --git a/src/chat/chat-message/imdn-message-p.h b/src/chat/chat-message/imdn-message-p.h new file mode 100644 index 000000000..edd994c40 --- /dev/null +++ b/src/chat/chat-message/imdn-message-p.h @@ -0,0 +1,44 @@ +/* + * imdn-message-p.h + * Copyright (C) 2010-2018 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 _L_IMDN_MESSAGE_P_H_ +#define _L_IMDN_MESSAGE_P_H_ + +#include "chat/chat-message/imdn-message.h" +#include "chat/chat-message/notification-message-p.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class ImdnMessagePrivate : public NotificationMessagePrivate { +private: + ImdnMessagePrivate (const ImdnMessage::Context &context) + : NotificationMessagePrivate(context.chatRoom, ChatMessage::Direction::Outgoing), context(context) {} + + void setState (ChatMessage::State newState, bool force = false) override; + + ImdnMessage::Context context; + + L_DECLARE_PUBLIC(ImdnMessage); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_IMDN_MESSAGE_P_H_ diff --git a/src/chat/chat-message/imdn-message.cpp b/src/chat/chat-message/imdn-message.cpp index eb70de34d..76daa18a2 100644 --- a/src/chat/chat-message/imdn-message.cpp +++ b/src/chat/chat-message/imdn-message.cpp @@ -17,9 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "chat/chat-message/notification-message-p.h" -#include "chat/chat-message/imdn-message.h" +#include "chat/chat-message/imdn-message-p.h" +#include "chat/chat-room/chat-room-p.h" #include "content/content-disposition.h" +#include "logger/logger.h" #include "sip-tools/sip-headers.h" // ============================================================================= @@ -30,38 +31,49 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- +void ImdnMessagePrivate::setState (ChatMessage::State newState, bool force) { + L_Q(); + + if (newState == ChatMessage::State::Delivered) { + for (const auto &message : context.deliveredMessages) + message->getPrivate()->updateInDb(); + for (const auto &message : context.displayedMessages) + message->getPrivate()->updateInDb(); + static_pointer_cast(context.chatRoom)->getPrivate()->getImdnHandler()->onImdnMessageDelivered(q->getSharedFromThis()); + } +} + +// ----------------------------------------------------------------------------- + ImdnMessage::ImdnMessage ( const shared_ptr &chatRoom, - const list> &deliveredMessages, - const list> &displayedMessages -) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) { + const list> &deliveredMessages, + const list> &displayedMessages +) : ImdnMessage(Context(chatRoom, deliveredMessages, displayedMessages)) {} + +ImdnMessage::ImdnMessage ( + const shared_ptr &chatRoom, + const list &nonDeliveredMessages +) : ImdnMessage(Context(chatRoom, nonDeliveredMessages)) {} + +ImdnMessage::ImdnMessage (const Context &context) : NotificationMessage(*new ImdnMessagePrivate(context)) { L_D(); - for (const auto &message : deliveredMessages) { + for (const auto &message : d->context.deliveredMessages) { Content *content = new Content(); content->setContentDisposition(ContentDisposition::Notification); content->setContentType(ContentType::Imdn); content->setBody(Imdn::createXml(message->getImdnMessageId(), message->getTime(), Imdn::Type::Delivery, LinphoneReasonNone)); addContent(content); } - for (const auto &message : displayedMessages) { + for (const auto &message : d->context.displayedMessages) { Content *content = new Content(); content->setContentDisposition(ContentDisposition::Notification); content->setContentType(ContentType::Imdn); content->setBody(Imdn::createXml(message->getImdnMessageId(), message->getTime(), Imdn::Type::Display, LinphoneReasonNone)); addContent(content); } - - d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); -} - -ImdnMessage::ImdnMessage ( - const shared_ptr &chatRoom, - const list &nonDeliveredMessages -) : NotificationMessage(*new NotificationMessagePrivate(chatRoom, ChatMessage::Direction::Outgoing)) { - L_D(); - - for (const auto &mr : nonDeliveredMessages) { + for (const auto &mr : d->context.nonDeliveredMessages) { Content *content = new Content(); content->setContentDisposition(ContentDisposition::Notification); content->setContentType(ContentType::Imdn); @@ -70,7 +82,8 @@ ImdnMessage::ImdnMessage ( } d->addSalCustomHeader(PriorityHeader::HeaderName, PriorityHeader::NonUrgent); - d->setEncryptionPrevented(true); + if (!d->context.nonDeliveredMessages.empty()) + d->setEncryptionPrevented(true); } LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-message/imdn-message.h b/src/chat/chat-message/imdn-message.h index a7aa026ca..3cc4c0e23 100644 --- a/src/chat/chat-message/imdn-message.h +++ b/src/chat/chat-message/imdn-message.h @@ -21,11 +21,14 @@ #define _L_IMDN_MESSAGE_H_ #include "chat/chat-message/notification-message.h" +#include "chat/notification/imdn.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE +class ImdnMessagePrivate; + class LINPHONE_PUBLIC ImdnMessage : public NotificationMessage { public: friend class ChatRoomPrivate; @@ -35,17 +38,35 @@ public: virtual ~ImdnMessage () = default; private: + struct Context { + Context ( + const std::shared_ptr &chatRoom, + const std::list> &deliveredMessages, + const std::list> &displayedMessages + ) : chatRoom(chatRoom), deliveredMessages(deliveredMessages), displayedMessages(displayedMessages) {} + Context ( + const std::shared_ptr &chatRoom, + const std::list &nonDeliveredMessages + ) : chatRoom(chatRoom), nonDeliveredMessages(nonDeliveredMessages) {} + + std::shared_ptr chatRoom; + std::list> deliveredMessages; + std::list> displayedMessages; + std::list nonDeliveredMessages; + }; + ImdnMessage ( const std::shared_ptr &chatRoom, - const std::list> &deliveredMessages, - const std::list> &displayedMessages + const std::list> &deliveredMessages, + const std::list> &displayedMessages ); ImdnMessage ( const std::shared_ptr &chatRoom, const std::list &nonDeliveredMessages ); + ImdnMessage (const Context &context); - L_DECLARE_PRIVATE(NotificationMessage); + L_DECLARE_PRIVATE(ImdnMessage); L_DISABLE_COPY(ImdnMessage); }; diff --git a/src/chat/chat-message/notification-message-p.h b/src/chat/chat-message/notification-message-p.h index 259d7da02..28e2bbb52 100644 --- a/src/chat/chat-message/notification-message-p.h +++ b/src/chat/chat-message/notification-message-p.h @@ -31,10 +31,13 @@ class NotificationMessagePrivate : public ChatMessagePrivate { friend class ImdnMessage; friend class IsComposingMessage; -private: +protected: NotificationMessagePrivate(const std::shared_ptr &cr, ChatMessage::Direction dir) : ChatMessagePrivate(cr, dir) {} + void setState (ChatMessage::State newState, bool force = false) override {}; + +private: void setDisplayNotificationRequired (bool value) override {} void setNegativeDeliveryNotificationRequired (bool value) override {} void setPositiveDeliveryNotificationRequired (bool value) override {} diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 438f08a5e..dd6604b07 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -32,6 +32,9 @@ LINPHONE_BEGIN_NAMESPACE +class ImdnMessage; +class IsComposingMessage; + class ChatRoomPrivate : public AbstractChatRoomPrivate, public IsComposingListener { public: inline void setProxyChatRoom (AbstractChatRoom *value) { proxyChatRoom = value; } @@ -55,17 +58,17 @@ public: void removeTransientEvent (const std::shared_ptr &eventLog) override; std::shared_ptr createChatMessage (ChatMessage::Direction direction); - std::shared_ptr createImdnMessage ( - const std::list> &deliveredMessages, - const std::list> &displayedMessages + std::shared_ptr createImdnMessage ( + const std::list> &deliveredMessages, + const std::list> &displayedMessages ); - std::shared_ptr createImdnMessage (const std::list &nonDeliveredMessages); - std::shared_ptr createIsComposingMessage (); + std::shared_ptr createImdnMessage (const std::list &nonDeliveredMessages); + std::shared_ptr createIsComposingMessage (); std::list> findChatMessages (const std::string &messageId) const; void sendDeliveryErrorNotification (const std::shared_ptr &message, LinphoneReason reason); void sendDeliveryNotification (const std::shared_ptr &message); - void sendDisplayNotification (const std::shared_ptr &message); + bool sendDisplayNotification (const std::shared_ptr &message); void notifyChatMessageReceived (const std::shared_ptr &chatMessage) override; void notifyIsComposingReceived (const Address &remoteAddress, bool isComposing); @@ -80,6 +83,8 @@ public: void onIsComposingStateChanged (bool isComposing) override; void onIsRemoteComposingStateChanged (const Address &remoteAddress, bool isComposing) override; + Imdn *getImdnHandler () const { return imdnHandler.get(); } + LinphoneChatRoom *getCChatRoom () const; std::list remoteIsComposing; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index ed0762922..44af4294e 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -25,6 +25,7 @@ #include "chat/chat-message/chat-message-p.h" #include "chat/chat-message/imdn-message.h" #include "chat/chat-message/is-composing-message.h" +#include "chat/chat-message/notification-message-p.h" #include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" #include "logger/logger.h" @@ -109,22 +110,22 @@ shared_ptr ChatRoomPrivate::createChatMessage (ChatMessage::Directi return shared_ptr(new ChatMessage(q->getSharedFromThis(), direction)); } -shared_ptr ChatRoomPrivate::createImdnMessage ( - const list> &deliveredMessages, - const list> &displayedMessages +shared_ptr ChatRoomPrivate::createImdnMessage ( + const list> &deliveredMessages, + const list> &displayedMessages ) { L_Q(); - return shared_ptr(new ImdnMessage(q->getSharedFromThis(), deliveredMessages, displayedMessages)); + return shared_ptr(new ImdnMessage(q->getSharedFromThis(), deliveredMessages, displayedMessages)); } -shared_ptr ChatRoomPrivate::createImdnMessage (const list &nonDeliveredMessages) { +shared_ptr ChatRoomPrivate::createImdnMessage (const list &nonDeliveredMessages) { L_Q(); - return shared_ptr(new ImdnMessage(q->getSharedFromThis(), nonDeliveredMessages)); + return shared_ptr(new ImdnMessage(q->getSharedFromThis(), nonDeliveredMessages)); } -shared_ptr ChatRoomPrivate::createIsComposingMessage () { +shared_ptr ChatRoomPrivate::createIsComposingMessage () { L_Q(); - return shared_ptr(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing)); + return shared_ptr(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing)); } list> ChatRoomPrivate::findChatMessages (const string &messageId) const { @@ -148,11 +149,14 @@ void ChatRoomPrivate::sendDeliveryNotification (const shared_ptr &m imdnHandler->notifyDelivery(message); } -void ChatRoomPrivate::sendDisplayNotification (const shared_ptr &message) { +bool ChatRoomPrivate::sendDisplayNotification (const shared_ptr &message) { L_Q(); LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); - if (linphone_im_notif_policy_get_send_imdn_displayed(policy)) + if (linphone_im_notif_policy_get_send_imdn_displayed(policy)) { imdnHandler->notifyDisplay(message); + return true; + } + return false; } // ----------------------------------------------------------------------------- @@ -468,16 +472,21 @@ shared_ptr ChatRoom::findChatMessage (const string &messageId, Chat void ChatRoom::markAsRead () { L_D(); + bool globallyMarkAsReadInDb = true; CorePrivate *dCore = getCore()->getPrivate(); for (auto &chatMessage : dCore->mainDb->getUnreadChatMessages(d->chatRoomId)) { // Do not send display notification for file transfer until it has been downloaded (it won't have a file transfer content anymore) if (!chatMessage->getPrivate()->hasFileTransferContent()) { - d->sendDisplayNotification(chatMessage); - chatMessage->getPrivate()->setState(ChatMessage::State::Displayed, true); // True will ensure the setState won't update the database so it will be done below by the markChatMessagesAsRead + bool doNotStoreInDb = d->sendDisplayNotification(chatMessage); + // Force the state so it is stored directly in DB, but when the IMDN has successfully been delivered + chatMessage->getPrivate()->setState(ChatMessage::State::Displayed, doNotStoreInDb); + if (doNotStoreInDb) + globallyMarkAsReadInDb = false; } } - dCore->mainDb->markChatMessagesAsRead(d->chatRoomId); + if (globallyMarkAsReadInDb) + dCore->mainDb->markChatMessagesAsRead(d->chatRoomId); } LINPHONE_END_NAMESPACE diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index db261a90f..acde23615 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -32,6 +32,7 @@ class LINPHONE_PUBLIC ChatRoom : public AbstractChatRoom { public: friend class ChatMessagePrivate; friend class Imdn; + friend class ImdnMessagePrivate; friend class ProxyChatRoomPrivate; L_OVERRIDE_SHARED_FROM_THIS(ChatRoom); diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 27b4776b0..23644f2b9 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -20,6 +20,7 @@ #include #include "chat/chat-message/chat-message-p.h" +#include "chat/chat-message/imdn-message.h" #include "chat/chat-room/chat-room-p.h" #include "core/core.h" #include "logger/logger.h" @@ -74,6 +75,12 @@ void Imdn::notifyDisplay (const shared_ptr &message) { // ----------------------------------------------------------------------------- +void Imdn::onImdnMessageDelivered (const std::shared_ptr &message) { + sentImdnMessages.remove(message); +} + +// ----------------------------------------------------------------------------- + string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, LinphoneReason reason) { char *datetime = linphone_timestamp_to_rfc3339_string(timestamp); Xsd::Imdn::Imdn imdn(id, datetime); @@ -153,10 +160,22 @@ int Imdn::timerExpired (void *data, unsigned int revents) { // ----------------------------------------------------------------------------- void Imdn::send () { - if (!deliveredMessages.empty() || !displayedMessages.empty()) - chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages)->send(); - if (!nonDeliveredMessages.empty()) - chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages)->send(); + bool networkReachable = linphone_core_is_network_reachable(chatRoom->getCore()->getCCore()); + if (!deliveredMessages.empty() || !displayedMessages.empty()) { + auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages); + sentImdnMessages.push_back(imdnMessage); + if (networkReachable) + imdnMessage->send(); + deliveredMessages.clear(); + displayedMessages.clear(); + } + if (!nonDeliveredMessages.empty()) { + auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages); + sentImdnMessages.push_back(imdnMessage); + if (networkReachable) + imdnMessage->send(); + nonDeliveredMessages.clear(); + } } void Imdn::startTimer () { diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index e9b8c633b..de467f859 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -32,6 +32,7 @@ LINPHONE_BEGIN_NAMESPACE class ChatMessage; class ChatRoom; +class ImdnMessage; class Imdn { public: @@ -55,6 +56,8 @@ public: void notifyDeliveryError (const std::shared_ptr &message, LinphoneReason reason); void notifyDisplay (const std::shared_ptr &message); + void onImdnMessageDelivered (const std::shared_ptr &message); + static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason); static void parse (const std::shared_ptr &chatMessage); @@ -67,9 +70,10 @@ private: private: ChatRoom *chatRoom = nullptr; - std::list> deliveredMessages; - std::list> displayedMessages; + std::list> deliveredMessages; + std::list> displayedMessages; std::list nonDeliveredMessages; + std::list> sentImdnMessages; belle_sip_source_t *timer = nullptr; BackgroundTask bgTask { "IMDN sending" }; }; From 71f5d99c4450f5ad951f6792e8e27c8800de1b9e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 19 Apr 2018 09:47:18 +0200 Subject: [PATCH 053/143] Retry sending IMDN messages that have not been delivered when the SIP network gets up. --- src/chat/chat-message/imdn-message.cpp | 4 ++++ src/chat/chat-message/imdn-message.h | 1 + src/chat/chat-room/chat-room-p.h | 1 + src/chat/chat-room/chat-room.cpp | 10 ++++++++++ src/chat/chat-room/chat-room.h | 2 ++ src/chat/notification/imdn.cpp | 25 +++++++++++++++++++++++-- src/chat/notification/imdn.h | 6 +++++- src/core/core.h | 1 + tester/group_chat_tester.c | 25 ++++++++++++++++++++++--- 9 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/chat/chat-message/imdn-message.cpp b/src/chat/chat-message/imdn-message.cpp index 76daa18a2..9e849560d 100644 --- a/src/chat/chat-message/imdn-message.cpp +++ b/src/chat/chat-message/imdn-message.cpp @@ -40,6 +40,8 @@ void ImdnMessagePrivate::setState (ChatMessage::State newState, bool force) { for (const auto &message : context.displayedMessages) message->getPrivate()->updateInDb(); static_pointer_cast(context.chatRoom)->getPrivate()->getImdnHandler()->onImdnMessageDelivered(q->getSharedFromThis()); + } else if (newState == ChatMessage::State::NotDelivered) { + // TODO: Maybe we should retry sending the IMDN message if we get an error here } } @@ -56,6 +58,8 @@ ImdnMessage::ImdnMessage ( const list &nonDeliveredMessages ) : ImdnMessage(Context(chatRoom, nonDeliveredMessages)) {} +ImdnMessage::ImdnMessage (const std::shared_ptr &message) : ImdnMessage(message->getPrivate()->context) {} + ImdnMessage::ImdnMessage (const Context &context) : NotificationMessage(*new ImdnMessagePrivate(context)) { L_D(); diff --git a/src/chat/chat-message/imdn-message.h b/src/chat/chat-message/imdn-message.h index 3cc4c0e23..243b7ae66 100644 --- a/src/chat/chat-message/imdn-message.h +++ b/src/chat/chat-message/imdn-message.h @@ -64,6 +64,7 @@ private: const std::shared_ptr &chatRoom, const std::list &nonDeliveredMessages ); + ImdnMessage (const std::shared_ptr &message); ImdnMessage (const Context &context); L_DECLARE_PRIVATE(ImdnMessage); diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index dd6604b07..dfd7c8fa9 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -63,6 +63,7 @@ public: const std::list> &displayedMessages ); std::shared_ptr createImdnMessage (const std::list &nonDeliveredMessages); + std::shared_ptr createImdnMessage (const std::shared_ptr &message); std::shared_ptr createIsComposingMessage (); std::list> findChatMessages (const std::string &messageId) const; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 44af4294e..30e0a8843 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -123,6 +123,10 @@ shared_ptr ChatRoomPrivate::createImdnMessage (const list(new ImdnMessage(q->getSharedFromThis(), nonDeliveredMessages)); } +shared_ptr ChatRoomPrivate::createImdnMessage (const shared_ptr &message) { + return shared_ptr(new ImdnMessage(message)); +} + shared_ptr ChatRoomPrivate::createIsComposingMessage () { L_Q(); return shared_ptr(new IsComposingMessage(q->getSharedFromThis(), *isComposingHandler.get(), isComposing)); @@ -318,6 +322,12 @@ ChatRoom::ChatRoom (ChatRoomPrivate &p, const shared_ptr &core, const Chat d->isComposingHandler.reset(new IsComposing(core->getCCore(), d)); } +ChatRoom::~ChatRoom () { + L_D(); + + d->imdnHandler.reset(); +} + // ----------------------------------------------------------------------------- const ChatRoomId &ChatRoom::getChatRoomId () const { diff --git a/src/chat/chat-room/chat-room.h b/src/chat/chat-room/chat-room.h index acde23615..9c361df82 100644 --- a/src/chat/chat-room/chat-room.h +++ b/src/chat/chat-room/chat-room.h @@ -37,6 +37,8 @@ public: L_OVERRIDE_SHARED_FROM_THIS(ChatRoom); + ~ChatRoom (); + const ChatRoomId &getChatRoomId () const override; const IdentityAddress &getPeerAddress () const override; diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 23644f2b9..6cccf52f0 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -22,7 +22,7 @@ #include "chat/chat-message/chat-message-p.h" #include "chat/chat-message/imdn-message.h" #include "chat/chat-room/chat-room-p.h" -#include "core/core.h" +#include "core/core-p.h" #include "logger/logger.h" #include "xml/imdn.h" #include "xml/linphone-imdn.h" @@ -37,10 +37,13 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- -Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) {} +Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) { + chatRoom->getCore()->getPrivate()->registerListener(this); +} Imdn::~Imdn () { stopTimer(); + chatRoom->getCore()->getPrivate()->unregisterListener(this); } // ----------------------------------------------------------------------------- @@ -76,11 +79,29 @@ void Imdn::notifyDisplay (const shared_ptr &message) { // ----------------------------------------------------------------------------- void Imdn::onImdnMessageDelivered (const std::shared_ptr &message) { + // If an IMDN has been successfully delivered, remove it from the list so that + // it does not get sent again sentImdnMessages.remove(message); } // ----------------------------------------------------------------------------- +void Imdn::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) { + if (sipNetworkReachable) { + // When the SIP network gets up, retry sending every IMDN message that has not + // successfully been delivered + auto messages = sentImdnMessages; + sentImdnMessages.clear(); + for (const auto &message : messages) { + auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(message); + sentImdnMessages.push_back(imdnMessage); + imdnMessage->send(); + } + } +} + +// ----------------------------------------------------------------------------- + string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, LinphoneReason reason) { char *datetime = linphone_timestamp_to_rfc3339_string(timestamp); Xsd::Imdn::Imdn imdn(id, datetime); diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index de467f859..0d1b00940 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -22,6 +22,7 @@ #include "linphone/utils/general.h" +#include "core/core-listener.h" #include "utils/background-task.h" #include "private.h" @@ -34,7 +35,7 @@ class ChatMessage; class ChatRoom; class ImdnMessage; -class Imdn { +class Imdn : public CoreListener { public: enum class Type { Delivery, @@ -58,6 +59,9 @@ public: void onImdnMessageDelivered (const std::shared_ptr &message); + // CoreListener + void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override; + static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason); static void parse (const std::shared_ptr &chatMessage); diff --git a/src/core/core.h b/src/core/core.h index bcb458a87..1588eb4d4 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -51,6 +51,7 @@ class LINPHONE_PUBLIC Core : public Object { friend class ClientGroupChatRoom; friend class ClientGroupChatRoomPrivate; friend class ClientGroupToBasicChatRoomPrivate; + friend class Imdn; friend class LocalConferenceEventHandlerPrivate; friend class MainDb; friend class MainDbChatMessageKey; diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index ca6eed11d..98e714a89 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -3144,7 +3144,7 @@ end: linphone_core_manager_destroy(chloe); } -static void aggregated_imdn_for_group_chat_room (void) { +static void aggregated_imdn_for_group_chat_room_base (bool_t read_while_offline) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); LinphoneCoreManager *chloe = linphone_core_manager_create("chloe_rc"); @@ -3196,9 +3196,19 @@ static void aggregated_imdn_for_group_chat_room (void) { // Mark the messages as read on Marie's and Pauline's sides linphone_chat_room_mark_as_read(marieCr); - linphone_chat_room_mark_as_read(paulineCr); - BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 1000)); + if (read_while_offline) { + linphone_core_set_network_reachable(pauline->lc, FALSE); + linphone_chat_room_mark_as_read(paulineCr); + wait_for_list(coresList, 0, 1, 2000); + linphone_core_set_network_reachable(pauline->lc, TRUE); + } else { + linphone_chat_room_mark_as_read(paulineCr); + } + BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 3000)); BC_ASSERT_EQUAL(chloe->stat.number_of_LinphoneMessageDeliveredToUser, 0, int, "%d"); + if (read_while_offline) { + wait_for_list(coresList, 0, 1, 2000); // To prevent memory leak + } linphone_chat_message_unref(chloeMessage3); linphone_chat_message_unref(chloeMessage2); @@ -3217,6 +3227,14 @@ end: linphone_core_manager_destroy(chloe); } +static void aggregated_imdn_for_group_chat_room (void) { + aggregated_imdn_for_group_chat_room_base(FALSE); +} + +static void aggregated_imdn_for_group_chat_room_read_while_offline (void) { + aggregated_imdn_for_group_chat_room_base(TRUE); +} + static void find_one_to_one_chat_room (void) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); @@ -3404,6 +3422,7 @@ test_t group_chat_tests[] = { TEST_NO_TAG("Unique one-to-one chatroom re-created from the party that deleted it, with inactive devices", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2), TEST_NO_TAG("IMDN for group chat room", imdn_for_group_chat_room), TEST_NO_TAG("Aggregated IMDN for group chat room", aggregated_imdn_for_group_chat_room), + TEST_NO_TAG("Aggregated IMDN for group chat room read while offline", aggregated_imdn_for_group_chat_room_read_while_offline), TEST_NO_TAG("Find one to one chat room", find_one_to_one_chat_room), TEST_NO_TAG("New device after group chat room creation", group_chat_room_new_device_after_creation) }; From babbd33142b0c251de8e706770dfb74cbc495650 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 09:13:29 +0200 Subject: [PATCH 054/143] Store if we have to send a delivery and/or display notification for a message in DB. --- src/db/internal/statements.cpp | 4 +- src/db/main-db.cpp | 68 ++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/db/internal/statements.cpp b/src/db/internal/statements.cpp index 6b6754228..2dddf1fef 100644 --- a/src/db/internal/statements.cpp +++ b/src/db/internal/statements.cpp @@ -81,7 +81,7 @@ namespace Statements { )", [SelectConferenceEvent] = R"( - SELECT conference_event_view.id AS event_id, type, conference_event_view.creation_time, from_sip_address.value, to_sip_address.value, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address.value, participant_sip_address.value, conference_event_view.subject, peer_sip_address.value, local_sip_address.value + SELECT conference_event_view.id AS event_id, type, conference_event_view.creation_time, from_sip_address.value, to_sip_address.value, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address.value, participant_sip_address.value, conference_event_view.subject, delivery_notification_required, display_notification_required, peer_sip_address.value, local_sip_address.value FROM conference_event_view JOIN chat_room ON chat_room.id = chat_room_id JOIN sip_address AS peer_sip_address ON peer_sip_address.id = peer_sip_address_id @@ -94,7 +94,7 @@ namespace Statements { )", [SelectConferenceEvents] = R"( - SELECT conference_event_view.id AS event_id, type, creation_time, from_sip_address.value, to_sip_address.value, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address.value, participant_sip_address.value, subject + SELECT conference_event_view.id AS event_id, type, creation_time, from_sip_address.value, to_sip_address.value, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address.value, participant_sip_address.value, subject, delivery_notification_required, display_notification_required FROM conference_event_view LEFT JOIN sip_address AS from_sip_address ON from_sip_address.id = from_sip_address_id LEFT JOIN sip_address AS to_sip_address ON to_sip_address.id = to_sip_address_id diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index b153a4e2e..2f104f576 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -47,7 +47,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE namespace { - constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 3); + constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 4); constexpr unsigned int ModuleVersionFriends = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyFriendsImport = makeVersion(1, 0, 0); constexpr unsigned int ModuleVersionLegacyHistoryImport = makeVersion(1, 0, 0); @@ -612,6 +612,8 @@ shared_ptr MainDbPrivate::selectConferenceChatMessageEvent ( dChatMessage->setTime(Utils::getTmAsTimeT(row.get(5))); dChatMessage->setImdnMessageId(row.get(6)); + dChatMessage->setPositiveDeliveryNotificationRequired(bool(row.get(14))); + dChatMessage->setDisplayNotificationRequired(bool(row.get(15))); dChatMessage->markContentsAsNotLoaded(); dChatMessage->setIsReadOnly(true); @@ -728,16 +730,21 @@ long long MainDbPrivate::insertConferenceChatMessageEvent (const shared_ptrgetDirection()); const string &imdnMessageId = chatMessage->getImdnMessageId(); const int &isSecured = chatMessage->isSecured() ? 1 : 0; + const int &deliveryNotificationRequired = chatMessage->getPrivate()->getPositiveDeliveryNotificationRequired(); + const int &displayNotificationRequired = chatMessage->getPrivate()->getDisplayNotificationRequired(); *dbSession.getBackendSession() << "INSERT INTO conference_chat_message_event (" " event_id, from_sip_address_id, to_sip_address_id," - " time, state, direction, imdn_message_id, is_secured" + " time, state, direction, imdn_message_id, is_secured," + " delivery_notification_required, display_notification_required" ") VALUES (" " :eventId, :localSipaddressId, :remoteSipaddressId," - " :time, :state, :direction, :imdnMessageId, :isSecured" + " :time, :state, :direction, :imdnMessageId, :isSecured," + " :deliveryNotificationRequired, :displayNotificationRequired" ")", soci::use(eventId), soci::use(fromSipAddressId), soci::use(toSipAddressId), soci::use(messageTime), soci::use(state), soci::use(direction), - soci::use(imdnMessageId), soci::use(isSecured); + soci::use(imdnMessageId), soci::use(isSecured), + soci::use(deliveryNotificationRequired), soci::use(displayNotificationRequired); for (const Content *content : chatMessage->getContents()) insertContent(eventId, *content); @@ -998,6 +1005,27 @@ void MainDbPrivate::updateSchema () { soci::use(capabilities), soci::use(capabilities); linphone_config_set_bool(linphone_core_get_config(q->getCore()->getCCore()), "misc", "prefer_basic_chat_room", TRUE); } + if (version < makeVersion(1, 0, 4)) { + *session << "ALTER TABLE conference_chat_message_event ADD COLUMN delivery_notification_required BOOLEAN NOT NULL DEFAULT 0"; + *session << "ALTER TABLE conference_chat_message_event ADD COLUMN display_notification_required BOOLEAN NOT NULL DEFAULT 0"; + + *session << "DROP VIEW IF EXISTS conference_event_view"; + + string query; + if (q->getBackend() == AbstractDb::Backend::Mysql) + query = "CREATE OR REPLACE VIEW conference_event_view AS"; + else + query = "CREATE VIEW IF NOT EXISTS conference_event_view AS"; + *session << query + + " SELECT id, type, creation_time, chat_room_id, from_sip_address_id, to_sip_address_id, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address_id, participant_sip_address_id, subject, delivery_notification_required, display_notification_required" + " FROM event" + " LEFT JOIN conference_event ON conference_event.event_id = event.id" + " LEFT JOIN conference_chat_message_event ON conference_chat_message_event.event_id = event.id" + " LEFT JOIN conference_notified_event ON conference_notified_event.event_id = event.id" + " LEFT JOIN conference_participant_device_event ON conference_participant_device_event.event_id = event.id" + " LEFT JOIN conference_participant_event ON conference_participant_event.event_id = event.id" + " LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id"; + } } // ----------------------------------------------------------------------------- @@ -1226,19 +1254,23 @@ void MainDbPrivate::importLegacyHistory (DbSession &inDbSession) { creationTime ); const int &isSecured = message.get(LegacyMessageColIsSecured, 0); + const int deliveryNotificationRequired = 0; + const int displayNotificationRequired = 0; *session << "INSERT INTO conference_event (event_id, chat_room_id)" " VALUES (:eventId, :chatRoomId)", soci::use(eventId), soci::use(chatRoomId); *session << "INSERT INTO conference_chat_message_event (" " event_id, from_sip_address_id, to_sip_address_id," - " time, state, direction, imdn_message_id, is_secured" + " time, state, direction, imdn_message_id, is_secured," + " delivery_notification_required, display_notification_required" ") VALUES (" " :eventId, :localSipAddressId, :remoteSipAddressId," - " :creationTime, :state, :direction, '', :isSecured" + " :creationTime, :state, :direction, '', :isSecured," + " :deliveryNotificationRequired, :displayNotificationRequired" ")", soci::use(eventId), soci::use(localSipAddressId), soci::use(remoteSipAddressId), - soci::use(creationTime), soci::use(state), soci::use(direction), - soci::use(isSecured); + soci::use(creationTime), soci::use(state), soci::use(direction), soci::use(isSecured), + soci::use(deliveryNotificationRequired), soci::use(displayNotificationRequired); if (content) insertContent(eventId, *content); @@ -1584,24 +1616,6 @@ void MainDb::init () { " ON DELETE CASCADE" ") " + charset; - { - string query; - if (getBackend() == Backend::Mysql) - query = "CREATE OR REPLACE VIEW conference_event_view AS"; - else - query = "CREATE VIEW IF NOT EXISTS conference_event_view AS"; - - *session << query + - " SELECT id, type, creation_time, chat_room_id, from_sip_address_id, to_sip_address_id, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address_id, participant_sip_address_id, subject" - " FROM event" - " LEFT JOIN conference_event ON conference_event.event_id = event.id" - " LEFT JOIN conference_chat_message_event ON conference_chat_message_event.event_id = event.id" - " LEFT JOIN conference_notified_event ON conference_notified_event.event_id = event.id" - " LEFT JOIN conference_participant_device_event ON conference_participant_device_event.event_id = event.id" - " LEFT JOIN conference_participant_event ON conference_participant_event.event_id = event.id" - " LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id"; - } - *session << "CREATE TABLE IF NOT EXISTS db_module_version (" " name" + varcharPrimaryKeyStr(255) + "," @@ -1779,7 +1793,7 @@ shared_ptr MainDb::getEventFromKey (const MainDbKey &dbKey) { *d->dbSession.getBackendSession() << Statements::get(Statements::SelectConferenceEvent), soci::into(row), soci::use(eventId); - ChatRoomId chatRoomId(IdentityAddress(row.get(14)), IdentityAddress(row.get(15))); + ChatRoomId chatRoomId(IdentityAddress(row.get(16)), IdentityAddress(row.get(17))); shared_ptr chatRoom = d->findChatRoom(chatRoomId); if (!chatRoom) return shared_ptr(); From 15b38e3a8b054eaec28df4286e0ca2c0c76a8d98 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 20 Apr 2018 09:13:59 +0200 Subject: [PATCH 055/143] Fix unread chat message count. --- src/chat/chat-room/chat-room.cpp | 6 +++++- src/chat/notification/imdn.cpp | 6 ++++++ src/chat/notification/imdn.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 30e0a8843..69e1e3f94 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -416,7 +416,11 @@ int ChatRoom::getChatMessageCount () const { } int ChatRoom::getUnreadChatMessageCount () const { - return getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId()); + L_D(); + int dbUnreadCount = getCore()->getPrivate()->mainDb->getUnreadChatMessageCount(getChatRoomId()); + int notifiedCount = d->imdnHandler->getDisplayNotificationCount(); + L_ASSERT(dbUnreadCount >= notifiedCount); + return dbUnreadCount - notifiedCount; } // ----------------------------------------------------------------------------- diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 6cccf52f0..b538cf015 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -48,6 +48,12 @@ Imdn::~Imdn () { // ----------------------------------------------------------------------------- +int Imdn::getDisplayNotificationCount () const { + return static_cast(displayedMessages.size()); +} + +// ----------------------------------------------------------------------------- + void Imdn::notifyDelivery (const shared_ptr &message) { if (find(deliveredMessages.begin(), deliveredMessages.end(), message) == deliveredMessages.end()) { deliveredMessages.push_back(message); diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index 0d1b00940..cf8c46eb8 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -53,6 +53,8 @@ public: Imdn (ChatRoom *chatRoom); ~Imdn (); + int getDisplayNotificationCount () const; + void notifyDelivery (const std::shared_ptr &message); void notifyDeliveryError (const std::shared_ptr &message, LinphoneReason reason); void notifyDisplay (const std::shared_ptr &message); From 6a119f971f5e50e2df80cdc785301f0399cbbe23 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 24 Apr 2018 11:31:20 +0200 Subject: [PATCH 056/143] Do not notify message delivery if the core is being shut down. --- coreapi/callbacks.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index bb6919d81..3c1717904 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -604,6 +604,12 @@ static LinphoneChatMessageState chatStatusSal2Linphone(SalMessageDeliveryStatus } static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status) { + auto lc = reinterpret_cast(op->get_sal()->get_user_pointer()); + if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { + static_cast(op)->reply(SalReasonDeclined); + return; + } + LinphonePrivate::ChatMessage *msg = reinterpret_cast(op->get_user_pointer()); if (!msg) return; // Do not handle delivery status for isComposing messages. From 1041cdb5da35711807f0a12dc35be7069f981006 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 24 Apr 2018 11:36:07 +0200 Subject: [PATCH 057/143] Do not aggregate IMDN for basic chat rooms. --- src/chat/notification/imdn.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index b538cf015..24d1300e1 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -206,6 +206,12 @@ void Imdn::send () { } void Imdn::startTimer () { + if (!chatRoom->canHandleCpim()) { + // Compatibility mode for basic chat rooms, do not aggregate notifications + send(); + return; + } + unsigned int duration = 500; if (!timer) timer = chatRoom->getCore()->getCCore()->sal->create_timer(timerExpired, this, duration, "imdn timeout"); From ae0bbc7ef8e02b0fdf1fc1b670c307bb0d2f5285 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 24 Apr 2018 11:38:46 +0200 Subject: [PATCH 058/143] Fix IMDN handling for chat rooms that do not use CPIM. --- src/chat/chat-message/chat-message.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 12bae8983..5cd203fce 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -496,6 +496,11 @@ void ChatMessagePrivate::notifyReceiving () { _linphone_chat_room_notify_chat_message_should_be_stored(chatRoom, L_GET_C_BACK_PTR(q->getSharedFromThis())); if (toBeStored) storeInDb(); + } else { + // For compatibility, when CPIM is not used + positiveDeliveryNotificationRequired = false; + negativeDeliveryNotificationRequired = false; + displayNotificationRequired = false; } shared_ptr event = make_shared( ::time(nullptr), q->getSharedFromThis() From 4223dbbc5ad0783bc0c2ec3b92400842f0ab57d5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Apr 2018 16:50:22 +0200 Subject: [PATCH 059/143] Fix memory leaks in IMDN handler. --- coreapi/vtables.c | 1 + src/chat/notification/imdn.cpp | 10 ++++++++++ src/chat/notification/imdn.h | 1 + src/core/core-listener.h | 1 + src/core/core-p.h | 1 + src/core/core.cpp | 12 ++++++++++-- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 13472609c..2c6f6d712 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -88,6 +88,7 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){ lc->vtable_notify_recursion--; void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message) { + L_GET_PRIVATE_FROM_C_OBJECT(lc)->notifyGlobalStateChanged(gstate); NOTIFY_IF_EXIST(global_state_changed,lc,gstate,message); cleanup_dead_vtable_refs(lc); } diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 24d1300e1..6c98c3143 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -92,6 +92,16 @@ void Imdn::onImdnMessageDelivered (const std::shared_ptr &message) // ----------------------------------------------------------------------------- +void Imdn::onGlobalStateChanged (LinphoneGlobalState state) { + if (state == LinphoneGlobalShutdown) { + auto ref = chatRoom->getSharedFromThis(); + deliveredMessages.clear(); + displayedMessages.clear(); + nonDeliveredMessages.clear(); + sentImdnMessages.clear(); + } +} + void Imdn::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) { if (sipNetworkReachable) { // When the SIP network gets up, retry sending every IMDN message that has not diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index cf8c46eb8..1fd44caf8 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -62,6 +62,7 @@ public: void onImdnMessageDelivered (const std::shared_ptr &message); // CoreListener + void onGlobalStateChanged (LinphoneGlobalState state) override; void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override; static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason); diff --git a/src/core/core-listener.h b/src/core/core-listener.h index d3589bc2e..b26d2de8d 100644 --- a/src/core/core-listener.h +++ b/src/core/core-listener.h @@ -30,6 +30,7 @@ class CoreListener { public: virtual ~CoreListener () = default; + virtual void onGlobalStateChanged (LinphoneGlobalState state) {} virtual void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {} virtual void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) {} }; diff --git a/src/core/core-p.h b/src/core/core-p.h index cfd5e5755..772ea2941 100644 --- a/src/core/core-p.h +++ b/src/core/core-p.h @@ -39,6 +39,7 @@ public: void unregisterListener (CoreListener *listener); void uninit (); + void notifyGlobalStateChanged (LinphoneGlobalState state); void notifyNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable); void notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message); diff --git a/src/core/core.cpp b/src/core/core.cpp index 9e9d94cc6..aeb77fd2d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -86,13 +86,21 @@ void CorePrivate::uninit () { // ----------------------------------------------------------------------------- +void CorePrivate::notifyGlobalStateChanged (LinphoneGlobalState state) { + auto listenersCopy = listeners; // Allow removable of a listener in its own call + for (const auto &listener : listenersCopy) + listener->onGlobalStateChanged(state); +} + void CorePrivate::notifyNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) { - for (const auto &listener : listeners) + auto listenersCopy = listeners; // Allow removable of a listener in its own call + for (const auto &listener : listenersCopy) listener->onNetworkReachable(sipNetworkReachable, mediaNetworkReachable); } void CorePrivate::notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const string &message) { - for (const auto &listener : listeners) + auto listenersCopy = listeners; // Allow removable of a listener in its own call + for (const auto &listener : listenersCopy) listener->onRegistrationStateChanged(cfg, state, message); } From 9b0d705ee0d73da2569a2efd55211739b27d5b32 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 25 Apr 2018 17:21:38 +0200 Subject: [PATCH 060/143] Add config parameter to be able to disable aggregation of IMDN. --- src/chat/notification/imdn.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 6c98c3143..19085772a 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -216,7 +216,9 @@ void Imdn::send () { } void Imdn::startTimer () { - if (!chatRoom->canHandleCpim()) { + auto config = linphone_core_get_config(chatRoom->getCore()->getCCore()); + bool aggregateImdn = linphone_config_get_bool(config, "misc", "aggregate_imdn", TRUE); + if (!chatRoom->canHandleCpim() || !aggregateImdn) { // Compatibility mode for basic chat rooms, do not aggregate notifications send(); return; From 38ea7dc357595a6c98ee8caf321db65eff9b6036 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 11:06:05 +0200 Subject: [PATCH 061/143] Send delivery notifications when loading chat rooms from DB if needed. --- src/chat/chat-room/abstract-chat-room-p.h | 2 + src/chat/chat-room/chat-room-p.h | 1 + src/chat/chat-room/chat-room.cpp | 10 +++ src/chat/chat-room/proxy-chat-room-p.h | 4 + src/core/core-chat-room.cpp | 4 +- src/db/main-db.cpp | 37 +++++++++ src/db/main-db.h | 4 + tester/group_chat_tester.c | 98 +++++++++++++++++++++++ 8 files changed, 159 insertions(+), 1 deletion(-) diff --git a/src/chat/chat-room/abstract-chat-room-p.h b/src/chat/chat-room/abstract-chat-room-p.h index bd2ea703e..de9054965 100644 --- a/src/chat/chat-room/abstract-chat-room-p.h +++ b/src/chat/chat-room/abstract-chat-room-p.h @@ -47,6 +47,8 @@ public: virtual void addTransientEvent (const std::shared_ptr &eventLog) = 0; virtual void removeTransientEvent (const std::shared_ptr &eventLog) = 0; + virtual void sendDeliveryNotifications () = 0; + virtual void notifyChatMessageReceived (const std::shared_ptr &chatMessage) = 0; virtual void notifyUndecryptableChatMessageReceived (const std::shared_ptr &chatMessage) = 0; diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index dfd7c8fa9..e882891c9 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -69,6 +69,7 @@ public: void sendDeliveryErrorNotification (const std::shared_ptr &message, LinphoneReason reason); void sendDeliveryNotification (const std::shared_ptr &message); + void sendDeliveryNotifications () override; bool sendDisplayNotification (const std::shared_ptr &message); void notifyChatMessageReceived (const std::shared_ptr &chatMessage) override; diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 69e1e3f94..50a48b567 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -153,6 +153,16 @@ void ChatRoomPrivate::sendDeliveryNotification (const shared_ptr &m imdnHandler->notifyDelivery(message); } +void ChatRoomPrivate::sendDeliveryNotifications () { + L_Q(); + LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); + if (linphone_im_notif_policy_get_send_imdn_delivered(policy)) { + auto messages = q->getCore()->getPrivate()->mainDb->findChatMessagesToBeNotifiedAsDelivered(q->getChatRoomId()); + for (const auto message : messages) + imdnHandler->notifyDelivery(message); + } +} + bool ChatRoomPrivate::sendDisplayNotification (const shared_ptr &message) { L_Q(); LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(q->getCore()->getCCore()); diff --git a/src/chat/chat-room/proxy-chat-room-p.h b/src/chat/chat-room/proxy-chat-room-p.h index b10aa3d8a..fc6840b34 100644 --- a/src/chat/chat-room/proxy-chat-room-p.h +++ b/src/chat/chat-room/proxy-chat-room-p.h @@ -57,6 +57,10 @@ public: chatRoom->getPrivate()->removeTransientEvent(eventLog); } + inline void sendDeliveryNotifications () override { + chatRoom->getPrivate()->sendDeliveryNotifications(); + } + inline void notifyChatMessageReceived (const std::shared_ptr &chatMessage) override { chatRoom->getPrivate()->notifyChatMessageReceived(chatMessage); } diff --git a/src/core/core-chat-room.cpp b/src/core/core-chat-room.cpp index cac503c2c..fdd7eb5a5 100644 --- a/src/core/core-chat-room.cpp +++ b/src/core/core-chat-room.cpp @@ -179,8 +179,10 @@ void CorePrivate::insertChatRoomWithDb (const shared_ptr &chat void CorePrivate::loadChatRooms () { chatRooms.clear(); chatRoomsById.clear(); - for (auto &chatRoom : mainDb->getChatRooms()) + for (auto &chatRoom : mainDb->getChatRooms()) { insertChatRoom(chatRoom); + chatRoom->getPrivate()->sendDeliveryNotifications(); + } } void CorePrivate::replaceChatRoom (const shared_ptr &replacedChatRoom, const shared_ptr &newChatRoom) { diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 2f104f576..dcb589a60 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -2148,6 +2148,43 @@ list> MainDb::findChatMessages ( }; } +list> MainDb::findChatMessagesToBeNotifiedAsDelivered ( + const ChatRoomId &chatRoomId +) const { + static const string query = Statements::get(Statements::SelectConferenceEvents) + + string(" AND direction = :direction AND state = :state AND delivery_notification_required <> 0"); + + DurationLogger durationLogger( + "Find chat messages to be notified as delivered: (peer=" + chatRoomId.getPeerAddress().asString() + + ", local=" + chatRoomId.getLocalAddress().asString() + ")." + ); + + return L_DB_TRANSACTION { + L_D(); + + shared_ptr chatRoom = d->findChatRoom(chatRoomId); + list> chatMessages; + if (!chatRoom) + return chatMessages; + + const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId); + const int &state = int(ChatMessage::State::Delivered); + const int &direction = int(ChatMessage::Direction::Incoming); + soci::rowset rows = ( + d->dbSession.getBackendSession()->prepare << query, soci::use(dbChatRoomId), soci::use(direction), soci::use(state) + ); + for (const auto &row : rows) { + shared_ptr event = d->selectGenericConferenceEvent(chatRoom, row); + if (event) { + L_ASSERT(event->getType() == EventLog::Type::ConferenceChatMessage); + chatMessages.push_back(static_pointer_cast(event)->getChatMessage()); + } + } + + return chatMessages; + }; +} + list> MainDb::getHistory (const ChatRoomId &chatRoomId, int nLast, FilterMask mask) const { return getHistoryRange(chatRoomId, 0, nLast, mask); } diff --git a/src/db/main-db.h b/src/db/main-db.h index bb134ab50..e43cb9130 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -130,6 +130,10 @@ public: const std::string &imdnMessageId ) const; + std::list> findChatMessagesToBeNotifiedAsDelivered ( + const ChatRoomId &chatRoomId + ) const; + // --------------------------------------------------------------------------- // Conference events. // --------------------------------------------------------------------------- diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index 98e714a89..f183aa73c 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -3235,6 +3235,103 @@ static void aggregated_imdn_for_group_chat_room_read_while_offline (void) { aggregated_imdn_for_group_chat_room_base(TRUE); } +static void imdn_sent_from_db_state (void) { + LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); + LinphoneCoreManager *chloe = linphone_core_manager_create("chloe_rc"); + bctbx_list_t *coresManagerList = NULL; + bctbx_list_t *participantsAddresses = NULL; + coresManagerList = bctbx_list_append(coresManagerList, marie); + coresManagerList = bctbx_list_append(coresManagerList, pauline); + coresManagerList = bctbx_list_append(coresManagerList, chloe); + bctbx_list_t *coresList = init_core_for_conference(coresManagerList); + start_core_for_conference(coresManagerList); + participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc))); + participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(chloe->lc))); + stats initialMarieStats = marie->stat; + stats initialPaulineStats = pauline->stat; + stats initialChloeStats = chloe->stat; + time_t initialTime = ms_time(NULL); + + // Enable IMDN except for Marie + linphone_im_notif_policy_clear(linphone_core_get_im_notif_policy(marie->lc)); + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(pauline->lc)); + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(chloe->lc)); + + // Marie creates a new group chat room + const char *initialSubject = "Colleagues"; + LinphoneChatRoom *marieCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject, -1); + LinphoneAddress *confAddr = linphone_address_clone(linphone_chat_room_get_conference_address(marieCr)); + + // Check that the chat room is correctly created on Pauline's side and that the participants are added + LinphoneChatRoom *paulineCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 2, FALSE); + + // Check that the chat room is correctly created on Chloe's side and that the participants are added + LinphoneChatRoom *chloeCr = check_creation_chat_room_client_side(coresList, chloe, &initialChloeStats, confAddr, initialSubject, 2, FALSE); + + // Chloe begins composing a message + const char *chloeTextMessage = "Hello"; + LinphoneChatMessage *chloeMessage = _send_message(chloeCr, chloeTextMessage); + BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, initialMarieStats.number_of_LinphoneMessageReceived + 1, 3000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 3000)); + LinphoneChatMessage *marieLastMsg = marie->stat.last_received_chat_message; + if (!BC_ASSERT_PTR_NOT_NULL(marieLastMsg)) + goto end; + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marieLastMsg), chloeTextMessage); + LinphoneAddress *chloeAddr = linphone_address_new(linphone_core_get_identity(chloe->lc)); + BC_ASSERT_TRUE(linphone_address_weak_equal(chloeAddr, linphone_chat_message_get_from_address(marieLastMsg))); + linphone_address_unref(chloeAddr); + + // Check that the message is not globally marked as delivered to user since Marie do not notify its delivery + BC_ASSERT_FALSE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 3000)); + + // Restart Marie's core with IMDN enabled so that delivery notification is sent when chat room is loaded from DB + coresList = bctbx_list_remove(coresList, marie->lc); + linphone_core_manager_reinit(marie); + bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, marie); + bctbx_list_t *tmpCoresList = init_core_for_conference(tmpCoresManagerList); + bctbx_list_free(tmpCoresManagerList); + coresList = bctbx_list_concat(coresList, tmpCoresList); + linphone_im_notif_policy_enable_all(linphone_core_get_im_notif_policy(marie->lc)); + linphone_core_manager_start(marie, TRUE); + char *marieIdentity = linphone_core_get_device_identity(marie->lc); + LinphoneAddress *marieAddr = linphone_address_new(marieIdentity); + bctbx_free(marieIdentity); + marieCr = linphone_core_find_chat_room(marie->lc, confAddr, marieAddr); + linphone_address_unref(marieAddr); + linphone_address_unref(confAddr); + + // Check that the message has been delivered to Marie and Pauline + BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 3000)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_displayed(chloeMessage)); + bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_that_have_received(chloeMessage); + if (BC_ASSERT_PTR_NOT_NULL(participantsThatReceivedChloeMessage)) { + BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatReceivedChloeMessage), 2, int, "%d"); + for (bctbx_list_t *item = participantsThatReceivedChloeMessage; item; item = bctbx_list_next(item)) { + LinphoneParticipantImdnState *state = (LinphoneParticipantImdnState *)bctbx_list_get_data(item); + BC_ASSERT_GREATER(linphone_participant_imdn_state_get_state_change_time(state), initialTime, int, "%d"); + BC_ASSERT_EQUAL(linphone_participant_imdn_state_get_state(state), LinphoneChatMessageStateDeliveredToUser, int, "%d"); + BC_ASSERT_PTR_NOT_NULL(linphone_participant_imdn_state_get_participant(state)); + } + bctbx_list_free_with_data(participantsThatReceivedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); + } + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_not_received(chloeMessage)); + + linphone_chat_message_unref(chloeMessage); + +end: + // Clean db from chat room + linphone_core_manager_delete_chat_room(marie, marieCr, coresList); + linphone_core_manager_delete_chat_room(chloe, chloeCr, coresList); + linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList); + + bctbx_list_free(coresList); + bctbx_list_free(coresManagerList); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(chloe); +} + static void find_one_to_one_chat_room (void) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); @@ -3423,6 +3520,7 @@ test_t group_chat_tests[] = { TEST_NO_TAG("IMDN for group chat room", imdn_for_group_chat_room), TEST_NO_TAG("Aggregated IMDN for group chat room", aggregated_imdn_for_group_chat_room), TEST_NO_TAG("Aggregated IMDN for group chat room read while offline", aggregated_imdn_for_group_chat_room_read_while_offline), + TEST_ONE_TAG("IMDN sent from DB state", imdn_sent_from_db_state, "LeaksMemory"), TEST_NO_TAG("Find one to one chat room", find_one_to_one_chat_room), TEST_NO_TAG("New device after group chat room creation", group_chat_room_new_device_after_creation) }; From df0f8cfa9c16962e1386ed1fc7778c84afc57ed4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 26 Apr 2018 12:13:00 +0200 Subject: [PATCH 062/143] fix(friendlist): avoid memory leaks in linphone_friend_list_find_friend_by_ref_key --- coreapi/friendlist.c | 16 ++++++++++------ tester/vcard_tester.c | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 8712bd455..878fc14f0 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -800,15 +800,19 @@ LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendLis return result; } -LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key) { - if(list) { - bctbx_iterator_t* it = bctbx_map_cchar_find_key(list->friends_map, ref_key); - if (!bctbx_iterator_cchar_equals(it, bctbx_map_cchar_end(list->friends_map))) { +LinphoneFriend *linphone_friend_list_find_friend_by_ref_key (const LinphoneFriendList *list, const char *ref_key) { + LinphoneFriend *result = NULL; + if (list) { + bctbx_iterator_t *it = bctbx_map_cchar_find_key(list->friends_map, ref_key); + bctbx_iterator_t *end = bctbx_map_cchar_end(list->friends_map); + if (!bctbx_iterator_cchar_equals(it, end)) { bctbx_pair_t *pair = bctbx_iterator_cchar_get_pair(it); - return (LinphoneFriend *)bctbx_pair_cchar_get_second(pair); + result = (LinphoneFriend *)bctbx_pair_cchar_get_second(pair); } + bctbx_iterator_cchar_delete(end); + bctbx_iterator_cchar_delete(it); } - return NULL; + return result; } LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe ( diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 213c02fa5..84cfcd62f 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -365,7 +365,7 @@ static void friends_sqlite_store_lot_of_friends(void) { int ret; char *buf; char *friends_db = bc_tester_file("friends.db"); - + unlink(friends_db); ret = sqlite3_open(friends_db, &db); bc_free(friends_db); @@ -437,7 +437,7 @@ static void friends_sqlite_find_friend_in_lot_of_friends(void) { bctoolboxTimeSpec t1; bctoolboxTimeSpec t2; char *friends_db = bc_tester_file("friends.db"); - + unlink(friends_db); ret = sqlite3_open(friends_db, &db); bc_free(friends_db); @@ -951,7 +951,9 @@ static void find_friend_by_ref_key_test(void) { goto end; } addr = linphone_friend_get_address(lf2); - BC_ASSERT_STRING_EQUAL(linphone_address_as_string_uri_only(addr), "sip:toto@sip.linphone.org"); + char *uri_addr = linphone_address_as_string_uri_only(addr); + BC_ASSERT_STRING_EQUAL(uri_addr, "sip:toto@sip.linphone.org"); + bctbx_free(uri_addr); BC_ASSERT_EQUAL(lf2, lf, void*, "%p"); end: linphone_friend_unref(lf); From b537254c7b42943453ab51d841b1a0ee2ef24fe4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 26 Apr 2018 14:34:52 +0200 Subject: [PATCH 063/143] fix(localplayer): destroy correctly ms player --- coreapi/localplayer.c | 1 - coreapi/player.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/localplayer.c b/coreapi/localplayer.c index 88ecc06a8..8984eda1d 100644 --- a/coreapi/localplayer.c +++ b/coreapi/localplayer.c @@ -88,7 +88,6 @@ static int _local_player_get_current_position(LinphonePlayer *obj) { static void _local_player_destroy(LinphonePlayer *obj) { ms_media_player_free((MSMediaPlayer *)obj->impl); - _linphone_player_destroy(obj); } static void _local_player_close(LinphonePlayer *obj) { diff --git a/coreapi/player.c b/coreapi/player.c index a8a73453c..fcfee87f3 100644 --- a/coreapi/player.c +++ b/coreapi/player.c @@ -100,10 +100,11 @@ void linphone_player_close(LinphonePlayer *obj){ } void linphone_player_destroy(LinphonePlayer *obj) { - if(obj->destroy) obj->destroy(obj); + _linphone_player_destroy(obj); } void _linphone_player_destroy(LinphonePlayer *player) { + if(player->destroy) player->destroy(player); linphone_player_cbs_unref(player->callbacks); } From 90ca06096cb4fa875e279f19f1bbcf5830dff4c5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 26 Apr 2018 14:53:36 +0200 Subject: [PATCH 064/143] Fixed multiple file transfer in same message issue --- .../modifier/file-transfer-chat-message-modifier.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index f73581c6b..43ae3663e 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -310,8 +310,13 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h FileTransferContent *fileTransferContent = nullptr; for (Content *c : message->getPrivate()->getContents()) { if (c->isFileTransfer()) { - fileTransferContent = static_cast(c); - break; + FileTransferContent *tmpContent = static_cast(c); + if (!tmpContent->getFileContent() && tmpContent->getSize() == 0) { + // If FileTransferContent doesn't have a FileContent yet and is empty + // It's the one we seek, otherwise it may be a previous uploaded FileTransferContent + fileTransferContent = tmpContent; + break; + } } } From 360077ec8698551825745b3b1a2e86108e21b5bf Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 26 Apr 2018 15:08:19 +0200 Subject: [PATCH 065/143] fix(tester): reset counters in core manager uninit + clean dtmf list received --- tester/dtmf_tester.c | 4 +--- tester/tester.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tester/dtmf_tester.c b/tester/dtmf_tester.c index c73e05acc..3523fd339 100644 --- a/tester/dtmf_tester.c +++ b/tester/dtmf_tester.c @@ -22,9 +22,7 @@ void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { stats* counters = get_stats(lc); char** dst = &counters->dtmf_list_received; - *dst = *dst ? - ms_strcat_printf(*dst, "%c", dtmf) - : ms_strdup_printf("%c", dtmf); + *dst = *dst ? ms_strcat_printf(*dst, "%c", dtmf) : ms_strdup_printf("%c", dtmf); counters->dtmf_count++; } diff --git a/tester/tester.c b/tester/tester.c index cd8481381..58607dec7 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -107,6 +107,8 @@ static void auth_info_requested(LinphoneCore *lc, const char *realm, const char void reset_counters( stats* counters) { if (counters->last_received_chat_message) linphone_chat_message_unref(counters->last_received_chat_message); if (counters->last_received_info_message) linphone_info_message_unref(counters->last_received_info_message); + if (counters->dtmf_list_received) bctbx_free(counters->dtmf_list_received); + memset(counters,0,sizeof(stats)); } @@ -504,6 +506,8 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { if (mgr->cbs) linphone_core_cbs_unref(mgr->cbs); + reset_counters(&mgr->stat); + manager_count--; linphone_core_set_log_level_mask(old_log_level); } From f09e3cd1360b23dc8c9483e4ffd228e55700d126 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 20 Dec 2017 17:34:11 +0100 Subject: [PATCH 066/143] fix double callback notification of EOP on LinphonePlayer --- coreapi/player.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/coreapi/player.c b/coreapi/player.c index fcfee87f3..ac9e3f5ab 100644 --- a/coreapi/player.c +++ b/coreapi/player.c @@ -134,9 +134,13 @@ static bool_t call_player_check_state(LinphonePlayer *player, bool_t check_playe static void on_eof(void *user_data, MSFilter *f, unsigned int event_id, void *arg){ LinphonePlayer *player=(LinphonePlayer *)user_data; - LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); - LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs); - if (cb) cb(player); + switch (event_id){ + case MS_PLAYER_EOF: + LinphonePlayerCbs *cbs = linphone_player_get_callbacks(player); + LinphonePlayerCbsEofReachedCb cb = linphone_player_cbs_get_eof_reached(cbs); + if (cb) cb(player); + break; + } } static int call_player_open(LinphonePlayer* player, const char *filename){ From 728574a549205369f217aba3a06cd8c6768905e8 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 26 Apr 2018 17:08:23 +0200 Subject: [PATCH 067/143] fix(linphonecore): fix many leaks with bad libxml usage (use xmlFree doc instead of xmlFree) --- coreapi/linphonecore.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a414450e8..a9e84cc76 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -850,7 +850,7 @@ static void process_response_from_post_file_log_collection(void *data, const bel cur = cur->xmlChildrenNode; /* now loop on the content of the file-info node */ while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"data")) { - file_url = xmlGetProp(cur, (const xmlChar *)"url"); + file_url = xmlGetProp(cur, (const xmlChar *)"url"); } cur=cur->next; } @@ -864,7 +864,9 @@ static void process_response_from_post_file_log_collection(void *data, const bel } if (file_url != NULL) { linphone_core_notify_log_collection_upload_state_changed(core, LinphoneCoreLogCollectionUploadStateDelivered, (const char *)file_url); + xmlFree(file_url); } + xmlFreeDoc(xmlMessageBody); clean_log_collection_upload_context(core); } else { ms_error("Unexpected HTTP response code %i during log collection upload to %s", code, linphone_core_get_log_collection_upload_server_url(core)); @@ -6495,7 +6497,7 @@ void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file){ /* clean up */ bctbx_free(bkpFile); - xmlFree(cacheXml); + xmlFreeDoc(cacheXml); } bctbx_free(tmpFile); } else { From 6e0a7ae397463ae5176098489f39d04d5c0bf36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:02:03 +0200 Subject: [PATCH 068/143] Add specific headers --- src/chat/cpim/header/cpim-core-headers.cpp | 359 +++++++++++++++++-- src/chat/cpim/header/cpim-core-headers.h | 190 ++++++++-- src/chat/cpim/header/cpim-generic-header.cpp | 57 ++- src/chat/cpim/header/cpim-generic-header.h | 10 +- src/chat/cpim/header/cpim-header-p.h | 2 - src/chat/cpim/header/cpim-header.cpp | 16 - src/chat/cpim/header/cpim-header.h | 7 +- 7 files changed, 522 insertions(+), 119 deletions(-) diff --git a/src/chat/cpim/header/cpim-core-headers.cpp b/src/chat/cpim/header/cpim-core-headers.cpp index 1a85d7e81..0da0b2721 100644 --- a/src/chat/cpim/header/cpim-core-headers.cpp +++ b/src/chat/cpim/header/cpim-core-headers.cpp @@ -17,6 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include +#include + +#include "linphone/utils/utils.h" + +#include "logger/logger.h" + #include "chat/cpim/parser/cpim-parser.h" #include "cpim-header-p.h" @@ -28,50 +35,348 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -Cpim::CoreHeader::CoreHeader () : Header(*new HeaderPrivate) {} +class Cpim::ContactHeaderPrivate : public HeaderPrivate { +public: + string uri; + string formalName; +}; -Cpim::CoreHeader::CoreHeader (HeaderPrivate &p) : Header(p) {} +Cpim::ContactHeader::ContactHeader () : Header(*new ContactHeaderPrivate) {} -Cpim::CoreHeader::~CoreHeader () {} +Cpim::ContactHeader::ContactHeader (const string &uri, const string &formalName) : ContactHeader() { + setUri(uri); + setFormalName(formalName); +} -bool Cpim::CoreHeader::isValid () const { - return !getValue().empty(); +string Cpim::ContactHeader::getUri () const { + L_D(); + return d->uri; +} + +bool Cpim::ContactHeader::setUri (const string &uri) { + if (uri.empty()) + return false; + + L_D(); + d->uri = uri; + + return true; +} + +string Cpim::ContactHeader::getFormalName () const { + L_D(); + return d->formalName; +} + +bool Cpim::ContactHeader::setFormalName (const string &formalName) { + if (formalName.empty()) + return false; + + L_D(); + if (formalName.front() == '\"' && formalName.back() == '\"') + d->formalName = formalName.substr(1, formalName.size() - 2); + else if (formalName.back() == ' ') + d->formalName = formalName.substr(0, formalName.size() - 1); + else + d->formalName = formalName; + + return true; +} + +string Cpim::ContactHeader::getValue () const { + L_D(); + return "\"" + d->formalName + "\"" + "<" + d->uri + ">"; +} + +string Cpim::ContactHeader::asString () const { + return getName() + ": " + getValue() + "\r\n"; } // ----------------------------------------------------------------------------- -#define MAKE_CORE_HEADER_IMPL(CLASS_PREFIX) \ - bool Cpim::CLASS_PREFIX ## Header::setValue(const string &value) { \ - return Parser::getInstance()->coreHeaderIsValid(value) && Header::setValue(value); \ - } +class Cpim::MessageIdHeaderPrivate : public HeaderPrivate { +public: + string token; +}; -MAKE_CORE_HEADER_IMPL(From); -MAKE_CORE_HEADER_IMPL(To); -MAKE_CORE_HEADER_IMPL(Cc); -MAKE_CORE_HEADER_IMPL(DateTime); +Cpim::MessageIdHeader::MessageIdHeader () : Header(*new MessageIdHeaderPrivate) {} -MAKE_CORE_HEADER_IMPL(Ns); -MAKE_CORE_HEADER_IMPL(Require); +Cpim::MessageIdHeader::MessageIdHeader (const string &token) : MessageIdHeader() { + L_D(); + d->token = token; +} -#undef MAKE_CORE_HEADER_IMPL +string Cpim::MessageIdHeader::getToken () const { + L_D(); + return d->token; +} + +bool Cpim::MessageIdHeader::setToken (string token) { + if (token.empty()) + return false; + + L_D(); + d->token = token; + + return true; +} + +string Cpim::MessageIdHeader::getValue () const { + return getToken(); +} + +string Cpim::MessageIdHeader::asString () const { + return getName() + ": " + getValue() + "\r\n"; +} // ----------------------------------------------------------------------------- -void Cpim::CoreHeader::force (const string &value) { - Header::setValue(value); +class Cpim::DateTimeHeaderPrivate : public HeaderPrivate { +public: + tm timeT; + tm timeTOffset; + string signOffset; +}; + +Cpim::DateTimeHeader::DateTimeHeader () : Header(*new DateTimeHeaderPrivate) {} + +Cpim::DateTimeHeader::DateTimeHeader (time_t time) : DateTimeHeader() { + setTime(time); +} + +Cpim::DateTimeHeader::DateTimeHeader (const tm &time, const tm &timeOffset, const string &signOffset) : DateTimeHeader() { + setTime(time, timeOffset, signOffset); +} + +time_t Cpim::DateTimeHeader::getTime () const { + L_D(); + + tm result = d->timeT; + result.tm_year -= 1900; + result.tm_isdst = 0; + + if (d->signOffset == "+") { + result.tm_hour += d->timeTOffset.tm_hour; + result.tm_min += d->timeTOffset.tm_min; + + while (result.tm_min > 59) { + result.tm_hour++; + result.tm_min -= 60; + } + } + else if (d->signOffset == "-") { + result.tm_hour -= d->timeTOffset.tm_hour; + result.tm_hour -= d->timeTOffset.tm_min; + + while (result.tm_min < 0) { + result.tm_hour--; + result.tm_min += 60; + } + } + + return Utils::getTmAsTimeT(result); +} + +bool Cpim::DateTimeHeader::setTime (const time_t time) { + L_D(); + + d->signOffset = "Z"; + d->timeT = Utils::getTimeTAsTm(time); + d->timeT.tm_year += 1900; + + return true; +} + +bool Cpim::DateTimeHeader::setTime (const tm &time, const tm &timeOffset, const string &signOffset) { + L_D(); + + d->timeT = time; + d->timeTOffset = timeOffset; + d->signOffset = signOffset; + + return true; +} + +string Cpim::DateTimeHeader::getValue () const { + L_D(); + + stringstream ss; + ss << setfill('0') << setw(4) << d->timeT.tm_year << "-" + << setfill('0') << setw(2) << d->timeT.tm_mon << "-" + << setfill('0') << setw(2) << d->timeT.tm_mday << "T" + << setfill('0') << setw(2) << d->timeT.tm_hour << ":" + << setfill('0') << setw(2) << d->timeT.tm_min << ":" + << setfill('0') << setw(2) << d->timeT.tm_sec; + + ss << d->signOffset; + if (d->signOffset != "Z") + ss << setfill('0') << setw(2) << d->timeTOffset.tm_hour << ":" + << setfill('0') << setw(2) << d->timeTOffset.tm_min; + + return ss.str(); +} + +string Cpim::DateTimeHeader::asString () const { + return getName() + ": " + getValue() + "\r\n"; +} + +struct tm Cpim::DateTimeHeader::getTimeStruct () const { + L_D(); + return d->timeT; +} + +struct tm Cpim::DateTimeHeader::getTimeOffset () const { + L_D(); + return d->timeTOffset; +} + +string Cpim::DateTimeHeader::getSignOffset () const { + L_D(); + return d->signOffset; +} + +// ----------------------------------------------------------------------------- + +class Cpim::NsHeaderPrivate : public HeaderPrivate { +public: + string uri; + string prefixName; +}; + +Cpim::NsHeader::NsHeader () : Header(*new NsHeaderPrivate) {} + +Cpim::NsHeader::NsHeader (const string &uri, const string &prefixName) : NsHeader() { + L_D(); + d->uri = uri; + d->prefixName = prefixName; +} + +string Cpim::NsHeader::getUri () const { + L_D(); + return d->uri; +} + +bool Cpim::NsHeader::setUri (const string &uri) { + if (uri.empty()) + return false; + + L_D(); + d->uri = uri; + + return true; +} + +string Cpim::NsHeader::getPrefixName () const { + L_D(); + return d->prefixName; +} + +bool Cpim::NsHeader::setPrefixName (const string &prefixName) { + if (prefixName.empty()) + return false; + + L_D(); + d->prefixName = prefixName; + + return true; +} + +string Cpim::NsHeader::getValue () const { + L_D(); + + string ns; + if (!d->prefixName.empty()) + ns = d->prefixName + " "; + + return ns + "<" + d->uri + ">"; +} + +string Cpim::NsHeader::asString () const { + return getName() + ": " + getValue() + "\r\n"; +} + +// ----------------------------------------------------------------------------- + +class Cpim::RequireHeaderPrivate : public HeaderPrivate { +public: + list headerNames; +}; + +Cpim::RequireHeader::RequireHeader () : Header(*new RequireHeaderPrivate) {} + +Cpim::RequireHeader::RequireHeader (const string &headerNames) : RequireHeader() { + L_D(); + for (const string &header : Utils::split(headerNames, ",")) { + d->headerNames.push_back(header); + } +} + +Cpim::RequireHeader::RequireHeader (const list &headerNames) : RequireHeader() { + L_D(); + d->headerNames = headerNames; +} + +list Cpim::RequireHeader::getHeaderNames () const { + L_D(); + return d->headerNames; +} + +bool Cpim::RequireHeader::addHeaderName (const string &headerName) { + if (headerName.empty()) + return false; + + L_D(); + d->headerNames.push_back(headerName); + + return true; +} + +string Cpim::RequireHeader::getValue () const { + L_D(); + + string requires; + for (const string &header : d->headerNames) { + if (header != d->headerNames.front()) + requires += ","; + requires += header; + } + + return requires; +} + +string Cpim::RequireHeader::asString () const { + return getName() + ": " + getValue() + "\r\n"; } // ----------------------------------------------------------------------------- class Cpim::SubjectHeaderPrivate : public HeaderPrivate { public: + string subject; string language; }; -Cpim::SubjectHeader::SubjectHeader () : CoreHeader(*new SubjectHeaderPrivate) {} +Cpim::SubjectHeader::SubjectHeader () : Header(*new SubjectHeaderPrivate) {} -bool Cpim::SubjectHeader::setValue (const string &value) { - return Parser::getInstance()->coreHeaderIsValid(value) && Header::setValue(value); +Cpim::SubjectHeader::SubjectHeader (const string &subject, const string &language) : SubjectHeader() { + L_D(); + d->subject = subject; + d->language = language; +} + +string Cpim::SubjectHeader::getSubject () const { + L_D(); + return d->subject; +} + +bool Cpim::SubjectHeader::setSubject (const string &subject) { + if (subject.empty()) + return false; + + L_D(); + d->subject = subject; + + return true; } string Cpim::SubjectHeader::getLanguage () const { @@ -80,7 +385,7 @@ string Cpim::SubjectHeader::getLanguage () const { } bool Cpim::SubjectHeader::setLanguage (const string &language) { - if (!language.empty() && !Parser::getInstance()->subjectHeaderLanguageIsValid(language)) + if (!language.empty()) return false; L_D(); @@ -89,20 +394,18 @@ bool Cpim::SubjectHeader::setLanguage (const string &language) { return true; } -string Cpim::SubjectHeader::asString () const { +string Cpim::SubjectHeader::getValue () const { L_D(); string languageParam; if (!d->language.empty()) languageParam = ";lang=" + d->language; - return getName() + ":" + languageParam + " " + getValue() + "\r\n"; + return languageParam + " " + d->subject; } -void Cpim::SubjectHeader::force (const string &value, const string &language) { - L_D(); - CoreHeader::force(value); - d->language = language; +string Cpim::SubjectHeader::asString () const { + return getName() + ":" + getValue() + "\r\n"; } LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/header/cpim-core-headers.h b/src/chat/cpim/header/cpim-core-headers.h index 1c7321ce4..89971cac0 100644 --- a/src/chat/cpim/header/cpim-core-headers.h +++ b/src/chat/cpim/header/cpim-core-headers.h @@ -20,60 +20,188 @@ #ifndef _L_CPIM_CORE_HEADERS_H_ #define _L_CPIM_CORE_HEADERS_H_ +#include +#include + #include "cpim-header.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE -#define MAKE_CORE_HEADER(CLASS_PREFIX, NAME) \ - class LINPHONE_PUBLIC CLASS_PREFIX ## Header : public CoreHeader { \ +#define MAKE_CONTACT_HEADER(CLASS_PREFIX, NAME) \ + class LINPHONE_PUBLIC CLASS_PREFIX ## Header : public ContactHeader { \ public: \ - CLASS_PREFIX ## Header() = default; \ - inline std::string getName() const override { \ + CLASS_PREFIX ## Header () = default; \ + CLASS_PREFIX ## Header (const std::string &uri, const std::string &formalName = "") : ContactHeader (uri, formalName) {} \ + inline std::string getName () const override { \ return NAME; \ } \ - bool setValue(const std::string &value) override; \ private: \ L_DISABLE_COPY(CLASS_PREFIX ## Header); \ }; namespace Cpim { - class HeaderNode; + class DateTimeHeaderNode; // ------------------------------------------------------------------------- - // Generic core header. + // Specific Contact headers declaration. // ------------------------------------------------------------------------- - class LINPHONE_PUBLIC CoreHeader : public Header { - friend class HeaderNode; + class ContactHeaderPrivate; + class LINPHONE_PUBLIC ContactHeader : public Header { public: - CoreHeader (); + ContactHeader (); - virtual ~CoreHeader () = 0; + ContactHeader (const std::string &uri, const std::string &formalName = ""); - bool isValid () const override; + std::string getUri () const; + bool setUri (const std::string &uri); - protected: - explicit CoreHeader (HeaderPrivate &p); + std::string getFormalName () const; + bool setFormalName (const std::string &formalName); - void force (const std::string &value); + std::string getValue () const override; + + std::string asString () const override; private: - L_DISABLE_COPY(CoreHeader); + L_DECLARE_PRIVATE(ContactHeader); + L_DISABLE_COPY(ContactHeader); }; // ------------------------------------------------------------------------- - // Core headers. + + MAKE_CONTACT_HEADER(From, "From"); + MAKE_CONTACT_HEADER(To, "To"); + MAKE_CONTACT_HEADER(Cc, "cc"); + + // ------------------------------------------------------------------------- + // Specific MessageId declaration. // ------------------------------------------------------------------------- - MAKE_CORE_HEADER(From, "From"); - MAKE_CORE_HEADER(To, "To"); - MAKE_CORE_HEADER(Cc, "cc"); - MAKE_CORE_HEADER(DateTime, "DateTime"); - MAKE_CORE_HEADER(Ns, "NS"); - MAKE_CORE_HEADER(Require, "Require"); + class MessageIdHeaderPrivate; + + class LINPHONE_PUBLIC MessageIdHeader : public Header { + public: + MessageIdHeader (); + + MessageIdHeader (const std::string &token); + + inline std::string getName() const override { + return "Message-ID"; + } + + std::string getToken () const; + bool setToken (std::string token); + + std::string getValue () const override; + + std::string asString () const override; + + private: + L_DECLARE_PRIVATE(MessageIdHeader); + L_DISABLE_COPY(MessageIdHeader); + }; + + // ------------------------------------------------------------------------- + // Specific DateTime declaration. + // ------------------------------------------------------------------------- + + class DateTimeHeaderPrivate; + + class LINPHONE_PUBLIC DateTimeHeader : public Header { + friend class DateTimeHeaderNode; + + public: + DateTimeHeader (); + + DateTimeHeader (time_t time); + + DateTimeHeader (const tm &time, const tm &timeOffset, const std::string &signOffset); + + inline std::string getName () const override { + return "DateTime"; + } + + time_t getTime () const; + bool setTime (const time_t time); + + bool setTime (const tm &time, const tm &timeOffset, const std::string &signOffset); + + std::string getValue () const override; + + std::string asString () const override; + + private: + tm getTimeStruct () const; + tm getTimeOffset () const; + std::string getSignOffset () const; + + L_DECLARE_PRIVATE(DateTimeHeader); + L_DISABLE_COPY(DateTimeHeader); + }; + + // ------------------------------------------------------------------------- + // Specific Ns declaration. + // ------------------------------------------------------------------------- + + class NsHeaderPrivate; + + class LINPHONE_PUBLIC NsHeader : public Header { + public: + NsHeader (); + + NsHeader (const std::string &uri, const std::string &prefixName = ""); + + inline std::string getName () const override { + return "NS"; + } + + std::string getPrefixName () const; + bool setPrefixName (const std::string &prefixName); + + std::string getUri () const; + bool setUri (const std::string &uri); + + std::string getValue () const override; + + std::string asString () const override; + + private: + L_DECLARE_PRIVATE(NsHeader); + L_DISABLE_COPY(NsHeader); + }; + + // ------------------------------------------------------------------------- + // Specific Require declaration. + // ------------------------------------------------------------------------- + + class RequireHeaderPrivate; + + class LINPHONE_PUBLIC RequireHeader : public Header { + public: + RequireHeader (); + + RequireHeader (const std::string &headerNames); + RequireHeader (const std::list &headerNames); + + inline std::string getName () const override { + return "Require"; + } + + std::list getHeaderNames () const; + bool addHeaderName (const std::string &headerName); + + std::string getValue () const override; + + std::string asString () const override; + + private: + L_DECLARE_PRIVATE(RequireHeader); + L_DISABLE_COPY(RequireHeader); + }; // ------------------------------------------------------------------------- // Specific Subject declaration. @@ -81,25 +209,25 @@ namespace Cpim { class SubjectHeaderPrivate; - class LINPHONE_PUBLIC SubjectHeader : public CoreHeader { - friend class HeaderNode; - + class LINPHONE_PUBLIC SubjectHeader : public Header { public: SubjectHeader (); + SubjectHeader (const std::string &subject, const std::string &language = ""); + inline std::string getName () const override { return "Subject"; } - bool setValue (const std::string &value) override; + std::string getSubject () const; + bool setSubject (const std::string &subject); std::string getLanguage () const; bool setLanguage (const std::string &language); - std::string asString () const override; + std::string getValue () const override; - protected: - void force (const std::string &value, const std::string &language); + std::string asString () const override; private: L_DECLARE_PRIVATE(SubjectHeader); @@ -107,7 +235,7 @@ namespace Cpim { }; } -#undef MAKE_CORE_HEADER +#undef MAKE_CONTACT_HEADER LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/header/cpim-generic-header.cpp b/src/chat/cpim/header/cpim-generic-header.cpp index 67a7b81d4..8e4bc57ab 100644 --- a/src/chat/cpim/header/cpim-generic-header.cpp +++ b/src/chat/cpim/header/cpim-generic-header.cpp @@ -37,11 +37,24 @@ public: GenericHeaderPrivate () : parameters(make_shared > >()) {} string name; + string value; shared_ptr > > parameters; }; Cpim::GenericHeader::GenericHeader () : Header(*new GenericHeaderPrivate) {} +Cpim::GenericHeader::GenericHeader (string name, string value, string parameters) : GenericHeader() { + L_D(); + d->name = name; + d->value = value; + + for (const auto ¶meter : Utils::split(parameters, ';')) { + size_t equalIndex = parameter.find('='); + if (equalIndex != string::npos) + d->parameters->push_back(make_pair(parameter.substr(0, equalIndex), parameter.substr(equalIndex + 1))); + } +} + string Cpim::GenericHeader::getName () const { L_D(); return d->name; @@ -54,18 +67,26 @@ bool Cpim::GenericHeader::setName (const string &name) { "From", "To", "cc", "DateTime", "Subject", "NS", "Require" }; - if ( - reserved.find(name) != reserved.end() || - !Parser::getInstance()->headerNameIsValid(name) - ) + if (reserved.find(name) != reserved.end()) return false; d->name = name; return true; } +string Cpim::GenericHeader::getValue () const { + L_D(); + return d->value; +} + bool Cpim::GenericHeader::setValue (const string &value) { - return Parser::getInstance()->headerValueIsValid(value) && Header::setValue(value); + if (value.empty()) + return false; + + L_D(); + d->value = value; + + return true; } Cpim::GenericHeader::ParameterList Cpim::GenericHeader::getParameters () const { @@ -75,10 +96,6 @@ Cpim::GenericHeader::ParameterList Cpim::GenericHeader::getParameters () const { bool Cpim::GenericHeader::addParameter (const string &key, const string &value) { L_D(); - - if (!Parser::getInstance()->headerParameterIsValid(key + "=" + value)) - return false; - d->parameters->push_back(make_pair(key, value)); return true; } @@ -88,11 +105,6 @@ void Cpim::GenericHeader::removeParameter (const string &key, const string &valu d->parameters->remove(make_pair(key, value)); } -bool Cpim::GenericHeader::isValid () const { - L_D(); - return !d->name.empty() && !getValue().empty(); -} - string Cpim::GenericHeader::asString () const { L_D(); @@ -103,21 +115,4 @@ string Cpim::GenericHeader::asString () const { return d->name + ":" + parameters + " " + getValue() + "\r\n"; } -// ----------------------------------------------------------------------------- - -void Cpim::GenericHeader::force (const string &name, const string &value, const string ¶meters) { - L_D(); - - // Set name/value. - d->name = name; - Header::setValue(value); - - // Parse and build parameters list. - for (const auto ¶meter : Utils::split(parameters, ';')) { - size_t equalIndex = parameter.find('='); - if (equalIndex != string::npos) - d->parameters->push_back(make_pair(parameter.substr(0, equalIndex), parameter.substr(equalIndex + 1))); - } -} - LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/header/cpim-generic-header.h b/src/chat/cpim/header/cpim-generic-header.h index 2433a9cb7..711b3c641 100644 --- a/src/chat/cpim/header/cpim-generic-header.h +++ b/src/chat/cpim/header/cpim-generic-header.h @@ -38,10 +38,13 @@ namespace Cpim { public: GenericHeader (); + GenericHeader (std::string name, std::string value, std::string parameters = ""); + std::string getName () const override; bool setName (const std::string &name); - bool setValue (const std::string &value) override; + std::string getValue () const override; + bool setValue (const std::string &value); typedef std::shared_ptr > > ParameterList; @@ -49,13 +52,8 @@ namespace Cpim { bool addParameter (const std::string &key, const std::string &value); void removeParameter (const std::string &key, const std::string &value); - bool isValid () const override; - std::string asString () const override; - protected: - void force (const std::string &name, const std::string &value, const std::string ¶meters); - private: L_DECLARE_PRIVATE(GenericHeader); L_DISABLE_COPY(GenericHeader); diff --git a/src/chat/cpim/header/cpim-header-p.h b/src/chat/cpim/header/cpim-header-p.h index 048e91309..2aaea0acb 100644 --- a/src/chat/cpim/header/cpim-header-p.h +++ b/src/chat/cpim/header/cpim-header-p.h @@ -30,8 +30,6 @@ LINPHONE_BEGIN_NAMESPACE namespace Cpim { class HeaderPrivate : public ObjectPrivate { private: - std::string value; - L_DECLARE_PUBLIC(Header); }; } diff --git a/src/chat/cpim/header/cpim-header.cpp b/src/chat/cpim/header/cpim-header.cpp index 8141d7811..6a3b83470 100644 --- a/src/chat/cpim/header/cpim-header.cpp +++ b/src/chat/cpim/header/cpim-header.cpp @@ -29,20 +29,4 @@ LINPHONE_BEGIN_NAMESPACE Cpim::Header::Header (HeaderPrivate &p) : Object(p) {} -string Cpim::Header::getValue () const { - L_D(); - return d->value; -} - -bool Cpim::Header::setValue (const string &value) { - L_D(); - d->value = value; - return true; -} - -string Cpim::Header::asString () const { - L_D(); - return getName() + ": " + d->value + "\r\n"; -} - LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/header/cpim-header.h b/src/chat/cpim/header/cpim-header.h index 13dcfdce8..f71d115b0 100644 --- a/src/chat/cpim/header/cpim-header.h +++ b/src/chat/cpim/header/cpim-header.h @@ -35,12 +35,9 @@ namespace Cpim { virtual std::string getName () const = 0; - std::string getValue () const; - virtual bool setValue (const std::string &value); + virtual std::string getValue () const = 0; - virtual bool isValid () const = 0; - - virtual std::string asString () const; + virtual std::string asString () const = 0; protected: explicit Header (HeaderPrivate &p); From 4ec0c6eda4f267a65fb5381cf7792652c7122027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:02:44 +0200 Subject: [PATCH 069/143] Changed rules to parse specific headers directly --- src/chat/cpim/parser/cpim-parser.cpp | 736 ++++++++++++++++++--------- src/chat/cpim/parser/cpim-parser.h | 34 -- src/chat/cpim/parser/cpim-rules | 24 +- 3 files changed, 507 insertions(+), 287 deletions(-) diff --git a/src/chat/cpim/parser/cpim-parser.cpp b/src/chat/cpim/parser/cpim-parser.cpp index 3d34fcd71..a918a802a 100644 --- a/src/chat/cpim/parser/cpim-parser.cpp +++ b/src/chat/cpim/parser/cpim-parser.cpp @@ -53,20 +53,10 @@ namespace Cpim { HeaderNode () = default; explicit HeaderNode (const Header &header) : mName(header.getName()), mValue(header.getValue()) { - // Generic header. const GenericHeader *genericHeader = dynamic_cast(&header); if (genericHeader) { for (const auto ¶meter : *genericHeader->getParameters()) mParameters += ";" + parameter.first + "=" + parameter.second; - return; - } - - // Subject header. - const SubjectHeader *subjectHeader = dynamic_cast(&header); - if (subjectHeader) { - const string language = subjectHeader->getLanguage(); - if (!language.empty()) - mParameters = ";lang=" + language; } } @@ -94,67 +84,425 @@ namespace Cpim { mValue = value; } - shared_ptr
createHeader (bool force) const; + virtual shared_ptr
createHeader () const; + + virtual bool isValid () const; private: - template - shared_ptr
createCoreHeader (bool force) const { - shared_ptr header = make_shared(); - if (force) - header->force(mValue); - else if (!header->setValue(mValue)) { - lWarning() << "Unable to set value on core header: `" << mName << "` => `" << mValue << "`."; - return nullptr; - } - - return header; - } - string mName; string mValue; string mParameters; }; - template<> - shared_ptr
HeaderNode::createCoreHeader(bool force) const { - shared_ptr header = make_shared(); - const string language = mParameters.length() >= 6 ? mParameters.substr(6) : ""; - - if (force) - header->force(mValue, language); - else if (!header->setValue(mValue) || (!language.empty() && !header->setLanguage(language))) { - lWarning() << "Unable to set value on subject header: `" << - mName << "` => `" << mValue << "`, `" << language << "`."; - return nullptr; - } - - return header; + bool HeaderNode::isValid () const { + return !mName.empty() && !mValue.empty(); } - shared_ptr
HeaderNode::createHeader (bool force = false) const { - static const unordered_map(HeaderNode::*)(bool)const> reservedHandlers = { - { "From", &HeaderNode::createCoreHeader }, - { "To", &HeaderNode::createCoreHeader }, - { "cc", &HeaderNode::createCoreHeader }, - { "DateTime", &HeaderNode::createCoreHeader }, - { "Subject", &HeaderNode::createCoreHeader }, - { "NS", &HeaderNode::createCoreHeader }, - { "Require", &HeaderNode::createCoreHeader } - }; + shared_ptr
HeaderNode::createHeader () const { + if (!isValid()) + return nullptr; - // Core Header. - const auto it = reservedHandlers.find(mName); - if (it != reservedHandlers.cend()) - return (this->*it->second)(force); - - // Generic Header shared_ptr genericHeader = make_shared(); - genericHeader->force(mName, mValue, mParameters); + genericHeader->setName(mName); + + for (const auto ¶meter : Utils::split(mParameters, ';')) { + size_t equalIndex = parameter.find('='); + if (equalIndex != string::npos) + genericHeader->addParameter(parameter.substr(0, equalIndex), parameter.substr(equalIndex + 1)); + } + + genericHeader->setValue(mValue); return genericHeader; } // ------------------------------------------------------------------------- + class ContactHeaderNode : public HeaderNode { + public: + ContactHeaderNode () = default; + + string getFormalName () const { + return mFormalName; + } + + void setFormalName (const string &formalName) { + mFormalName = formalName; + } + + string getUri () const { + return mUri; + } + + void setUri (const string &uri) { + mUri = uri; + } + + bool isValid () const override; + + private: + string mFormalName; + string mUri; + }; + + bool ContactHeaderNode::isValid () const { + return !mUri.empty(); + } + + // ------------------------------------------------------------------------- + + class FromHeaderNode : public ContactHeaderNode { + public: + FromHeaderNode () = default; + + explicit FromHeaderNode (const Header &header) { + const FromHeader *fromHeader = dynamic_cast(&header); + if (fromHeader) { + setFormalName(fromHeader->getFormalName()); + setUri(fromHeader->getUri()); + } + } + + shared_ptr
createHeader () const override; + }; + + shared_ptr
FromHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getUri(), getFormalName()); + } + + // ------------------------------------------------------------------------- + + class ToHeaderNode : public ContactHeaderNode { + public: + ToHeaderNode () = default; + + explicit ToHeaderNode (const Header &header) { + const ToHeader *toHeader = dynamic_cast(&header); + if (toHeader) { + setFormalName(toHeader->getFormalName()); + setUri(toHeader->getUri()); + } + } + + shared_ptr
createHeader () const override; + }; + + shared_ptr
ToHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getUri(), getFormalName()); + } + + // ------------------------------------------------------------------------- + + class CcHeaderNode : public ContactHeaderNode { + public: + CcHeaderNode () = default; + + explicit CcHeaderNode (const Header &header) { + const CcHeader *ccHeader = dynamic_cast(&header); + if (ccHeader) { + setFormalName(ccHeader->getFormalName()); + setUri(ccHeader->getUri()); + } + } + + shared_ptr
createHeader () const override; + }; + + shared_ptr
CcHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getUri(), getFormalName()); + } + + // ------------------------------------------------------------------------- + + class DateTimeOffsetNode : public Node { + friend class DateTimeHeaderNode; + + public: + DateTimeOffsetNode () { + mSign = "Z"; + } + + void setHour (const string &value) { + mHour = Utils::stoi(value); + } + + void setMinute (const string &value) { + mMinute = Utils::stoi(value); + } + + void setSign (const string &value) { + mSign = value; + } + + private: + string mSign; + int mHour; + int mMinute; + }; + + class DateTimeHeaderNode : public HeaderNode { + public: + DateTimeHeaderNode () = default; + + explicit DateTimeHeaderNode (const Header &header) { + const DateTimeHeader *dateTimeHeader = dynamic_cast(&header); + if (dateTimeHeader) { + setTime(dateTimeHeader->getTimeStruct()); + setTimeOffset(dateTimeHeader->getTimeOffset()); + setSignOffset(dateTimeHeader->getSignOffset()); + } + } + + struct tm getTime () const { + return mTime; + } + + void setTime (const struct tm &time) { + mTime = time; + } + + struct tm getTimeOffset () const { + return mTimeOffset; + } + + void setTimeOffset (const struct tm &timeOffset) { + mTimeOffset = timeOffset; + } + + string getSignOffset () const { + return mSignOffset; + } + + void setSignOffset (const string &signOffset) { + mSignOffset = signOffset; + } + + void setYear (const string &value) { + mTime.tm_year = Utils::stoi(value); + } + + void setMonth (const string &value) { + mTime.tm_mon = Utils::stoi(value); + } + + void setMonthDay (const string &value) { + mTime.tm_mday = Utils::stoi(value); + } + + void setHour (const string &value) { + mTime.tm_hour = Utils::stoi(value); + } + + void setMinute (const string &value) { + mTime.tm_min = Utils::stoi(value); + } + + void setSecond (const string &value) { + mTime.tm_sec = Utils::stoi(value); + } + + void setOffset (const shared_ptr &offset) { + mTimeOffset.tm_hour = offset->mHour; + mTimeOffset.tm_min = offset->mMinute; + mSignOffset = offset->mSign; + } + + bool isValid () const override; + + shared_ptr
createHeader() const override; + + private: + tm mTime; + tm mTimeOffset; + string mSignOffset; + }; + + bool DateTimeHeaderNode::isValid () const { + static const int daysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + + // Check date. + const bool isLeapYear = (mTime.tm_year % 4 == 0 && mTime.tm_year % 100 != 0) || mTime.tm_year % 400 == 0; + + if (mTime.tm_mon < 1 || mTime.tm_mon > 12) + return false; + + if (mTime.tm_mday < 1 || (mTime.tm_mon == 2 && isLeapYear ? mTime.tm_mday > 29 : mTime.tm_mday > daysInMonth[mTime.tm_mon - 1])) + return false; + + // Check time. + if (mTime.tm_hour > 24 || mTime.tm_min > 59 || mTime.tm_sec > 60) + return false; + + // Check num offset. + if (mSignOffset != "Z") { + if (mTimeOffset.tm_hour > 24 || mTime.tm_min > 59) + return false; + } + + return true; + } + + shared_ptr
DateTimeHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getTime(), getTimeOffset(), getSignOffset()); + } + + // ------------------------------------------------------------------------- + + class SubjectHeaderNode : public HeaderNode { + public: + SubjectHeaderNode () = default; + + explicit SubjectHeaderNode (const Header &header) { + const SubjectHeader *subjectHeader = dynamic_cast(&header); + if (subjectHeader) { + setLanguage(subjectHeader->getLanguage()); + setSubject(subjectHeader->getSubject()); + } + } + + string getLanguage () const { + return mLanguage; + } + + void setLanguage (const string &language) { + mLanguage = language; + } + + string getSubject () const { + return mSubject; + } + + void setSubject (const string &subject) { + mSubject = subject; + } + + bool isValid () const override; + + shared_ptr
createHeader () const override; + + private: + string mLanguage; + string mSubject; + }; + + bool SubjectHeaderNode::isValid () const { + return !mSubject.empty(); + } + + shared_ptr
SubjectHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getSubject(), getLanguage()); + } + + // ------------------------------------------------------------------------- + + class NsHeaderNode : public HeaderNode { + public: + NsHeaderNode () = default; + + explicit NsHeaderNode (const Header &header) { + const NsHeader *nsHeader = dynamic_cast(&header); + if (nsHeader) { + setPrefixName(nsHeader->getPrefixName()); + setUri(nsHeader->getUri()); + } + } + + string getPrefixName () const { + return mPrefixName; + } + + void setPrefixName (const string &prefixName) { + mPrefixName = prefixName; + } + + string getUri () const { + return mUri; + } + + void setUri (const string &uri) { + mUri = uri; + } + + bool isValid () const override; + + shared_ptr
createHeader () const override; + + private: + string mPrefixName; + string mUri; + }; + + bool NsHeaderNode::isValid () const { + return !mUri.empty(); + } + + shared_ptr
NsHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(getUri(), getPrefixName()); + } + + // ------------------------------------------------------------------------- + + class RequireHeaderNode : public HeaderNode { + public: + RequireHeaderNode () = default; + + explicit RequireHeaderNode (const Header &header) { + const RequireHeader *requireHeader = dynamic_cast(&header); + if (requireHeader) { + for (const auto &header : requireHeader->getHeaderNames()) { + if (header != requireHeader->getHeaderNames().front()) + mHeaderNames += ","; + mHeaderNames += header; + } + } + } + + string getHeaderNames () const { + return mHeaderNames; + } + + void setHeaderNames (const string &headerNames) { + mHeaderNames = headerNames; + } + + bool isValid () const override; + + shared_ptr
createHeader () const override; + + private: + string mHeaderNames; + }; + + bool RequireHeaderNode::isValid () const { + return !mHeaderNames.empty(); + } + + shared_ptr
RequireHeaderNode::createHeader () const { + if (!isValid()) + return nullptr; + + return make_shared(mHeaderNames); + } + + // ------------------------------------------------------------------------- + class ListHeaderNode : public Node, public list > {}; @@ -163,57 +511,38 @@ namespace Cpim { class MessageNode : public Node { public: - void addHeaders (const shared_ptr &headers) { - mHeaders->push_back(headers); + void addMessageHeaders (const shared_ptr &headers) { + for (const auto &headerNode : *headers) { + mMessageHeaders.push_back(headerNode); + } + } + + void addContentHeaders (const shared_ptr &headers) { + for (const auto &headerNode : *headers) { + mContentHeaders.push_back(headerNode); + } } // Warning: Call this function one time! shared_ptr createMessage () const { - size_t size = mHeaders->size(); - if (size < 2 || size > 3) { // TODO: Check that size is == 2 + if (mContentHeaders.empty() || mMessageHeaders.empty()) { lWarning() << "Bad headers lists size."; return nullptr; } + //TODO: Verify all headers from other namespaces + const shared_ptr message = make_shared(); - // TODO: To remove - if (size == 3) { - const shared_ptr cpimHeaders = mHeaders->front(); - if (find_if(cpimHeaders->cbegin(), cpimHeaders->cend(), - [](const shared_ptr &headerNode) { - return Utils::iequals(headerNode->getName(), "content-type") && (ContentType(headerNode->getValue()) == ContentType::Cpim); - }) == cpimHeaders->cend()) { - lWarning() << "No MIME `Content-Type` found!"; + // Add message headers. + for (const auto &headerNode : mMessageHeaders) { + const shared_ptr header = headerNode->createHeader(); + if (!header || !message->addMessageHeader(*header)) return nullptr; - } - - // Add MIME headers. - for (const auto &headerNode : *cpimHeaders) { - const shared_ptr header = headerNode->createHeader(); - if (!header || !message->addCpimHeader(*header)) - return nullptr; - } - - // Add message headers. - for (const auto &headerNode : **(++mHeaders->cbegin())) { - const shared_ptr header = headerNode->createHeader(); - if (!header || !message->addMessageHeader(*header)) - return nullptr; - } - } - // TODO: To remove - else { - // Add message headers. - for (const auto &headerNode : *mHeaders->front()) { - const shared_ptr header = headerNode->createHeader(); - if (!header || !message->addMessageHeader(*header)) - return nullptr; - } } // Add content headers. - for (const auto &headerNode : *mHeaders->back()) { + for (const auto &headerNode : mContentHeaders) { const shared_ptr header = headerNode->createHeader(); if (!header || !message->addContentHeader(*header)) return nullptr; @@ -223,7 +552,8 @@ namespace Cpim { } private: - shared_ptr > > mHeaders = make_shared > >(); + list> mContentHeaders; + list> mMessageHeaders; }; } @@ -260,27 +590,64 @@ shared_ptr Cpim::Parser::parseMessage (const string &input) { typedef void (list >::*pushPtr)(const shared_ptr &value); belr::Parser > parser(d->grammar); - parser.setHandler( - "Message", belr::make_fn(make_shared ) - )->setCollector( - "Headers", belr::make_sfn(&MessageNode::addHeaders) - ); + parser.setHandler("Message", belr::make_fn(make_shared)) + ->setCollector("Message-headers", belr::make_sfn(&MessageNode::addMessageHeaders)) + ->setCollector("Content-headers", belr::make_sfn(&MessageNode::addContentHeaders)); - parser.setHandler( - "Headers", belr::make_fn(make_shared ) - )->setCollector( - "Header", belr::make_sfn(static_cast(&ListHeaderNode::push_back)) - ); + parser.setHandler("Message-headers", belr::make_fn(make_shared)) + ->setCollector("Header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("From-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("To-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("DateTime-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("cc-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("Subject-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("NS-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))) + ->setCollector("Require-header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))); - parser.setHandler( - "Header", belr::make_fn(make_shared ) - )->setCollector( - "Header-name", belr::make_sfn(&HeaderNode::setName) - )->setCollector( - "Header-value", belr::make_sfn(&HeaderNode::setValue) - )->setCollector( - "Header-parameters", belr::make_sfn(&HeaderNode::setParameters) - ); + parser.setHandler("Content-headers", belr::make_fn(make_shared)) + ->setCollector("Header", belr::make_sfn(static_cast(&ListHeaderNode::push_back))); + + parser.setHandler("Header", belr::make_fn(make_shared)) + ->setCollector("Header-name", belr::make_sfn(&HeaderNode::setName)) + ->setCollector("Header-value", belr::make_sfn(&HeaderNode::setValue)) + ->setCollector("Header-parameters", belr::make_sfn(&HeaderNode::setParameters)); + + parser.setHandler("From-header", belr::make_fn(make_shared)) + ->setCollector("Formal-name", belr::make_sfn(&FromHeaderNode::setFormalName)) + ->setCollector("URI", belr::make_sfn(&FromHeaderNode::setUri)); + + parser.setHandler("To-header", belr::make_fn(make_shared)) + ->setCollector("Formal-name", belr::make_sfn(&ToHeaderNode::setFormalName)) + ->setCollector("URI", belr::make_sfn(&ToHeaderNode::setUri)); + + parser.setHandler("cc-header", belr::make_fn(make_shared)) + ->setCollector("Formal-name", belr::make_sfn(&CcHeaderNode::setFormalName)) + ->setCollector("URI", belr::make_sfn(&CcHeaderNode::setUri)); + + parser.setHandler("DateTime-header", belr::make_fn(make_shared)) + ->setCollector("date-fullyear", belr::make_sfn(&DateTimeHeaderNode::setYear)) + ->setCollector("date-month", belr::make_sfn(&DateTimeHeaderNode::setMonth)) + ->setCollector("date-mday", belr::make_sfn(&DateTimeHeaderNode::setMonthDay)) + ->setCollector("time-hour", belr::make_sfn(&DateTimeHeaderNode::setHour)) + ->setCollector("time-minute", belr::make_sfn(&DateTimeHeaderNode::setMinute)) + ->setCollector("time-second", belr::make_sfn(&DateTimeHeaderNode::setSecond)) + ->setCollector("time-offset", belr::make_sfn(&DateTimeHeaderNode::setOffset)); + + parser.setHandler("time-offset", belr::make_fn(make_shared)) + ->setCollector("time-sign", belr::make_sfn(&DateTimeOffsetNode::setSign)) + ->setCollector("time-hour", belr::make_sfn(&DateTimeOffsetNode::setHour)) + ->setCollector("time-minute", belr::make_sfn(&DateTimeOffsetNode::setMinute)); + + parser.setHandler("Subject-header", belr::make_fn(make_shared)) + ->setCollector("Language-tag", belr::make_sfn(&SubjectHeaderNode::setLanguage)) + ->setCollector("Header-value", belr::make_sfn(&SubjectHeaderNode::setSubject)); + + parser.setHandler("Ns-header", belr::make_fn(make_shared)) + ->setCollector("Name-prefix", belr::make_sfn(&NsHeaderNode::setPrefixName)) + ->setCollector("URI", belr::make_sfn(&NsHeaderNode::setUri)); + + parser.setHandler("Require-header", belr::make_fn(make_shared)) + ->setCollector("Require-header-value", belr::make_sfn(&RequireHeaderNode::setHeaderNames)); size_t parsedSize; shared_ptr node = parser.parseInput("Message", input, &parsedSize); @@ -305,143 +672,28 @@ shared_ptr Cpim::Parser::parseMessage (const string &input) { // ----------------------------------------------------------------------------- shared_ptr Cpim::Parser::cloneHeader (const Header &header) { - return HeaderNode(header).createHeader(true); -} + if (header.getName() == "From") + return FromHeaderNode(header).createHeader(); -// ----------------------------------------------------------------------------- + if (header.getName() == "To") + return ToHeaderNode(header).createHeader(); -class EmptyObject {}; + if (header.getName() == "cc") + return CcHeaderNode(header).createHeader(); -static bool headerIsValid (const shared_ptr &grammar, const string &input) { - belr::Parser > parser(grammar); - parser.setHandler( - "Header", belr::make_fn(make_shared ) - ); + if (header.getName() == "DateTime") + return DateTimeHeaderNode(header).createHeader(); - size_t parsedSize; - shared_ptr node = parser.parseInput("Header", input, &parsedSize); - return node && parsedSize == input.length(); -} + if (header.getName() == "Subject") + return SubjectHeaderNode(header).createHeader(); -bool Cpim::Parser::headerNameIsValid (const string &headerName) const { - L_D(); - return headerIsValid(d->grammar, headerName + ": value\r\n"); -} + if (header.getName() == "NS") + return NsHeaderNode(header).createHeader(); -bool Cpim::Parser::headerValueIsValid (const string &headerValue) const { - L_D(); - return headerIsValid(d->grammar, "key: " + headerValue + "\r\n"); -} + if (header.getName() == "Require") + return RequireHeaderNode(header).createHeader(); -bool Cpim::Parser::headerParameterIsValid (const string &headerParameter) const { - L_D(); - return headerIsValid(d->grammar, "key:;" + headerParameter + " value\r\n"); -} - -// ----------------------------------------------------------------------------- - -static bool coreHeaderIsValid ( - const shared_ptr &grammar, - const string &headerName, - const string &headerValue, - const string &headerParams = string() -) { - const string mainRule = headerName + "-header"; - - belr::Parser > parser(grammar); - parser.setHandler( - mainRule, belr::make_fn(make_shared ) - ); - - const string input = headerName + ":" + headerParams + " " + headerValue; - - size_t parsedSize; - shared_ptr node = parser.parseInput(mainRule, input, &parsedSize); - return node && parsedSize == input.length(); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "From", headerValue); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "To", headerValue); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "cc", headerValue); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - static const int daysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - - L_D(); - if (!LinphonePrivate::coreHeaderIsValid(d->grammar, "DateTime", headerValue)) - return false; - - // Check date. - const int year = Utils::stoi(headerValue.substr(0, 4)); - const bool isLeapYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; - - const int month = Utils::stoi(headerValue.substr(5, 2)); - if (month < 1 || month > 12) - return false; - - const int day = Utils::stoi(headerValue.substr(8, 2)); - if (day < 1 || (month == 2 && isLeapYear ? day > 29 : day > daysInMonth[month - 1])) - return false; - - // Check time. - if ( - Utils::stoi(headerValue.substr(11, 2)) > 24 || - Utils::stoi(headerValue.substr(14, 2)) > 59 || - Utils::stoi(headerValue.substr(17, 2)) > 60 - ) - return false; - - // Check num offset. - if (headerValue.back() != 'Z') { - size_t length = headerValue.length(); - if ( - Utils::stoi(headerValue.substr(length - 5, 2)) > 24 || - Utils::stoi(headerValue.substr(length - 2, 2)) > 59 - ) - return false; - } - - return true; -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "Subject", headerValue); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "NS", headerValue); -} - -template<> -bool Cpim::Parser::coreHeaderIsValid (const string &headerValue) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "Require", headerValue); -} - -// ----------------------------------------------------------------------------- - -bool Cpim::Parser::subjectHeaderLanguageIsValid (const string &language) const { - L_D(); - return LinphonePrivate::coreHeaderIsValid(d->grammar, "Subject", "SubjectValue", ";lang=" + language); + return HeaderNode(header).createHeader(); } LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/parser/cpim-parser.h b/src/chat/cpim/parser/cpim-parser.h index bdb32f7e4..076400841 100644 --- a/src/chat/cpim/parser/cpim-parser.h +++ b/src/chat/cpim/parser/cpim-parser.h @@ -38,46 +38,12 @@ namespace Cpim { std::shared_ptr
cloneHeader (const Header &header); - bool headerNameIsValid (const std::string &headerName) const; - bool headerValueIsValid (const std::string &headerValue) const; - bool headerParameterIsValid (const std::string &headerParameter) const; - - template - bool coreHeaderIsValid (const std::string &headerValue) const { - return false; - } - - bool subjectHeaderLanguageIsValid (const std::string &language) const; - private: Parser (); L_DECLARE_PRIVATE(Parser); L_DISABLE_COPY(Parser); }; - - // --------------------------------------------------------------------------- - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; - - template<> - bool Parser::coreHeaderIsValid(const std::string &headerValue) const; } LINPHONE_END_NAMESPACE diff --git a/src/chat/cpim/parser/cpim-rules b/src/chat/cpim/parser/cpim-rules index bba8e019c..d2837db2a 100644 --- a/src/chat/cpim/parser/cpim-rules +++ b/src/chat/cpim/parser/cpim-rules @@ -1,6 +1,7 @@ -Message = Headers CRLF Headers CRLF [Headers CRLF] +Message = Message-headers CRLF Content-headers CRLF -Headers = *Header +Message-headers = *( From-header / To-header / DateTime-header / cc-header / Subject-header / NS-header / Require-header / Header ) +Content-headers = *Header Header = Header-name ":" Header-parameters SP Header-value CRLF Header-name = [ Name-prefix "." ] Name @@ -16,25 +17,25 @@ Param-value = Token / Number / String Header-value = *HEADERCHAR -From-header = %d70.114.111.109 ": " From-header-value +From-header = %d70.114.111.109 ": " From-header-value CRLF From-header-value = [ Formal-name ] "<" URI ">" -To-header = %d84.111 ": " To-header-value +To-header = %d84.111 ": " To-header-value CRLF To-header-value = [ Formal-name ] "<" URI ">" -DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value +DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value CRLF DateTime-header-value = date-time -cc-header = %d99.99 ": " cc-header-value +cc-header = %d99.99 ": " cc-header-value CRLF cc-header-value = [ Formal-name ] "<" URI ">" -Subject-header = %d83.117.98.106.101.99.116 ":" Subject-header-value -Subject-header-value = [ ";" Lang-param ] SP *HEADERCHAR +Subject-header = %d83.117.98.106.101.99.116 ":" Subject-header-value CRLF +Subject-header-value = [ ";" Lang-param ] SP Header-value -NS-header = %d78.83 ": " NS-header-value +NS-header = %d78.83 ": " NS-header-value CRLF NS-header-value = [ Name-prefix SP ] "<" URI ">" -Require-header = %d82.101.113.117.105.114.101 ": " Require-header-value +Require-header = %d82.101.113.117.105.114.101 ": " Require-header-value CRLF Require-header-value = Header-name *( "," Header-name ) Name = 1*NAMECHAR @@ -134,7 +135,8 @@ time-minute = 2DIGIT time-second = 2DIGIT time-secfrac = "." 1*DIGIT -time-numoffset = ( "+" / "-" ) time-hour ":" time-minute +time-sign = "+" / "-" +time-numoffset = time-sign time-hour ":" time-minute time-offset = "Z" / time-numoffset partial-time = time-hour ":" time-minute ":" time-second [ time-secfrac ] From b687bf9d684651c77a5a191d56b61b30686ac21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:03:01 +0200 Subject: [PATCH 070/143] Removed CPIM headers --- src/chat/cpim/message/cpim-message.cpp | 50 ------------------- src/chat/cpim/message/cpim-message.h | 8 --- .../modifier/cpim-chat-message-modifier.cpp | 33 +++++------- .../modifier/cpim-chat-message-modifier.h | 3 +- 4 files changed, 14 insertions(+), 80 deletions(-) diff --git a/src/chat/cpim/message/cpim-message.cpp b/src/chat/cpim/message/cpim-message.cpp index 123ef6c66..d6fb78080 100644 --- a/src/chat/cpim/message/cpim-message.cpp +++ b/src/chat/cpim/message/cpim-message.cpp @@ -38,7 +38,6 @@ class Cpim::MessagePrivate : public ObjectPrivate { public: typedef list > PrivHeaderList; - shared_ptr cpimHeaders = make_shared(); // TODO: Remove this useless variable shared_ptr messageHeaders = make_shared(); shared_ptr contentHeaders = make_shared(); string content; @@ -48,30 +47,6 @@ Cpim::Message::Message () : Object(*new MessagePrivate) {} // ----------------------------------------------------------------------------- -Cpim::Message::HeaderList Cpim::Message::getCpimHeaders () const { - L_D(); - return d->cpimHeaders; -} - -bool Cpim::Message::addCpimHeader (const Header &cpimHeader) { - L_D(); - - if (!cpimHeader.isValid()) - return false; - - d->cpimHeaders->push_back(Parser::getInstance()->cloneHeader(cpimHeader)); - return true; -} - -void Cpim::Message::removeCpimHeader (const Header &cpimHeader) { - L_D(); - d->cpimHeaders->remove_if([&cpimHeader](const shared_ptr &header) { - return cpimHeader.getName() == header->getName() && cpimHeader.getValue() == header->getValue(); - }); -} - -// ----------------------------------------------------------------------------- - Cpim::Message::HeaderList Cpim::Message::getMessageHeaders () const { L_D(); return d->messageHeaders; @@ -80,9 +55,6 @@ Cpim::Message::HeaderList Cpim::Message::getMessageHeaders () const { bool Cpim::Message::addMessageHeader (const Header &messageHeader) { L_D(); - if (!messageHeader.isValid()) - return false; - d->messageHeaders->push_back(Parser::getInstance()->cloneHeader(messageHeader)); return true; } @@ -104,9 +76,6 @@ Cpim::Message::HeaderList Cpim::Message::getContentHeaders () const { bool Cpim::Message::addContentHeader (const Header &contentHeader) { L_D(); - if (!contentHeader.isValid()) - return false; - d->contentHeaders->push_back(Parser::getInstance()->cloneHeader(contentHeader)); return true; } @@ -133,29 +102,10 @@ bool Cpim::Message::setContent (const string &content) { // ----------------------------------------------------------------------------- -bool Cpim::Message::isValid () const { - L_D(); - - return find_if(d->cpimHeaders->cbegin(), d->cpimHeaders->cend(), - [](const shared_ptr &header) { - return Utils::iequals(header->getName(), "content-type") && (ContentType(header->getValue()) == ContentType::Cpim); - }) != d->cpimHeaders->cend(); -} - -// ----------------------------------------------------------------------------- - string Cpim::Message::asString () const { L_D(); string output; - // TODO: Remove cpimHeaders - if (d->cpimHeaders->size() > 0) { - for (const auto &cpimHeader : *d->cpimHeaders) - output += cpimHeader->asString(); - output += "\r\n"; - } - // TODO Remove cpimHeaders - if (d->messageHeaders->size() > 0) { for (const auto &messageHeader : *d->messageHeaders) output += messageHeader->asString(); diff --git a/src/chat/cpim/message/cpim-message.h b/src/chat/cpim/message/cpim-message.h index c7778c929..7c4ce693c 100644 --- a/src/chat/cpim/message/cpim-message.h +++ b/src/chat/cpim/message/cpim-message.h @@ -36,12 +36,6 @@ namespace Cpim { typedef std::shared_ptr > > HeaderList; - // TODO: Remove these useless methods - HeaderList getCpimHeaders () const; - bool addCpimHeader (const Header &cpimHeader); - void removeCpimHeader (const Header &cpimHeader); - // TODO: Remove these useless methods - HeaderList getMessageHeaders () const; bool addMessageHeader (const Header &messageHeader); void removeMessageHeader (const Header &messageHeader); @@ -53,8 +47,6 @@ namespace Cpim { std::string getContent () const; bool setContent (const std::string &content); - bool isValid () const; // TODO: Remove this useless method - std::string asString () const; static std::shared_ptr createFromString (const std::string &str); diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 9c7d48f6b..04c73f9c1 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -38,11 +38,9 @@ LINPHONE_BEGIN_NAMESPACE ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr &message, int &errorCode) { Cpim::Message cpimMessage; - Cpim::FromHeader cpimFromHeader; - cpimFromHeader.setValue(cpimAddressAsString(message->getFromAddress())); + Cpim::FromHeader cpimFromHeader(cpimAddressUri(message->getFromAddress()), cpimAddressDisplayName(message->getFromAddress())); cpimMessage.addMessageHeader(cpimFromHeader); - Cpim::ToHeader cpimToHeader; - cpimToHeader.setValue(cpimAddressAsString(message->getToAddress())); + Cpim::ToHeader cpimToHeader(cpimAddressUri(message->getToAddress()), cpimAddressDisplayName(message->getToAddress())); cpimMessage.addMessageHeader(cpimToHeader); if (message->getPrivate()->getPositiveDeliveryNotificationRequired() @@ -50,8 +48,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetPrivate()->getDisplayNotificationRequired() ) { const string imdnNamespace = "imdn"; - Cpim::NsHeader cpimNsHeader; - cpimNsHeader.setValue(imdnNamespace + " "); + Cpim::NsHeader cpimNsHeader(imdnNamespace, ""); cpimMessage.addMessageHeader(cpimNsHeader); char token[13]; @@ -88,18 +85,12 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetBodyAsString(); if (content->getContentDisposition().isValid()) { - Cpim::GenericHeader contentDispositionHeader; - contentDispositionHeader.setName("Content-Disposition"); - contentDispositionHeader.setValue(content->getContentDisposition().asString()); + Cpim::GenericHeader contentDispositionHeader("Content-Disposition", content->getContentDisposition().asString()); cpimMessage.addContentHeader(contentDispositionHeader); } - Cpim::GenericHeader contentTypeHeader; - contentTypeHeader.setName("Content-Type"); - contentTypeHeader.setValue(content->getContentType().asString()); + Cpim::GenericHeader contentTypeHeader("Content-Type", content->getContentType().asString()); cpimMessage.addContentHeader(contentTypeHeader); - Cpim::GenericHeader contentLengthHeader; - contentLengthHeader.setName("Content-Length"); - contentLengthHeader.setValue(to_string(contentBody.size())); + Cpim::GenericHeader contentLengthHeader("Content-Length", to_string(contentBody.size())); cpimMessage.addContentHeader(contentLengthHeader); cpimMessage.setContent(contentBody); @@ -203,12 +194,12 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptr"; - return os.str(); +string CpimChatMessageModifier::cpimAddressDisplayName (const Address &addr) const { + return addr.getDisplayName(); +} + +string CpimChatMessageModifier::cpimAddressUri (const Address &addr) const { + return addr.asStringUriOnly(); } LINPHONE_END_NAMESPACE diff --git a/src/chat/modifier/cpim-chat-message-modifier.h b/src/chat/modifier/cpim-chat-message-modifier.h index ab63c74e6..04dab858a 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.h +++ b/src/chat/modifier/cpim-chat-message-modifier.h @@ -34,7 +34,8 @@ public: Result decode (const std::shared_ptr &message, int &errorCode) override; private: - std::string cpimAddressAsString (const Address &addr) const; + std::string cpimAddressDisplayName (const Address &addr) const; + std::string cpimAddressUri (const Address &addr) const; }; LINPHONE_END_NAMESPACE From ec400bfe4a931f4126694cda0081b08ab0e137fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:04:22 +0200 Subject: [PATCH 071/143] Adapted tm to time_t and time_t to tm conversions for windows --- src/utils/utils.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 897f5dc8f..a2eda88c3 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -27,6 +27,10 @@ #include "linphone/utils/utils.h" +#include "logger/logger.h" + +#include "private.h" + // ============================================================================= using namespace std; @@ -184,12 +188,42 @@ string Utils::trim (const string &str) { // ----------------------------------------------------------------------------- tm Utils::getTimeTAsTm (time_t time) { - tm result; - return *gmtime_r(&time, &result); + #ifndef _WIN32 + tm result; + return *gmtime_r(&time, &result); + #else + return *gmtime(&time); + #endif } time_t Utils::getTmAsTimeT (const tm &time) { - return timegm(&const_cast(time)); + time_t result; + + #if defined(LINPHONE_WINDOWS_UNIVERSAL) || defined(LINPHONE_MSC_VER_GREATER_19) + long adjust_timezone; + #else + time_t adjust_timezone; + #endif + + #if TARGET_IPHONE_SIMULATOR + result = timegm(&const_cast(time)); + adjust_timezone = 0; + #else + result = mktime(&const_cast(time)); + + #if defined(LINPHONE_WINDOWS_UNIVERSAL) || defined(LINPHONE_MSC_VER_GREATER_19) + _get_timezone(&adjust_timezone); + #else + adjust_timezone = timezone; + #endif + #endif + + if (result == (time_t)-1) { + lError() << "mktime failed: " << strerror(errno); + return (time_t)-1; + } + + return result - (time_t)adjust_timezone; } // ----------------------------------------------------------------------------- From df89ba16f74eed3fb66955f8049f64b31286d446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:04:38 +0200 Subject: [PATCH 072/143] Adapted test to new changes --- tester/cpim-tester.cpp | 247 +++++++---------------------------------- 1 file changed, 40 insertions(+), 207 deletions(-) diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 83a45430e..51d8c1776 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -37,7 +37,7 @@ using namespace std; using namespace LinphonePrivate; static void parse_minimal_message () { - const string str = "Content-type: Message/CPIM\r\n" + const string str = "Subject: the weather will be fine today\r\n" "\r\n" "Content-Type: text/plain; charset=utf-8\r\n" "\r\n"; @@ -54,13 +54,6 @@ static void parse_minimal_message () { static void set_generic_header_name () { const list > entries = { - { "toto", true }, - { "george.abitbol", true }, - { "tata/titi", false }, - { "hey ho", false }, - { " fail", false }, - { "fail2 ", false }, - // Reserved. { "From", false }, { "To", false }, @@ -68,59 +61,21 @@ static void set_generic_header_name () { { "DateTime", false }, { "Subject", false }, { "NS", false }, - { "Require", false }, - - // Case sensitivity. - { "FROM", true }, - { "to", true }, - { "cC", true }, - { "Datetime", true }, - { "SuBject", true }, - { "nS", true }, - { "requirE", true } + { "Require", false } }; for (const auto &entry : entries) { - Cpim::GenericHeader genericHeader; - - const bool result = genericHeader.setName(entry.first); - BC_ASSERT_EQUAL(result, entry.second, bool, "%d"); + Cpim::GenericHeader genericHeader(entry.first, ""); + genericHeader.setName(entry.first); const string name = genericHeader.getName(); - if (result) - BC_ASSERT_STRING_EQUAL(name.c_str(), entry.first.c_str()); - else - BC_ASSERT_STRING_EQUAL(name.c_str(), ""); - } -} - -static void set_generic_header_value () { - const list > entries = { - { "MyFeatures ", true }, - { "2000-12-13T13:40:00-08:00", true }, - { "2000-12-13T13:40:00-08:00", true }, - { "text/xml; charset=utf-8", true }, - { "text/xml; charset=ut\r\nf-8", false } - }; - - for (const auto &entry : entries) { - Cpim::GenericHeader genericHeader; - - const bool result = genericHeader.setValue(entry.first); - BC_ASSERT_EQUAL(result, entry.second, bool, "%d"); - - const string value = genericHeader.getValue(); - - if (result) - BC_ASSERT_STRING_EQUAL(value.c_str(), entry.first.c_str()); - else - BC_ASSERT_STRING_EQUAL(value.c_str(), ""); + BC_ASSERT_STRING_EQUAL(name.c_str(), entry.first.c_str()); } } static void check_core_header_names () { - const list, string> > entries = { + const list, string> > entries = { { make_shared(), "From" }, { make_shared(), "To" }, { make_shared(), "cc" }, @@ -136,118 +91,13 @@ static void check_core_header_names () { } } -static void set_core_header_values () { - const list, list > > > entries = { - { make_shared(), { - { "Winnie the Pooh ", true }, - { "", true }, - { "", true }, - { "toto", false } - } }, - { make_shared(), { - { "", true }, - { "toto", false }, - { "", true }, - { "", true } - } }, - { make_shared(), { - { "", true }, - { "", true }, - { "", true }, - { "toto", false } - } }, - { make_shared(), { - { "abcd", false }, - { "1985-04-12T23:20:50.52Z", true }, - { "1996-12-19T16:39:57-08:00", true }, - { "1990-12-31T23:59:60Z", true }, - { "1990-12-31T15:59:60-08:00", true }, - { "2001-02-29T10:10:10Z", false }, - { "2000-02-29T10:10:10Z", true }, - { "1937-01-01T12:00:27.87+00:20", true }, - { "1937-01-01T12:00:27.87Z", true }, - { "1956", false } - } }, - { make_shared(), { - { "Eeyore's feeling very depressed today", true }, - { "🤣", true }, - { "hello", true } - } }, - { make_shared(), { - { "MyAlias ", true }, - { "What is this? - Barry Burton", false }, - { "", true }, - { "(), { - { "MyAlias.VitalHeader", true }, - { "MyAlias.VitalHeader,Test", true }, - { "MyAlias.VitalHeader,🤣", false } - } } - }; - - for (const auto &entry : entries) { - const shared_ptr header = entry.first; - string previousValue; - - for (const auto &test : entry.second) { - const bool result = header->setValue(test.first); - BC_ASSERT_EQUAL(result, test.second, bool, "%d"); - - const string value = header->getValue(); - - if (result) - BC_ASSERT_STRING_EQUAL(value.c_str(), test.first.c_str()); - else - BC_ASSERT_STRING_EQUAL(value.c_str(), previousValue.c_str()); - - previousValue = value; - } - } -} - -static void check_subject_header_language () { - Cpim::SubjectHeader subjectHeader; - - // Check for not defined language. - { - const string language = subjectHeader.getLanguage(); - BC_ASSERT_STRING_EQUAL(language.c_str(), ""); - } - - // Set valid language. - { - const string languageToSet = "fr"; - - BC_ASSERT_TRUE(subjectHeader.setLanguage(languageToSet)); - BC_ASSERT_TRUE(languageToSet == subjectHeader.getLanguage()); - - const string str = subjectHeader.asString(); - const string expected = "Subject:;lang=" + languageToSet + " \r\n"; - BC_ASSERT_STRING_EQUAL(str.c_str(), expected.c_str()); - } - - // Set invalid language. - { - const string languageToSet = "fr--"; - BC_ASSERT_FALSE(subjectHeader.setLanguage(languageToSet)); - BC_ASSERT_FALSE(languageToSet == subjectHeader.getLanguage()); - BC_ASSERT_FALSE(subjectHeader.isValid()); - } -} - static void parse_rfc_example () { const string body = "" "Here is the text of my message." ""; - const string str = "Content-type: Message/CPIM\r\n" - "\r\n" - "From: MR SANDERS \r\n" - "To: Depressed Donkey \r\n" + const string str = "From: \"MR SANDERS\"\r\n" + "To: \"Depressed Donkey\"\r\n" "DateTime: 2000-12-13T13:40:00-08:00\r\n" "Subject: the weather will be fine today\r\n" "Subject:;lang=fr beau temps prevu pour aujourd'hui\r\n" @@ -275,9 +125,7 @@ static void parse_message_with_generic_header_parameters () { "Here is the text of my message." ""; - const string str = "Content-type: Message/CPIM\r\n" - "\r\n" - "From: MR SANDERS \r\n" + const string str = "From: \"MR SANDERS\"\r\n" "Test:;aaa=bbb;yes=no CheckMe\r\n" "yaya: coucou\r\n" "yepee:;good=bad ugly\r\n" @@ -298,50 +146,41 @@ static void parse_message_with_generic_header_parameters () { static void build_message () { Cpim::Message message; - if (!BC_ASSERT_FALSE(message.isValid())) - return; - - // Set CPIM headers. - Cpim::GenericHeader cpimContentTypeHeader; - if (!BC_ASSERT_TRUE(cpimContentTypeHeader.setName("Content-Type"))) return; - if (!BC_ASSERT_TRUE(cpimContentTypeHeader.setValue("Message/CPIM"))) return; - - if (!BC_ASSERT_TRUE(message.addCpimHeader(cpimContentTypeHeader))) return; // Set message headers. - Cpim::FromHeader fromHeader; - if (!BC_ASSERT_TRUE(fromHeader.setValue("MR SANDERS "))) return; + Cpim::FromHeader fromHeader("im:piglet@100akerwood.com", "MR SANDERS"); + //if (!BC_ASSERT_TRUE(fromHeader.setValue("MR SANDERS "))) return; - Cpim::ToHeader toHeader; - if (!BC_ASSERT_TRUE(toHeader.setValue("Depressed Donkey "))) return; + Cpim::ToHeader toHeader("im:eeyore@100akerwood.com", "Depressed Donkey"); + //if (!BC_ASSERT_TRUE(toHeader.setValue("Depressed Donkey "))) return; - Cpim::DateTimeHeader dateTimeHeader; - if (!BC_ASSERT_TRUE(dateTimeHeader.setValue("2000-12-13T13:40:00-08:00"))) return; + //Cpim::DateTimeHeader dateTimeHeader; //TODO value + //if (!BC_ASSERT_TRUE(dateTimeHeader.setValue("2000-12-13T13:40:00-08:00"))) return; - Cpim::SubjectHeader subjectHeader; - if (!BC_ASSERT_TRUE(subjectHeader.setValue("the weather will be fine today"))) return; + Cpim::SubjectHeader subjectHeader("the weather will be fine today"); + //if (!BC_ASSERT_TRUE(subjectHeader.setValue("the weather will be fine today"))) return; - Cpim::SubjectHeader subjectWithLanguageHeader; - if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setValue("beau temps prevu pour aujourd'hui"))) return; - if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setLanguage("fr"))) return; + Cpim::SubjectHeader subjectWithLanguageHeader("beau temps prevu pour aujourd'hui", "fr"); + //if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setValue("beau temps prevu pour aujourd'hui"))) return; + //if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setLanguage("fr"))) return; - Cpim::NsHeader nsHeader; - if (!BC_ASSERT_TRUE(nsHeader.setValue("MyFeatures "))) return; + Cpim::NsHeader nsHeader("mid:MessageFeatures@id.foo.com", "MyFeatures"); + //if (!BC_ASSERT_TRUE(nsHeader.setValue("MyFeatures "))) return; - Cpim::RequireHeader requireHeader; - if (!BC_ASSERT_TRUE(requireHeader.setValue("MyFeatures.VitalMessageOption"))) return; + Cpim::RequireHeader requireHeader("MyFeatures.VitalMessageOption"); + //if (!BC_ASSERT_TRUE(requireHeader.setValue("MyFeatures.VitalMessageOption"))) return; - Cpim::GenericHeader vitalMessageHeader; - if (!BC_ASSERT_TRUE(vitalMessageHeader.setName("MyFeatures.VitalMessageOption"))) return; - if (!BC_ASSERT_TRUE(vitalMessageHeader.setValue("Confirmation-requested"))) return; + Cpim::GenericHeader vitalMessageHeader("MyFeatures.VitalMessageOption", "Confirmation-requested"); + //if (!BC_ASSERT_TRUE(vitalMessageHeader.setName("MyFeatures.VitalMessageOption"))) return; + //if (!BC_ASSERT_TRUE(vitalMessageHeader.setValue("Confirmation-requested"))) return; - Cpim::GenericHeader wackyMessageHeader; - if (!BC_ASSERT_TRUE(wackyMessageHeader.setName("MyFeatures.WackyMessageOption"))) return; - if (!BC_ASSERT_TRUE(wackyMessageHeader.setValue("Use-silly-font"))) return; + Cpim::GenericHeader wackyMessageHeader("MyFeatures.WackyMessageOption", "Use-silly-font"); + //if (!BC_ASSERT_TRUE(wackyMessageHeader.setName("MyFeatures.WackyMessageOption"))) return; + //if (!BC_ASSERT_TRUE(wackyMessageHeader.setValue("Use-silly-font"))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(fromHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(toHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return; + //if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectWithLanguageHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(nsHeader))) return; @@ -350,14 +189,14 @@ static void build_message () { if (!BC_ASSERT_TRUE(message.addMessageHeader(wackyMessageHeader))) return; // Set Content headers. - Cpim::GenericHeader contentTypeHeader; - if (!BC_ASSERT_TRUE(contentTypeHeader.setName("Content-Type"))) return; - if (!BC_ASSERT_TRUE( contentTypeHeader.setValue("text/xml; charset=utf-8"))) return; + Cpim::GenericHeader contentTypeHeader("Content-Type", "text/xml; charset=utf-8"); + //if (!BC_ASSERT_TRUE(contentTypeHeader.setName("Content-Type"))) return; + //if (!BC_ASSERT_TRUE( contentTypeHeader.setValue("text/xml; charset=utf-8"))) return; if (!BC_ASSERT_TRUE(message.addContentHeader(contentTypeHeader))) return; - Cpim::GenericHeader contentIdHeader; - if (!BC_ASSERT_TRUE(contentIdHeader.setName("Content-ID"))) return; - if (!BC_ASSERT_TRUE( contentIdHeader.setValue("<1234567890@foo.com>"))) return; + Cpim::GenericHeader contentIdHeader("Content-ID", "<1234567890@foo.com>"); + //if (!BC_ASSERT_TRUE(contentIdHeader.setName("Content-ID"))) return; + //if (!BC_ASSERT_TRUE( contentIdHeader.setValue("<1234567890@foo.com>"))) return; if (!BC_ASSERT_TRUE(message.addContentHeader(contentIdHeader))) return; const string content = "" @@ -365,14 +204,11 @@ static void build_message () { ""; if (!BC_ASSERT_TRUE(message.setContent(content))) return; - if (!BC_ASSERT_TRUE(message.isValid())) return; const string strMessage = message.asString(); - const string expectedMessage = "Content-Type: Message/CPIM\r\n" - "\r\n" - "From: MR SANDERS \r\n" - "To: Depressed Donkey \r\n" - "DateTime: 2000-12-13T13:40:00-08:00\r\n" + const string expectedMessage = "From: \"MR SANDERS\"\r\n" + "To: \"Depressed Donkey\"\r\n" + //"DateTime: 2000-12-13T13:40:00-08:00\r\n" "Subject: the weather will be fine today\r\n" "Subject:;lang=fr beau temps prevu pour aujourd'hui\r\n" "NS: MyFeatures \r\n" @@ -471,10 +307,7 @@ static void cpim_chat_message_modifier_with_multipart_body () { test_t cpim_tests[] = { TEST_NO_TAG("Parse minimal CPIM message", parse_minimal_message), TEST_NO_TAG("Set generic header name", set_generic_header_name), - TEST_NO_TAG("Set generic header value", set_generic_header_value), TEST_NO_TAG("Check core header names", check_core_header_names), - TEST_NO_TAG("Set core header values", set_core_header_values), - TEST_NO_TAG("Check Subject header language", check_subject_header_language), TEST_NO_TAG("Parse RFC example", parse_rfc_example), TEST_NO_TAG("Parse Message with generic header parameters", parse_message_with_generic_header_parameters), TEST_NO_TAG("Build Message", build_message), From aaec49c6da4890b36f347bf29ad0b00d047fda70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:05:16 +0200 Subject: [PATCH 073/143] Updated the new cpim_grammar binary --- share/cpim_grammar | Bin 5158 -> 5340 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/share/cpim_grammar b/share/cpim_grammar index 7ea914ca5fe9dc16205704b241c8649960421b6c..b3f2a560f3d2caa03421e09fcddbe7b7996e8e9a 100644 GIT binary patch delta 462 zcmZ3caYu8)BSw~qk5xFil8bWE7+8{%CpQY3O?F`9P-IQc&nrpIE78qJO-xBGDrNwI z|3JV65n!0?!MKZ&Wim696FWpV=VW~*vCT0|1&l!9v&?$jP(#y-@^eAPZZ=~{WZb-g zwT!u*g)29;xHvIA6>d62Ef>0_5Mfqy)iAd(F)#v|99$qPphhupmE^;jDTyViC7HP} zYZ$nalR2tZuNdet znawF&G0Z@TgS@t^U>UTE;?mL=wtrcQPjDB$J- vyRbMjJ&$4XF@aWfCIlbkJ0?a3ZAL~0T}Bp!$AH2tlcNMxpw`t2u4DoLH?@vv delta 251 zcmcbkxlCiiBSz+lk5wk~GCEGqXWYfeJXwp$X>$=%J0p17 From 31b9e4589f3deb1e08ceef7a7f914068c6b1c564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:16:08 +0200 Subject: [PATCH 074/143] Removed useless asserts --- src/chat/cpim/header/cpim-core-headers.cpp | 42 +++++++++++----------- tester/cpim-tester.cpp | 29 ++++++--------- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/src/chat/cpim/header/cpim-core-headers.cpp b/src/chat/cpim/header/cpim-core-headers.cpp index 0da0b2721..908c99a50 100644 --- a/src/chat/cpim/header/cpim-core-headers.cpp +++ b/src/chat/cpim/header/cpim-core-headers.cpp @@ -133,8 +133,8 @@ string Cpim::MessageIdHeader::asString () const { class Cpim::DateTimeHeaderPrivate : public HeaderPrivate { public: - tm timeT; - tm timeTOffset; + tm dateTime; + tm dateTimeOffset; string signOffset; }; @@ -151,13 +151,13 @@ Cpim::DateTimeHeader::DateTimeHeader (const tm &time, const tm &timeOffset, cons time_t Cpim::DateTimeHeader::getTime () const { L_D(); - tm result = d->timeT; + tm result = d->dateTime; result.tm_year -= 1900; result.tm_isdst = 0; if (d->signOffset == "+") { - result.tm_hour += d->timeTOffset.tm_hour; - result.tm_min += d->timeTOffset.tm_min; + result.tm_hour += d->dateTimeOffset.tm_hour; + result.tm_min += d->dateTimeOffset.tm_min; while (result.tm_min > 59) { result.tm_hour++; @@ -165,8 +165,8 @@ time_t Cpim::DateTimeHeader::getTime () const { } } else if (d->signOffset == "-") { - result.tm_hour -= d->timeTOffset.tm_hour; - result.tm_hour -= d->timeTOffset.tm_min; + result.tm_hour -= d->dateTimeOffset.tm_hour; + result.tm_hour -= d->dateTimeOffset.tm_min; while (result.tm_min < 0) { result.tm_hour--; @@ -181,8 +181,8 @@ bool Cpim::DateTimeHeader::setTime (const time_t time) { L_D(); d->signOffset = "Z"; - d->timeT = Utils::getTimeTAsTm(time); - d->timeT.tm_year += 1900; + d->dateTime = Utils::getTimeTAsTm(time); + d->dateTime.tm_year += 1900; return true; } @@ -190,8 +190,8 @@ bool Cpim::DateTimeHeader::setTime (const time_t time) { bool Cpim::DateTimeHeader::setTime (const tm &time, const tm &timeOffset, const string &signOffset) { L_D(); - d->timeT = time; - d->timeTOffset = timeOffset; + d->dateTime = time; + d->dateTimeOffset = timeOffset; d->signOffset = signOffset; return true; @@ -201,17 +201,17 @@ string Cpim::DateTimeHeader::getValue () const { L_D(); stringstream ss; - ss << setfill('0') << setw(4) << d->timeT.tm_year << "-" - << setfill('0') << setw(2) << d->timeT.tm_mon << "-" - << setfill('0') << setw(2) << d->timeT.tm_mday << "T" - << setfill('0') << setw(2) << d->timeT.tm_hour << ":" - << setfill('0') << setw(2) << d->timeT.tm_min << ":" - << setfill('0') << setw(2) << d->timeT.tm_sec; + ss << setfill('0') << setw(4) << d->dateTime.tm_year << "-" + << setfill('0') << setw(2) << d->dateTime.tm_mon << "-" + << setfill('0') << setw(2) << d->dateTime.tm_mday << "T" + << setfill('0') << setw(2) << d->dateTime.tm_hour << ":" + << setfill('0') << setw(2) << d->dateTime.tm_min << ":" + << setfill('0') << setw(2) << d->dateTime.tm_sec; ss << d->signOffset; if (d->signOffset != "Z") - ss << setfill('0') << setw(2) << d->timeTOffset.tm_hour << ":" - << setfill('0') << setw(2) << d->timeTOffset.tm_min; + ss << setfill('0') << setw(2) << d->dateTimeOffset.tm_hour << ":" + << setfill('0') << setw(2) << d->dateTimeOffset.tm_min; return ss.str(); } @@ -222,12 +222,12 @@ string Cpim::DateTimeHeader::asString () const { struct tm Cpim::DateTimeHeader::getTimeStruct () const { L_D(); - return d->timeT; + return d->dateTime; } struct tm Cpim::DateTimeHeader::getTimeOffset () const { L_D(); - return d->timeTOffset; + return d->dateTimeOffset; } string Cpim::DateTimeHeader::getSignOffset () const { diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 51d8c1776..edca28a64 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -149,38 +149,33 @@ static void build_message () { // Set message headers. Cpim::FromHeader fromHeader("im:piglet@100akerwood.com", "MR SANDERS"); - //if (!BC_ASSERT_TRUE(fromHeader.setValue("MR SANDERS "))) return; Cpim::ToHeader toHeader("im:eeyore@100akerwood.com", "Depressed Donkey"); - //if (!BC_ASSERT_TRUE(toHeader.setValue("Depressed Donkey "))) return; - //Cpim::DateTimeHeader dateTimeHeader; //TODO value - //if (!BC_ASSERT_TRUE(dateTimeHeader.setValue("2000-12-13T13:40:00-08:00"))) return; + tm dateTime = { 0 }, offset = { 0 }; + dateTime.tm_year = 2000; + dateTime.tm_mon = 12; + dateTime.tm_mday = 13; + dateTime.tm_hour = 13; + dateTime.tm_min = 40; + offset.tm_hour = 8; + Cpim::DateTimeHeader dateTimeHeader(dateTime, offset, "-"); Cpim::SubjectHeader subjectHeader("the weather will be fine today"); - //if (!BC_ASSERT_TRUE(subjectHeader.setValue("the weather will be fine today"))) return; Cpim::SubjectHeader subjectWithLanguageHeader("beau temps prevu pour aujourd'hui", "fr"); - //if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setValue("beau temps prevu pour aujourd'hui"))) return; - //if (!BC_ASSERT_TRUE(subjectWithLanguageHeader.setLanguage("fr"))) return; Cpim::NsHeader nsHeader("mid:MessageFeatures@id.foo.com", "MyFeatures"); - //if (!BC_ASSERT_TRUE(nsHeader.setValue("MyFeatures "))) return; Cpim::RequireHeader requireHeader("MyFeatures.VitalMessageOption"); - //if (!BC_ASSERT_TRUE(requireHeader.setValue("MyFeatures.VitalMessageOption"))) return; Cpim::GenericHeader vitalMessageHeader("MyFeatures.VitalMessageOption", "Confirmation-requested"); - //if (!BC_ASSERT_TRUE(vitalMessageHeader.setName("MyFeatures.VitalMessageOption"))) return; - //if (!BC_ASSERT_TRUE(vitalMessageHeader.setValue("Confirmation-requested"))) return; Cpim::GenericHeader wackyMessageHeader("MyFeatures.WackyMessageOption", "Use-silly-font"); - //if (!BC_ASSERT_TRUE(wackyMessageHeader.setName("MyFeatures.WackyMessageOption"))) return; - //if (!BC_ASSERT_TRUE(wackyMessageHeader.setValue("Use-silly-font"))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(fromHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(toHeader))) return; - //if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return; + if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectWithLanguageHeader))) return; if (!BC_ASSERT_TRUE(message.addMessageHeader(nsHeader))) return; @@ -190,13 +185,9 @@ static void build_message () { // Set Content headers. Cpim::GenericHeader contentTypeHeader("Content-Type", "text/xml; charset=utf-8"); - //if (!BC_ASSERT_TRUE(contentTypeHeader.setName("Content-Type"))) return; - //if (!BC_ASSERT_TRUE( contentTypeHeader.setValue("text/xml; charset=utf-8"))) return; if (!BC_ASSERT_TRUE(message.addContentHeader(contentTypeHeader))) return; Cpim::GenericHeader contentIdHeader("Content-ID", "<1234567890@foo.com>"); - //if (!BC_ASSERT_TRUE(contentIdHeader.setName("Content-ID"))) return; - //if (!BC_ASSERT_TRUE( contentIdHeader.setValue("<1234567890@foo.com>"))) return; if (!BC_ASSERT_TRUE(message.addContentHeader(contentIdHeader))) return; const string content = "" @@ -208,7 +199,7 @@ static void build_message () { const string strMessage = message.asString(); const string expectedMessage = "From: \"MR SANDERS\"\r\n" "To: \"Depressed Donkey\"\r\n" - //"DateTime: 2000-12-13T13:40:00-08:00\r\n" + "DateTime: 2000-12-13T13:40:00-08:00\r\n" "Subject: the weather will be fine today\r\n" "Subject:;lang=fr beau temps prevu pour aujourd'hui\r\n" "NS: MyFeatures \r\n" From 17d196447e4af2fba2e7973cb7fa711e181a2c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 15:53:48 +0200 Subject: [PATCH 075/143] struct tm month is 0 to 11 --- src/chat/cpim/header/cpim-core-headers.cpp | 2 +- src/chat/cpim/parser/cpim-parser.cpp | 2 +- tester/cpim-tester.cpp | 13 ++++--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/chat/cpim/header/cpim-core-headers.cpp b/src/chat/cpim/header/cpim-core-headers.cpp index 908c99a50..2c5b5be6b 100644 --- a/src/chat/cpim/header/cpim-core-headers.cpp +++ b/src/chat/cpim/header/cpim-core-headers.cpp @@ -202,7 +202,7 @@ string Cpim::DateTimeHeader::getValue () const { stringstream ss; ss << setfill('0') << setw(4) << d->dateTime.tm_year << "-" - << setfill('0') << setw(2) << d->dateTime.tm_mon << "-" + << setfill('0') << setw(2) << d->dateTime.tm_mon + 1 << "-" << setfill('0') << setw(2) << d->dateTime.tm_mday << "T" << setfill('0') << setw(2) << d->dateTime.tm_hour << ":" << setfill('0') << setw(2) << d->dateTime.tm_min << ":" diff --git a/src/chat/cpim/parser/cpim-parser.cpp b/src/chat/cpim/parser/cpim-parser.cpp index a918a802a..bd5d32df5 100644 --- a/src/chat/cpim/parser/cpim-parser.cpp +++ b/src/chat/cpim/parser/cpim-parser.cpp @@ -290,7 +290,7 @@ namespace Cpim { } void setMonth (const string &value) { - mTime.tm_mon = Utils::stoi(value); + mTime.tm_mon = Utils::stoi(value) - 1; } void setMonthDay (const string &value) { diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index edca28a64..79586cf3a 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -152,14 +152,9 @@ static void build_message () { Cpim::ToHeader toHeader("im:eeyore@100akerwood.com", "Depressed Donkey"); - tm dateTime = { 0 }, offset = { 0 }; - dateTime.tm_year = 2000; - dateTime.tm_mon = 12; - dateTime.tm_mday = 13; - dateTime.tm_hour = 13; - dateTime.tm_min = 40; - offset.tm_hour = 8; - Cpim::DateTimeHeader dateTimeHeader(dateTime, offset, "-"); + // 976686000 is 2000-12-13T13:40:00-08:00 + Cpim::DateTimeHeader dateTimeHeader(976686000); + BC_ASSERT_EQUAL(dateTimeHeader.getTime(), 976686000, int, "%d"); Cpim::SubjectHeader subjectHeader("the weather will be fine today"); @@ -199,7 +194,7 @@ static void build_message () { const string strMessage = message.asString(); const string expectedMessage = "From: \"MR SANDERS\"\r\n" "To: \"Depressed Donkey\"\r\n" - "DateTime: 2000-12-13T13:40:00-08:00\r\n" + "DateTime: 2000-12-13T05:40:00Z\r\n" "Subject: the weather will be fine today\r\n" "Subject:;lang=fr beau temps prevu pour aujourd'hui\r\n" "NS: MyFeatures \r\n" From 55909fbe162dce3be4b3571bf8cd46e1c5722302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Wed, 25 Apr 2018 16:32:08 +0200 Subject: [PATCH 076/143] Change setters from bool to void and fix crash when a specific header is malformed --- src/chat/cpim/header/cpim-core-headers.cpp | 80 ++++---------------- src/chat/cpim/header/cpim-core-headers.h | 20 ++--- src/chat/cpim/header/cpim-generic-header.cpp | 30 +++----- src/chat/cpim/header/cpim-generic-header.h | 8 +- src/chat/cpim/message/cpim-message.cpp | 8 +- src/chat/cpim/message/cpim-message.h | 4 +- src/chat/cpim/parser/cpim-parser.cpp | 16 +++- tester/cpim-tester.cpp | 28 ++++--- 8 files changed, 70 insertions(+), 124 deletions(-) diff --git a/src/chat/cpim/header/cpim-core-headers.cpp b/src/chat/cpim/header/cpim-core-headers.cpp index 2c5b5be6b..eedcaa173 100644 --- a/src/chat/cpim/header/cpim-core-headers.cpp +++ b/src/chat/cpim/header/cpim-core-headers.cpp @@ -53,14 +53,9 @@ string Cpim::ContactHeader::getUri () const { return d->uri; } -bool Cpim::ContactHeader::setUri (const string &uri) { - if (uri.empty()) - return false; - +void Cpim::ContactHeader::setUri (const string &uri) { L_D(); d->uri = uri; - - return true; } string Cpim::ContactHeader::getFormalName () const { @@ -68,10 +63,7 @@ string Cpim::ContactHeader::getFormalName () const { return d->formalName; } -bool Cpim::ContactHeader::setFormalName (const string &formalName) { - if (formalName.empty()) - return false; - +void Cpim::ContactHeader::setFormalName (const string &formalName) { L_D(); if (formalName.front() == '\"' && formalName.back() == '\"') d->formalName = formalName.substr(1, formalName.size() - 2); @@ -79,8 +71,6 @@ bool Cpim::ContactHeader::setFormalName (const string &formalName) { d->formalName = formalName.substr(0, formalName.size() - 1); else d->formalName = formalName; - - return true; } string Cpim::ContactHeader::getValue () const { @@ -102,8 +92,7 @@ public: Cpim::MessageIdHeader::MessageIdHeader () : Header(*new MessageIdHeaderPrivate) {} Cpim::MessageIdHeader::MessageIdHeader (const string &token) : MessageIdHeader() { - L_D(); - d->token = token; + setToken(token); } string Cpim::MessageIdHeader::getToken () const { @@ -111,14 +100,9 @@ string Cpim::MessageIdHeader::getToken () const { return d->token; } -bool Cpim::MessageIdHeader::setToken (string token) { - if (token.empty()) - return false; - +void Cpim::MessageIdHeader::setToken (string token) { L_D(); d->token = token; - - return true; } string Cpim::MessageIdHeader::getValue () const { @@ -177,24 +161,20 @@ time_t Cpim::DateTimeHeader::getTime () const { return Utils::getTmAsTimeT(result); } -bool Cpim::DateTimeHeader::setTime (const time_t time) { +void Cpim::DateTimeHeader::setTime (const time_t time) { L_D(); d->signOffset = "Z"; d->dateTime = Utils::getTimeTAsTm(time); d->dateTime.tm_year += 1900; - - return true; } -bool Cpim::DateTimeHeader::setTime (const tm &time, const tm &timeOffset, const string &signOffset) { +void Cpim::DateTimeHeader::setTime (const tm &time, const tm &timeOffset, const string &signOffset) { L_D(); d->dateTime = time; d->dateTimeOffset = timeOffset; d->signOffset = signOffset; - - return true; } string Cpim::DateTimeHeader::getValue () const { @@ -246,9 +226,8 @@ public: Cpim::NsHeader::NsHeader () : Header(*new NsHeaderPrivate) {} Cpim::NsHeader::NsHeader (const string &uri, const string &prefixName) : NsHeader() { - L_D(); - d->uri = uri; - d->prefixName = prefixName; + setUri(uri); + setPrefixName(prefixName); } string Cpim::NsHeader::getUri () const { @@ -256,14 +235,9 @@ string Cpim::NsHeader::getUri () const { return d->uri; } -bool Cpim::NsHeader::setUri (const string &uri) { - if (uri.empty()) - return false; - +void Cpim::NsHeader::setUri (const string &uri) { L_D(); d->uri = uri; - - return true; } string Cpim::NsHeader::getPrefixName () const { @@ -271,14 +245,9 @@ string Cpim::NsHeader::getPrefixName () const { return d->prefixName; } -bool Cpim::NsHeader::setPrefixName (const string &prefixName) { - if (prefixName.empty()) - return false; - +void Cpim::NsHeader::setPrefixName (const string &prefixName) { L_D(); d->prefixName = prefixName; - - return true; } string Cpim::NsHeader::getValue () const { @@ -305,9 +274,8 @@ public: Cpim::RequireHeader::RequireHeader () : Header(*new RequireHeaderPrivate) {} Cpim::RequireHeader::RequireHeader (const string &headerNames) : RequireHeader() { - L_D(); for (const string &header : Utils::split(headerNames, ",")) { - d->headerNames.push_back(header); + addHeaderName(header); } } @@ -321,14 +289,9 @@ list Cpim::RequireHeader::getHeaderNames () const { return d->headerNames; } -bool Cpim::RequireHeader::addHeaderName (const string &headerName) { - if (headerName.empty()) - return false; - +void Cpim::RequireHeader::addHeaderName (const string &headerName) { L_D(); d->headerNames.push_back(headerName); - - return true; } string Cpim::RequireHeader::getValue () const { @@ -359,9 +322,8 @@ public: Cpim::SubjectHeader::SubjectHeader () : Header(*new SubjectHeaderPrivate) {} Cpim::SubjectHeader::SubjectHeader (const string &subject, const string &language) : SubjectHeader() { - L_D(); - d->subject = subject; - d->language = language; + setSubject(subject); + setLanguage(language); } string Cpim::SubjectHeader::getSubject () const { @@ -369,14 +331,9 @@ string Cpim::SubjectHeader::getSubject () const { return d->subject; } -bool Cpim::SubjectHeader::setSubject (const string &subject) { - if (subject.empty()) - return false; - +void Cpim::SubjectHeader::setSubject (const string &subject) { L_D(); d->subject = subject; - - return true; } string Cpim::SubjectHeader::getLanguage () const { @@ -384,14 +341,9 @@ string Cpim::SubjectHeader::getLanguage () const { return d->language; } -bool Cpim::SubjectHeader::setLanguage (const string &language) { - if (!language.empty()) - return false; - +void Cpim::SubjectHeader::setLanguage (const string &language) { L_D(); d->language = language; - - return true; } string Cpim::SubjectHeader::getValue () const { diff --git a/src/chat/cpim/header/cpim-core-headers.h b/src/chat/cpim/header/cpim-core-headers.h index 89971cac0..d80acc869 100644 --- a/src/chat/cpim/header/cpim-core-headers.h +++ b/src/chat/cpim/header/cpim-core-headers.h @@ -57,10 +57,10 @@ namespace Cpim { ContactHeader (const std::string &uri, const std::string &formalName = ""); std::string getUri () const; - bool setUri (const std::string &uri); + void setUri (const std::string &uri); std::string getFormalName () const; - bool setFormalName (const std::string &formalName); + void setFormalName (const std::string &formalName); std::string getValue () const override; @@ -94,7 +94,7 @@ namespace Cpim { } std::string getToken () const; - bool setToken (std::string token); + void setToken (std::string token); std::string getValue () const override; @@ -126,9 +126,9 @@ namespace Cpim { } time_t getTime () const; - bool setTime (const time_t time); + void setTime (const time_t time); - bool setTime (const tm &time, const tm &timeOffset, const std::string &signOffset); + void setTime (const tm &time, const tm &timeOffset, const std::string &signOffset); std::string getValue () const override; @@ -160,10 +160,10 @@ namespace Cpim { } std::string getPrefixName () const; - bool setPrefixName (const std::string &prefixName); + void setPrefixName (const std::string &prefixName); std::string getUri () const; - bool setUri (const std::string &uri); + void setUri (const std::string &uri); std::string getValue () const override; @@ -192,7 +192,7 @@ namespace Cpim { } std::list getHeaderNames () const; - bool addHeaderName (const std::string &headerName); + void addHeaderName (const std::string &headerName); std::string getValue () const override; @@ -220,10 +220,10 @@ namespace Cpim { } std::string getSubject () const; - bool setSubject (const std::string &subject); + void setSubject (const std::string &subject); std::string getLanguage () const; - bool setLanguage (const std::string &language); + void setLanguage (const std::string &language); std::string getValue () const override; diff --git a/src/chat/cpim/header/cpim-generic-header.cpp b/src/chat/cpim/header/cpim-generic-header.cpp index 8e4bc57ab..6c5947777 100644 --- a/src/chat/cpim/header/cpim-generic-header.cpp +++ b/src/chat/cpim/header/cpim-generic-header.cpp @@ -34,24 +34,23 @@ LINPHONE_BEGIN_NAMESPACE class Cpim::GenericHeaderPrivate : public HeaderPrivate { public: - GenericHeaderPrivate () : parameters(make_shared > >()) {} + GenericHeaderPrivate () : parameters(make_shared>>()) {} string name; string value; - shared_ptr > > parameters; + shared_ptr>> parameters; }; Cpim::GenericHeader::GenericHeader () : Header(*new GenericHeaderPrivate) {} Cpim::GenericHeader::GenericHeader (string name, string value, string parameters) : GenericHeader() { - L_D(); - d->name = name; - d->value = value; + setName(name); + setValue(value); for (const auto ¶meter : Utils::split(parameters, ';')) { size_t equalIndex = parameter.find('='); if (equalIndex != string::npos) - d->parameters->push_back(make_pair(parameter.substr(0, equalIndex), parameter.substr(equalIndex + 1))); + addParameter(parameter.substr(0, equalIndex), parameter.substr(equalIndex + 1)); } } @@ -60,18 +59,15 @@ string Cpim::GenericHeader::getName () const { return d->name; } -bool Cpim::GenericHeader::setName (const string &name) { +void Cpim::GenericHeader::setName (const string &name) { L_D(); static const set reserved = { "From", "To", "cc", "DateTime", "Subject", "NS", "Require" }; - if (reserved.find(name) != reserved.end()) - return false; - - d->name = name; - return true; + if (reserved.find(name) == reserved.end()) + d->name = name; } string Cpim::GenericHeader::getValue () const { @@ -79,14 +75,9 @@ string Cpim::GenericHeader::getValue () const { return d->value; } -bool Cpim::GenericHeader::setValue (const string &value) { - if (value.empty()) - return false; - +void Cpim::GenericHeader::setValue (const string &value) { L_D(); d->value = value; - - return true; } Cpim::GenericHeader::ParameterList Cpim::GenericHeader::getParameters () const { @@ -94,10 +85,9 @@ Cpim::GenericHeader::ParameterList Cpim::GenericHeader::getParameters () const { return d->parameters; } -bool Cpim::GenericHeader::addParameter (const string &key, const string &value) { +void Cpim::GenericHeader::addParameter (const string &key, const string &value) { L_D(); d->parameters->push_back(make_pair(key, value)); - return true; } void Cpim::GenericHeader::removeParameter (const string &key, const string &value) { diff --git a/src/chat/cpim/header/cpim-generic-header.h b/src/chat/cpim/header/cpim-generic-header.h index 711b3c641..6ee8a3695 100644 --- a/src/chat/cpim/header/cpim-generic-header.h +++ b/src/chat/cpim/header/cpim-generic-header.h @@ -41,15 +41,15 @@ namespace Cpim { GenericHeader (std::string name, std::string value, std::string parameters = ""); std::string getName () const override; - bool setName (const std::string &name); + void setName (const std::string &name); std::string getValue () const override; - bool setValue (const std::string &value); + void setValue (const std::string &value); - typedef std::shared_ptr > > ParameterList; + typedef std::shared_ptr>> ParameterList; ParameterList getParameters () const; - bool addParameter (const std::string &key, const std::string &value); + void addParameter (const std::string &key, const std::string &value); void removeParameter (const std::string &key, const std::string &value); std::string asString () const override; diff --git a/src/chat/cpim/message/cpim-message.cpp b/src/chat/cpim/message/cpim-message.cpp index d6fb78080..18e148648 100644 --- a/src/chat/cpim/message/cpim-message.cpp +++ b/src/chat/cpim/message/cpim-message.cpp @@ -52,11 +52,9 @@ Cpim::Message::HeaderList Cpim::Message::getMessageHeaders () const { return d->messageHeaders; } -bool Cpim::Message::addMessageHeader (const Header &messageHeader) { +void Cpim::Message::addMessageHeader (const Header &messageHeader) { L_D(); - d->messageHeaders->push_back(Parser::getInstance()->cloneHeader(messageHeader)); - return true; } void Cpim::Message::removeMessageHeader (const Header &messageHeader) { @@ -73,11 +71,9 @@ Cpim::Message::HeaderList Cpim::Message::getContentHeaders () const { return d->contentHeaders; } -bool Cpim::Message::addContentHeader (const Header &contentHeader) { +void Cpim::Message::addContentHeader (const Header &contentHeader) { L_D(); - d->contentHeaders->push_back(Parser::getInstance()->cloneHeader(contentHeader)); - return true; } void Cpim::Message::removeContentHeader (const Header &contentHeader) { diff --git a/src/chat/cpim/message/cpim-message.h b/src/chat/cpim/message/cpim-message.h index 7c4ce693c..4177b4972 100644 --- a/src/chat/cpim/message/cpim-message.h +++ b/src/chat/cpim/message/cpim-message.h @@ -37,11 +37,11 @@ namespace Cpim { typedef std::shared_ptr > > HeaderList; HeaderList getMessageHeaders () const; - bool addMessageHeader (const Header &messageHeader); + void addMessageHeader (const Header &messageHeader); void removeMessageHeader (const Header &messageHeader); HeaderList getContentHeaders () const; - bool addContentHeader (const Header &contentHeader); + void addContentHeader (const Header &contentHeader); void removeContentHeader (const Header &contentHeader); std::string getContent () const; diff --git a/src/chat/cpim/parser/cpim-parser.cpp b/src/chat/cpim/parser/cpim-parser.cpp index bd5d32df5..a3201af22 100644 --- a/src/chat/cpim/parser/cpim-parser.cpp +++ b/src/chat/cpim/parser/cpim-parser.cpp @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include @@ -65,7 +66,12 @@ namespace Cpim { } void setName (const string &name) { - mName = name; + static const set reserved = { + "From", "To", "cc", "DateTime", "Subject", "NS", "Require" + }; + + if (reserved.find(name) == reserved.end()) + mName = name; } string getParameters () const { @@ -537,15 +543,19 @@ namespace Cpim { // Add message headers. for (const auto &headerNode : mMessageHeaders) { const shared_ptr header = headerNode->createHeader(); - if (!header || !message->addMessageHeader(*header)) + if (!header) return nullptr; + + message->addMessageHeader(*header); } // Add content headers. for (const auto &headerNode : mContentHeaders) { const shared_ptr header = headerNode->createHeader(); - if (!header || !message->addContentHeader(*header)) + if (!header) return nullptr; + + message->addContentHeader(*header); } return message; diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 79586cf3a..147dc4209 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -67,10 +67,8 @@ static void set_generic_header_name () { for (const auto &entry : entries) { Cpim::GenericHeader genericHeader(entry.first, ""); - genericHeader.setName(entry.first); const string name = genericHeader.getName(); - - BC_ASSERT_STRING_EQUAL(name.c_str(), entry.first.c_str()); + BC_ASSERT_STRING_EQUAL(name.c_str(), ""); } } @@ -168,22 +166,22 @@ static void build_message () { Cpim::GenericHeader wackyMessageHeader("MyFeatures.WackyMessageOption", "Use-silly-font"); - if (!BC_ASSERT_TRUE(message.addMessageHeader(fromHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(toHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(dateTimeHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(subjectWithLanguageHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(nsHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(requireHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(vitalMessageHeader))) return; - if (!BC_ASSERT_TRUE(message.addMessageHeader(wackyMessageHeader))) return; + message.addMessageHeader(fromHeader); + message.addMessageHeader(toHeader); + message.addMessageHeader(dateTimeHeader); + message.addMessageHeader(subjectHeader); + message.addMessageHeader(subjectWithLanguageHeader); + message.addMessageHeader(nsHeader); + message.addMessageHeader(requireHeader); + message.addMessageHeader(vitalMessageHeader); + message.addMessageHeader(wackyMessageHeader); // Set Content headers. Cpim::GenericHeader contentTypeHeader("Content-Type", "text/xml; charset=utf-8"); - if (!BC_ASSERT_TRUE(message.addContentHeader(contentTypeHeader))) return; + message.addContentHeader(contentTypeHeader); - Cpim::GenericHeader contentIdHeader("Content-ID", "<1234567890@foo.com>"); - if (!BC_ASSERT_TRUE(message.addContentHeader(contentIdHeader))) return; + Cpim::GenericHeader contentIdHeader("Content-ID", "<1234567890@foo.com>"); + message.addContentHeader(contentIdHeader); const string content = "" "Here is the text of my message." From daddec29d830ab251a2b8c108940dc109a8a3ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Thu, 26 Apr 2018 09:47:46 +0200 Subject: [PATCH 077/143] Changed Cpim message to be able to return headers from a specific namespace --- src/chat/cpim/message/cpim-message.cpp | 71 +++++++++++++++++++++----- src/chat/cpim/message/cpim-message.h | 10 ++-- src/chat/cpim/parser/cpim-parser.cpp | 11 +++- tester/cpim-tester.cpp | 8 +++ 4 files changed, 81 insertions(+), 19 deletions(-) diff --git a/src/chat/cpim/message/cpim-message.cpp b/src/chat/cpim/message/cpim-message.cpp index 18e148648..91bd670f6 100644 --- a/src/chat/cpim/message/cpim-message.cpp +++ b/src/chat/cpim/message/cpim-message.cpp @@ -18,6 +18,7 @@ */ #include +#include #include "linphone/utils/utils.h" @@ -36,9 +37,10 @@ LINPHONE_BEGIN_NAMESPACE class Cpim::MessagePrivate : public ObjectPrivate { public: - typedef list > PrivHeaderList; + using PrivHeaderList = list>; + using PrivHeaderMap = map>; - shared_ptr messageHeaders = make_shared(); + PrivHeaderMap messageHeaders; shared_ptr contentHeaders = make_shared(); string content; }; @@ -47,21 +49,47 @@ Cpim::Message::Message () : Object(*new MessagePrivate) {} // ----------------------------------------------------------------------------- -Cpim::Message::HeaderList Cpim::Message::getMessageHeaders () const { +Cpim::Message::HeaderList Cpim::Message::getMessageHeaders (const string &ns) const { L_D(); - return d->messageHeaders; + + if (d->messageHeaders.find(ns) == d->messageHeaders.end()) + return nullptr; + + return d->messageHeaders.at(ns); } -void Cpim::Message::addMessageHeader (const Header &messageHeader) { +void Cpim::Message::addMessageHeader (const Header &messageHeader, const string &ns) { L_D(); - d->messageHeaders->push_back(Parser::getInstance()->cloneHeader(messageHeader)); + + if (d->messageHeaders.find(ns) == d->messageHeaders.end()) + d->messageHeaders[ns] = make_shared(); + + auto list = d->messageHeaders.at(ns); + list->push_back(Parser::getInstance()->cloneHeader(messageHeader)); } -void Cpim::Message::removeMessageHeader (const Header &messageHeader) { +void Cpim::Message::removeMessageHeader (const Header &messageHeader, const string &ns) { L_D(); - d->messageHeaders->remove_if([&messageHeader](const shared_ptr &header) { - return messageHeader.getName() == header->getName() && messageHeader.getValue() == header->getValue(); - }); + + if (d->messageHeaders.find(ns) != d->messageHeaders.end()) + d->messageHeaders.at(ns)->remove_if([&messageHeader](const shared_ptr &header) { + return messageHeader.getName() == header->getName() && messageHeader.getValue() == header->getValue(); + }); +} + +shared_ptr Cpim::Message::getMessageHeader (const string &name, const string &ns) { + L_D(); + + if (d->messageHeaders.find(ns) == d->messageHeaders.end()) + return nullptr; + + auto list = d->messageHeaders.at(ns); + for (const auto &messageHeader : *list) { + if (messageHeader->getName() == name) + return messageHeader; + } + + return nullptr; } // ----------------------------------------------------------------------------- @@ -83,6 +111,17 @@ void Cpim::Message::removeContentHeader (const Header &contentHeader) { }); } +shared_ptr Cpim::Message::getContentHeader(const string &name) { + L_D(); + + for (const auto &contentHeader : *d->contentHeaders) { + if (contentHeader->getName() == name) + return contentHeader; + } + + return nullptr; +} + // ----------------------------------------------------------------------------- string Cpim::Message::getContent () const { @@ -102,9 +141,15 @@ string Cpim::Message::asString () const { L_D(); string output; - if (d->messageHeaders->size() > 0) { - for (const auto &messageHeader : *d->messageHeaders) - output += messageHeader->asString(); + if (d->messageHeaders.size() > 0) { + for (const auto &entry : d->messageHeaders) { + auto list = entry.second; + for (const auto &messageHeader : *list) { + if (entry.first != "") + output += entry.first + "."; + output += messageHeader->asString(); + } + } output += "\r\n"; } diff --git a/src/chat/cpim/message/cpim-message.h b/src/chat/cpim/message/cpim-message.h index 4177b4972..7745dfe76 100644 --- a/src/chat/cpim/message/cpim-message.h +++ b/src/chat/cpim/message/cpim-message.h @@ -34,15 +34,17 @@ namespace Cpim { public: Message (); - typedef std::shared_ptr > > HeaderList; + typedef std::shared_ptr>> HeaderList; - HeaderList getMessageHeaders () const; - void addMessageHeader (const Header &messageHeader); - void removeMessageHeader (const Header &messageHeader); + HeaderList getMessageHeaders (const std::string &ns = "") const; + void addMessageHeader (const Header &messageHeader, const std::string &ns = ""); + void removeMessageHeader (const Header &messageHeader, const std::string &ns = ""); + std::shared_ptr getMessageHeader (const std::string &name, const std::string &ns = ""); HeaderList getContentHeaders () const; void addContentHeader (const Header &contentHeader); void removeContentHeader (const Header &contentHeader); + std::shared_ptr getContentHeader (const std::string &name); std::string getContent () const; bool setContent (const std::string &content); diff --git a/src/chat/cpim/parser/cpim-parser.cpp b/src/chat/cpim/parser/cpim-parser.cpp index a3201af22..23fa0a360 100644 --- a/src/chat/cpim/parser/cpim-parser.cpp +++ b/src/chat/cpim/parser/cpim-parser.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include @@ -542,11 +541,19 @@ namespace Cpim { // Add message headers. for (const auto &headerNode : mMessageHeaders) { + string ns = ""; + + string::size_type n = headerNode->getName().find("."); + if (n != string::npos) { + ns = headerNode->getName().substr(0, n); + headerNode->setName(headerNode->getName().substr(n + 1)); + } + const shared_ptr header = headerNode->createHeader(); if (!header) return nullptr; - message->addMessageHeader(*header); + message->addMessageHeader(*header, ns); } // Add content headers. diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 147dc4209..7bac7d0fc 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -116,6 +116,14 @@ static void parse_rfc_example () { string content = message->getContent(); BC_ASSERT_STRING_EQUAL(content.c_str(), body.c_str()); + + Cpim::Message::HeaderList list = message->getMessageHeaders(); + if (!BC_ASSERT_PTR_NOT_NULL(list)) return; + BC_ASSERT_EQUAL(list->size(), 7, int, "%d"); + + list = message->getMessageHeaders("MyFeatures"); + if (!BC_ASSERT_PTR_NOT_NULL(list)) return; + BC_ASSERT_EQUAL(list->size(), 2, int, "%d"); } static void parse_message_with_generic_header_parameters () { From a0e40432171a0113ac2c317cbedcfe52c873c0b5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 17:05:00 +0200 Subject: [PATCH 078/143] Some cleaning in CPIM parser. --- src/chat/cpim/header/cpim-core-headers.cpp | 37 +++------------------- src/chat/cpim/header/cpim-core-headers.h | 28 ---------------- src/chat/cpim/message/cpim-message.cpp | 4 +-- src/chat/cpim/message/cpim-message.h | 6 ++-- 4 files changed, 10 insertions(+), 65 deletions(-) diff --git a/src/chat/cpim/header/cpim-core-headers.cpp b/src/chat/cpim/header/cpim-core-headers.cpp index eedcaa173..4f35651fe 100644 --- a/src/chat/cpim/header/cpim-core-headers.cpp +++ b/src/chat/cpim/header/cpim-core-headers.cpp @@ -75,7 +75,11 @@ void Cpim::ContactHeader::setFormalName (const string &formalName) { string Cpim::ContactHeader::getValue () const { L_D(); - return "\"" + d->formalName + "\"" + "<" + d->uri + ">"; + string result; + if (!d->formalName.empty()) + result += "\"" + d->formalName + "\""; + result += "<" + d->uri + ">"; + return result; } string Cpim::ContactHeader::asString () const { @@ -84,37 +88,6 @@ string Cpim::ContactHeader::asString () const { // ----------------------------------------------------------------------------- -class Cpim::MessageIdHeaderPrivate : public HeaderPrivate { -public: - string token; -}; - -Cpim::MessageIdHeader::MessageIdHeader () : Header(*new MessageIdHeaderPrivate) {} - -Cpim::MessageIdHeader::MessageIdHeader (const string &token) : MessageIdHeader() { - setToken(token); -} - -string Cpim::MessageIdHeader::getToken () const { - L_D(); - return d->token; -} - -void Cpim::MessageIdHeader::setToken (string token) { - L_D(); - d->token = token; -} - -string Cpim::MessageIdHeader::getValue () const { - return getToken(); -} - -string Cpim::MessageIdHeader::asString () const { - return getName() + ": " + getValue() + "\r\n"; -} - -// ----------------------------------------------------------------------------- - class Cpim::DateTimeHeaderPrivate : public HeaderPrivate { public: tm dateTime; diff --git a/src/chat/cpim/header/cpim-core-headers.h b/src/chat/cpim/header/cpim-core-headers.h index d80acc869..2ddd7ea29 100644 --- a/src/chat/cpim/header/cpim-core-headers.h +++ b/src/chat/cpim/header/cpim-core-headers.h @@ -77,34 +77,6 @@ namespace Cpim { MAKE_CONTACT_HEADER(To, "To"); MAKE_CONTACT_HEADER(Cc, "cc"); - // ------------------------------------------------------------------------- - // Specific MessageId declaration. - // ------------------------------------------------------------------------- - - class MessageIdHeaderPrivate; - - class LINPHONE_PUBLIC MessageIdHeader : public Header { - public: - MessageIdHeader (); - - MessageIdHeader (const std::string &token); - - inline std::string getName() const override { - return "Message-ID"; - } - - std::string getToken () const; - void setToken (std::string token); - - std::string getValue () const override; - - std::string asString () const override; - - private: - L_DECLARE_PRIVATE(MessageIdHeader); - L_DISABLE_COPY(MessageIdHeader); - }; - // ------------------------------------------------------------------------- // Specific DateTime declaration. // ------------------------------------------------------------------------- diff --git a/src/chat/cpim/message/cpim-message.cpp b/src/chat/cpim/message/cpim-message.cpp index 91bd670f6..ca4aa3b4d 100644 --- a/src/chat/cpim/message/cpim-message.cpp +++ b/src/chat/cpim/message/cpim-message.cpp @@ -77,7 +77,7 @@ void Cpim::Message::removeMessageHeader (const Header &messageHeader, const stri }); } -shared_ptr Cpim::Message::getMessageHeader (const string &name, const string &ns) { +shared_ptr Cpim::Message::getMessageHeader (const string &name, const string &ns) const { L_D(); if (d->messageHeaders.find(ns) == d->messageHeaders.end()) @@ -111,7 +111,7 @@ void Cpim::Message::removeContentHeader (const Header &contentHeader) { }); } -shared_ptr Cpim::Message::getContentHeader(const string &name) { +shared_ptr Cpim::Message::getContentHeader(const string &name) const { L_D(); for (const auto &contentHeader : *d->contentHeaders) { diff --git a/src/chat/cpim/message/cpim-message.h b/src/chat/cpim/message/cpim-message.h index 7745dfe76..19e91a43a 100644 --- a/src/chat/cpim/message/cpim-message.h +++ b/src/chat/cpim/message/cpim-message.h @@ -39,12 +39,12 @@ namespace Cpim { HeaderList getMessageHeaders (const std::string &ns = "") const; void addMessageHeader (const Header &messageHeader, const std::string &ns = ""); void removeMessageHeader (const Header &messageHeader, const std::string &ns = ""); - std::shared_ptr getMessageHeader (const std::string &name, const std::string &ns = ""); - + std::shared_ptr getMessageHeader (const std::string &name, const std::string &ns = "") const; + HeaderList getContentHeaders () const; void addContentHeader (const Header &contentHeader); void removeContentHeader (const Header &contentHeader); - std::shared_ptr getContentHeader (const std::string &name); + std::shared_ptr getContentHeader (const std::string &name) const; std::string getContent () const; bool setContent (const std::string &content); From 84afb118b3451c445e8446e0e28b38ea10e17d0f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 17:07:00 +0200 Subject: [PATCH 079/143] Improve CPIM grammar. --- share/cpim_grammar | Bin 5340 -> 5346 bytes src/chat/cpim/parser/cpim-rules | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/share/cpim_grammar b/share/cpim_grammar index b3f2a560f3d2caa03421e09fcddbe7b7996e8e9a..066afb55811392f443765d48c539188ba12c945a 100644 GIT binary patch delta 210 zcmcbk`ABoZBSz+lk5wk~GKNYp{s#gU1|VSK%1BL2NiAaFN-oMto1DkEn~{047L(KF zBBpjmAoCZq-ef(NwT!Hj@35F{mS7EM;b+QCEiO(>Pt}F!oZQKoXN)RT3^Ezn4peEV zU0*r(0xj6grLy@hS2Z(`8OdkM$TGQ+PjvGpzQrKR!vt(L&k!gCF}Z|Pm|05lCkrr| KZO#?SX9582W1Y8-Zi7BZ?lS>$PGqOxJ zU~*ywE8JYj)WHZ8_{FRT5tyvbvW}5$@--GSr~+=*2o@>U+|=UY#Pn2Mh$+PkAOJF! zX>t)~-egfOkf9g3;I`)#18tX?tj;RDS)JRH87NuEXA3oOE#EGXjTr(q>`=E(?iUc< Tyh|V&BrGPR0##=zw2}z`SVKch diff --git a/src/chat/cpim/parser/cpim-rules b/src/chat/cpim/parser/cpim-rules index d2837db2a..b11cccb9a 100644 --- a/src/chat/cpim/parser/cpim-rules +++ b/src/chat/cpim/parser/cpim-rules @@ -1,8 +1,11 @@ Message = Message-headers CRLF Content-headers CRLF -Message-headers = *( From-header / To-header / DateTime-header / cc-header / Subject-header / NS-header / Require-header / Header ) -Content-headers = *Header -Header = Header-name ":" Header-parameters SP Header-value CRLF +Message-headers = 1*( Message-header CRLF ) +Message-header = From-header / To-header / DateTime-header / cc-header / Subject-header / NS-header / Require-header / Header + +Content-headers = 1*( Header CRLF ) + +Header = Header-name ":" Header-parameters SP Header-value Header-name = [ Name-prefix "." ] Name Name-prefix = Name @@ -17,25 +20,25 @@ Param-value = Token / Number / String Header-value = *HEADERCHAR -From-header = %d70.114.111.109 ": " From-header-value CRLF +From-header = %d70.114.111.109 ": " From-header-value From-header-value = [ Formal-name ] "<" URI ">" -To-header = %d84.111 ": " To-header-value CRLF +To-header = %d84.111 ": " To-header-value To-header-value = [ Formal-name ] "<" URI ">" -DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value CRLF +DateTime-header = %d68.97.116.101.84.105.109.101 ": " DateTime-header-value DateTime-header-value = date-time -cc-header = %d99.99 ": " cc-header-value CRLF +cc-header = %d99.99 ": " cc-header-value cc-header-value = [ Formal-name ] "<" URI ">" -Subject-header = %d83.117.98.106.101.99.116 ":" Subject-header-value CRLF +Subject-header = %d83.117.98.106.101.99.116 ":" Subject-header-value Subject-header-value = [ ";" Lang-param ] SP Header-value -NS-header = %d78.83 ": " NS-header-value CRLF +NS-header = %d78.83 ": " NS-header-value NS-header-value = [ Name-prefix SP ] "<" URI ">" -Require-header = %d82.101.113.117.105.114.101 ": " Require-header-value CRLF +Require-header = %d82.101.113.117.105.114.101 ": " Require-header-value Require-header-value = Header-name *( "," Header-name ) Name = 1*NAMECHAR From 86bd71ce3384e3fbe53516fa7cecf2355cbb4492 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 17:02:50 +0200 Subject: [PATCH 080/143] Fix datetime values when fetching from database. --- src/db/main-db-p.h | 2 ++ src/db/main-db.cpp | 16 +++++++++++----- src/utils/utils.cpp | 6 +++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/db/main-db-p.h b/src/db/main-db-p.h index bd2076407..35c93f42d 100644 --- a/src/db/main-db-p.h +++ b/src/db/main-db-p.h @@ -44,6 +44,8 @@ private: // Misc helpers. // --------------------------------------------------------------------------- + static time_t getTmAsTimeT (const tm &t); + std::shared_ptr findChatRoom (const ChatRoomId &chatRoomId) const; // --------------------------------------------------------------------------- diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index dcb589a60..bd5245f67 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -226,6 +226,12 @@ static string buildSqlEventFilter ( // Misc helpers. // ----------------------------------------------------------------------------- +time_t MainDbPrivate::getTmAsTimeT (const tm &t) { + tm t2 = t; + t2.tm_isdst = 0; + return Utils::getTmAsTimeT(t2); +} + shared_ptr MainDbPrivate::findChatRoom (const ChatRoomId &chatRoomId) const { L_Q(); shared_ptr chatRoom = q->getCore()->findChatRoom(chatRoomId); @@ -610,7 +616,7 @@ shared_ptr MainDbPrivate::selectConferenceChatMessageEvent ( dChatMessage->forceFromAddress(IdentityAddress(row.get(3))); dChatMessage->forceToAddress(IdentityAddress(row.get(4))); - dChatMessage->setTime(Utils::getTmAsTimeT(row.get(5))); + dChatMessage->setTime(MainDbPrivate::getTmAsTimeT(row.get(5))); dChatMessage->setImdnMessageId(row.get(6)); dChatMessage->setPositiveDeliveryNotificationRequired(bool(row.get(14))); dChatMessage->setDisplayNotificationRequired(bool(row.get(15))); @@ -1976,7 +1982,7 @@ list MainDb::getChatMessageParticipantsThatHaveDisplay list result; for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Displayed, Utils::getTmAsTimeT(row.get(1))); + result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Displayed, MainDbPrivate::getTmAsTimeT(row.get(1))); return result; }; } @@ -2029,7 +2035,7 @@ list MainDb::getChatMessageParticipantsThatHaveReceive list result; for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::DeliveredToUser, Utils::getTmAsTimeT(row.get(1))); + result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::DeliveredToUser, MainDbPrivate::getTmAsTimeT(row.get(1))); return result; }; } @@ -2483,8 +2489,8 @@ list> MainDb::getChatRooms () const { continue; // Not fetched. AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); - dChatRoom->setCreationTime(Utils::getTmAsTimeT(creationTime)); - dChatRoom->setLastUpdateTime(Utils::getTmAsTimeT(lastUpdateTime)); + dChatRoom->setCreationTime(MainDbPrivate::getTmAsTimeT(creationTime)); + dChatRoom->setLastUpdateTime(MainDbPrivate::getTmAsTimeT(lastUpdateTime)); lInfo() << "Found chat room in DB: (peer=" << chatRoomId.getPeerAddress().asString() << ", local=" << chatRoomId.getLocalAddress().asString() << ")."; diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index a2eda88c3..b05174a63 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -188,11 +188,11 @@ string Utils::trim (const string &str) { // ----------------------------------------------------------------------------- tm Utils::getTimeTAsTm (time_t time) { - #ifndef _WIN32 + #ifdef _WIN32 + return *gmtime(&time); + #else tm result; return *gmtime_r(&time, &result); - #else - return *gmtime(&time); #endif } From 251147589c011d79c447fb104058759e6367c6cb Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 17:03:33 +0200 Subject: [PATCH 081/143] Improve CPIM chat message modifier with better use of CPIM parser. --- .../modifier/cpim-chat-message-modifier.cpp | 142 +++++++++--------- 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 04c73f9c1..39104a674 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -38,29 +38,30 @@ LINPHONE_BEGIN_NAMESPACE ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptr &message, int &errorCode) { Cpim::Message cpimMessage; - Cpim::FromHeader cpimFromHeader(cpimAddressUri(message->getFromAddress()), cpimAddressDisplayName(message->getFromAddress())); - cpimMessage.addMessageHeader(cpimFromHeader); - Cpim::ToHeader cpimToHeader(cpimAddressUri(message->getToAddress()), cpimAddressDisplayName(message->getToAddress())); - cpimMessage.addMessageHeader(cpimToHeader); + cpimMessage.addMessageHeader( + Cpim::FromHeader(cpimAddressUri(message->getFromAddress()), cpimAddressDisplayName(message->getFromAddress())) + ); + cpimMessage.addMessageHeader( + Cpim::ToHeader(cpimAddressUri(message->getToAddress()), cpimAddressDisplayName(message->getToAddress())) + ); + cpimMessage.addMessageHeader( + Cpim::DateTimeHeader(message->getTime()) + ); if (message->getPrivate()->getPositiveDeliveryNotificationRequired() || message->getPrivate()->getNegativeDeliveryNotificationRequired() || message->getPrivate()->getDisplayNotificationRequired() ) { const string imdnNamespace = "imdn"; - Cpim::NsHeader cpimNsHeader(imdnNamespace, ""); - cpimMessage.addMessageHeader(cpimNsHeader); + cpimMessage.addMessageHeader(Cpim::NsHeader("urn:ietf:params:imdn", imdnNamespace)); char token[13]; belle_sip_random_token(token, sizeof(token)); - Cpim::GenericHeader cpimMessageIdHeader; - cpimMessageIdHeader.setName("Message-ID"); // TODO: Replace by imdnNamespace + ".Message-ID"); - cpimMessageIdHeader.setValue(token); - cpimMessage.addMessageHeader(cpimMessageIdHeader); + cpimMessage.addMessageHeader( + Cpim::GenericHeader("Message-ID", token) // TODO: Replace by imdnNamespace + ".Message-ID"); + ); message->getPrivate()->setImdnMessageId(token); - Cpim::GenericHeader dispositionNotificationHeader; - dispositionNotificationHeader.setName(imdnNamespace + ".Disposition-Notification"); vector dispositionNotificationValues; if (message->getPrivate()->getPositiveDeliveryNotificationRequired()) dispositionNotificationValues.emplace_back("positive-delivery"); @@ -68,8 +69,12 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetPrivate()->getDisplayNotificationRequired()) dispositionNotificationValues.emplace_back("display"); - dispositionNotificationHeader.setValue(Utils::join(dispositionNotificationValues, ", ")); - cpimMessage.addMessageHeader(dispositionNotificationHeader); + cpimMessage.addMessageHeader( + Cpim::GenericHeader( + imdnNamespace + ".Disposition-Notification", + Utils::join(dispositionNotificationValues, ", ") + ) + ); } const Content *content; @@ -85,13 +90,16 @@ ChatMessageModifier::Result CpimChatMessageModifier::encode (const shared_ptrgetBodyAsString(); if (content->getContentDisposition().isValid()) { - Cpim::GenericHeader contentDispositionHeader("Content-Disposition", content->getContentDisposition().asString()); - cpimMessage.addContentHeader(contentDispositionHeader); + cpimMessage.addContentHeader( + Cpim::GenericHeader("Content-Disposition", content->getContentDisposition().asString()) + ); } - Cpim::GenericHeader contentTypeHeader("Content-Type", content->getContentType().asString()); - cpimMessage.addContentHeader(contentTypeHeader); - Cpim::GenericHeader contentLengthHeader("Content-Length", to_string(contentBody.size())); - cpimMessage.addContentHeader(contentLengthHeader); + cpimMessage.addContentHeader( + Cpim::GenericHeader("Content-Type", content->getContentType().asString()) + ); + cpimMessage.addContentHeader( + Cpim::GenericHeader("Content-Length", to_string(contentBody.size())) + ); cpimMessage.setContent(contentBody); Content newContent; @@ -116,76 +124,70 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetBodyAsString(); const shared_ptr cpimMessage = Cpim::Message::createFromString(contentBody); - if (!cpimMessage) { + if (!cpimMessage || !cpimMessage->getMessageHeader("From") || !cpimMessage->getMessageHeader("To")) { lError() << "[CPIM] Message is invalid: " << contentBody; errorCode = 500; return ChatMessageModifier::Result::Error; } Content newContent; - bool contentTypeFound = false; - Cpim::Message::HeaderList l = cpimMessage->getContentHeaders(); - if (l) { - for (const auto &header : *l.get()) { - if (header->getName() == "Content-Disposition") { - newContent.setContentDisposition(ContentDisposition(header->getValue())); - } else if (header->getName() == "Content-Type") { - contentTypeFound = true; - newContent.setContentType(ContentType(header->getValue())); - } - } - } - if (!contentTypeFound) { + auto contentTypeHeader = cpimMessage->getContentHeader("Content-Type"); + if (!contentTypeHeader) { lError() << "[CPIM] No Content-type for the content of the message"; errorCode = 500; return ChatMessageModifier::Result::Error; } + newContent.setContentType(ContentType(contentTypeHeader->getValue())); + auto contentDispositionHeader = cpimMessage->getContentHeader("Content-Disposition"); + if (contentDispositionHeader) + newContent.setContentDisposition(ContentDisposition(contentDispositionHeader->getValue())); newContent.setBody(cpimMessage->getContent()); message->getPrivate()->setPositiveDeliveryNotificationRequired(false); message->getPrivate()->setNegativeDeliveryNotificationRequired(false); message->getPrivate()->setDisplayNotificationRequired(false); - Address cpimFromAddress; - Address cpimToAddress; - l = cpimMessage->getMessageHeaders(); - if (l) { - string imdnNamespace = ""; - for (const auto &header : *l.get()) { - if (header->getName() == "NS") { - string val = header->getValue(); - size_t startPos = 0; - startPos = val.find("<", startPos); - if (startPos == string::npos) - break; - size_t endPos = 0; - endPos = val.find(">", startPos); - if (endPos == string::npos) - break; - if (val.substr(startPos, endPos) == "") - imdnNamespace = Utils::trim(val.substr(0, startPos)); - } - } - for (const auto &header : *l.get()) { - if (header->getName() == "From") - cpimFromAddress = Address(header->getValue()); - else if (header->getName() == "To") - cpimToAddress = Address(header->getValue()); - else if ((header->getName() == "Message-ID") || (header->getName() == (imdnNamespace + ".Message-ID"))) - message->getPrivate()->setImdnMessageId(header->getValue()); - else if ((header->getName() == (imdnNamespace + ".Disposition-Notification"))) { - vector values = Utils::split(header->getValue(), ", "); - for (const auto &value : values) - if (value == "positive-delivery") - message->getPrivate()->setPositiveDeliveryNotificationRequired(true); - else if (value == "negative-delivery") - message->getPrivate()->setNegativeDeliveryNotificationRequired(true); - else if (value == "display") - message->getPrivate()->setDisplayNotificationRequired(true); + string imdnNamespace = ""; + auto messageHeaders = cpimMessage->getMessageHeaders(); + if (messageHeaders) { + for (const auto &header : *messageHeaders.get()) { + if (header->getName() != "NS") + continue; + auto nsHeader = static_pointer_cast(header); + if (nsHeader->getUri() == "urn:ietf:params:imdn") { + imdnNamespace = nsHeader->getPrefixName(); + break; } } } + auto fromHeader = static_pointer_cast(cpimMessage->getMessageHeader("From")); + Address cpimFromAddress(fromHeader->getValue()); + auto toHeader = static_pointer_cast(cpimMessage->getMessageHeader("To")); + Address cpimToAddress(toHeader->getValue()); + auto dateTimeHeader = static_pointer_cast(cpimMessage->getMessageHeader("DateTime")); + if (dateTimeHeader) + message->getPrivate()->setTime(dateTimeHeader->getTime()); + + auto messageIdHeader = cpimMessage->getMessageHeader("Message-ID"); // TODO: For compatibility, to remove + if (!imdnNamespace.empty()) { + if (!messageIdHeader) + messageIdHeader = cpimMessage->getMessageHeader("Message-ID", imdnNamespace); + auto dispositionNotificationHeader = cpimMessage->getMessageHeader("Disposition-Notification", imdnNamespace); + if (dispositionNotificationHeader) { + vector values = Utils::split(dispositionNotificationHeader->getValue(), ", "); + for (const auto &value : values) + if (value == "positive-delivery") + message->getPrivate()->setPositiveDeliveryNotificationRequired(true); + else if (value == "negative-delivery") + message->getPrivate()->setNegativeDeliveryNotificationRequired(true); + else if (value == "display") + message->getPrivate()->setDisplayNotificationRequired(true); + } + } + if (messageIdHeader) + message->getPrivate()->setImdnMessageId(messageIdHeader->getValue()); + // Modify the initial message since there was no error message->setInternalContent(newContent); if (cpimFromAddress.isValid()) From 96e0a6a22898b8e41355877cf5bd492639f2c65f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 26 Apr 2018 17:03:59 +0200 Subject: [PATCH 082/143] Fix crash in CPIM tester. --- tester/cpim-tester.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tester/cpim-tester.cpp b/tester/cpim-tester.cpp index 7bac7d0fc..ec1f8338a 100644 --- a/tester/cpim-tester.cpp +++ b/tester/cpim-tester.cpp @@ -281,6 +281,9 @@ static void cpim_chat_message_modifier_base (bool useMultipart) { BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_content_type(pauline->stat.last_received_chat_message), expected.c_str()); } + marieMessage.reset(); + marieRoom.reset(); + linphone_im_encryption_engine_unref(marie_imee); linphone_im_encryption_engine_unref(pauline_imee); From b60346b25b488733a41010158c6db236758ff878 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 09:15:33 +0200 Subject: [PATCH 083/143] Generate smaller xml content for IMDN if possible. --- src/chat/notification/imdn.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 19085772a..4eb7247b2 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -122,6 +122,7 @@ string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, char *datetime = linphone_timestamp_to_rfc3339_string(timestamp); Xsd::Imdn::Imdn imdn(id, datetime); ms_free(datetime); + bool needLinphoneImdnNamespace = false; if (imdnType == Imdn::Type::Delivery) { Xsd::Imdn::Status status; if (reason == LinphoneReasonNone) { @@ -133,6 +134,7 @@ string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, Xsd::LinphoneImdn::ImdnReason imdnReason(linphone_reason_to_string(reason)); imdnReason.setCode(linphone_reason_to_error_code(reason)); status.setReason(imdnReason); + needLinphoneImdnNamespace = true; } Xsd::Imdn::DeliveryNotification deliveryNotification(status); imdn.setDeliveryNotification(deliveryNotification); @@ -147,7 +149,8 @@ string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, stringstream ss; Xsd::XmlSchema::NamespaceInfomap map; map[""].name = "urn:ietf:params:xml:ns:imdn"; - map["imdn"].name = "http://www.linphone.org/xsds/imdn.xsd"; + if (needLinphoneImdnNamespace) + map["imdn"].name = "http://www.linphone.org/xsds/imdn.xsd"; Xsd::Imdn::serializeImdn(ss, imdn, map); return ss.str(); } From 6157e3a92a44ee053452668bbb38636d4e98ebaa Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 09:33:13 +0200 Subject: [PATCH 084/143] Fix crash in linphone_core_manager_uninit(). --- tester/tester.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tester/tester.c b/tester/tester.c index 58607dec7..595739902 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -489,10 +489,6 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { if (mgr->phone_alias) { ms_free(mgr->phone_alias); } - if (mgr->stat.last_received_chat_message) { - linphone_chat_message_unref(mgr->stat.last_received_chat_message); - } - if (mgr->stat.last_received_info_message) linphone_info_message_unref(mgr->stat.last_received_info_message); if (mgr->identity) { linphone_address_unref(mgr->identity); } From 065dbf970ff922a73e7792d9ca1fb00009461a0e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 14:17:47 +0200 Subject: [PATCH 085/143] Prevent sent IMDN messages from being notified to the application. --- src/chat/chat-message/imdn-message.h | 1 + src/chat/notification/imdn.cpp | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chat/chat-message/imdn-message.h b/src/chat/chat-message/imdn-message.h index 243b7ae66..28ce11084 100644 --- a/src/chat/chat-message/imdn-message.h +++ b/src/chat/chat-message/imdn-message.h @@ -32,6 +32,7 @@ class ImdnMessagePrivate; class LINPHONE_PUBLIC ImdnMessage : public NotificationMessage { public: friend class ChatRoomPrivate; + friend class Imdn; L_OVERRIDE_SHARED_FROM_THIS(ImdnMessage); diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 4eb7247b2..7c8269b3d 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -19,8 +19,7 @@ #include -#include "chat/chat-message/chat-message-p.h" -#include "chat/chat-message/imdn-message.h" +#include "chat/chat-message/imdn-message-p.h" #include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" #include "logger/logger.h" @@ -205,7 +204,7 @@ void Imdn::send () { auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages); sentImdnMessages.push_back(imdnMessage); if (networkReachable) - imdnMessage->send(); + imdnMessage->getPrivate()->send(); deliveredMessages.clear(); displayedMessages.clear(); } @@ -213,7 +212,7 @@ void Imdn::send () { auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages); sentImdnMessages.push_back(imdnMessage); if (networkReachable) - imdnMessage->send(); + imdnMessage->getPrivate()->send(); nonDeliveredMessages.clear(); } } From 28df97f9343efd989d4ac693c2ce0149fc243d14 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 14:18:21 +0200 Subject: [PATCH 086/143] Do not include the sender of the message when getting its IMDN state. --- src/chat/chat-message/chat-message.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 5cd203fce..f47f42283 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -82,8 +82,9 @@ list ChatMessagePrivate::getParticipantsByImdnState (MainD shared_ptr eventLog = mainDb->getEventFromKey(dbKey); list dbResults = func(eventLog); for (const auto &dbResult : dbResults) { + auto sender = q->getChatRoom()->findParticipant(q->getFromAddress()); auto participant = q->getChatRoom()->findParticipant(dbResult.address); - if (participant) + if (participant && (participant != sender)) result.emplace_back(participant, dbResult.state, dbResult.timestamp); } From 6d4666b03a129204aec5ff0c05e1389f01fc29a5 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 27 Apr 2018 14:20:04 +0200 Subject: [PATCH 087/143] fix(quality-reporting): avoid memory leaks, invalid read... --- include/linphone/api/c-content.h | 2 +- src/c-wrapper/api/c-content.cpp | 4 +- tester/eventapi_tester.c | 2 +- tester/message_tester.c | 2 +- tester/quality_reporting_tester.c | 63 ++++++++++++++++++------------- 5 files changed, 41 insertions(+), 32 deletions(-) diff --git a/include/linphone/api/c-content.h b/include/linphone/api/c-content.h index d7fbdc577..48e3a5ccb 100644 --- a/include/linphone/api/c-content.h +++ b/include/linphone/api/c-content.h @@ -105,7 +105,7 @@ LINPHONE_PUBLIC void linphone_content_add_content_type_parameter ( * @param[in] content #LinphoneContent object. * @return The content data buffer. */ -LINPHONE_PUBLIC uint8_t *linphone_content_get_buffer (const LinphoneContent *content); +LINPHONE_PUBLIC const uint8_t *linphone_content_get_buffer (const LinphoneContent *content); /** * Set the content data buffer, usually a string. diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index a9fdb1ea5..1575248a1 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -107,8 +107,8 @@ void linphone_content_add_content_type_parameter (LinphoneContent *content, cons L_GET_CPP_PTR_FROM_C_OBJECT(content)->setContentType(contentType); } -uint8_t *linphone_content_get_buffer (const LinphoneContent *content) { - return (uint8_t *)linphone_content_get_string_buffer(content); +const uint8_t *linphone_content_get_buffer (const LinphoneContent *content) { + return reinterpret_cast(linphone_content_get_string_buffer(content)); } void linphone_content_set_buffer (LinphoneContent *content, const uint8_t *buffer, size_t size) { diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 66ae0f165..8324a587e 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -41,7 +41,7 @@ void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char * if (!BC_ASSERT_PTR_NOT_NULL(content)) return; if (!linphone_content_is_multipart(content) && (!ua || !strstr(ua, "flexisip"))) { /*disable check for full presence server support*/ /*hack to disable content checking for list notify */ - BC_ASSERT_STRING_EQUAL((const char*)linphone_content_get_buffer(content),notify_content); + BC_ASSERT_STRING_EQUAL(linphone_content_get_string_buffer(content), notify_content); } mgr=get_manager(lc); mgr->stat.number_of_NotifyReceived++; diff --git a/tester/message_tester.c b/tester/message_tester.c index 17dc41e43..441f471cf 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -861,7 +861,7 @@ void info_message_base(bool_t with_content) { BC_ASSERT_PTR_NOT_NULL(linphone_content_get_subtype(content)); if (linphone_content_get_type(content)) BC_ASSERT_STRING_EQUAL(linphone_content_get_type(content),"application"); if (linphone_content_get_subtype(content)) BC_ASSERT_STRING_EQUAL(linphone_content_get_subtype(content),"somexml"); - if (linphone_content_get_buffer(content))BC_ASSERT_STRING_EQUAL((const char*)linphone_content_get_buffer(content),info_content); + if (linphone_content_get_buffer(content))BC_ASSERT_STRING_EQUAL(linphone_content_get_string_buffer(content),info_content); BC_ASSERT_EQUAL((int)linphone_content_get_size(content),(int)strlen(info_content), int, "%d"); } } diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 1ebe8e1d0..b1f301465 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -16,7 +16,6 @@ along with this program. If not, see . */ -#include #include "linphone/core.h" #include "liblinphone_tester.h" #include "tester_utils.h" @@ -26,7 +25,7 @@ #define __strstr(x, y) ((x==NULL)?NULL:strstr(x,y)) void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char * body = (char *)linphone_content_get_buffer(content); + const char *body = linphone_content_get_string_buffer(content); char * remote_metrics_start = __strstr(body, "RemoteMetrics:"); BC_ASSERT_TRUE( __strstr(body, "VQIntervalReport\r\n") == body || @@ -63,30 +62,32 @@ void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_typ BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "DialogID:")); } -char * on_report_send_verify_metrics(const reporting_content_metrics_t *metrics, char * body){ - if (metrics->rtcp_xr_count){ - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SessionDesc:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "JitterBuffer:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PacketLoss:")); +const char *on_report_send_verify_metrics (const reporting_content_metrics_t *metrics, const char *body) { + if (metrics->rtcp_xr_count) { + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SessionDesc:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "JitterBuffer:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PacketLoss:")); } - if (metrics->rtcp_sr_count+metrics->rtcp_xr_count>0){ - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Delay:")); + if (metrics->rtcp_sr_count + metrics->rtcp_xr_count > 0) { + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Delay:")); } if (metrics->rtcp_xr_count){ - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "QualityEst:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "QualityEst:")); } return body; } -void on_report_send_with_rtcp_xr_local(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char * body = (char*)linphone_content_get_buffer(content); - char * remote_metrics_start = __strstr(body, "RemoteMetrics:"); - reporting_session_report_t * report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; - on_report_send_mandatory(call,stream_type,content); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalMetrics:")); - BC_ASSERT_TRUE(!remote_metrics_start || on_report_send_verify_metrics(&report->local_metrics,body) < remote_metrics_start); +void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + char *remote_metrics_start = __strstr(linphone_content_get_string_buffer(content), "RemoteMetrics:"); + reporting_session_report_t *report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; + on_report_send_mandatory(call, stream_type, content); + + const char *body = linphone_content_get_string_buffer(content); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalMetrics:")); + BC_ASSERT_TRUE(!remote_metrics_start || on_report_send_verify_metrics(&report->local_metrics, body) < remote_metrics_start); } + void on_report_send_with_rtcp_xr_remote(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ char * body = (char*)linphone_content_get_buffer(content); reporting_session_report_t * report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; @@ -207,7 +208,7 @@ static void quality_reporting_not_sent_if_low_bandwidth(void) { } void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char *body = (char*)linphone_content_get_buffer(content); + char *body = (char *)linphone_content_get_string_buffer(content); /*corrupt start of the report*/ strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); } @@ -339,7 +340,9 @@ static void quality_reporting_session_report_if_video_stopped(void) { void publish_report_with_route_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){ if (state == LinphonePublishProgress) { - BC_ASSERT_STRING_EQUAL(linphone_address_as_string(linphone_event_get_resource(ev)), linphone_proxy_config_get_quality_reporting_collector(linphone_core_get_default_proxy_config(lc))); + char *uri = linphone_address_as_string(linphone_event_get_resource(ev)); + BC_ASSERT_STRING_EQUAL(uri, linphone_proxy_config_get_quality_reporting_collector(linphone_core_get_default_proxy_config(lc))); + bctbx_free(uri); } } @@ -378,7 +381,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { LinphoneCall* call_pauline = NULL; LinphoneCallParams* pauline_params; LinphoneCallParams* marie_params; - LinphoneChatRoom *pauline_chat_room; + LinphoneChatRoom *pauline_chat_room; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); @@ -408,10 +411,11 @@ static void quality_reporting_interval_report_video_and_rtt(void) { pauline_chat_room = linphone_call_get_chat_room(call_pauline); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); + LinphoneChatMessage *rtt_message; if (pauline_chat_room) { const char* message = "Lorem Ipsum Belledonnum Communicatum"; size_t i; - LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); + rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(call_marie); for (i = 0; i < strlen(message); i++) { @@ -425,6 +429,9 @@ static void quality_reporting_interval_report_video_and_rtt(void) { end_call(marie, pauline); /*wait that all publish complete*/ BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,marie->stat.number_of_LinphonePublishProgress,60000)); + + if (rtt_message) + linphone_chat_message_unref(rtt_message); } linphone_call_params_unref(marie_params); @@ -478,13 +485,15 @@ test_t quality_reporting_tests[] = { TEST_NO_TAG("Call term session report sent if call ended normally", quality_reporting_at_call_termination), TEST_NO_TAG("Interval report if interval is configured", quality_reporting_interval_report), #ifdef VIDEO_ENABLED - TEST_NO_TAG("Interval report if interval is configured with video and realtime text", quality_reporting_interval_report_video_and_rtt), - TEST_NO_TAG("Session report sent if video stopped during call", quality_reporting_session_report_if_video_stopped), - #endif + TEST_NO_TAG("Interval report if interval is configured with video and realtime text", quality_reporting_interval_report_video_and_rtt), + TEST_NO_TAG("Session report sent if video stopped during call", quality_reporting_session_report_if_video_stopped), + #endif // ifdef VIDEO_ENABLED TEST_NO_TAG("Sent using custom route", quality_reporting_sent_using_custom_route), TEST_NO_TAG("Video bandwidth estimation", video_bandwidth_estimation) }; -test_suite_t quality_reporting_test_suite = {"QualityReporting", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, - sizeof(quality_reporting_tests) / sizeof(quality_reporting_tests[0]), - quality_reporting_tests}; +test_suite_t quality_reporting_test_suite = { + "QualityReporting", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, + sizeof(quality_reporting_tests) / sizeof(quality_reporting_tests[0]), + quality_reporting_tests +}; From 6c752ae38b66d250382ee8e8bdd326110f8a6c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Turnel?= Date: Fri, 27 Apr 2018 14:24:59 +0200 Subject: [PATCH 088/143] Prevent tests from crashing if call is null --- tester/flexisip_tester.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 79be0ad9f..9b87c3c55 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1478,8 +1478,11 @@ void sequential_forking(void) { /*the second should not*/ BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d"); + LinphoneCall *call = linphone_core_get_current_call(marie->lc); + if (!BC_ASSERT_PTR_NOT_NULL(call)) return; + /*marie accepts the call on its second device*/ - linphone_call_accept(linphone_core_get_current_call(marie->lc)); + linphone_call_accept(call); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); @@ -1540,8 +1543,11 @@ void sequential_forking_with_timeout_for_highest_priority(void) { BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallIncomingReceived,1,3000)); + LinphoneCall *call = linphone_core_get_current_call(marie3->lc); + if (!BC_ASSERT_PTR_NOT_NULL(call)) return; + /*marie accepts the call on her third device*/ - linphone_call_accept(linphone_core_get_current_call(marie3->lc)); + linphone_call_accept(call); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallConnected,1,1000)); @@ -1600,8 +1606,11 @@ void sequential_forking_with_no_response_for_highest_priority(void) { /*then the second device should receive the call*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 3000)); + LinphoneCall *call = linphone_core_get_current_call(marie2->lc); + if (!BC_ASSERT_PTR_NOT_NULL(call)) return; + /*marie accepts the call on her second device*/ - linphone_call_accept(linphone_core_get_current_call(marie2->lc)); + linphone_call_accept(call); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); @@ -1661,8 +1670,11 @@ void sequential_forking_with_insertion_of_higher_priority(void) { /*this device should receive the call*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallIncomingReceived,1,3000)); + LinphoneCall *call = linphone_core_get_current_call(marie3->lc); + if (!BC_ASSERT_PTR_NOT_NULL(call)) return; + /*marie accepts the call on her third device*/ - linphone_call_accept(linphone_core_get_current_call(marie3->lc)); + linphone_call_accept(call); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallConnected,1,1000)); @@ -1686,7 +1698,6 @@ void sequential_forking_with_insertion_of_higher_priority(void) { } void sequential_forking_with_fallback_route(void) { -#if 0 //fixme Mickael LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline2 = linphone_core_manager_create(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie = linphone_core_manager_create("marie_rc"); @@ -1734,8 +1745,11 @@ void sequential_forking_with_fallback_route(void) { /*the call should be routed to the first server with pauline account*/ BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallIncomingReceived,1,3000)); + LinphoneCall *call = linphone_core_get_current_call(pauline->lc); + if (!BC_ASSERT_PTR_NOT_NULL(call)) return; + /*pauline accepts the call*/ - linphone_call_accept(linphone_core_get_current_call(pauline->lc)); + linphone_call_accept(call); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); @@ -1752,9 +1766,6 @@ void sequential_forking_with_fallback_route(void) { linphone_core_manager_destroy(pauline2); linphone_core_manager_destroy(marie); bctbx_list_free(lcs); -#else - ms_error("sequential_forking_with_fallback_route temporaly removed"); -#endif } test_t flexisip_tests[] = { From 4fc81372895bc50a4c394307b25556ba9f8ba50c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 27 Apr 2018 14:28:21 +0200 Subject: [PATCH 089/143] Fixed grammars and some other importants file not being overwritten --- .../classes/tools/AndroidPlatformHelper.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/wrappers/java/classes/tools/AndroidPlatformHelper.java b/wrappers/java/classes/tools/AndroidPlatformHelper.java index 1c20b94c6..4523b9a37 100644 --- a/wrappers/java/classes/tools/AndroidPlatformHelper.java +++ b/wrappers/java/classes/tools/AndroidPlatformHelper.java @@ -181,24 +181,32 @@ public class AndroidPlatformHelper { if (resId == 0) { Log.d("App doesn't seem to embed resource " + name + "in it's res/raw/ directory, use linphone's instead"); resId = mResources.getIdentifier(name, "raw", "org.linphone"); + if (resId == 0) { + Log.e("App doesn't seem to embed resource " + name + "in it's res/raw/ directory, please add it"); + } } return resId; } private void copyAssetsFromPackage() throws IOException { - copyIfNotExist(getResourceIdentifierFromName("notes_of_the_optimistic"), mRingSoundFile); - copyIfNotExist(getResourceIdentifierFromName("ringback"), mRingbackSoundFile); - copyIfNotExist(getResourceIdentifierFromName("hold"), mPauseSoundFile); - copyIfNotExist(getResourceIdentifierFromName("incoming_chat"), mErrorToneFile); - copyIfNotExist(getResourceIdentifierFromName("cpim_grammar"), mGrammarCpimFile); - copyIfNotExist(getResourceIdentifierFromName("vcard_grammar"), mGrammarVcardFile); - copyIfNotExist(getResourceIdentifierFromName("rootca"), mLinphoneRootCaFile); + copyEvenIfExists(getResourceIdentifierFromName("cpim_grammar"), mGrammarCpimFile); + copyEvenIfExists(getResourceIdentifierFromName("vcard_grammar"), mGrammarVcardFile); + copyEvenIfExists(getResourceIdentifierFromName("rootca"), mLinphoneRootCaFile); + copyEvenIfExists(getResourceIdentifierFromName("notes_of_the_optimistic"), mRingSoundFile); + copyEvenIfExists(getResourceIdentifierFromName("ringback"), mRingbackSoundFile); + copyEvenIfExists(getResourceIdentifierFromName("hold"), mPauseSoundFile); + copyEvenIfExists(getResourceIdentifierFromName("incoming_chat"), mErrorToneFile); + } + + public void copyEvenIfExists(int ressourceId, String target) throws IOException { + File lFileToCopy = new File(target); + copyFromPackage(ressourceId, lFileToCopy.getName()); } public void copyIfNotExist(int ressourceId, String target) throws IOException { File lFileToCopy = new File(target); if (!lFileToCopy.exists()) { - copyFromPackage(ressourceId,lFileToCopy.getName()); + copyFromPackage(ressourceId, lFileToCopy.getName()); } } From 480cca5f5be39723359a30a319f64f37607cc437 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 27 Apr 2018 14:34:41 +0200 Subject: [PATCH 090/143] Fixed build --- tester/quality_reporting_tester.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index b1f301465..0c0b640fe 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -411,7 +411,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { pauline_chat_room = linphone_call_get_chat_room(call_pauline); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); - LinphoneChatMessage *rtt_message; + LinphoneChatMessage *rtt_message = NULL; if (pauline_chat_room) { const char* message = "Lorem Ipsum Belledonnum Communicatum"; size_t i; From a06c0cf3d796842007905a22fc9a198438faeb7c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 27 Apr 2018 14:37:16 +0200 Subject: [PATCH 091/143] fix(linphonecore): avoid many leaks when config is read --- coreapi/linphonecore.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a9e84cc76..2c7224314 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1462,8 +1462,10 @@ static void rtp_config_read(LinphoneCore *lc) { linphone_core_set_avpf_mode(lc,static_cast(lp_config_get_int(lc->config,"rtp","avpf",LinphoneAVPFDisabled))); if ((tmp=lp_config_get_string(lc->config,"rtp","audio_multicast_addr",NULL))) linphone_core_set_audio_multicast_addr(lc,tmp); - else + else { + if (lc->rtp_conf.audio_multicast_addr) bctbx_free(lc->rtp_conf.audio_multicast_addr); lc->rtp_conf.audio_multicast_addr=ms_strdup("224.1.2.3"); + } if ((tmp_int=lp_config_get_int(lc->config,"rtp","audio_multicast_enabled",-1)) >-1) linphone_core_enable_audio_multicast(lc, !!tmp_int); if ((tmp_int=lp_config_get_int(lc->config,"rtp","audio_multicast_ttl",-1))>0) @@ -1472,8 +1474,10 @@ static void rtp_config_read(LinphoneCore *lc) { lc->rtp_conf.audio_multicast_ttl=1;/*local network*/ if ((tmp=lp_config_get_string(lc->config,"rtp","video_multicast_addr",NULL))) linphone_core_set_video_multicast_addr(lc,tmp); - else + else { + if (lc->rtp_conf.video_multicast_addr) bctbx_free(lc->rtp_conf.video_multicast_addr); lc->rtp_conf.video_multicast_addr=ms_strdup("224.1.2.3"); + } if ((tmp_int=lp_config_get_int(lc->config,"rtp","video_multicast_ttl",-1))>-1) linphone_core_set_video_multicast_ttl(lc,tmp_int); else @@ -1962,12 +1966,15 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const linphone_core_notify_global_state_changed(lc,gstate,message); } -static void misc_config_read(LinphoneCore *lc) { - LpConfig *config=lc->config; +static void misc_config_read (LinphoneCore *lc) { + LpConfig *config = lc->config; + + lc->max_call_logs = lp_config_get_int(config,"misc","history_max_size",LINPHONE_MAX_CALL_HISTORY_SIZE); + lc->max_calls = lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS); + + if (lc->user_certificates_path) bctbx_free(lc->user_certificates_path); + lc->user_certificates_path = bctbx_strdup(lp_config_get_string(config, "misc", "user_certificates_path", ".")); - lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",LINPHONE_MAX_CALL_HISTORY_SIZE); - lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS); - lc->user_certificates_path=ms_strdup(lp_config_get_string(config,"misc","user_certificates_path",".")); lc->send_call_stats_periodical_updates = !!lp_config_get_int(config, "misc", "send_call_stats_periodical_updates", 0); } @@ -6570,12 +6577,11 @@ end: #endif /* SQLITE_STORAGE_ENABLED */ } -void linphone_core_set_user_certificates_path(LinphoneCore *lc, const char* path){ - char* new_value; - new_value = path?ms_strdup(path):NULL; - if (lc->user_certificates_path) ms_free(lc->user_certificates_path); - lp_config_set_string(lc->config,"misc","user_certificates_path",lc->user_certificates_path=new_value); - return ; +void linphone_core_set_user_certificates_path (LinphoneCore *lc, const char *path) { + char *new_value = path ? bctbx_strdup(path) : NULL; + if (lc->user_certificates_path) bctbx_free(lc->user_certificates_path); + lc->user_certificates_path = new_value; + lp_config_set_string(lc->config, "misc", "user_certificates_path", lc->user_certificates_path); } const char *linphone_core_get_user_certificates_path(LinphoneCore *lc){ From 38b6a410bcb23c215d2b0f4b959ecb0e8122d997 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 27 Apr 2018 15:24:52 +0200 Subject: [PATCH 092/143] Replace 500 by 488 if CPIM is wrongly formatted --- src/chat/modifier/cpim-chat-message-modifier.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 39104a674..d4853bf2d 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -126,7 +126,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptr cpimMessage = Cpim::Message::createFromString(contentBody); if (!cpimMessage || !cpimMessage->getMessageHeader("From") || !cpimMessage->getMessageHeader("To")) { lError() << "[CPIM] Message is invalid: " << contentBody; - errorCode = 500; + errorCode = 488; // Not Acceptable return ChatMessageModifier::Result::Error; } @@ -134,7 +134,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetContentHeader("Content-Type"); if (!contentTypeHeader) { lError() << "[CPIM] No Content-type for the content of the message"; - errorCode = 500; + errorCode = 488; // Not Acceptable return ChatMessageModifier::Result::Error; } newContent.setContentType(ContentType(contentTypeHeader->getValue())); From fcd2b834c9cb09893d532be7df2dacfea8358e15 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 27 Apr 2018 15:55:35 +0200 Subject: [PATCH 093/143] fix(multipart-tester): fix tests, avoid bad weak ptr --- tester/multipart-tester.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/multipart-tester.cpp b/tester/multipart-tester.cpp index 1c54389f2..663b114f4 100644 --- a/tester/multipart-tester.cpp +++ b/tester/multipart-tester.cpp @@ -96,6 +96,8 @@ static void chat_message_multipart_modifier_base(bool first_file_transfer, bool BC_ASSERT_STRING_EQUAL(content, "Hello part 2"); } + marieRoom.reset(); // Avoid bad weak ptr when the core is destroyed below this line. + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } From 7604ca8744b19ab0103aa4d906ea7d2de8a4406a Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Fri, 27 Apr 2018 16:13:11 +0200 Subject: [PATCH 094/143] add test for message-expires --- tester/flexisip_tester.c | 42 +++++++++++++++++++++++++++++++++++++ tester/liblinphone_tester.h | 1 + tester/tester.c | 11 ++++++++++ 3 files changed, 54 insertions(+) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 9b87c3c55..64f6b4c7e 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -259,6 +259,46 @@ static void message_forking_with_unreachable_recipients_with_gruu(void) { bctbx_list_free(lcs); } +static void text_message_expires(void) { + LinphoneCoreManager* marie = linphone_core_manager_new4("marie_rc",TRUE,NULL,"message-expires=60",3); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + + linphone_core_set_network_reachable(marie->lc, FALSE); + /* Wait for 5 seconds for surely cut marie of network */ + wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000); + + linphone_chat_room_send_message(linphone_core_get_chat_room(pauline->lc,marie->identity), "hello"); + linphone_core_set_network_reachable(marie->lc, TRUE); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void text_call_expires(void) { + LinphoneCoreManager* marie = linphone_core_manager_new4("marie_rc",TRUE,NULL,"message-expires=60",3); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + + linphone_core_set_network_reachable(marie->lc, FALSE); + /* Wait for 5 seconds for surely cut marie of network */ + wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000); + + linphone_core_invite_address(pauline->lc,marie->identity); + linphone_core_set_network_reachable(marie->lc, TRUE); + + /*pauline shouldn't hear ringback*/ + BC_ASSERT_FALSE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,5000)); + /*all devices from Marie shouldn't be ringing*/ + BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,5000)); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + bctbx_list_free(lcs); +} + static void call_forking(void){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1774,6 +1814,8 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Message forking with unreachable recipients", message_forking_with_unreachable_recipients), TEST_NO_TAG("Message forking with all recipients unreachable", message_forking_with_all_recipients_unreachable), TEST_NO_TAG("Message forking with unreachable recipients with gruu", message_forking_with_unreachable_recipients_with_gruu), + TEST_NO_TAG("Message expires", text_message_expires), + TEST_NO_TAG("Call expires", text_call_expires), TEST_NO_TAG("Call forking", call_forking), TEST_NO_TAG("Call forking cancelled", call_forking_cancelled), TEST_NO_TAG("Call forking declined globaly", call_forking_declined_globaly), diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 9a7531460..0979de45c 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -328,6 +328,7 @@ void linphone_core_manager_configure (LinphoneCoreManager *mgr); void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_proxies); LinphoneCoreManager* linphone_core_manager_create2(const char* rc_file, const char* phone_alias); LinphoneCoreManager* linphone_core_manager_create(const char* rc_file); +LinphoneCoreManager* linphone_core_manager_new4(const char* rc_file, int check_for_proxies, const char* phone_aliasconst, const char* contact_params, int expires); LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, bool_t check_for_proxies, const char* phone_alias); LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, bool_t check_for_proxies); LinphoneCoreManager* linphone_core_manager_new(const char* rc_file); diff --git a/tester/tester.c b/tester/tester.c index 595739902..15e83ac56 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -432,6 +432,17 @@ LinphoneCoreManager* linphone_core_manager_create(const char* rc_file) { return linphone_core_manager_create2(rc_file, NULL); } +LinphoneCoreManager* linphone_core_manager_new4(const char* rc_file, int check_for_proxies, const char* phone_alias, const char* contact_params, int expires) { + /* This function is for testing purposes. */ + LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1); + + linphone_core_manager_init(manager, rc_file, phone_alias); + linphone_proxy_config_set_contact_parameters(linphone_core_get_default_proxy_config(manager->lc), contact_params); + linphone_proxy_config_set_expires(linphone_core_get_default_proxy_config(manager->lc), expires); + linphone_core_manager_start(manager, check_for_proxies); + return manager; +} + LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, bool_t check_for_proxies, const char* phone_alias) { LinphoneCoreManager *manager = linphone_core_manager_create2(rc_file, phone_alias); linphone_core_manager_start(manager, check_for_proxies); From 30a903954b0a956fe6ec95c90e7bde49ad8a6c06 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Fri, 27 Apr 2018 16:41:39 +0200 Subject: [PATCH 095/143] Add incall-player in linphone-daemon --- daemon/CMakeLists.txt | 2 + daemon/commands/play.cc | 233 ++++++++++++++++++++++++++++++++++++++++ daemon/commands/play.h | 50 +++++++++ daemon/daemon.cc | 18 ++++ daemon/daemon.h | 7 +- 5 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 daemon/commands/play.cc create mode 100644 daemon/commands/play.h diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index c50915234..a104ed5c9 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -79,6 +79,8 @@ set(DAEMON_SOURCE_FILES commands/msfilter-add-fmtp.h commands/netsim.cc commands/netsim.h + commands/play.cc + commands/play.h commands/play-wav.cc commands/play-wav.h commands/pop-event.cc diff --git a/daemon/commands/play.cc b/daemon/commands/play.cc new file mode 100644 index 000000000..f60ae7198 --- /dev/null +++ b/daemon/commands/play.cc @@ -0,0 +1,233 @@ +/* +play-wav.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "play.h" +#include "call.h" +#include +using namespace std; +#define VOIDPTR_TO_INT(p) ((int)(intptr_t)(p)) + +void IncallPlayerStartCommand::onEof(LinphonePlayer *player){ + pair *callPlayingData = (pair *)linphone_player_get_user_data(player); + Daemon *app = callPlayingData->second; + int id = callPlayingData->first; + app->callPlayingComplete(id); + delete callPlayingData; + linphone_player_set_user_data(player, NULL); +} + + +IncallPlayerStartCommand::IncallPlayerStartCommand() : + DaemonCommand("incall-player-start", "incall-player-start []", + "Play a WAV audio file or a MKV audio/video file. The played media stream will be sent through \n" + "the RTP session of the given call.\n" + " is the file to be played.\n") { + addExample(new DaemonCommandExample("incall-player-start /usr/local/share/sounds/linphone/hello8000.wav 1", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-start /usr/local/share/sounds/linphone/hello8000.wav 1", + "Status: Error\n" + "Reason: No call with such id.")); + addExample(new DaemonCommandExample("incall-player-start /usr/local/share/sounds/linphone/hello8000.wav", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-start /usr/local/share/sounds/linphone/hello8000.wav", + "Status: Error\n" + "Reason: No active call.")); +} + +void IncallPlayerStartCommand::exec(Daemon *app, const string& args) { + LinphoneCall *call = NULL; + int cid; + const MSList *elem; + istringstream ist(args); + string filename; + + ist >> filename; + if (ist.eof() && (filename.length() == 0)) { + app->sendResponse(Response("Missing filename parameter.", Response::Error)); + return; + } + if (ist.fail()) { + app->sendResponse(Response("Incorrect filename parameter.", Response::Error)); + return; + } + + ist >> cid; + if (ist.fail()) { + elem = linphone_core_get_calls(app->getCore()); + if (elem != NULL && elem->next == NULL) { + call = (LinphoneCall*)elem->data; + } + } else { + call = app->findCall(cid); + if (call == NULL) { + app->sendResponse(Response("No call with such id.")); + return; + } + } + if (call == NULL) { + app->sendResponse(Response("No active call.")); + return; + } + LinphonePlayer *p = linphone_call_get_player(call); + + LinphonePlayerCbs *cbs=linphone_player_get_callbacks(p); + + pair *callPlayingData = (pair *)linphone_player_get_user_data(p); + if(callPlayingData) callPlayingData = new pair({ + VOIDPTR_TO_INT(linphone_call_get_user_data(call)), + app + }); + linphone_player_set_user_data(p, callPlayingData); + linphone_player_cbs_set_eof_reached(cbs, onEof); + linphone_player_open(p,filename.c_str()); + linphone_player_start(p); + app->sendResponse(Response()); +} + + +IncallPlayerStopCommand::IncallPlayerStopCommand() : + DaemonCommand("incall-player-stop", "incall-player-stop []","Close the opened file.\n") { + addExample(new DaemonCommandExample("incall-player-stop 1", + "Status: Error\n" + "Reason: No call with such id.")); + addExample(new DaemonCommandExample("incall-player-stop 1", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-stop", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-stop", + "Status: Error\n" + "Reason: No active call.")); +} + +void IncallPlayerStopCommand::exec(Daemon *app, const string& args) { + LinphoneCall *call = NULL; + int cid; + const MSList *elem; + istringstream ist(args); + ist >> cid; + if (ist.fail()) { + elem = linphone_core_get_calls(app->getCore()); + if (elem != NULL && elem->next == NULL) { + call = (LinphoneCall*)elem->data; + } + } else { + call = app->findCall(cid); + if (call == NULL) { + app->sendResponse(Response("No call with such id.")); + return; + } + } + if (call == NULL) { + app->sendResponse(Response("No active call.")); + return; + } + + LinphonePlayer *p = linphone_call_get_player(call); + + linphone_player_close(p); + app->sendResponse(Response()); + pair *callPlayingData = (pair *)linphone_player_get_user_data(p); + if(callPlayingData) delete callPlayingData; +} + +IncallPlayerPauseCommand::IncallPlayerPauseCommand() : + DaemonCommand("incall-player-pause", "incall-player-pause []", + "Pause the playing of a file.\n") { + addExample(new DaemonCommandExample("incall-player-pause 1", + "Status: Error\n" + "Reason: No call with such id.")); + addExample(new DaemonCommandExample("incall-player-pause 1", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-pause", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-pause", + "Status: Error\n" + "Reason: No active call.")); +} + +void IncallPlayerPauseCommand::exec(Daemon *app, const string& args) { + LinphoneCall *call = NULL; + int cid; + const MSList *elem; + istringstream ist(args); + ist >> cid; + if (ist.fail()) { + elem = linphone_core_get_calls(app->getCore()); + if (elem != NULL && elem->next == NULL) { + call = (LinphoneCall*)elem->data; + } + } else { + call = app->findCall(cid); + if (call == NULL) { + app->sendResponse(Response("No call with such id.")); + return; + } + } + if (call == NULL) { + app->sendResponse(Response("No active call.")); + return; + } + + LinphonePlayer *p = linphone_call_get_player(call); + linphone_player_pause(p); + app->sendResponse(Response()); +} + +IncallPlayerResumeCommand::IncallPlayerResumeCommand() : + DaemonCommand("incall-player-resume", "incall-player-resume []", + "Unpause the playing of a file.\n") { + addExample(new DaemonCommandExample("incall-player-resume 1", + "Status: Error\n" + "Reason: No call with such id.")); + addExample(new DaemonCommandExample("incall-player-resume 1", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-resume", + "Status: Ok\n")); + addExample(new DaemonCommandExample("incall-player-resume", + "Status: Error\n" + "Reason: No active call.")); +} + +void IncallPlayerResumeCommand::exec(Daemon *app, const string& args) { + LinphoneCall *call = NULL; + int cid; + const MSList *elem; + istringstream ist(args); + ist >> cid; + if (ist.fail()) { + elem = linphone_core_get_calls(app->getCore()); + if (elem != NULL && elem->next == NULL) { + call = (LinphoneCall*)elem->data; + } + } else { + call = app->findCall(cid); + if (call == NULL) { + app->sendResponse(Response("No call with such id.")); + return; + } + } + if (call == NULL) { + app->sendResponse(Response("No active call.")); + return; + } + + LinphonePlayer *p = linphone_call_get_player(call); + linphone_player_start(p); + app->sendResponse(Response()); +} diff --git a/daemon/commands/play.h b/daemon/commands/play.h new file mode 100644 index 000000000..e8787e71b --- /dev/null +++ b/daemon/commands/play.h @@ -0,0 +1,50 @@ +/* +play-wav.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef LINPHONE_DAEMON_COMMAND_PLAY_H_ +#define LINPHONE_DAEMON_COMMAND_PLAY_H_ + +#include "daemon.h" + +class IncallPlayerStartCommand: public DaemonCommand { +public: + IncallPlayerStartCommand(); + virtual void exec(Daemon *app, const std::string& args); +private: + static void onEof(LinphonePlayer *player); +}; + +class IncallPlayerStopCommand: public DaemonCommand { +public: + IncallPlayerStopCommand(); + virtual void exec(Daemon *app, const std::string& args); +}; + +class IncallPlayerPauseCommand: public DaemonCommand { +public: + IncallPlayerPauseCommand(); + virtual void exec(Daemon *app, const std::string& args); +}; + +class IncallPlayerResumeCommand: public DaemonCommand { +public: + IncallPlayerResumeCommand(); + virtual void exec(Daemon *app, const std::string& args); +}; +#endif // LINPHONE_DAEMON_COMMAND_PLAY_H_ diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 77b769f9d..57dbe3b4e 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -79,6 +79,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "commands/netsim.h" #include "commands/cn.h" #include "commands/version.h" +#include "commands/play.h" #include "private.h" using namespace std; @@ -214,6 +215,15 @@ AudioStreamStatsResponse::AudioStreamStatsResponse(Daemon* daemon, AudioStream* setBody(ostr.str().c_str()); } +CallPlayingStatsResponse::CallPlayingStatsResponse(Daemon* daemon, int id) { + ostringstream ostr; + + ostr << "Event-type: call-playing-complete\n"; + ostr << "Id: " << id << "\n"; + + setBody(ostr.str().c_str()); +} + PayloadTypeResponse::PayloadTypeResponse(LinphoneCore *core, const PayloadType *payloadType, int index, const string &prefix, bool enabled_status) { ostringstream ostr; if (payloadType != NULL) { @@ -486,6 +496,10 @@ void Daemon::initCommands() { mCommands.push_back(new ConfigSetCommand()); mCommands.push_back(new NetsimCommand()); mCommands.push_back(new CNCommand()); + mCommands.push_back(new IncallPlayerStartCommand()); + mCommands.push_back(new IncallPlayerStopCommand()); + mCommands.push_back(new IncallPlayerPauseCommand()); + mCommands.push_back(new IncallPlayerResumeCommand()); mCommands.sort(compareCommands); } @@ -524,6 +538,10 @@ void Daemon::callStatsUpdated(LinphoneCall *call, const LinphoneCallStats *stats } } +void Daemon::callPlayingComplete(int id) { + mEventQueue.push(new CallPlayingStatsResponse(this, id)); +} + void Daemon::dtmfReceived(LinphoneCall *call, int dtmf) { mEventQueue.push(new DtmfResponse(this, call, dtmf)); } diff --git a/daemon/daemon.h b/daemon/daemon.h index 97591982e..79ae20c1e 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -160,6 +160,11 @@ public: const LinphoneCallStats *stats, bool event); }; +class CallPlayingStatsResponse: public Response { +public: + CallPlayingStatsResponse(Daemon *daemon, int id); +}; + class DtmfResponse: public Response { public: DtmfResponse(Daemon *daemon, LinphoneCall *call, int dtmf); @@ -230,7 +235,7 @@ public: void dumpCommandsHelpHtml(); void enableStatsEvents(bool enabled); void enableLSD(bool enabled); - + void callPlayingComplete(int id); void setAutoVideo( bool enabled ){ mAutoVideo = enabled; } inline bool autoVideo(){ return mAutoVideo; } From 1250a6a2bdf6a9ee1b85155cd5baabd9159d248e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 27 Apr 2018 17:14:08 +0200 Subject: [PATCH 096/143] fix(play): use missing override --- daemon/commands/play.h | 13 +++++++++---- tester/flexisip_tester.c | 32 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/daemon/commands/play.h b/daemon/commands/play.h index e8787e71b..ad746dea8 100644 --- a/daemon/commands/play.h +++ b/daemon/commands/play.h @@ -25,7 +25,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA class IncallPlayerStartCommand: public DaemonCommand { public: IncallPlayerStartCommand(); - virtual void exec(Daemon *app, const std::string& args); + + void exec (Daemon *app, const std::string& args) override; + private: static void onEof(LinphonePlayer *player); }; @@ -33,18 +35,21 @@ private: class IncallPlayerStopCommand: public DaemonCommand { public: IncallPlayerStopCommand(); - virtual void exec(Daemon *app, const std::string& args); + + void exec (Daemon *app, const std::string& args) override; }; class IncallPlayerPauseCommand: public DaemonCommand { public: IncallPlayerPauseCommand(); - virtual void exec(Daemon *app, const std::string& args); + + void exec (Daemon *app, const std::string& args) override; }; class IncallPlayerResumeCommand: public DaemonCommand { public: IncallPlayerResumeCommand(); - virtual void exec(Daemon *app, const std::string& args); + + void exec (Daemon *app, const std::string& args) override; }; #endif // LINPHONE_DAEMON_COMMAND_PLAY_H_ diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 64f6b4c7e..b2cdf5c23 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -265,13 +265,13 @@ static void text_message_expires(void) { linphone_core_set_network_reachable(marie->lc, FALSE); /* Wait for 5 seconds for surely cut marie of network */ - wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000); + wait_for_until(pauline->lc, marie->lc, NULL, 0, 5000); linphone_chat_room_send_message(linphone_core_get_chat_room(pauline->lc,marie->identity), "hello"); linphone_core_set_network_reachable(marie->lc, TRUE); - + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -281,19 +281,19 @@ static void text_call_expires(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); lcs=bctbx_list_append(lcs,marie->lc); - + linphone_core_set_network_reachable(marie->lc, FALSE); /* Wait for 5 seconds for surely cut marie of network */ - wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000); - + wait_for_until(pauline->lc, marie->lc, NULL, 0, 5000); + linphone_core_invite_address(pauline->lc,marie->identity); linphone_core_set_network_reachable(marie->lc, TRUE); - + /*pauline shouldn't hear ringback*/ BC_ASSERT_FALSE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,5000)); /*all devices from Marie shouldn't be ringing*/ BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,5000)); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); bctbx_list_free(lcs); @@ -532,9 +532,9 @@ static void call_forking_with_push_notification_single(void){ BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - + liblinphone_tester_check_rtcp(pauline,marie); - + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000)); @@ -581,14 +581,14 @@ static void call_forking_with_push_notification_multiple(void){ BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,1000)); - + /*call to marie should be cancelled*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); - + liblinphone_tester_check_rtcp(pauline,marie2); - + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); - + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); } @@ -1299,7 +1299,7 @@ static void tls_client_auth_try_register(const char *identity, bool_t with_good_ }else{ BC_ASSERT_TRUE(wait_for(lcm->lc, NULL, &lcm->stat.number_of_LinphoneRegistrationFailed, 1)); BC_ASSERT_EQUAL(lcm->stat.number_of_LinphoneRegistrationOk,0, int, "%d"); - /*we should expect at least 2 "auth_requested": one for the TLS certificate, another one because the server rejects the REGISTER with 401, + /*we should expect at least 2 "auth_requested": one for the TLS certificate, another one because the server rejects the REGISTER with 401, with eventually MD5 + SHA256 challenge*/ /*If the certificate isn't recognized at all, the connection will not happen and no SIP response will be received from server.*/ if (with_good_cert) BC_ASSERT_GREATER(lcm->stat.number_of_auth_info_requested,2, int, "%d"); @@ -1431,7 +1431,7 @@ static void on_refer_received(SalOp *op, const SalAddress *refer_to) { Sal *sal = sal_op_get_sal(op); LinphoneCoreManager *receiver = (LinphoneCoreManager*)sal_get_user_pointer(sal); receiver->stat.number_of_LinphoneCallRefered++; - + } void resend_refer_other_devices(void) { From e88a0a4a90b7c2b70c1f5e5821ea57c72c364337 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Fri, 27 Apr 2018 17:51:29 +0200 Subject: [PATCH 098/143] add test for register with username with espace --- tester/register_tester.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tester/register_tester.c b/tester/register_tester.c index 8e5e9996c..5808c5b7e 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -479,6 +479,46 @@ static void authenticated_register_with_provided_credentials(void){ linphone_core_manager_destroy(lcm); } +static void authenticated_register_with_provided_credentials_and_username_with_espace(void){ + LinphoneCoreManager *lcm; + stats* counters; + LinphoneProxyConfig *cfg; + char route[256]; + LinphoneAddress *from; + char *addr; + LinphoneAuthInfo *ai; + const char* username = "test username"; + sprintf(route,"sip:%s",test_route); + + lcm = linphone_core_manager_new(NULL); + + counters = get_stats(lcm->lc); + cfg = linphone_core_create_proxy_config(lcm->lc); + from = create_linphone_address_for_algo(auth_domain,username); + + linphone_proxy_config_set_identity(cfg, addr=linphone_address_as_string(from)); + ms_free(addr); + + linphone_proxy_config_enable_register(cfg,TRUE); + linphone_proxy_config_set_expires(cfg,1); + linphone_proxy_config_set_route(cfg, test_route); + linphone_proxy_config_set_server_addr(cfg,test_route); + linphone_address_unref(from); + + ai = linphone_auth_info_new(username, NULL, test_password, NULL, NULL, NULL); + linphone_core_add_auth_info(lcm->lc, ai); + linphone_auth_info_unref(ai); + linphone_core_add_proxy_config(lcm->lc, cfg); + + BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1)); + BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d"); + + BC_ASSERT_PTR_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "passwd", NULL)); + BC_ASSERT_PTR_NOT_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "ha1", NULL)); + + linphone_proxy_config_destroy(cfg); + linphone_core_manager_destroy(lcm); +} static void authenticated_register_with_wrong_late_credentials(void){ LinphoneCoreManager *lcm; stats* counters; @@ -1325,6 +1365,7 @@ test_t register_tests[] = { TEST_NO_TAG("Authenticated register with wrong late credentials", authenticated_register_with_wrong_late_credentials), TEST_NO_TAG("Authenticated register with late credentials", authenticated_register_with_late_credentials), TEST_NO_TAG("Authenticated register with provided credentials", authenticated_register_with_provided_credentials), + TEST_NO_TAG("Authenticated register with provided credentials, username with espace", authenticated_register_with_provided_credentials_and_username_with_espace), TEST_NO_TAG("Register with refresh", simple_register_with_refresh), TEST_NO_TAG("Authenticated register with refresh", simple_auth_register_with_refresh), TEST_NO_TAG("Register with refresh and send error", register_with_refresh_with_send_error), From cb8928e6d7898dab379aca45b4a0385444f110b6 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 27 Dec 2017 16:08:05 +0100 Subject: [PATCH 099/143] change username_regex to use username with space --- tester/rcfiles/account_creator_rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/rcfiles/account_creator_rc b/tester/rcfiles/account_creator_rc index 443827462..943f8fca2 100644 --- a/tester/rcfiles/account_creator_rc +++ b/tester/rcfiles/account_creator_rc @@ -4,7 +4,7 @@ password_max_length=12 password_min_length=3 username_max_length=14 username_min_length=3 -username_regex=^[A-Za-z0-9_.\-]*$ +username_regex=^[A-Za-z0-9_.\-\ ]*$ xmlrpc_url=https://sip2.linphone.org:446/wizard.php [proxy_default_values] From 550502650a8e20d7746394fb06826e20c7616d64 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 17:55:37 +0200 Subject: [PATCH 100/143] Simplify API to get IMDN message state for each participants. --- include/linphone/api/c-chat-message.h | 20 +---- src/c-wrapper/api/c-chat-message.cpp | 12 +-- src/chat/chat-message/chat-message-p.h | 1 - src/chat/chat-message/chat-message.cpp | 49 ++++-------- src/chat/chat-message/chat-message.h | 4 +- src/db/main-db-p.h | 7 ++ src/db/main-db.cpp | 103 ++++++++----------------- src/db/main-db.h | 11 +-- tester/group_chat_tester.c | 28 ++++--- 9 files changed, 80 insertions(+), 155 deletions(-) diff --git a/include/linphone/api/c-chat-message.h b/include/linphone/api/c-chat-message.h index d37931c74..715ed8b41 100644 --- a/include/linphone/api/c-chat-message.h +++ b/include/linphone/api/c-chat-message.h @@ -381,25 +381,13 @@ LINPHONE_PUBLIC const char *linphone_chat_message_get_text_content (const Linpho LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer_in_progress (LinphoneChatMessage *msg); /** - * Gets the list of participants that displayed this message and the time at which they did. + * Gets the list of participants for which the imdn state has reached the specified state and the time at which they did. * @param[in] msg #LinphoneChatMessage object. + * @param[in] state The LinphoneChatMessageState the imdn have reached (only use LinphoneChatMessageStateDelivered, + * LinphoneChatMessageStateDeliveredToUser, LinphoneChatMessageStateDisplayed and LinphoneChatMessageStateNotDelivered) * @return \bctbx_list{LinphoneParticipantImdnState} */ -LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_displayed (const LinphoneChatMessage *msg); - -/** - * Gets the list of participants that did not receive this message. - * @param[in] msg #LinphoneChatMessage object. - * @return \bctbx_list{LinphoneParticipantImdnState} - */ -LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_not_received (const LinphoneChatMessage *msg); - -/** - * Gets the list of participants that received this message and the time at which they did. - * @param[in] msg #LinphoneChatMessage object. - * @return \bctbx_list{LinphoneParticipantImdnState} - */ -LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_that_have_received (const LinphoneChatMessage *msg); +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_by_imdn_state (const LinphoneChatMessage *msg, LinphoneChatMessageState state); /** * @} diff --git a/src/c-wrapper/api/c-chat-message.cpp b/src/c-wrapper/api/c-chat-message.cpp index 12314bf52..743b728cd 100644 --- a/src/c-wrapper/api/c-chat-message.cpp +++ b/src/c-wrapper/api/c-chat-message.cpp @@ -251,16 +251,8 @@ bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *m return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isFileTransferInProgress(); } -bctbx_list_t *linphone_chat_message_get_participants_that_have_displayed (const LinphoneChatMessage *msg) { - return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getParticipantsThatHaveDisplayed()); -} - -bctbx_list_t *linphone_chat_message_get_participants_that_have_not_received (const LinphoneChatMessage *msg) { - return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getParticipantsThatHaveNotReceived()); -} - -bctbx_list_t *linphone_chat_message_get_participants_that_have_received (const LinphoneChatMessage *msg) { - return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getParticipantsThatHaveReceived()); +bctbx_list_t *linphone_chat_message_get_participants_by_imdn_state (const LinphoneChatMessage *msg, LinphoneChatMessageState state) { + return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(msg)->getParticipantsByImdnState(LinphonePrivate::ChatMessage::State(state))); } diff --git a/src/chat/chat-message/chat-message-p.h b/src/chat/chat-message/chat-message-p.h index b013e9b96..86bdff7e1 100644 --- a/src/chat/chat-message/chat-message-p.h +++ b/src/chat/chat-message/chat-message-p.h @@ -60,7 +60,6 @@ public: void setDirection (ChatMessage::Direction dir); - std::list getParticipantsByImdnState (MainDb::ParticipantStateRetrievalFunc func) const; void setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState, time_t stateChangeTime); virtual void setState (ChatMessage::State newState, bool force = false); diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index f47f42283..9eaaa4086 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -71,26 +71,6 @@ void ChatMessagePrivate::setIsReadOnly (bool readOnly) { isReadOnly = readOnly; } -list ChatMessagePrivate::getParticipantsByImdnState (MainDb::ParticipantStateRetrievalFunc func) const { - L_Q(); - - list result; - if (!(q->getChatRoom()->getCapabilities() & AbstractChatRoom::Capabilities::Conference) || !dbKey.isValid()) - return result; - - unique_ptr &mainDb = q->getChatRoom()->getCore()->getPrivate()->mainDb; - shared_ptr eventLog = mainDb->getEventFromKey(dbKey); - list dbResults = func(eventLog); - for (const auto &dbResult : dbResults) { - auto sender = q->getChatRoom()->findParticipant(q->getFromAddress()); - auto participant = q->getChatRoom()->findParticipant(dbResult.address); - if (participant && (participant != sender)) - result.emplace_back(participant, dbResult.state, dbResult.timestamp); - } - - return result; -} - void ChatMessagePrivate::setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState, time_t stateChangeTime) { L_Q(); @@ -1018,25 +998,24 @@ void ChatMessage::setToBeStored (bool value) { // ----------------------------------------------------------------------------- -list ChatMessage::getParticipantsThatHaveDisplayed () const { +list ChatMessage::getParticipantsByImdnState (ChatMessage::State state) const { L_D(); - unique_ptr &mainDb = getChatRoom()->getCore()->getPrivate()->mainDb; - auto func = bind(&MainDb::getChatMessageParticipantsThatHaveDisplayed, mainDb.get(), std::placeholders::_1); - return d->getParticipantsByImdnState(func); -} -list ChatMessage::getParticipantsThatHaveNotReceived () const { - L_D(); - unique_ptr &mainDb = getChatRoom()->getCore()->getPrivate()->mainDb; - auto func = bind(&MainDb::getChatMessageParticipantsThatHaveNotReceived, mainDb.get(), std::placeholders::_1); - return d->getParticipantsByImdnState(func); -} + list result; + if (!(getChatRoom()->getCapabilities() & AbstractChatRoom::Capabilities::Conference) || !d->dbKey.isValid()) + return result; -list ChatMessage::getParticipantsThatHaveReceived () const { - L_D(); unique_ptr &mainDb = getChatRoom()->getCore()->getPrivate()->mainDb; - auto func = bind(&MainDb::getChatMessageParticipantsThatHaveReceived, mainDb.get(), std::placeholders::_1); - return d->getParticipantsByImdnState(func); + shared_ptr eventLog = mainDb->getEventFromKey(d->dbKey); + list dbResults = mainDb->getChatMessageParticipantsByImdnState(eventLog, state); + for (const auto &dbResult : dbResults) { + auto sender = getChatRoom()->findParticipant(getFromAddress()); + auto participant = getChatRoom()->findParticipant(dbResult.address); + if (participant && (participant != sender)) + result.emplace_back(participant, dbResult.state, dbResult.timestamp); + } + + return result; } // ----------------------------------------------------------------------------- diff --git a/src/chat/chat-message/chat-message.h b/src/chat/chat-message/chat-message.h index 7b5af855a..ef188d8bc 100644 --- a/src/chat/chat-message/chat-message.h +++ b/src/chat/chat-message/chat-message.h @@ -94,9 +94,7 @@ public: bool getToBeStored () const; virtual void setToBeStored (bool value); - std::list getParticipantsThatHaveDisplayed () const; - std::list getParticipantsThatHaveReceived () const; - std::list getParticipantsThatHaveNotReceived () const; + std::list getParticipantsByImdnState (State state) const; const std::list &getContents () const; void addContent (Content *content); diff --git a/src/db/main-db-p.h b/src/db/main-db-p.h index 35c93f42d..195cd1abe 100644 --- a/src/db/main-db-p.h +++ b/src/db/main-db-p.h @@ -150,6 +150,13 @@ private: long long insertConferenceParticipantDeviceEvent (const std::shared_ptr &eventLog); long long insertConferenceSubjectEvent (const std::shared_ptr &eventLog); + void setChatMessageParticipantState ( + const std::shared_ptr &eventLog, + const IdentityAddress &participantAddress, + ChatMessage::State state, + time_t stateChangeTime + ); + // --------------------------------------------------------------------------- // Cache API. // --------------------------------------------------------------------------- diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index bd5245f67..3a85ed5aa 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -779,6 +779,13 @@ void MainDbPrivate::updateConferenceChatMessageEvent (const shared_ptr deleteContents(eventId); for (const auto &content : chatMessage->getContents()) insertContent(eventId, *content); + + if ((chatMessage->getDirection() == ChatMessage::Direction::Outgoing) + && ((chatMessage->getState() == ChatMessage::State::Delivered) || (chatMessage->getState() == ChatMessage::State::NotDelivered)) + ) { + for (const auto &participant : chatMessage->getChatRoom()->getParticipants()) + setChatMessageParticipantState(eventLog, participant->getAddress(), chatMessage->getState(), std::time(nullptr)); + } } long long MainDbPrivate::insertConferenceNotifiedEvent (const shared_ptr &eventLog, long long *chatRoomId) { @@ -904,6 +911,26 @@ long long MainDbPrivate::insertConferenceSubjectEvent (const shared_ptr &eventLog, + const IdentityAddress &participantAddress, + ChatMessage::State state, + time_t stateChangeTime +) { + const EventLogPrivate *dEventLog = eventLog->getPrivate(); + MainDbKeyPrivate *dEventKey = static_cast(dEventLog->dbKey).getPrivate(); + const long long &eventId = dEventKey->storageId; + const long long &participantSipAddressId = selectSipAddressId(participantAddress.asString()); + int stateInt = static_cast(state); + const tm &stateChangeTm = Utils::getTimeTAsTm(stateChangeTime); + + *dbSession.getBackendSession() << "UPDATE chat_message_participant SET state = :state," + " state_change_time = :stateChangeTm" + " WHERE event_id = :eventId AND participant_sip_address_id = :participantSipAddressId", + soci::use(stateInt), soci::use(stateChangeTm), soci::use(eventId), soci::use(participantSipAddressId); +} + + // ----------------------------------------------------------------------------- // Cache API. // ----------------------------------------------------------------------------- @@ -1961,8 +1988,9 @@ list> MainDb::getUnreadChatMessages (const ChatRoomId &c }; } -list MainDb::getChatMessageParticipantsThatHaveDisplayed ( - const shared_ptr &eventLog +list MainDb::getChatMessageParticipantsByImdnState ( + const shared_ptr &eventLog, + ChatMessage::State state ) const { return L_DB_TRANSACTION { L_D(); @@ -1970,7 +1998,7 @@ list MainDb::getChatMessageParticipantsThatHaveDisplay const EventLogPrivate *dEventLog = eventLog->getPrivate(); MainDbKeyPrivate *dEventKey = static_cast(dEventLog->dbKey).getPrivate(); const long long &eventId = dEventKey->storageId; - int stateInt = static_cast(ChatMessage::State::Displayed); + int stateInt = static_cast(state); static const string query = "SELECT sip_address.value, chat_message_participant.state_change_time" " FROM sip_address, chat_message_participant" @@ -1982,60 +2010,7 @@ list MainDb::getChatMessageParticipantsThatHaveDisplay list result; for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Displayed, MainDbPrivate::getTmAsTimeT(row.get(1))); - return result; - }; -} - -list MainDb::getChatMessageParticipantsThatHaveNotReceived ( - const shared_ptr &eventLog -) const { - return L_DB_TRANSACTION { - L_D(); - - const EventLogPrivate *dEventLog = eventLog->getPrivate(); - MainDbKeyPrivate *dEventKey = static_cast(dEventLog->dbKey).getPrivate(); - const long long &eventId = dEventKey->storageId; - int deliveredStateInt = static_cast(ChatMessage::State::DeliveredToUser); - int displayedStateInt = static_cast(ChatMessage::State::Displayed); - - static const string query = "SELECT sip_address.value, chat_message_participant.state_change_time" - " FROM sip_address, chat_message_participant" - " WHERE event_id = :eventId AND state <> :deliveredState AND state <> :displayedState" - " AND sip_address.id = chat_message_participant.participant_sip_address_id"; - soci::rowset rows = (d->dbSession.getBackendSession()->prepare << query, - soci::use(eventId), soci::use(deliveredStateInt), soci::use(displayedStateInt) - ); - - list result; - for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::Idle, 0); - return result; - }; -} - -list MainDb::getChatMessageParticipantsThatHaveReceived ( - const shared_ptr &eventLog -) const { - return L_DB_TRANSACTION { - L_D(); - - const EventLogPrivate *dEventLog = eventLog->getPrivate(); - MainDbKeyPrivate *dEventKey = static_cast(dEventLog->dbKey).getPrivate(); - const long long &eventId = dEventKey->storageId; - int stateInt = static_cast(ChatMessage::State::DeliveredToUser); - - static const string query = "SELECT sip_address.value, chat_message_participant.state_change_time" - " FROM sip_address, chat_message_participant" - " WHERE event_id = :eventId AND state = :state" - " AND sip_address.id = chat_message_participant.participant_sip_address_id"; - soci::rowset rows = (d->dbSession.getBackendSession()->prepare << query, - soci::use(eventId), soci::use(stateInt) - ); - - list result; - for (const auto &row : rows) - result.emplace_back(IdentityAddress(row.get(0)), ChatMessage::State::DeliveredToUser, MainDbPrivate::getTmAsTimeT(row.get(1))); + result.emplace_back(IdentityAddress(row.get(0)), state, MainDbPrivate::getTmAsTimeT(row.get(1))); return result; }; } @@ -2092,19 +2067,7 @@ void MainDb::setChatMessageParticipantState ( ) { L_DB_TRANSACTION { L_D(); - - const EventLogPrivate *dEventLog = eventLog->getPrivate(); - MainDbKeyPrivate *dEventKey = static_cast(dEventLog->dbKey).getPrivate(); - const long long &eventId = dEventKey->storageId; - const long long &participantSipAddressId = d->selectSipAddressId(participantAddress.asString()); - int stateInt = static_cast(state); - const tm &stateChangeTm = Utils::getTimeTAsTm(stateChangeTime); - - *d->dbSession.getBackendSession() << "UPDATE chat_message_participant SET state = :state," - " state_change_time = :stateChangeTm" - " WHERE event_id = :eventId AND participant_sip_address_id = :participantSipAddressId", - soci::use(stateInt), soci::use(stateChangeTm), soci::use(eventId), soci::use(participantSipAddressId); - + d->setChatMessageParticipantState(eventLog, participantAddress, state, stateChangeTime); tr.commit(); }; } diff --git a/src/db/main-db.h b/src/db/main-db.h index e43cb9130..04ed07a71 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -102,14 +102,9 @@ public: void markChatMessagesAsRead (const ChatRoomId &chatRoomId) const; std::list> getUnreadChatMessages (const ChatRoomId &chatRoomId) const; - std::list getChatMessageParticipantsThatHaveDisplayed ( - const std::shared_ptr &eventLog - ) const; - std::list getChatMessageParticipantsThatHaveNotReceived ( - const std::shared_ptr &eventLog - ) const; - std::list getChatMessageParticipantsThatHaveReceived ( - const std::shared_ptr &eventLog + std::list getChatMessageParticipantsByImdnState ( + const std::shared_ptr &eventLog, + ChatMessage::State state ) const; std::list getChatMessageParticipantStates (const std::shared_ptr &eventLog) const; ChatMessage::State getChatMessageParticipantState ( diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index f183aa73c..1990453bf 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -3089,8 +3089,8 @@ static void imdn_for_group_chat_room (void) { // Check that the message has been delivered to Marie and Pauline BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 3000)); - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_displayed(chloeMessage)); - bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_that_have_received(chloeMessage); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDisplayed)); + bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDeliveredToUser); if (BC_ASSERT_PTR_NOT_NULL(participantsThatReceivedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatReceivedChloeMessage), 2, int, "%d"); for (bctbx_list_t *item = participantsThatReceivedChloeMessage; item; item = bctbx_list_next(item)) { @@ -3101,33 +3101,36 @@ static void imdn_for_group_chat_room (void) { } bctbx_list_free_with_data(participantsThatReceivedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); } - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_not_received(chloeMessage)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDelivered)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateNotDelivered)); // Marie marks the message as read, check that the state is not yet displayed on Chloe's side linphone_chat_room_mark_as_read(marieCr); BC_ASSERT_FALSE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 3000)); - bctbx_list_t *participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_that_have_displayed(chloeMessage); + bctbx_list_t *participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDisplayed); if (BC_ASSERT_PTR_NOT_NULL(participantsThatDisplayedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatDisplayedChloeMessage), 1, int, "%d"); bctbx_list_free_with_data(participantsThatDisplayedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); } - participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_that_have_received(chloeMessage); + participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDeliveredToUser); if (BC_ASSERT_PTR_NOT_NULL(participantsThatReceivedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatReceivedChloeMessage), 1, int, "%d"); bctbx_list_free_with_data(participantsThatReceivedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); } - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_not_received(chloeMessage)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDelivered)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateNotDelivered)); // Pauline also marks the message as read, check that the state is now displayed on Chloe's side linphone_chat_room_mark_as_read(paulineCr); BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDisplayed, initialChloeStats.number_of_LinphoneMessageDisplayed + 1, 3000)); - participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_that_have_displayed(chloeMessage); + participantsThatDisplayedChloeMessage = linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDisplayed); if (BC_ASSERT_PTR_NOT_NULL(participantsThatDisplayedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatDisplayedChloeMessage), 2, int, "%d"); bctbx_list_free_with_data(participantsThatDisplayedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); } - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_received(chloeMessage)); - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_not_received(chloeMessage)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDeliveredToUser)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDelivered)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateNotDelivered)); linphone_chat_message_unref(chloeMessage); @@ -3303,8 +3306,8 @@ static void imdn_sent_from_db_state (void) { // Check that the message has been delivered to Marie and Pauline BC_ASSERT_TRUE(wait_for_list(coresList, &chloe->stat.number_of_LinphoneMessageDeliveredToUser, initialChloeStats.number_of_LinphoneMessageDeliveredToUser + 1, 3000)); - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_displayed(chloeMessage)); - bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_that_have_received(chloeMessage); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDisplayed)); + bctbx_list_t *participantsThatReceivedChloeMessage = linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDeliveredToUser); if (BC_ASSERT_PTR_NOT_NULL(participantsThatReceivedChloeMessage)) { BC_ASSERT_EQUAL((int)bctbx_list_size(participantsThatReceivedChloeMessage), 2, int, "%d"); for (bctbx_list_t *item = participantsThatReceivedChloeMessage; item; item = bctbx_list_next(item)) { @@ -3315,7 +3318,8 @@ static void imdn_sent_from_db_state (void) { } bctbx_list_free_with_data(participantsThatReceivedChloeMessage, (bctbx_list_free_func)linphone_participant_imdn_state_unref); } - BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_that_have_not_received(chloeMessage)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateDelivered)); + BC_ASSERT_PTR_NULL(linphone_chat_message_get_participants_by_imdn_state(chloeMessage, LinphoneChatMessageStateNotDelivered)); linphone_chat_message_unref(chloeMessage); From fc852805fa5669458edffa279fda083b406dd81a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 27 Apr 2018 18:15:15 +0200 Subject: [PATCH 101/143] Check keywords before setting the OneToOne capability on a ClientGroupChatRoom. --- src/chat/chat-room/client-group-chat-room.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 1c21542f6..0635c833b 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + #include "linphone/utils/utils.h" #include "address/address-p.h" @@ -522,7 +524,8 @@ void ClientGroupChatRoom::onConferenceCreated (const IdentityAddress &addr) { void ClientGroupChatRoom::onConferenceKeywordsChanged (const vector &keywords) { L_D(); - d->capabilities |= ClientGroupChatRoom::Capabilities::OneToOne; + if (find(keywords.cbegin(), keywords.cend(), "one-to-one") != keywords.cend()) + d->capabilities |= ClientGroupChatRoom::Capabilities::OneToOne; } void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) { From f314b694a0717896af1b519476bfbd9e0b8062e6 Mon Sep 17 00:00:00 2001 From: Matthieu Tanon Date: Fri, 5 Jan 2018 15:07:46 +0000 Subject: [PATCH 102/143] Add zrtp rcfiles in tester CMakeList --- tester/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 10df74697..ce37dbd30 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -115,6 +115,8 @@ set(RC_FILES rcfiles/marie_zrtp_aes256_rc rcfiles/marie_zrtp_b256_rc rcfiles/marie_zrtp_srtpsuite_aes256_rc + rcfiles/marie_zrtp_ecdh255_rc + rcfiles/marie_zrtp_ecdh448_rc rcfiles/michelle_rc_udp rcfiles/multi_account_rc rcfiles/pauline_alt_rc From 149fd7bfcc3c51e4251e7ea408515db14aba8582 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 30 Apr 2018 10:24:53 +0200 Subject: [PATCH 103/143] Allow parsing of CPIM with wrong "Content-type: Message/CPIM" header. --- share/cpim_grammar | Bin 5346 -> 5437 bytes src/chat/cpim/parser/cpim-rules | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/share/cpim_grammar b/share/cpim_grammar index 066afb55811392f443765d48c539188ba12c945a..c89e4f87f05c19ac615b1ef4b24bc4a8957230ce 100644 GIT binary patch delta 108 zcmaE)xmRmL9iwq#K|!T%MrvY8Y7qkvFtIZv=jWBA=9TD{R2HOKDdeUW7bm8t>L(Xu n<}z?47v-ceY_4Y9$*#uA3Q`XOj4U9M2`Gtd7*wq(=UQ$6>P8+9 delta 19 bcmdn1^+ Date: Mon, 30 Apr 2018 10:44:28 +0200 Subject: [PATCH 104/143] feat(event-log-enums): add documentation, please use this commit like an example to generate doxygen doc properly --- include/linphone/enums/event-log-enums.h | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/include/linphone/enums/event-log-enums.h b/include/linphone/enums/event-log-enums.h index 3acd1b62c..fd23f7977 100644 --- a/include/linphone/enums/event-log-enums.h +++ b/include/linphone/enums/event-log-enums.h @@ -23,18 +23,18 @@ // ============================================================================= #define L_ENUM_VALUES_EVENT_LOG_TYPE(F) \ - F(None) \ - F(ConferenceCreated) \ - F(ConferenceTerminated) \ - F(ConferenceCallStart) \ - F(ConferenceCallEnd) \ - F(ConferenceChatMessage) \ - F(ConferenceParticipantAdded) \ - F(ConferenceParticipantRemoved) \ - F(ConferenceParticipantSetAdmin) \ - F(ConferenceParticipantUnsetAdmin) \ - F(ConferenceParticipantDeviceAdded) \ - F(ConferenceParticipantDeviceRemoved) \ - F(ConferenceSubjectChanged) + F(None /**< No defined event */) \ + F(ConferenceCreated /**< Conference (created) event */) \ + F(ConferenceTerminated /**< Conference (terminated) event */) \ + F(ConferenceCallStart /**< Conference call (start) event */) \ + F(ConferenceCallEnd /**< Conference call (end) event */) \ + F(ConferenceChatMessage /**< Conference chat message event */) \ + F(ConferenceParticipantAdded /**< Conference participant (added) event */) \ + F(ConferenceParticipantRemoved /**< Conference participant (removed) event */) \ + F(ConferenceParticipantSetAdmin /**< Conference participant (set admin) event */) \ + F(ConferenceParticipantUnsetAdmin /**< Conference participant (unset admin) event */) \ + F(ConferenceParticipantDeviceAdded /**< Conference participant device (added) event */) \ + F(ConferenceParticipantDeviceRemoved /**< Conference participant device (removed) event */) \ + F(ConferenceSubjectChanged /**< Conference subject event */) \ #endif // ifndef _L_EVENT_LOG_ENUMS_H_ From 444ec1ac9a51de918a2aeff783307cc053f23866 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 30 Apr 2018 12:02:59 +0200 Subject: [PATCH 105/143] Rewrite commit a858005 from master branch (Don't unregister previous contact by default. It is causing troubles with +sip.instance) --- coreapi/proxy.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index a49154e90..cd815de65 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -457,20 +457,16 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *cfg,LinphoneCore *lc){ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig * cfg){ LinphoneAddress *contact_addr = NULL; - { - const SalAddress *sal_addr = cfg->op && cfg->state == LinphoneRegistrationOk - ? cfg->op->get_contact_address() - : NULL; - if (sal_addr) { - char *buf = sal_address_as_string(sal_addr); - contact_addr = buf ? linphone_address_new(buf) : NULL; - ms_free(buf); - } + const SalAddress *sal_addr = cfg->op && cfg->state == LinphoneRegistrationOk ? cfg->op->get_contact_address() : NULL; + if (sal_addr) { + char *buf = sal_address_as_string(sal_addr); + contact_addr = buf ? linphone_address_new(buf) : NULL; + ms_free(buf); } /*with udp, there is a risk of port reuse, so I prefer to not do anything for now*/ if (contact_addr) { - if (linphone_address_get_transport(contact_addr) != LinphoneTransportUdp) { + if (linphone_address_get_transport(contact_addr) != LinphoneTransportUdp && lp_config_get_int(cfg->lc->config, "sip", "unregister_previous_contact", 0)) { if (cfg->pending_contact) linphone_address_unref(cfg->pending_contact); cfg->pending_contact=contact_addr; @@ -1589,4 +1585,4 @@ bool_t linphone_proxy_config_is_push_notification_allowed(const LinphoneProxyCon void linphone_proxy_config_set_push_notification_allowed(LinphoneProxyConfig *cfg, bool_t is_allowed) { cfg->push_notification_allowed = is_allowed; -} \ No newline at end of file +} From 936c69ea97d6773b035d6218103c4e6addd4ba0f Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 9 Jan 2018 16:55:06 +0100 Subject: [PATCH 106/143] Fixing regid on register test --- tester/register_tester.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/register_tester.c b/tester/register_tester.c index 5808c5b7e..389ca3095 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -1336,7 +1336,7 @@ static void register_without_regid(void) { if(cfg) { const LinphoneAddress *addr = linphone_proxy_config_get_contact(cfg); BC_ASSERT_PTR_NOT_NULL(addr); - BC_ASSERT_PTR_NOT_NULL(strstr(linphone_address_as_string_uri_only(addr), "regid")); + BC_ASSERT_PTR_NULL(strstr(linphone_address_as_string_uri_only(addr), "regid")); } linphone_core_manager_destroy(marie); } From 387398eed2c9a763a62386765332a59929fb4d80 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 9 Jan 2018 17:14:59 +0100 Subject: [PATCH 107/143] Move "regid" test to Flexisip suite. --- tester/flexisip_tester.c | 15 ++++++++++++++- tester/register_tester.c | 16 +--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index b2cdf5c23..75b40b9be 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1395,6 +1395,18 @@ end: ms_free(hellopath); } +static void register_without_regid(void) { + LinphoneCoreManager *marie = linphone_core_manager_new2("marie_rc", FALSE); + linphone_core_manager_start(marie,TRUE); + LinphoneProxyConfig *cfg=linphone_core_get_default_proxy_config(marie->lc); + if(cfg) { + const LinphoneAddress *addr = linphone_proxy_config_get_contact(cfg); + BC_ASSERT_PTR_NOT_NULL(addr); + BC_ASSERT_PTR_NULL(strstr(linphone_address_as_string_uri_only(addr), "regid")); + } + linphone_core_manager_destroy(marie); +} + void test_removing_old_tport(void) { bctbx_list_t* lcs; LinphoneCoreManager* marie2; @@ -1852,7 +1864,8 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Sequential forking with timeout for highest priority", sequential_forking_with_timeout_for_highest_priority), TEST_NO_TAG("Sequential forking with no response from highest priority", sequential_forking_with_no_response_for_highest_priority), TEST_NO_TAG("Sequential forking with insertion of higher priority", sequential_forking_with_insertion_of_higher_priority), - TEST_NO_TAG("Sequential forking with fallback route", sequential_forking_with_fallback_route) + TEST_NO_TAG("Sequential forking with fallback route", sequential_forking_with_fallback_route), + TEST_NO_TAG("Registered contact does not have regid param", register_without_regid) }; diff --git a/tester/register_tester.c b/tester/register_tester.c index 389ca3095..3b051089c 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -1328,19 +1328,6 @@ static void multi_devices_register_with_gruu(void) { linphone_core_manager_destroy(marie); } -static void register_without_regid(void) { - LinphoneCoreManager *marie = ms_new0(LinphoneCoreManager, 1); - linphone_core_manager_init(marie, "marie_rc", NULL); - linphone_core_manager_start(marie,TRUE); - LinphoneProxyConfig *cfg=linphone_core_get_default_proxy_config(marie->lc); - if(cfg) { - const LinphoneAddress *addr = linphone_proxy_config_get_contact(cfg); - BC_ASSERT_PTR_NOT_NULL(addr); - BC_ASSERT_PTR_NULL(strstr(linphone_address_as_string_uri_only(addr), "regid")); - } - linphone_core_manager_destroy(marie); -} - test_t register_tests[] = { TEST_NO_TAG("Simple register", simple_register), @@ -1391,8 +1378,7 @@ test_t register_tests[] = { TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback", tls_auth_info_client_cert_cb), TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback 2", tls_auth_info_client_cert_cb_2), TEST_NO_TAG("Register get GRUU", register_get_gruu), - TEST_NO_TAG("Register get GRUU for multi device", multi_devices_register_with_gruu), - TEST_NO_TAG("Register contact do not have regid param", register_without_regid) + TEST_NO_TAG("Register get GRUU for multi device", multi_devices_register_with_gruu) }; test_suite_t register_test_suite = {"Register", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From 9570ab8a396884c52a1970e87edcaa125316185e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 10 Jan 2018 16:34:22 +0100 Subject: [PATCH 108/143] add new test for ambigous register. --- tester/flexisip_tester.c | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 75b40b9be..fae2f4242 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -544,6 +544,64 @@ static void call_forking_with_push_notification_single(void){ bctbx_list_free(lcs); } +/* + * This test is a variant of push notification (single) where the client do send ambigous REGISTER with two contacts, + * one of them being the previous contact address with "expires=0" to tell the server to remove it. +**/ +static void call_forking_with_push_notification_double_contact(void){ + bctbx_list_t* lcs; + LinphoneCoreManager* marie = linphone_core_manager_new2( "marie_rc", FALSE); + LinphoneCoreManager* pauline = linphone_core_manager_new2( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc",FALSE); + int dummy=0; + + + lp_config_set_int(linphone_core_get_config(marie->lc), "sip", "unregister_previous_contact", 1); + lp_config_set_int(linphone_core_get_config(pauline->lc), "sip", "unregister_previous_contact", 1); + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + linphone_proxy_config_set_contact_uri_parameters( + linphone_core_get_default_proxy_config(marie->lc), + "app-id=org.linphonetester;pn-tok=aaabbb;pn-type=apple;pn-msg-str=33;pn-call-str=34;"); + + lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneRegistrationOk,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,1,5000)); + + /*unfortunately marie gets unreachable due to crappy 3G operator or iOS bug...*/ + linphone_core_set_network_reachable(marie->lc,FALSE); + + linphone_core_invite_address(pauline->lc,marie->identity); + + /*After 5 seconds the server is expected to send a push notification to marie, this will wake up linphone, that will reconnect:*/ + wait_for_list(lcs,&dummy,1,6000); + linphone_core_set_network_reachable(marie->lc,TRUE); + + /*Marie shall receive the call immediately*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,5000)); + /*pauline should hear ringback as well*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,1000)); + + /*marie accepts the call*/ + if (BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc))) { + linphone_call_accept(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + + liblinphone_tester_check_rtcp(pauline,marie); + + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000)); + } + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(marie); + bctbx_list_free(lcs); +} + static void call_forking_with_push_notification_multiple(void){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1834,6 +1892,7 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Call forking declined localy", call_forking_declined_localy), TEST_NO_TAG("Call forking with urgent reply", call_forking_with_urgent_reply), TEST_NO_TAG("Call forking with push notification (single)", call_forking_with_push_notification_single), + TEST_NO_TAG("Call forking with push notification with double contact", call_forking_with_push_notification_double_contact), TEST_NO_TAG("Call forking with push notification (multiple)", call_forking_with_push_notification_multiple), TEST_NO_TAG("Call forking not responded", call_forking_not_responded), TEST_NO_TAG("Early-media call forking", early_media_call_forking), From d67eeda8731b4db5ddae62b1439aef09132e9457 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 30 Apr 2018 12:52:53 +0200 Subject: [PATCH 109/143] Applied snapshot taken callback changes from master --- coreapi/private_functions.h | 1 + include/linphone/api/c-call-cbs.h | 14 ++++ include/linphone/api/c-callbacks.h | 7 ++ src/c-wrapper/api/c-call-cbs.cpp | 9 +++ src/c-wrapper/api/c-call.cpp | 3 + src/call/call-p.h | 1 + src/call/call.cpp | 5 ++ .../session/call-session-listener.h | 2 + src/conference/session/media-session-p.h | 3 + src/conference/session/media-session.cpp | 21 +++++ tester/call_video_tester.c | 76 ++++++++++++++++++- tester/liblinphone_tester.h | 2 + 12 files changed, 141 insertions(+), 3 deletions(-) diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 031e00eef..8e6ce8394 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -49,6 +49,7 @@ void linphone_call_notify_stats_updated(LinphoneCall *call, const LinphoneCallSt void linphone_call_notify_info_message_received(LinphoneCall *call, const LinphoneInfoMessage *msg); void linphone_call_notify_ack_processing(LinphoneCall *call, LinphoneHeaders *msg, bool_t is_received); void linphone_call_notify_tmmbr_received(LinphoneCall *call, int stream_index, int tmmbr); +void linphone_call_notify_snapshot_taken(LinphoneCall *call, const char *file_path); LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg); LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op); diff --git a/include/linphone/api/c-call-cbs.h b/include/linphone/api/c-call-cbs.h index 3901702fc..5ef4d70b8 100644 --- a/include/linphone/api/c-call-cbs.h +++ b/include/linphone/api/c-call-cbs.h @@ -173,6 +173,20 @@ LINPHONE_PUBLIC LinphoneCallCbsTmmbrReceivedCb linphone_call_cbs_get_tmmbr_recei */ LINPHONE_PUBLIC void linphone_call_cbs_set_tmmbr_received(LinphoneCallCbs *cbs, LinphoneCallCbsTmmbrReceivedCb cb); +/** + * Get the snapshot taken callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current snapshot taken callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsSnapshotTakenCb linphone_call_cbs_get_snapshot_taken(LinphoneCallCbs *cbs); + +/** + * Set the snapshot taken callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The snapshot taken callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_snapshot_taken(LinphoneCallCbs *cbs, LinphoneCallCbsSnapshotTakenCb cb); + /** * @} */ diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index 6a707e7b1..f3a29a94a 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -95,6 +95,13 @@ typedef void (*LinphoneCallCbsAckProcessingCb)(LinphoneCall *call, LinphoneHeade */ typedef void (*LinphoneCallCbsTmmbrReceivedCb)(LinphoneCall *call, int stream_index, int tmmbr); +/** + * Callback for notifying a snapshot taken. + * @param call LinphoneCall for which the snapshot was taken + * @param filepath the name of the saved file + */ +typedef void (*LinphoneCallCbsSnapshotTakenCb)(LinphoneCall *call, const char *filepath); + /** * @} **/ diff --git a/src/c-wrapper/api/c-call-cbs.cpp b/src/c-wrapper/api/c-call-cbs.cpp index 903dfa26a..3280c3e0b 100644 --- a/src/c-wrapper/api/c-call-cbs.cpp +++ b/src/c-wrapper/api/c-call-cbs.cpp @@ -34,6 +34,7 @@ struct _LinphoneCallCbs { LinphoneCallCbsTransferStateChangedCb transferStateChangedCb; LinphoneCallCbsAckProcessingCb ackProcessing; LinphoneCallCbsTmmbrReceivedCb tmmbrReceivedCb; + LinphoneCallCbsSnapshotTakenCb snapshotTakenCb; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallCbs); @@ -133,3 +134,11 @@ LinphoneCallCbsTmmbrReceivedCb linphone_call_cbs_get_tmmbr_received (LinphoneCal void linphone_call_cbs_set_tmmbr_received (LinphoneCallCbs *cbs, LinphoneCallCbsTmmbrReceivedCb cb) { cbs->tmmbrReceivedCb = cb; } + +LinphoneCallCbsSnapshotTakenCb linphone_call_cbs_get_snapshot_taken(LinphoneCallCbs *cbs) { + return cbs->snapshotTakenCb; +} + +void linphone_call_cbs_set_snapshot_taken(LinphoneCallCbs *cbs, LinphoneCallCbsSnapshotTakenCb cb) { + cbs->snapshotTakenCb = cb; +} diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index c3f05d29a..1eae338a6 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -184,6 +184,9 @@ void linphone_call_notify_tmmbr_received (LinphoneCall *call, int stream_index, NOTIFY_IF_EXIST(TmmbrReceived, tmmbr_received, call, stream_index, tmmbr) } +void linphone_call_notify_snapshot_taken(LinphoneCall *call, const char *file_path) { + NOTIFY_IF_EXIST(SnapshotTaken, snapshot_taken, call, file_path) +} // ============================================================================= // Public functions. diff --git a/src/call/call-p.h b/src/call/call-p.h index 0477198df..488df87aa 100644 --- a/src/call/call-p.h +++ b/src/call/call-p.h @@ -111,6 +111,7 @@ private: bool isPlayingRingbackTone (const std::shared_ptr &session) override; void onRealTimeTextCharacterReceived (const std::shared_ptr &session, RealtimeTextReceivedCharacter *character) override; void onTmmbrReceived(const std::shared_ptr &session, int streamIndex, int tmmbr) override; + void onSnapshotTaken(const std::shared_ptr &session, const char *file_path) override; mutable LinphonePlayer *player = nullptr; diff --git a/src/call/call.cpp b/src/call/call.cpp index 6d51ce781..e57c788ea 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -496,6 +496,11 @@ void CallPrivate::onTmmbrReceived (const shared_ptr &session, int s linphone_call_notify_tmmbr_received(L_GET_C_BACK_PTR(q), streamIndex, tmmbr); } +void CallPrivate::onSnapshotTaken(const shared_ptr &session, const char *file_path) { + L_Q(); + linphone_call_notify_snapshot_taken(L_GET_C_BACK_PTR(q), file_path); +} + // ============================================================================= Call::Call (CallPrivate &p, shared_ptr core) : Object(p), CoreAccessor(core) { diff --git a/src/conference/session/call-session-listener.h b/src/conference/session/call-session-listener.h index edc634f22..3b9c20668 100644 --- a/src/conference/session/call-session-listener.h +++ b/src/conference/session/call-session-listener.h @@ -55,6 +55,7 @@ public: virtual void onInfoReceived (const std::shared_ptr &session, const LinphoneInfoMessage *im) {} virtual void onNoMediaTimeoutCheck (const std::shared_ptr &session, bool oneSecondElapsed) {} virtual void onTmmbrReceived (const std::shared_ptr &session, int streamIndex, int tmmbr) {} + virtual void onSnapshotTaken(const std::shared_ptr &session, const char *file_path) {} virtual void onEncryptionChanged (const std::shared_ptr &session, bool activated, const std::string &authToken) {} @@ -80,6 +81,7 @@ public: virtual bool isPlayingRingbackTone (const std::shared_ptr &session) { return false; } virtual void onRealTimeTextCharacterReceived (const std::shared_ptr &session, RealtimeTextReceivedCharacter *data) {} + }; LINPHONE_END_NAMESPACE diff --git a/src/conference/session/media-session-p.h b/src/conference/session/media-session-p.h index 7013e7b18..efdfe04fd 100644 --- a/src/conference/session/media-session-p.h +++ b/src/conference/session/media-session-p.h @@ -106,6 +106,9 @@ public: // CoreListener void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override; + // Call listener + void snapshotTakenCb(void *userdata, struct _MSFilter *f, unsigned int id, void *arg); + private: static OrtpJitterBufferAlgorithm jitterBufferNameToAlgo (const std::string &name); diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 694ef27fd..69dda5acb 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -4364,11 +4364,30 @@ void MediaSession::resetFirstVideoFrameDecoded () { ms_filter_call_method_noarg(d->videoStream->ms.decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION); } +void MediaSessionPrivate::snapshotTakenCb(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) { +#ifdef VIDEO_ENABLED + L_Q(); + if (id == MS_JPEG_WRITER_SNAPSHOT_TAKEN) { + const char *filepath = (const char *) arg; + listener->onSnapshotTaken(q->getSharedFromThis(), filepath); + } +#endif +} + +#ifdef VIDEO_ENABLED +static void snapshot_taken(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) { + MediaSessionPrivate *d = (MediaSessionPrivate *)userdata; + d->snapshotTakenCb(userdata, f, id, arg); +} +#endif + LinphoneStatus MediaSession::takePreviewSnapshot (const string& file) { #ifdef VIDEO_ENABLED L_D(); if (d->videoStream && d->videoStream->local_jpegwriter) { + ms_filter_clear_notify_callback(d->videoStream->jpegwriter); const char *filepath = file.empty() ? nullptr : file.c_str(); + ms_filter_add_notify_callback(d->videoStream->local_jpegwriter, snapshot_taken, d, TRUE); return ms_filter_call_method(d->videoStream->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void *)filepath); } lWarning() << "Cannot take local snapshot: no currently running video stream on this call"; @@ -4380,7 +4399,9 @@ LinphoneStatus MediaSession::takeVideoSnapshot (const string& file) { #ifdef VIDEO_ENABLED L_D(); if (d->videoStream && d->videoStream->jpegwriter) { + ms_filter_clear_notify_callback(d->videoStream->jpegwriter); const char *filepath = file.empty() ? nullptr : file.c_str(); + ms_filter_add_notify_callback(d->videoStream->jpegwriter, snapshot_taken, d, TRUE); return ms_filter_call_method(d->videoStream->jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void *)filepath); } lWarning() << "Cannot take snapshot: no currently running video stream on this call"; diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 51d87b03c..89bbc22c5 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -1693,6 +1693,15 @@ static void video_call_recording_vp8_test(void) { record_call("recording", TRUE, "VP8"); } +static void snapshot_taken(LinphoneCall *call, const char *filepath) { + char *filename = bc_tester_file("snapshot.jpeg"); + LinphoneCore *lc = linphone_call_get_core(call); + stats *callstats = get_stats(lc); + BC_ASSERT_STRING_EQUAL(filepath, filename); + callstats->number_of_snapshot_taken++; + ms_free(filename); +} + static void video_call_snapshot(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1700,7 +1709,6 @@ static void video_call_snapshot(void) { LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); LinphoneCall *callInst = NULL; char *filename = bc_tester_file("snapshot.jpeg"); - int dummy = 0; bool_t call_succeeded = FALSE; linphone_core_enable_video_capture(marie->lc, TRUE); @@ -1712,12 +1720,73 @@ static void video_call_snapshot(void) { BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); - if((call_succeeded == TRUE) && (callInst != NULL)) { + if (call_succeeded == TRUE && callInst != NULL) { + LinphoneCall *marie_call = linphone_core_get_current_call(marie->lc); + LinphoneCallCbs *marie_call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); + BC_ASSERT_PTR_NOT_NULL(marie_call); + linphone_call_cbs_set_snapshot_taken(marie_call_cbs, snapshot_taken); + linphone_call_add_callbacks(marie_call, marie_call_cbs); + linphone_call_cbs_unref(marie_call_cbs); int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); if (jpeg_support < 0) { ms_warning("No jpegwriter support!"); } else { - wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_snapshot_taken,1)); + BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); + remove(filename); + } + end_call(marie, pauline); + } + ms_free(filename); + linphone_call_params_unref(marieParams); + linphone_call_params_unref(paulineParams); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_snapshots(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCallParams *marieParams = linphone_core_create_call_params(marie->lc, NULL); + LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); + LinphoneCall *callInst = NULL; + char *filename = bc_tester_file("snapshot.jpeg"); + bool_t call_succeeded = FALSE; + int dummy = 0; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + linphone_call_params_enable_video(marieParams, TRUE); + linphone_call_params_enable_video(paulineParams, TRUE); + + BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); + BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); + if (call_succeeded == TRUE && callInst != NULL) { + LinphoneCall *marie_call = linphone_core_get_current_call(marie->lc); + LinphoneCallCbs *marie_call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); + BC_ASSERT_PTR_NOT_NULL(marie_call); + linphone_call_cbs_set_snapshot_taken(marie_call_cbs, snapshot_taken); + linphone_call_add_callbacks(marie_call, marie_call_cbs); + linphone_call_cbs_unref(marie_call_cbs); + int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); + if (jpeg_support < 0) { + ms_warning("No jpegwriter support!"); + } else { + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_snapshot_taken,1)); + BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); + remove(filename); + + wait_for_until(marie->lc, pauline->lc, &dummy, 1, 1000); + linphone_call_take_video_snapshot(callInst, filename); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_snapshot_taken,2)); + BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); + remove(filename); + + wait_for_until(marie->lc, pauline->lc, &dummy, 1, 1000); + linphone_call_take_video_snapshot(callInst, filename); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_snapshot_taken,3)); BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); remove(filename); } @@ -2214,6 +2283,7 @@ test_t call_video_tests[] = { TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), TEST_NO_TAG("Snapshot", video_call_snapshot), + TEST_NO_TAG("Snapshots", video_call_snapshots), TEST_NO_TAG("Video call with early media and no matching audio codecs", video_call_with_early_media_no_matching_audio_codecs), TEST_NO_TAG("DTLS SRTP video call", dtls_srtp_video_call), TEST_ONE_TAG("DTLS SRTP ice video call", dtls_srtp_ice_video_call, "ICE"), diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 0979de45c..ca5c6b251 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -291,6 +291,8 @@ typedef struct _stats { int number_of_participants_removed; int number_of_subject_changed; int number_of_participant_devices_added; + + int number_of_snapshot_taken; }stats; From ab06d5147631b9689b21b658dbc5c4292fd9c90d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 17 Jan 2018 14:48:27 +0100 Subject: [PATCH 110/143] Do not crash in lime if either message or content type is NULL --- coreapi/lime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coreapi/lime.c b/coreapi/lime.c index 788a6c893..771f46384 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -485,6 +485,9 @@ int lime_createMultipartMessage(void *cachedb, const char *contentType, uint8_t if (bzrtp_getSelfZID(cachedb, selfURI, selfZid, NULL) != 0) { return LIME_UNABLE_TO_ENCRYPT_MESSAGE; } + if (message == NULL || contentType == NULL) { + return LIME_UNABLE_TO_ENCRYPT_MESSAGE; + } /* encrypted message length is plaintext + 16 for tag */ encryptedMessageLength = (uint32_t)strlen((char *)message) + 16; From 8958c8ac7bd51c90658b1dcf9a47e5395a55d817 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 30 Apr 2018 13:16:18 +0200 Subject: [PATCH 111/143] Applied from master callback for next video frame decoded --- coreapi/private_functions.h | 1 + include/linphone/api/c-call-cbs.h | 14 ++++++++++++++ include/linphone/api/c-callbacks.h | 6 ++++++ src/c-wrapper/api/c-call-cbs.cpp | 9 +++++++++ src/c-wrapper/api/c-call.cpp | 4 ++++ src/call/call.cpp | 1 + src/conference/session/media-session.cpp | 5 +++++ tester/call_multicast_tester.c | 6 +++--- tester/call_single_tester.c | 22 ++++++++++++++++------ tester/call_video_tester.c | 19 ++++++++----------- tester/liblinphone_tester.h | 2 +- 11 files changed, 68 insertions(+), 21 deletions(-) diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 8e6ce8394..9d6b29b08 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -50,6 +50,7 @@ void linphone_call_notify_info_message_received(LinphoneCall *call, const Linpho void linphone_call_notify_ack_processing(LinphoneCall *call, LinphoneHeaders *msg, bool_t is_received); void linphone_call_notify_tmmbr_received(LinphoneCall *call, int stream_index, int tmmbr); void linphone_call_notify_snapshot_taken(LinphoneCall *call, const char *file_path); +void linphone_call_notify_next_video_frame_decoded(LinphoneCall *call); LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg); LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op); diff --git a/include/linphone/api/c-call-cbs.h b/include/linphone/api/c-call-cbs.h index 5ef4d70b8..2cdd6de49 100644 --- a/include/linphone/api/c-call-cbs.h +++ b/include/linphone/api/c-call-cbs.h @@ -187,6 +187,20 @@ LINPHONE_PUBLIC LinphoneCallCbsSnapshotTakenCb linphone_call_cbs_get_snapshot_ta */ LINPHONE_PUBLIC void linphone_call_cbs_set_snapshot_taken(LinphoneCallCbs *cbs, LinphoneCallCbsSnapshotTakenCb cb); + /** + * Get the next video frame decoded callback. + * @param[in] cbs LinphoneCallCbs object. + * @return The current next video frame decoded callback. + */ +LINPHONE_PUBLIC LinphoneCallCbsNextVideoFrameDecodedCb linphone_call_cbs_get_next_video_frame_decoded(LinphoneCallCbs *cbs); + +/** + * Set the next video frame decoded callback. + * @param[in] cbs LinphoneCallCbs object. + * @param[in] cb The next video frame decoded callback to be used. + */ +LINPHONE_PUBLIC void linphone_call_cbs_set_next_video_frame_decoded(LinphoneCallCbs *cbs, LinphoneCallCbsNextVideoFrameDecodedCb cb); + /** * @} */ diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index f3a29a94a..ffedfaf92 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -102,6 +102,12 @@ typedef void (*LinphoneCallCbsTmmbrReceivedCb)(LinphoneCall *call, int stream_in */ typedef void (*LinphoneCallCbsSnapshotTakenCb)(LinphoneCall *call, const char *filepath); + /** + * Callback to notify a next video frame has been decoded + * @param call LinphoneCall for which the next video frame has been decoded + */ +typedef void (*LinphoneCallCbsNextVideoFrameDecodedCb)(LinphoneCall *call); + /** * @} **/ diff --git a/src/c-wrapper/api/c-call-cbs.cpp b/src/c-wrapper/api/c-call-cbs.cpp index 3280c3e0b..8db00054c 100644 --- a/src/c-wrapper/api/c-call-cbs.cpp +++ b/src/c-wrapper/api/c-call-cbs.cpp @@ -35,6 +35,7 @@ struct _LinphoneCallCbs { LinphoneCallCbsAckProcessingCb ackProcessing; LinphoneCallCbsTmmbrReceivedCb tmmbrReceivedCb; LinphoneCallCbsSnapshotTakenCb snapshotTakenCb; + LinphoneCallCbsNextVideoFrameDecodedCb nextVideoFrameDecodedCb; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallCbs); @@ -142,3 +143,11 @@ LinphoneCallCbsSnapshotTakenCb linphone_call_cbs_get_snapshot_taken(LinphoneCall void linphone_call_cbs_set_snapshot_taken(LinphoneCallCbs *cbs, LinphoneCallCbsSnapshotTakenCb cb) { cbs->snapshotTakenCb = cb; } + +LinphoneCallCbsNextVideoFrameDecodedCb linphone_call_cbs_get_next_video_frame_decoded(LinphoneCallCbs *cbs) { + return cbs->nextVideoFrameDecodedCb; +} + +void linphone_call_cbs_set_next_video_frame_decoded(LinphoneCallCbs *cbs, LinphoneCallCbsNextVideoFrameDecodedCb cb) { + cbs->nextVideoFrameDecodedCb = cb; +} diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index 1eae338a6..c0b3cb235 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -188,6 +188,10 @@ void linphone_call_notify_snapshot_taken(LinphoneCall *call, const char *file_pa NOTIFY_IF_EXIST(SnapshotTaken, snapshot_taken, call, file_path) } +void linphone_call_notify_next_video_frame_decoded(LinphoneCall *call) { + NOTIFY_IF_EXIST(NextVideoFrameDecoded, next_video_frame_decoded, call) +} + // ============================================================================= // Public functions. // ============================================================================= diff --git a/src/call/call.cpp b/src/call/call.cpp index e57c788ea..e5fbf5b15 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -418,6 +418,7 @@ void CallPrivate::onFirstVideoFrameDecoded (const shared_ptr &sessi nextVideoFrameDecoded._func = nullptr; nextVideoFrameDecoded._user_data = nullptr; } + linphone_call_notify_next_video_frame_decoded(L_GET_C_BACK_PTR(q)); } void CallPrivate::onResetFirstVideoFrameDecoded (const shared_ptr &session) { diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 69dda5acb..dd887d8df 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -4227,6 +4227,11 @@ void MediaSession::sendVfuRequest () { #ifdef VIDEO_ENABLED L_D(); MediaSessionParams *curParams = getCurrentParams(); + + if (d->videoStream && d->videoStream->ms.decoder) { + ms_filter_call_method_noarg(d->videoStream->ms.decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION); + } + if ((curParams->avpfEnabled() || curParams->getPrivate()->implicitRtcpFbEnabled()) && d->videoStream && media_stream_get_state(&d->videoStream->ms) == MSStreamStarted) { // || sal_media_description_has_implicit_avpf((const SalMediaDescription *)call->resultdesc) lInfo() << "Request Full Intra Request on CallSession [" << this << "]"; diff --git a/tester/call_multicast_tester.c b/tester/call_multicast_tester.c index 4b21370e8..249c2adfb 100644 --- a/tester/call_multicast_tester.c +++ b/tester/call_multicast_tester.c @@ -55,7 +55,7 @@ static void call_multicast_base(bool_t video) { BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%d"); if (video) { /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(marie->lc),linphone_call_iframe_decoded_cb,marie->lc); + linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(marie->lc)); linphone_call_send_vfu_request(linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1)); } @@ -149,7 +149,7 @@ static void early_media_with_multicast_base(bool_t video) { /* send a 183 to initiate the early media */ if (video) { /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(pauline->lc),linphone_call_iframe_decoded_cb,pauline->lc); + linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(pauline->lc)); } linphone_call_accept_early_media(linphone_core_get_current_call(pauline->lc)); @@ -160,7 +160,7 @@ static void early_media_with_multicast_base(bool_t video) { /* send a 183 to initiate the early media */ if (video) { /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(pauline2->lc),linphone_call_iframe_decoded_cb,pauline2->lc); + linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(pauline2->lc)); } linphone_call_accept_early_media(linphone_core_get_current_call(pauline2->lc)); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index c70a50925..8a97f5f3e 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -173,12 +173,12 @@ void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, } -void linphone_call_iframe_decoded_cb(LinphoneCall *call,void * user_data) { - LinphoneCallLog *calllog = linphone_call_get_call_log(call); - char* to=linphone_address_as_string(linphone_call_log_get_to(calllog)); - char* from=linphone_address_as_string(linphone_call_log_get_from(calllog)); +static void linphone_call_next_video_frame_decoded_cb(LinphoneCall *call) { + LinphoneCallLog *clog = linphone_call_get_call_log(call); + char* to=linphone_address_as_string(linphone_call_log_get_to(clog)); + char* from=linphone_address_as_string(linphone_call_log_get_to(clog)); stats* counters; - LinphoneCore* lc=(LinphoneCore*)user_data; + LinphoneCore* lc = linphone_call_get_core(call); ms_message("call from [%s] to [%s] receive iFrame",from,to); ms_free(to); ms_free(from); @@ -186,6 +186,13 @@ void linphone_call_iframe_decoded_cb(LinphoneCall *call,void * user_data) { counters->number_of_IframeDecoded++; } +void linphone_call_set_first_video_frame_decoded_cb(LinphoneCall *call) { + LinphoneCallCbs *call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); + linphone_call_cbs_set_next_video_frame_decoded(call_cbs, linphone_call_next_video_frame_decoded_cb); + linphone_call_add_callbacks(call, call_cbs); + linphone_call_cbs_unref(call_cbs); +} + #define reset_call_stats(var, value) \ if (var) linphone_call_stats_unref(var); \ var = value @@ -3655,9 +3662,12 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, bctbx_l LinphoneCallStats *stats = linphone_call_get_video_stats(call); if (video_dir != LinphoneMediaDirectionInactive){ + LinphoneCallCbs *call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); BC_ASSERT_TRUE(linphone_call_params_video_enabled(params)); BC_ASSERT_EQUAL(linphone_call_params_get_video_direction(params), video_dir, int, "%d"); - linphone_call_set_next_video_frame_decoded_callback(call,linphone_call_iframe_decoded_cb,mgr->lc); + linphone_call_cbs_set_next_video_frame_decoded(call_cbs, linphone_call_next_video_frame_decoded_cb); + linphone_call_add_callbacks(call, call_cbs); + linphone_call_cbs_unref(call_cbs); linphone_call_send_vfu_request(call); } switch (video_dir) { diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 89bbc22c5..70e6ac4bd 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -275,7 +275,7 @@ bool_t request_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bo } if (video_added) { - linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_set_first_video_frame_decoded_cb(call_obj); /*send vfu*/ linphone_call_send_vfu_request(call_obj); BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1)); @@ -599,7 +599,7 @@ void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_set_first_video_frame_decoded_cb(callee_call); linphone_call_send_vfu_request(callee_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); } else { @@ -622,8 +622,8 @@ static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ /*check video path is established in both directions. Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + linphone_call_set_first_video_frame_decoded_cb(callee_call); + linphone_call_set_first_video_frame_decoded_cb(caller_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -639,7 +639,7 @@ static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ ms_message("check_fir: [%p] received %d FIR ",&caller_call ,caller_vstream->ms_video_stat.counter_rcvd_fir); ms_message("check_fir: [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + linphone_call_set_first_video_frame_decoded_cb(caller_call); linphone_call_send_vfu_request(caller_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -878,8 +878,8 @@ static void video_call_established_by_reinvite_with_implicit_avpf(void) { BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(callee_call))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(caller_call))); - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_set_first_video_frame_decoded_cb(caller_call); + linphone_call_set_first_video_frame_decoded_cb(callee_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -1328,10 +1328,7 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone /*The send-only client shall set rtp symmetric in absence of media relay for this test.*/ lp_config_set_int(linphone_core_get_config(marie->lc),"rtp","symmetric",1); - linphone_call_set_next_video_frame_decoded_callback(linphone_core_invite_address(pauline->lc,marie->identity) - ,linphone_call_iframe_decoded_cb - ,pauline->lc); - + linphone_call_set_first_video_frame_decoded_cb(linphone_core_invite_address(pauline->lc,marie->identity)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index ca5c6b251..f10d14029 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -406,7 +406,7 @@ void account_manager_destroy(void); LinphoneAddress *account_manager_get_identity_with_modified_identity(const LinphoneAddress *modified_identity); LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const char *file, void *user_data); -void linphone_call_iframe_decoded_cb(LinphoneCall *call,void * user_data); +void linphone_call_set_first_video_frame_decoded_cb(LinphoneCall *call); void call_paused_resumed_base(bool_t multicast,bool_t with_losses); void simple_call_base(bool_t enable_multicast_recv_side); void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc); From 0566b2b1fe8d28c0dacd70251ee964af30a5734c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 6 Feb 2018 14:01:27 +0100 Subject: [PATCH 112/143] Fixed LIME --- coreapi/linphonecore.c | 8 ++++++-- include/linphone/core.h | 9 +++++++++ src/sal/sal.cpp | 8 ++++++++ src/sal/sal.h | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2c7224314..ce420c6c7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2527,8 +2527,8 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ LinphoneImEncryptionEngine *imee = linphone_im_encryption_engine_new(); LinphoneImEncryptionEngineCbs *cbs = linphone_im_encryption_engine_get_callbacks(imee); - if(lime_is_available()){ - if (linphone_core_ready(lc)){ + if (lime_is_available()) { + if (linphone_core_ready(lc)) { lp_config_set_int(lc->config,"sip","lime",val); } @@ -7174,6 +7174,10 @@ void linphone_core_add_content_type_support(LinphoneCore *lc, const char *conten lc->sal->add_content_type_support(content_type); } +void linphone_core_remove_content_type_support(LinphoneCore *lc, const char *content_type) { + lc->sal->remove_content_type_support(content_type); +} + #ifdef ENABLE_UPDATE_CHECK static void update_check_process_terminated(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url) { linphone_core_notify_version_update_check_result_received(lc, result, version, url); diff --git a/include/linphone/core.h b/include/linphone/core.h index b439cda8e..360f230e3 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -4972,6 +4972,15 @@ const char *linphone_core_get_linphone_specs (const LinphoneCore *core); */ void linphone_core_set_linphone_specs (LinphoneCore *core, const char *specs); +/** + * Remove support for the specified content type. + * It is the application responsibility to handle it correctly afterwards. + * @param[in] lc LinphoneCore object + * @param[in] content_type The content type to remove support for + */ +LINPHONE_PUBLIC void linphone_core_remove_content_type_support(LinphoneCore *lc, const char *content_type); + + /** * @addtogroup chatroom * @{ diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index a25236587..5c3a58385 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -670,6 +670,14 @@ void Sal::add_content_type_support(const char *content_type) { } } +void Sal::remove_content_type_support(const char *content_type) { + if (content_type != NULL) { + if (bctbx_list_find(this->supported_content_types, content_type)) { + this->supported_content_types = bctbx_list_remove(this->supported_content_types, (char *)content_type); + } + } +} + void Sal::use_rport(bool_t use_rports) { belle_sip_provider_enable_rport(this->prov,use_rports); ms_message("Sal use rport [%s]", use_rports ? "enabled" : "disabled"); diff --git a/src/sal/sal.h b/src/sal/sal.h index 3e48bc481..0bfd2afec 100644 --- a/src/sal/sal.h +++ b/src/sal/sal.h @@ -146,6 +146,7 @@ public: bool_t content_encoding_available(const char *content_encoding) {return (bool_t)belle_sip_stack_content_encoding_available(this->stack, content_encoding);} bool_t is_content_type_supported(const char *content_type) const; void add_content_type_support(const char *content_type); + void remove_content_type_support(const char *content_type); void set_default_sdp_handling(SalOpSDPHandling sdp_handling_method); From ebb36d6dd01160be59c494611ef55c0509025428 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 6 Feb 2018 14:52:31 +0100 Subject: [PATCH 113/143] Added logs related to incoming message decryption process --- coreapi/lime.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/coreapi/lime.c b/coreapi/lime.c index 771f46384..b19eae8be 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -805,6 +805,8 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn char *peerUri = NULL; char *selfUri = NULL; + ms_debug("Content type is known (%s), try to decrypt it", linphone_chat_message_get_content_type(msg)); + zrtp_cache_db = linphone_core_get_zrtp_cache_db(lc); if (zrtp_cache_db == NULL) { ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); @@ -827,9 +829,11 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn linphone_chat_message_set_text(msg, (char *)decrypted_body); ms_free(decrypted_body); if (decrypted_content_type != NULL) { + ms_debug("Decrypted content type is ", decrypted_content_type); linphone_chat_message_set_content_type(msg, decrypted_content_type); ms_free(decrypted_content_type); } else { + ms_debug("Decrypted content type is unknown, use plain/text or application/vnd.gsma.rcs-ft-http+xml"); if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", linphone_chat_message_get_content_type(msg)) == 0) { linphone_chat_message_set_content_type(msg, "application/vnd.gsma.rcs-ft-http+xml"); } else { @@ -837,6 +841,8 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn } } } + } else { + ms_message("Content type is unknown (%s), don't try to decrypt it", linphone_chat_message_get_content_type(msg)); } return errcode; } From 0506399e6bdd34b4258c15cdba52f69563061d9c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 7 Feb 2018 16:36:19 +0100 Subject: [PATCH 114/143] Fixed python wrapper compil --- tools/python/apixml2python.py | 5 ++++- tools/python/apixml2python/linphone_module.mustache | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 2c27fb386..c0d57b85e 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -29,7 +29,9 @@ from apixml2python.linphone import LinphoneModule, HandWrittenClassMethod, HandW blacklisted_classes = [ 'LinphoneIntRange', 'LinphoneTunnel', - 'LinphoneTunnelConfig' + 'LinphoneTunnelConfig', + 'LinphoneLoggingService', + 'LinphoneLoggingServiceCbs' ] blacklisted_events = [ 'LinphoneChatMessageStateChangedCb', # not respecting naming convention @@ -73,6 +75,7 @@ blacklisted_functions = [ 'linphone_proxy_config_set_privacy', # missing LinphonePrivacyMask 'linphone_tunnel_get_http_proxy', # to be handwritten because of double pointer indirection 'linphone_vcard_get_belcard', # specific to C++ + '' ] hand_written_functions = [ HandWrittenClassMethod('Buffer', 'new_from_data', 'linphone_buffer_new_from_data', "Create a new LinphoneBuffer object from existing data.\n\n:param data: The initial data to store in the LinphoneBuffer.\n:type data: ByteArray\n:returns: A new LinphoneBuffer object.\n:rtype: linphone.Buffer"), diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index 06c5b25ee..c0ed8f6fa 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include +#include #include #include From 6a4c4e979f5558233e01cff5220bb2ec4619d722 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 30 Apr 2018 14:06:02 +0200 Subject: [PATCH 115/143] Fix build with Xcode. --- CMakeLists.txt | 15 ++- coreapi/CMakeLists.txt | 180 +++++------------------------------- src/CMakeLists.txt | 151 +++++++++++++++++++++++++++--- src/xml/conference-info.cpp | 2 + src/xml/conference-info.h | 2 + src/xml/imdn.cpp | 2 + src/xml/imdn.h | 2 + src/xml/is-composing.cpp | 2 + src/xml/is-composing.h | 2 + src/xml/linphone-imdn.cpp | 2 + src/xml/linphone-imdn.h | 2 + src/xml/prologue.txt | 2 + src/xml/resource-lists.cpp | 2 + src/xml/resource-lists.h | 2 + src/xml/xml.cpp | 2 + src/xml/xml.h | 2 + 16 files changed, 201 insertions(+), 171 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5a4cbe6a..18a57418a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,19 @@ if(UNIX AND NOT APPLE) check_include_files(libudev.h HAVE_LIBUDEV_H) endif() +if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + find_library(LIBGCC NAMES gcc) + find_library(LIBMINGWEX NAMES mingwex) +endif() + +if(NOT WIN32) + find_package(Iconv QUIET) +endif() +if(ANDROID) + find_package(CpuFeatures REQUIRED) + find_package(Support REQUIRED) +endif() + set(LINPHONE_LDFLAGS "${BELLESIP_LDFLAGS} ${MEDIASTREAMER2_LDFLAGS}") if(BELCARD_FOUND AND APPLE) set(LINPHONE_LDFLAGS "${LINPHONE_LDFLAGS} -stdlib=libc++") @@ -342,8 +355,8 @@ add_subdirectory(java) if(ENABLE_JAVA_WRAPPER) add_subdirectory(wrappers/java) endif() -add_subdirectory(src) add_subdirectory(coreapi) +add_subdirectory(src) add_subdirectory(share) if(ENABLE_CONSOLE_UI) add_subdirectory(console) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 521d866a8..fb380c2a5 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -20,19 +20,6 @@ # ############################################################################ -if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - find_library(LIBGCC NAMES gcc) - find_library(LIBMINGWEX NAMES mingwex) -endif() - -if(NOT WIN32) - find_package(Iconv QUIET) -endif() -if(ANDROID) - find_package(CpuFeatures REQUIRED) - find_package(Support REQUIRED) -endif() - list(APPEND LINPHONE_PRIVATE_HEADER_FILES bellesip_sal/sal_impl.h carddav.h @@ -136,55 +123,7 @@ else() list(APPEND LINPHONE_SOURCE_FILES_C linphone_tunnel_stubs.c) endif() -bc_git_version(liblinphone ${PROJECT_VERSION}) - -add_definitions( - -DUSE_BELLESIP - -DLIBLINPHONE_EXPORTS - -DBCTBX_LOG_DOMAIN="liblinphone" -) - -set(LIBS - ${BCTOOLBOX_CORE_LIBRARIES} - ${BELLESIP_LIBRARIES} - ${MEDIASTREAMER2_LIBRARIES} - ${ORTP_LIBRARIES} - ${XML2_LIBRARIES} - ${BELR_LIBRARIES} - ${LIBXSD_LIBRARIES} -) -if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - list(APPEND LIBS "Ws2_32") -endif() -if(ENABLE_LIME) - list(APPEND LIBS ${BZRTP_LIBRARIES}) -endif() -if(ZLIB_FOUND) - list(APPEND LIBS ${ZLIB_LIBRARIES}) -endif() -if(SOCI_FOUND) - list(APPEND LIBS ${SOCI_LIBRARIES}) -endif() -if(SQLITE3_FOUND) - list(APPEND LIBS ${SQLITE3_LIBRARIES}) -endif() -if(ICONV_FOUND) - list(APPEND LIBS ${ICONV_LIBRARIES}) -endif() -if(ENABLE_TUNNEL) - list(APPEND LIBS ${TUNNEL_LIBRARIES}) -endif() -if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - list(APPEND LIBS ${LIBGCC} ${LIBMINGWEX}) -endif() -if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - list(APPEND LIBS shlwapi) -endif() -if(INTL_FOUND) - list(APPEND LIBS ${INTL_LIBRARIES}) -endif() if(BELCARD_FOUND) - list(APPEND LIBS ${BELCARD_LIBRARIES}) list(APPEND LINPHONE_SOURCE_FILES_CXX vcard.cc) if(NOT MSVC) list(APPEND STRICT_OPTIONS_CXX "-std=c++11") @@ -196,106 +135,37 @@ else() list(APPEND LINPHONE_SOURCE_FILES_C vcard_stubs.c) endif() + +bc_git_version(liblinphone ${PROJECT_VERSION}) + +add_definitions( + -DUSE_BELLESIP + -DLIBLINPHONE_EXPORTS + -DBCTBX_LOG_DOMAIN="liblinphone" +) + set_source_files_properties(${LINPHONE_SOURCE_FILES_C} PROPERTIES LANGUAGE CXX) bc_apply_compile_flags(LINPHONE_SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) bc_apply_compile_flags(LINPHONE_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) bc_apply_compile_flags(LINPHONE_SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC) -if(ENABLE_STATIC) - add_library(linphone-static STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_PRIVATE_HEADER_FILES} - ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC} - $ - ) - set_target_properties(linphone-static PROPERTIES OUTPUT_NAME linphone) - add_dependencies(linphone-static liblinphone-git-version) - target_include_directories(linphone-static PUBLIC ${LINPHONE_INCLUDE_DIRS}) - target_link_libraries(linphone-static INTERFACE ${LIBS}) - if(APPLE) - target_link_libraries(linphone-static INTERFACE "-framework Foundation" "-framework AVFoundation") - endif() - install(TARGETS linphone-static EXPORT ${EXPORT_TARGETS_NAME}Targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) -endif() -if(ENABLE_SHARED) - add_library(linphone SHARED "../share/cpim_grammar" ${LINPHONE_HEADER_FILES} ${LINPHONE_PRIVATE_HEADER_FILES} - ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC} - $ - ) - if(IOS) - if(IOS) - set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET}) - else() - set(MIN_OS ${CMAKE_OSX_DEPLOYMENT_TARGET}) - endif() - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/osx/") - set_target_properties(linphone PROPERTIES - FRAMEWORK TRUE - MACOSX_FRAMEWORK_IDENTIFIER org.linphone.linphone - MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in - PUBLIC_HEADER "${LINPHONE_HEADER_FILES}" - RESOURCE "../share/cpim_grammar" - ) - endif() - if(BELCARD_FOUND) - if(APPLE) - set_target_properties(linphone PROPERTIES LINK_FLAGS "-stdlib=libc++") - endif() - endif() - set_target_properties(linphone PROPERTIES LINKER_LANGUAGE CXX) - if(NOT ANDROID) - # Do not version shared library on Android - set_target_properties(linphone PROPERTIES SOVERSION ${LINPHONE_SO_VERSION}) - endif() - add_dependencies(linphone liblinphone-git-version) - target_include_directories(linphone PUBLIC ${LINPHONE_INCLUDE_DIRS}) - target_link_libraries(linphone PRIVATE ${LIBS}) - if(APPLE) - target_link_libraries(linphone PRIVATE "-framework Foundation" "-framework AVFoundation") - endif() - if(WIN32 AND CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - set_target_properties(linphone PROPERTIES PREFIX "lib") - elseif(ANDROID) - target_link_libraries(linphone PUBLIC "log" ${SUPPORT_LIBRARIES} ${CPUFEATURES_LIBRARIES}) - if(ENABLE_JAVA_WRAPPER) - add_dependencies(linphone linphonej) - endif() - endif() - if(MSVC) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/linphone.pdb - DESTINATION ${CMAKE_INSTALL_BINDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) - endif() - endif() - install(TARGETS linphone EXPORT ${EXPORT_TARGETS_NAME}Targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - FRAMEWORK DESTINATION Frameworks - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE +if (ENABLE_STATIC) + add_library(linphone-coreapi-static OBJECT + ${LINPHONE_PRIVATE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC} ) -endif() -if(ICONV_FOUND) - if(APPLE) - # Prevent conflict between the system iconv.h header and the one from macports. - if(ENABLE_STATIC) - target_compile_options(linphone-static PRIVATE "-include" "${ICONV_INCLUDE_DIRS}/iconv.h") - endif() - if(ENABLE_SHARED) - target_compile_options(linphone PRIVATE "-include" "${ICONV_INCLUDE_DIRS}/iconv.h") - endif() - else() - if(ENABLE_STATIC) - target_include_directories(linphone-static PRIVATE ${ICONV_INCLUDE_DIRS}) - endif() - if(ENABLE_SHARED) - target_include_directories(linphone PRIVATE ${ICONV_INCLUDE_DIRS}) - endif() - endif() -endif() + target_include_directories(linphone-coreapi-static SYSTEM PRIVATE ${LINPHONE_INCLUDE_DIRS}) + add_dependencies(linphone-coreapi-static liblinphone-git-version) +endif () + +if (ENABLE_SHARED) + add_library(linphone-coreapi OBJECT + ${LINPHONE_PRIVATE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX} ${LINPHONE_SOURCE_FILES_OBJC} + ) + target_include_directories(linphone-coreapi SYSTEM PRIVATE ${LINPHONE_INCLUDE_DIRS}) + target_compile_options(linphone-coreapi PRIVATE "-fPIC") + add_dependencies(linphone-coreapi liblinphone-git-version) +endif () + add_subdirectory(help) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4208e1479..013e84a7f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,50 @@ # ############################################################################ +set(LIBS + ${BCTOOLBOX_CORE_LIBRARIES} + ${BELLESIP_LIBRARIES} + ${MEDIASTREAMER2_LIBRARIES} + ${ORTP_LIBRARIES} + ${XML2_LIBRARIES} + ${BELR_LIBRARIES} + ${LIBXSD_LIBRARIES} +) +if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + list(APPEND LIBS "Ws2_32") +endif() +if(ENABLE_LIME) + list(APPEND LIBS ${BZRTP_LIBRARIES}) +endif() +if(ZLIB_FOUND) + list(APPEND LIBS ${ZLIB_LIBRARIES}) +endif() +if(SOCI_FOUND) + list(APPEND LIBS ${SOCI_LIBRARIES}) +endif() +if(SQLITE3_FOUND) + list(APPEND LIBS ${SQLITE3_LIBRARIES}) +endif() +if(ICONV_FOUND) + list(APPEND LIBS ${ICONV_LIBRARIES}) +endif() +if(ENABLE_TUNNEL) + list(APPEND LIBS ${TUNNEL_LIBRARIES}) +endif() +if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + list(APPEND LIBS ${LIBGCC} ${LIBMINGWEX}) +endif() +if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + list(APPEND LIBS shlwapi) +endif() +if(INTL_FOUND) + list(APPEND LIBS ${INTL_LIBRARIES}) +endif() +if(BELCARD_FOUND) + list(APPEND LIBS ${BELCARD_LIBRARIES}) +endif() + + set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES address/address-p.h address/address.h @@ -330,21 +374,98 @@ set(LINPHONE_PRIVATE_HEADER_FILES ${LINPHONE_PRIVATE_HEADER_FILES} PARENT_SCOPE) bc_apply_compile_flags(LINPHONE_CXX_OBJECTS_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX) bc_apply_compile_flags(LINPHONE_OBJC_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC) -if (ENABLE_STATIC) - add_library( - linphone-cxx-objects-static OBJECT - ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES} - ) - target_compile_definitions(linphone-cxx-objects-static PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS}) - target_include_directories(linphone-cxx-objects-static SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS}) -endif () -if (ENABLE_SHARED) - add_library( - linphone-cxx-objects OBJECT +if(ENABLE_STATIC) + add_library(linphone-static STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES} + $ ) - target_compile_definitions(linphone-cxx-objects PRIVATE ${LINPHONE_CXX_OBJECTS_DEFINITIONS}) - target_include_directories(linphone-cxx-objects SYSTEM PRIVATE ${LINPHONE_CXX_OBJECTS_INCLUDE_DIRS} ${LINPHONE_INCLUDE_DIRS}) - target_compile_options(linphone-cxx-objects PRIVATE "-fPIC") -endif () + set_target_properties(linphone-static PROPERTIES OUTPUT_NAME linphone) + target_include_directories(linphone-static PUBLIC ${LINPHONE_INCLUDE_DIRS}) + target_link_libraries(linphone-static INTERFACE ${LIBS}) + if(APPLE) + target_link_libraries(linphone-static INTERFACE "-framework Foundation" "-framework AVFoundation") + endif() + install(TARGETS linphone-static EXPORT ${EXPORT_TARGETS_NAME}Targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) +endif() +if(ENABLE_SHARED) + add_library(linphone SHARED "../share/cpim_grammar" ${LINPHONE_HEADER_FILES} + ${LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES} ${LINPHONE_CXX_OBJECTS_SOURCE_FILES} ${LINPHONE_OBJC_SOURCE_FILES} + $ + ) + if(IOS) + if(IOS) + set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET}) + else() + set(MIN_OS ${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/osx/") + set_target_properties(linphone PROPERTIES + FRAMEWORK TRUE + MACOSX_FRAMEWORK_IDENTIFIER org.linphone.linphone + MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in + PUBLIC_HEADER "${LINPHONE_HEADER_FILES}" + RESOURCE "../share/cpim_grammar" + ) + endif() + if(BELCARD_FOUND) + if(APPLE) + set_target_properties(linphone PROPERTIES LINK_FLAGS "-stdlib=libc++") + endif() + endif() + + set_target_properties(linphone PROPERTIES LINKER_LANGUAGE CXX) + if(NOT ANDROID) + # Do not version shared library on Android + set_target_properties(linphone PROPERTIES SOVERSION ${LINPHONE_SO_VERSION}) + endif() + target_include_directories(linphone PUBLIC ${LINPHONE_INCLUDE_DIRS}) + target_link_libraries(linphone PRIVATE ${LIBS}) + if(APPLE) + target_link_libraries(linphone PRIVATE "-framework Foundation" "-framework AVFoundation") + endif() + if(WIN32 AND CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + set_target_properties(linphone PROPERTIES PREFIX "lib") + elseif(ANDROID) + target_link_libraries(linphone PUBLIC "log" ${SUPPORT_LIBRARIES} ${CPUFEATURES_LIBRARIES}) + if(ENABLE_JAVA_WRAPPER) + add_dependencies(linphone linphonej) + endif() + endif() + if(MSVC) + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/linphone.pdb + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) + endif() + endif() + install(TARGETS linphone EXPORT ${EXPORT_TARGETS_NAME}Targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION Frameworks + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) +endif() +if(ICONV_FOUND) + if(APPLE) + # Prevent conflict between the system iconv.h header and the one from macports. + if(ENABLE_STATIC) + target_compile_options(linphone-static PRIVATE "-include" "${ICONV_INCLUDE_DIRS}/iconv.h") + endif() + if(ENABLE_SHARED) + target_compile_options(linphone PRIVATE "-include" "${ICONV_INCLUDE_DIRS}/iconv.h") + endif() + else() + if(ENABLE_STATIC) + target_include_directories(linphone-static PRIVATE ${ICONV_INCLUDE_DIRS}) + endif() + if(ENABLE_SHARED) + target_include_directories(linphone PRIVATE ${ICONV_INCLUDE_DIRS}) + endif() + endif() +endif() diff --git a/src/xml/conference-info.cpp b/src/xml/conference-info.cpp index fc2f8aac3..f887efce2 100644 --- a/src/xml/conference-info.cpp +++ b/src/xml/conference-info.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/conference-info.h b/src/xml/conference-info.h index cc7c48a96..9925b5539 100644 --- a/src/xml/conference-info.h +++ b/src/xml/conference-info.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/imdn.cpp b/src/xml/imdn.cpp index d180b9078..ade5553fb 100644 --- a/src/xml/imdn.cpp +++ b/src/xml/imdn.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/imdn.h b/src/xml/imdn.h index 687f80533..81c5a9ed3 100644 --- a/src/xml/imdn.h +++ b/src/xml/imdn.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/is-composing.cpp b/src/xml/is-composing.cpp index 24002401b..0f6ab0e78 100644 --- a/src/xml/is-composing.cpp +++ b/src/xml/is-composing.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/is-composing.h b/src/xml/is-composing.h index 1d7025245..b6ca96359 100644 --- a/src/xml/is-composing.h +++ b/src/xml/is-composing.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/linphone-imdn.cpp b/src/xml/linphone-imdn.cpp index d54b05414..e1e4a7934 100644 --- a/src/xml/linphone-imdn.cpp +++ b/src/xml/linphone-imdn.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/linphone-imdn.h b/src/xml/linphone-imdn.h index 42e1327a6..940553cfc 100644 --- a/src/xml/linphone-imdn.h +++ b/src/xml/linphone-imdn.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/prologue.txt b/src/xml/prologue.txt index 23e94d03a..410500a6d 100644 --- a/src/xml/prologue.txt +++ b/src/xml/prologue.txt @@ -1,6 +1,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/resource-lists.cpp b/src/xml/resource-lists.cpp index 79f90d384..fffeacbd8 100644 --- a/src/xml/resource-lists.cpp +++ b/src/xml/resource-lists.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/resource-lists.h b/src/xml/resource-lists.h index 4494881c4..ecb0de126 100644 --- a/src/xml/resource-lists.h +++ b/src/xml/resource-lists.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/xml.cpp b/src/xml/xml.cpp index f052e7f5a..2d76282c4 100644 --- a/src/xml/xml.cpp +++ b/src/xml/xml.cpp @@ -36,6 +36,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push diff --git a/src/xml/xml.h b/src/xml/xml.h index 681dc279d..14790ba3f 100644 --- a/src/xml/xml.h +++ b/src/xml/xml.h @@ -51,6 +51,8 @@ #if __clang__ || __GNUC__ >= 4 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" #endif #if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1) #pragma GCC diagnostic push From 7af5d9664e25ba7e4ab61f6858459798de08c33c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 30 Apr 2018 16:48:31 +0200 Subject: [PATCH 116/143] add missing ref causing crash in Java when core is destroyed before Java account creator. --- coreapi/account_creator.c | 9 +++++++-- tester/account_creator_tester.c | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 4e7575bc8..c28e510a7 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -268,8 +268,12 @@ void linphone_account_creator_cbs_set_update_account(LinphoneAccountCreatorCbs * 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 (creator->service != NULL && linphone_account_creator_service_get_destructor_cb(creator->service) != NULL) - linphone_account_creator_service_get_destructor_cb(creator->service)(creator); + if (creator->service != NULL ) { + if (linphone_account_creator_service_get_destructor_cb(creator->service) != NULL) + linphone_account_creator_service_get_destructor_cb(creator->service)(creator); + linphone_account_creator_service_unref(creator->service); + } + linphone_account_creator_cbs_unref(creator->cbs); linphone_proxy_config_unref(creator->proxy_cfg); linphone_account_creator_reset(creator); @@ -289,6 +293,7 @@ LinphoneAccountCreator * _linphone_account_creator_new(LinphoneCore *core, const const char* domain = lp_config_get_string(core->config, "assistant", "domain", NULL); creator = belle_sip_object_new(LinphoneAccountCreator); creator->service = linphone_core_get_account_creator_service(core); + linphone_account_creator_service_ref(creator->service); creator->cbs = linphone_account_creator_cbs_new(); creator->core = core; creator->transport = LinphoneTransportTcp; diff --git a/tester/account_creator_tester.c b/tester/account_creator_tester.c index 3ae77ff98..cc5773f3a 100644 --- a/tester/account_creator_tester.c +++ b/tester/account_creator_tester.c @@ -62,8 +62,9 @@ static void local_username_too_short(void) { LinphoneAccountCreatorUsernameStatus, "%i"); - linphone_account_creator_unref(creator); + linphone_core_manager_destroy(marie); + linphone_account_creator_unref(creator); } static void local_username_too_long(void) { From fffc65d486eb366e0313efbc611cd96cd44f45f9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 30 Apr 2018 15:52:47 +0200 Subject: [PATCH 117/143] Some fixes in flexisip tester. --- tester/flexisip_tester.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index fae2f4242..dcb1a0688 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -77,7 +77,7 @@ static void message_forking(void) { lcs=bctbx_list_append(lcs,marie2->lc); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, message); + linphone_chat_message_send(message); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,1000)); @@ -120,7 +120,7 @@ static void message_forking_with_unreachable_recipients(void) { linphone_core_set_network_reachable(marie3->lc,FALSE); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, message); + linphone_chat_message_send(message); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,1000)); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d"); @@ -174,7 +174,7 @@ static void message_forking_with_all_recipients_unreachable(void) { linphone_core_set_network_reachable(marie3->lc,FALSE); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, message); + linphone_chat_message_send(message); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageInProgress,1,5000)); /*flexisip will accept the message with 202 after 16 seconds*/ @@ -234,8 +234,8 @@ static void message_forking_with_unreachable_recipients_with_gruu(void) { linphone_core_set_network_reachable(marie->lc,FALSE); linphone_core_set_network_reachable(marie2->lc,FALSE); - linphone_chat_room_send_chat_message(chat_room_1, message_1); - linphone_chat_room_send_chat_message(chat_room_2, message_2); + linphone_chat_message_send(message_1); + linphone_chat_message_send(message_2); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceived, 0, int, "%d"); BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneMessageReceived, 0, int, "%d"); @@ -989,7 +989,7 @@ static void file_transfer_message_rcs_to_external_body_client(void) { } linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_send(cbs, tester_file_transfer_send); - linphone_chat_room_send_chat_message(chat_room,message); + linphone_chat_message_send(message); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1)); if (marie->stat.last_received_chat_message ) { @@ -1033,7 +1033,7 @@ static void dos_module_trigger(void) { char msg[128]; sprintf(msg, "Flood message number %i", i); chat_msg = linphone_chat_room_create_message(chat_room, msg); - linphone_chat_room_send_chat_message(chat_room, chat_msg); + linphone_chat_message_send(chat_msg); wait_for_until(marie->lc, pauline->lc, &dummy, 1, 10); i++; } while (i < number_of_messge_to_send); @@ -1045,7 +1045,7 @@ static void dos_module_trigger(void) { reset_counters(&marie->stat); reset_counters(&pauline->stat); chat_msg = linphone_chat_room_create_message(chat_room, passmsg); - linphone_chat_room_send_chat_message(chat_room, chat_msg); + linphone_chat_message_send(chat_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived, 1)); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceived, 1, int, "%d"); if (marie->stat.last_received_chat_message) { @@ -1466,23 +1466,20 @@ static void register_without_regid(void) { } void test_removing_old_tport(void) { - bctbx_list_t* lcs; - LinphoneCoreManager* marie2; LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_rc"); - lcs=bctbx_list_append(NULL,marie1->lc); + bctbx_list_t *lcs = bctbx_list_append(NULL, marie1->lc); BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneRegistrationOk,1,5000)); - marie2 = ms_new0(LinphoneCoreManager, 1); - linphone_core_manager_init(marie2, "marie_rc", NULL); - sal_set_uuid(linphone_core_get_sal(marie2->lc), linphone_config_get_string(linphone_core_get_config(marie1->lc),"misc", "uuid", "0")); + LinphoneCoreManager *marie2 = linphone_core_manager_create("marie_rc"); + const char *uuid = linphone_config_get_string(linphone_core_get_config(marie1->lc), "misc", "uuid", "0"); + lp_config_set_string(linphone_core_get_config(marie2->lc), "misc", "uuid", uuid); linphone_core_manager_start(marie2, TRUE); - lcs=bctbx_list_append(lcs, marie2->lc); + lcs = bctbx_list_append(lcs, marie2->lc); linphone_core_refresh_registers(marie2->lc); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneRegistrationOk,1,5000)); - - BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneRegistrationProgress,2,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneRegistrationOk, 1, 5000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneRegistrationProgress, 2, 5000)); linphone_core_manager_destroy(marie1); linphone_core_manager_destroy(marie2); From fc7b8816607ce7822535486019774851f037f873 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 30 Apr 2018 16:25:04 +0200 Subject: [PATCH 118/143] Fix "Search friend in large friends database" setup tester. --- tester/CMakeLists.txt | 1 + tester/setup_tester.c | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index ce37dbd30..694ba5a31 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(DB_FILES + db/friends.db db/linphone.db db/messages.db ) diff --git a/tester/setup_tester.c b/tester/setup_tester.c index 8a2e2ebcc..111a1136c 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -121,6 +121,7 @@ static void linphone_version_test(void){ static void core_init_test(void) { LinphoneCore* lc; lc = linphone_factory_create_core(linphone_factory_get(),NULL,NULL,NULL); + /* until we have good certificates on our test server... */ linphone_core_verify_server_certificates(lc,FALSE); if (BC_ASSERT_PTR_NOT_NULL(lc)) { @@ -846,37 +847,31 @@ static void search_friend_with_name(void) { } static void search_friend_large_database(void) { - MSTimeSpec start, current; - LinphoneMagicSearch *magicSearch = NULL; - bctbx_list_t *resultList = NULL; char *dbPath = bc_tester_res("db/friends.db"); - char searchedFriend[] = {"6295103032641994169"}; - char subBuff[30]; + char *searchedFriend = "6295103032641994169"; LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); - unsigned int i; - linphone_core_set_friends_database_path(manager->lc, dbPath); + LinphoneMagicSearch *magicSearch = linphone_magic_search_new(manager->lc); - magicSearch = linphone_magic_search_new(manager->lc); - - for (i = 1; i < sizeof(searchedFriend) ; i++) { - memcpy(subBuff, &searchedFriend, i); + for (size_t i = 1; i < strlen(searchedFriend) ; i++) { + MSTimeSpec start, current; + char subBuff[20]; + memcpy(subBuff, searchedFriend, i); subBuff[i] = '\0'; liblinphone_tester_clock_start(&start); - resultList = linphone_magic_search_get_contact_list_from_filter(magicSearch, subBuff, ""); + bctbx_list_t *resultList = linphone_magic_search_get_contact_list_from_filter(magicSearch, subBuff, ""); if (BC_ASSERT_PTR_NOT_NULL(resultList)) { ms_get_cur_time(¤t); - ms_message("Searching time: %lld ms" ,((current.tv_sec - start.tv_sec)*1000LL) + ((current.tv_nsec - start.tv_nsec)/1000000LL)); - - if (BC_ASSERT_PTR_NOT_NULL(resultList)) ms_message("List size: %zu", bctbx_list_size(resultList)); - + ms_message("Searching time: %lld ms", + ((current.tv_sec - start.tv_sec) * 1000LL) + ((current.tv_nsec - start.tv_nsec) / 1000000LL)); + ms_message("List size: %zu", bctbx_list_size(resultList)); bctbx_list_free_with_data(resultList, (bctbx_list_free_func)linphone_magic_search_unref); } } - free(dbPath); linphone_magic_search_unref(magicSearch); linphone_core_manager_destroy(manager); + free(dbPath); } test_t setup_tests[] = { From 551cb0c775a9a822d8aed374952740f7232498b1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 May 2018 11:35:32 +0200 Subject: [PATCH 119/143] Fix crash with referred call. --- src/call/call.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/call/call.cpp b/src/call/call.cpp index e5fbf5b15..527664189 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -124,7 +124,6 @@ shared_ptr CallPrivate::startReferredCall (const MediaSessionParams *param L_GET_PRIVATE(getActiveSession())->setReferPending(false); LinphoneCallParams *lcp = L_GET_C_BACK_PTR(&msp); LinphoneCall *newCall = linphone_core_invite_with_params(q->getCore()->getCCore(), q->getReferTo().c_str(), lcp); - linphone_call_params_unref(lcp); if (newCall) { getActiveSession()->getPrivate()->setTransferTarget(L_GET_PRIVATE_FROM_C_OBJECT(newCall)->getActiveSession()); L_GET_PRIVATE_FROM_C_OBJECT(newCall)->getActiveSession()->getPrivate()->notifyReferState(); From e60e2d4f2bc705a1c7519b353f6f3912ff848f2b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 May 2018 15:43:39 +0200 Subject: [PATCH 120/143] Fix real time text messages storage. --- src/call/call.cpp | 6 +- src/chat/chat-message/chat-message.cpp | 16 ++-- .../chat-room/real-time-text-chat-room.cpp | 36 ++++++--- src/core/core.h | 1 + tester/message_tester.c | 77 +++++++++---------- 5 files changed, 69 insertions(+), 67 deletions(-) diff --git a/src/call/call.cpp b/src/call/call.cpp index 527664189..99b5c83c9 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -41,10 +41,8 @@ bool CallPrivate::getAudioMuted () const { shared_ptr CallPrivate::getChatRoom () { L_Q(); if (!chatRoom && (q->getState() != CallSession::State::End) && (q->getState() != CallSession::State::Released)) { - ChatRoomId chatRoomId(q->getRemoteAddress(), q->getLocalAddress()); - RealTimeTextChatRoom *rttcr = new RealTimeTextChatRoom(q->getCore(), chatRoomId); - chatRoom.reset(rttcr); - rttcr->getPrivate()->setCall(q->getSharedFromThis()); + chatRoom = static_pointer_cast(q->getCore()->getOrCreateBasicChatRoom(q->getRemoteAddress(), true)); + chatRoom->getPrivate()->setCall(q->getSharedFromThis()); } return chatRoom; } diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 9eaaa4086..a60ff9d90 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -1142,22 +1142,16 @@ int ChatMessage::putCharacter (uint32_t character) { if (character == newLine || character == crlf || character == lf) { shared_ptr core = getCore(); if (lp_config_get_int(core->getCCore()->config, "misc", "store_rtt_messages", 1) == 1) { - // TODO: History. - lDebug() << "New line sent, forge a message with content " << d->rttMessage.c_str(); - d->setTime(ms_time(0)); + lInfo() << "New line sent, forge a message with content " << d->rttMessage; d->state = State::Displayed; - // d->direction = Direction::Outgoing; - // setFromAddress(Address( - // linphone_address_as_string(linphone_address_new(linphone_core_get_identity(core->getCCore()))) - // )); - // linphone_chat_message_store(L_GET_C_BACK_PTR(this)); + d->setText(d->rttMessage); + d->storeInDb(); d->rttMessage = ""; } } else { char *value = LinphonePrivate::Utils::utf8ToChar(character); - d->rttMessage = d->rttMessage + string(value); - lDebug() << "Sent RTT character: " << value << "(" << (unsigned long)character << - "), pending text is " << d->rttMessage.c_str(); + d->rttMessage += string(value); + lDebug() << "Sent RTT character: " << value << "(" << (unsigned long)character << "), pending text is " << d->rttMessage; delete[] value; } diff --git a/src/chat/chat-room/real-time-text-chat-room.cpp b/src/chat/chat-room/real-time-text-chat-room.cpp index a33a19535..bacf87a81 100644 --- a/src/chat/chat-room/real-time-text-chat-room.cpp +++ b/src/chat/chat-room/real-time-text-chat-room.cpp @@ -21,7 +21,7 @@ #include "call/call.h" #include "chat/chat-message/chat-message-p.h" #include "conference/participant.h" -#include "core/core.h" +#include "core/core-p.h" #include "logger/logger.h" #include "real-time-text-chat-room-p.h" @@ -43,8 +43,13 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, cons LinphoneCore *cCore = core->getCCore(); if (call && call->getCurrentParams()->realtimeTextEnabled()) { - if (!pendingMessage) - pendingMessage = q->createChatMessage(""); + if (!pendingMessage) { + pendingMessage = q->createChatMessage(); + pendingMessage->getPrivate()->setDirection(ChatMessage::Direction::Incoming); + Content *content = new Content(); + content->setContentType(ContentType::PlainText); + pendingMessage->addContent(content); + } Character cmc; cmc.value = character; @@ -56,23 +61,24 @@ void RealTimeTextChatRoomPrivate::realtimeTextReceived (uint32_t character, cons if ((character == new_line) || (character == crlf) || (character == lf)) { // End of message - lDebug() << "New line received, forge a message with content " << pendingMessage->getPrivate()->getText().c_str(); + auto content = pendingMessage->getContents().front(); + lDebug() << "New line received, forge a message with content " << content->getBodyAsString(); pendingMessage->getPrivate()->setState(ChatMessage::State::Delivered); - pendingMessage->getPrivate()->setDirection(ChatMessage::Direction::Incoming); pendingMessage->getPrivate()->setTime(::ms_time(0)); if (lp_config_get_int(linphone_core_get_config(cCore), "misc", "store_rtt_messages", 1) == 1) - pendingMessage->getPrivate()->storeInDb(); + pendingMessage->setToBeStored(true); + else + pendingMessage->setToBeStored(false); onChatMessageReceived(pendingMessage); pendingMessage = nullptr; receivedRttCharacters.clear(); } else { char *value = Utils::utf8ToChar(character); - string text(pendingMessage->getPrivate()->getText()); - text += string(value); - pendingMessage->getPrivate()->setText(text); - lDebug() << "Received RTT character: " << value << " (" << character << "), pending text is " << pendingMessage->getPrivate()->getText(); + auto content = pendingMessage->getContents().front(); + content->setBody(content->getBodyAsString() + string(value)); + lDebug() << "Received RTT character: " << value << " (" << character << "), pending text is " << content->getBodyAsString(); delete[] value; } } @@ -84,6 +90,16 @@ void RealTimeTextChatRoomPrivate::sendChatMessage (const shared_ptr if (call && call->getCurrentParams()->realtimeTextEnabled()) { uint32_t newLine = 0x2028; chatMessage->putCharacter(newLine); + + ChatMessagePrivate *dChatMessage = chatMessage->getPrivate(); + shared_ptr event = static_pointer_cast( + q->getCore()->getPrivate()->mainDb->getEventFromKey(dChatMessage->dbKey) + ); + if (!event) + event = make_shared(time(nullptr), chatMessage); + + LinphoneChatRoom *cr = getCChatRoom(); + _linphone_chat_room_notify_chat_message_sent(cr, L_GET_C_BACK_PTR(event)); } } diff --git a/src/core/core.h b/src/core/core.h index 1588eb4d4..14fab5259 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -57,6 +57,7 @@ class LINPHONE_PUBLIC Core : public Object { friend class MainDbChatMessageKey; friend class MainDbEventKey; friend class MediaSessionPrivate; + friend class RealTimeTextChatRoomPrivate; friend class RemoteConferenceEventHandler; friend class ServerGroupChatRoom; friend class ServerGroupChatRoomPrivate; diff --git a/tester/message_tester.c b/tester/message_tester.c index 441f471cf..096873f43 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -31,9 +31,6 @@ #include #endif -#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) -#pragma GCC diagnostic push -#endif #ifdef _MSC_VER #pragma warning(disable : 4996) #endif @@ -288,7 +285,7 @@ void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) LinphoneChatMessage* msg = linphone_chat_room_create_message(room,"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(room, msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); @@ -353,7 +350,7 @@ static void text_message_with_credential_from_auth_callback(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - linphone_auth_info_destroy(text_message_with_credential_from_auth_cb_auth_info); + linphone_auth_info_unref(text_message_with_credential_from_auth_cb_auth_info); text_message_with_credential_from_auth_cb_auth_info = NULL; } @@ -414,7 +411,7 @@ static void text_message_with_send_error(void) { /*simulate a network error*/ sal_set_send_error(linphone_core_get_sal(marie->lc), -1); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); /* check transient msg list: the msg should be in it, and should be the only one */ BC_ASSERT_EQUAL(_linphone_chat_room_get_transient_message_count(chat_room), 1, int, "%d"); @@ -463,7 +460,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau msg = create_message_from_sintel_trailer(chat_room); } - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); if (upload_error) { int chat_room_size = 0; @@ -613,7 +610,7 @@ static void transfer_message_upload_cancelled(void) { chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); msg = create_message_from_sintel_trailer(chat_room); - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); /*wait for file to be 25% uploaded and cancel the transfer */ BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.progress_of_LinphoneFileTransfer, 25, 60000)); @@ -642,7 +639,7 @@ static void transfer_message_download_cancelled(void) { /* create a chatroom on pauline's side */ chat_room = linphone_core_get_chat_room(pauline->lc,marie->identity); msg = create_message_from_sintel_trailer(chat_room); - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); /* wait for marie to receive pauline's msg */ BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000)); @@ -694,8 +691,8 @@ static void file_transfer_2_messages_simultaneously(void) { BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, unsigned int, "%u"); if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) == 0) { - linphone_chat_room_send_chat_message(pauline_room,msg); - linphone_chat_room_send_chat_message(pauline_room,msg2); + linphone_chat_message_send(msg); + linphone_chat_message_send(msg2); if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000))) { LinphoneChatMessage *recvMsg = linphone_chat_message_ref(marie->stat.last_received_chat_message); BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2, 60000)); @@ -753,7 +750,7 @@ static void file_transfer_external_body_url(bool_t use_file_body_handler_in_down linphone_chat_message_set_external_body_url(msg, "https://www.linphone.org/img/linphone-open-source-voip-projectX2.png"); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, msg); + linphone_chat_message_send(msg); linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageReceivedWithFile, 1, 60000)); @@ -799,7 +796,7 @@ static void text_message_denied(void) { /*pauline doesn't want to be disturbed*/ linphone_core_disable_chat(pauline->lc,LinphoneReasonDoNotDisturb); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1)); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d"); @@ -1038,7 +1035,7 @@ static void _imdn_notifications(bool_t with_lime) { sent_cm = linphone_chat_room_create_message(pauline_chat_room, "Tell me if you get my message"); cbs = linphone_chat_message_get_callbacks(sent_cm); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(pauline_chat_room, sent_cm); + linphone_chat_message_send(sent_cm); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); marie_chat_room = linphone_core_get_chat_room(marie->lc, pauline->identity); history = linphone_chat_room_get_history(marie_chat_room, 1); @@ -1118,7 +1115,7 @@ static void _im_notification_policy(bool_t with_lime) { msg1 = linphone_chat_room_create_message(pauline_chat_room, "Happy new year!"); cbs = linphone_chat_message_get_callbacks(msg1); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(pauline_chat_room, msg1); + linphone_chat_message_send(msg1); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); wait_for_until(pauline->lc, marie->lc, &dummy, 1, 1500); /* Just to sleep while iterating */ BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDeliveredToUser, 0, int, "%d"); @@ -1126,13 +1123,13 @@ static void _im_notification_policy(bool_t with_lime) { msg2 = linphone_chat_room_create_message(pauline_chat_room, "I said: Happy new year!"); cbs = linphone_chat_message_get_callbacks(msg2); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(pauline_chat_room, msg2); + linphone_chat_message_send(msg2); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 2)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageDeliveredToUser, 1)); msg3 = linphone_chat_room_create_message(marie_chat_room, "Thank you! Happy easter to you!"); cbs = linphone_chat_message_get_callbacks(msg3); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(marie_chat_room, msg3); + linphone_chat_message_send(msg3); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageReceived, 1)); wait_for_until(pauline->lc, marie->lc, &dummy, 1, 1500); /* Just to sleep while iterating */ BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageDeliveredToUser, 0, int, "%d"); @@ -1140,7 +1137,7 @@ static void _im_notification_policy(bool_t with_lime) { msg4 = linphone_chat_room_create_message(marie_chat_room, "Yeah, yeah, I heard that..."); cbs = linphone_chat_message_get_callbacks(msg4); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(marie_chat_room, msg4); + linphone_chat_message_send(msg4); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageReceived, 2)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageDeliveredToUser, 1)); @@ -1218,7 +1215,7 @@ static void _im_error_delivery_notification(bool_t online) { msg = linphone_chat_room_create_message(chat_room, "Happy new year!"); cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, msg); + linphone_chat_message_send(msg); if (!online) { linphone_core_set_network_reachable(marie->lc, FALSE); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageDelivered, 1, 60000)); @@ -1232,7 +1229,7 @@ static void _im_error_delivery_notification(bool_t online) { /* Restore the ZID cache of the receiver and resend the chat message */ linphone_core_set_zrtp_cache_db(marie->lc, zrtp_cache_db_holder); - linphone_chat_message_resend(msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 2)); /* Check the new message is now received */ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageDeliveredToUser, 1)); linphone_chat_message_unref(msg); @@ -1417,7 +1414,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st msg = create_message_from_sintel_trailer(linphone_core_get_chat_room(pauline->lc, marie->identity)); } - linphone_chat_room_send_chat_message(linphone_chat_message_get_chat_room(msg), msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000)); if (marie->stat.last_received_chat_message ) { LinphoneChatMessage *recv_msg; @@ -1635,7 +1632,7 @@ void crash_during_file_transfer(void) { /* Create a chatroom and a file transfer message on pauline's side */ chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); msg = create_file_transfer_message_from_sintel_trailer(chat_room); - linphone_chat_room_send_chat_message(chat_room, msg); + linphone_chat_message_send(msg); /* Wait for 25% of the file to be uploaded and crash by stopping the iteration, saving the chat database and destroying the core */ BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &pauline->stat.progress_of_LinphoneFileTransfer, 25, 60000)); @@ -1696,7 +1693,7 @@ static void text_status_after_destroying_chat_room(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, ""); LinphoneChatMessage *msg = linphone_chat_room_create_message(chatroom, "hello"); - linphone_chat_room_send_chat_message(chatroom, msg); + linphone_chat_message_send(msg); linphone_core_delete_chat_room(marie->lc, chatroom); //since message is orphan, we do not expect to be notified of state change BC_ASSERT_FALSE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000)); @@ -1712,7 +1709,7 @@ static void file_transfer_not_sent_if_invalid_url(void) { LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); linphone_core_set_file_transfer_server(marie->lc, "INVALID URL"); - linphone_chat_room_send_chat_message(chatroom, msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000)); linphone_chat_message_unref(msg); linphone_core_manager_destroy(marie); @@ -1725,7 +1722,7 @@ void file_transfer_io_error_base(char *server_url, bool_t destroy_room) { LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); linphone_core_set_file_transfer_server(marie->lc, server_url); - linphone_chat_room_send_chat_message(chatroom, msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageInProgress, 1, 1000)); if (destroy_room) { linphone_core_delete_chat_room(marie->lc, chatroom); @@ -1771,7 +1768,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo if (mess_with_marie_payload_number) { const bctbx_list_t *elem; - for (elem = linphone_core_get_text_codecs(marie->lc); elem != NULL; elem = elem->next) { + for (elem = linphone_core_get_text_payload_types(marie->lc); elem != NULL; elem = elem->next) { PayloadType *pt = (PayloadType*)elem->data; if (strcasecmp(pt->mime_type, payload_type_t140.mime_type) == 0) { payload_type_set_number(pt, 99); @@ -1780,7 +1777,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } } else if (mess_with_pauline_payload_number) { const bctbx_list_t *elem; - for (elem = linphone_core_get_text_codecs(pauline->lc); elem != NULL; elem = elem->next) { + for (elem = linphone_core_get_text_payload_types(pauline->lc); elem != NULL; elem = elem->next) { PayloadType *pt = (PayloadType*)elem->data; if (strcasecmp(pt->mime_type, payload_type_t140.mime_type) == 0) { payload_type_set_number(pt, 99); @@ -1836,7 +1833,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + linphone_chat_message_send(rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); linphone_chat_message_unref(rtt_message); @@ -1937,8 +1934,8 @@ static void real_time_text_conversation(void) { } /*Commit the message, triggers a NEW LINE in T.140 */ - linphone_chat_room_send_chat_message(pauline_chat_room, pauline_rtt_message); - linphone_chat_room_send_chat_message(marie_chat_room, marie_rtt_message); + linphone_chat_message_send(pauline_rtt_message); + linphone_chat_message_send(marie_rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); { @@ -1975,8 +1972,8 @@ static void real_time_text_conversation(void) { } /*Commit the message, triggers a NEW LINE in T.140 */ - linphone_chat_room_send_chat_message(pauline_chat_room, pauline_rtt_message); - linphone_chat_room_send_chat_message(marie_chat_room, marie_rtt_message); + linphone_chat_message_send(pauline_rtt_message); + linphone_chat_message_send(marie_rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); { @@ -2110,7 +2107,7 @@ static void real_time_text_message_accented_chars(void) { BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], unsigned long, "%lu"); } - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + linphone_chat_message_send(rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); BC_ASSERT_PTR_NOT_NULL(marie->stat.last_received_chat_message); if (marie->stat.last_received_chat_message) { @@ -2170,7 +2167,7 @@ static void real_time_text_copy_paste(void) { } } } - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + linphone_chat_message_send(rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); linphone_chat_message_unref(rtt_message); } @@ -2209,7 +2206,7 @@ void chat_message_custom_headers(void) { linphone_chat_message_remove_custom_header(msg, "Test1"); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room,msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); @@ -2259,7 +2256,7 @@ void _text_message_with_custom_content_type(bool_t with_lime) { cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_room_send_chat_message(chat_room, msg); + linphone_chat_message_send(msg); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneMessageDelivered, 1)); @@ -2346,7 +2343,7 @@ static int im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryption static bool_t im_encryption_engine_process_outgoing_message_async_impl(LinphoneChatMessage** msg) { if (*msg) { im_encryption_engine_process_outgoing_message_cb(NULL,NULL,*msg); - linphone_chat_room_send_chat_message(linphone_chat_message_get_chat_room(*msg), *msg); + linphone_chat_message_send(*msg); linphone_chat_message_unref(*msg); *msg=NULL; } @@ -2395,7 +2392,7 @@ void im_encryption_engine_b64_base(bool_t async) { chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); chat_msg = linphone_chat_room_create_message(chat_room, "Bla bla bla bla"); - linphone_chat_room_send_chat_message(chat_room, chat_msg); + linphone_chat_message_send(chat_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(chat_msg), "Bla bla bla bla"); BC_ASSERT_PTR_NOT_NULL(marie->stat.last_received_chat_message); @@ -2584,7 +2581,3 @@ test_suite_t message_test_suite = { liblinphone_tester_after_each, sizeof(message_tests) / sizeof(message_tests[0]), message_tests }; - -#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) -#pragma GCC diagnostic pop -#endif From 6f6e1637d9e7f21498fb7b9a8dcaf12b5598146f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 May 2018 17:46:37 +0200 Subject: [PATCH 121/143] Fix chosen bind IP when multicast is activated. --- src/conference/session/media-session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index dd887d8df..b12047565 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -1131,12 +1131,12 @@ string MediaSessionPrivate::getBindIpForStream (int streamIndex) { /* As multicast sender, we must decide a local interface to use to send multicast, and bind to it */ char multicastBindIp[LINPHONE_IPADDR_SIZE]; memset(multicastBindIp, 0, sizeof(multicastBindIp)); - linphone_core_get_local_ip_for(pc->multicastIp.find_first_of(':') ? AF_INET6 : AF_INET, nullptr, multicastBindIp); + linphone_core_get_local_ip_for((pc->multicastIp.find_first_of(':') == string::npos) ? AF_INET : AF_INET6, nullptr, multicastBindIp); bindIp = pc->multicastBindIp = multicastBindIp; } else { /* Otherwise we shall use an address family of the same family of the multicast address, because * dual stack socket and multicast don't work well on Mac OS (linux is OK, as usual). */ - bindIp = pc->multicastIp.find_first_of(':') ? "::0" : "0.0.0.0"; + bindIp = (pc->multicastIp.find_first_of(':') == string::npos) ? "0.0.0.0" : "::0"; } } return bindIp; From 293f1ce249fd4c6f518c1105a43e653688eb4cd1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 2 May 2018 17:47:15 +0200 Subject: [PATCH 122/143] Coding style fixes. --- src/conference/session/media-session.cpp | 34 +++++++++++------------ src/nat/ice-agent.cpp | 35 ++++++++++-------------- src/nat/ice-agent.h | 2 +- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index b12047565..08535ea08 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -706,31 +706,29 @@ shared_ptr MediaSessionPrivate::getMe () const { void MediaSessionPrivate::setState (CallSession::State newState, const string &message) { L_Q(); - SalMediaDescription *rmd; - - lInfo()<<"MediaSessionPrivate::setState"; - - /* Take a ref on the session otherwise it might get destroyed during the call to setState */ + + // Take a ref on the session otherwise it might get destroyed during the call to setState shared_ptr sessionRef = q->getSharedFromThis(); if ((newState != state) && (newState != CallSession::State::StreamsRunning)) q->cancelDtmfs(); CallSessionPrivate::setState(newState, message); if (listener) listener->onCallSessionStateChangedForReporting(q->getSharedFromThis()); - switch(newState){ + SalMediaDescription *rmd = nullptr; + switch (newState) { case CallSession::State::UpdatedByRemote: - /*Handle specifically the case of an incoming ICE-concluded reINVITE*/ - lInfo()<<"Checking for ICE reINVITE"; + // Handle specifically the case of an incoming ICE-concluded reINVITE + lInfo() << "Checking for ICE reINVITE"; rmd = op->get_remote_media_description(); - if (iceAgent && rmd != nullptr && iceAgent->checkIceReinviteNeedsDeferedResponse(rmd)){ + if (iceAgent && rmd && iceAgent->checkIceReinviteNeedsDeferedResponse(rmd)) { deferUpdate = true; deferUpdateInternal = true; incomingIceReinvitePending = true; - lInfo()<<"CallSession [" << q << "]: ICE reinvite received, but one or more check-lists are not completed. Response will be sent later, when ICE has completed"; + lInfo() << "CallSession [" << q << "]: ICE reinvite received, but one or more check-lists are not completed. Response will be sent later, when ICE has completed"; } - break; + break; default: - break; + break; } } @@ -1177,7 +1175,7 @@ void MediaSessionPrivate::getLocalIp (const Address &remoteAddr) { hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_NUMERICHOST; - err = getaddrinfo(remoteAddr.getDomain().c_str(), NULL, &hints, &res); + err = getaddrinfo(remoteAddr.getDomain().c_str(), nullptr, &hints, &res); if (err == 0) dest = remoteAddr.getDomain().c_str(); if (res) freeaddrinfo(res); @@ -1251,9 +1249,9 @@ void MediaSessionPrivate::selectOutgoingIpVersion () { bool haveIpv6 = false; bool haveIpv4 = false; /* Check connectivity for IPv4 and IPv6 */ - if (linphone_core_get_local_ip_for(AF_INET6, NULL, ipv6) == 0) + if (linphone_core_get_local_ip_for(AF_INET6, nullptr, ipv6) == 0) haveIpv6 = true; - if (linphone_core_get_local_ip_for(AF_INET, NULL, ipv4) == 0) + if (linphone_core_get_local_ip_for(AF_INET, nullptr, ipv4) == 0) haveIpv4 = true; if (haveIpv6) { if (!haveIpv4) @@ -2388,8 +2386,10 @@ void MediaSessionPrivate::initializeAudioStream () { params.limeKeyTimeSpan = bctbx_time_string_to_sec(lp_config_get_string(linphone_core_get_config(q->getCore()->getCCore()), "sip", "lime_key_validity", "0")); setZrtpCryptoTypesParameters(¶ms); audio_stream_enable_zrtp(audioStream, ¶ms); - if (peerUri != NULL) ms_free(peerUri); - if (selfUri != NULL) ms_free(selfUri); + if (peerUri) + ms_free(peerUri); + if (selfUri) + ms_free(selfUri); } media_stream_reclaim_sessions(&audioStream->ms, &sessions[mainAudioStreamIndex]); diff --git a/src/nat/ice-agent.cpp b/src/nat/ice-agent.cpp index 167acc8b9..48f15b5f2 100644 --- a/src/nat/ice-agent.cpp +++ b/src/nat/ice-agent.cpp @@ -740,32 +740,25 @@ void IceAgent::updateIceStateInCallStatsForStream (LinphoneCallStats *stats, Ice } } -bool IceAgent::checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md){ - int i,j; - IceCheckList *cl; - - if (!iceSession) return false; +bool IceAgent::checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md) { + if (!iceSession || (ice_session_state(iceSession) != IS_Running)) + return false; - if (ice_session_state(iceSession) != IS_Running ) return false; - - for (i = 0; i < md->nb_streams; i++) { + for (int i = 0; i < md->nb_streams; i++) { SalStreamDescription *stream = &md->streams[i]; - cl = ice_session_check_list(iceSession, i); - - if (cl==NULL) continue; - if (stream->ice_mismatch == TRUE) { - return false; - } - if (stream->rtp_port == 0) { + IceCheckList *cl = ice_session_check_list(iceSession, i); + if (!cl) continue; - } - - if (ice_check_list_state(cl) != ICL_Running) continue; - for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { + if (stream->ice_mismatch) + return false; + if ((stream->rtp_port == 0) || (ice_check_list_state(cl) != ICL_Running)) + continue; + + for (int j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { const SalIceRemoteCandidate *remote_candidate = &stream->ice_remote_candidates[j]; - if (remote_candidate->addr[0] != '\0') return true; - + if (remote_candidate->addr[0] != '\0') + return true; } } return false; diff --git a/src/nat/ice-agent.h b/src/nat/ice-agent.h index 0e702010b..cb688f0af 100644 --- a/src/nat/ice-agent.h +++ b/src/nat/ice-agent.h @@ -70,7 +70,7 @@ public: * Checks if an incoming offer with ICE needs a delayed answer, because the ice session hasn't completed yet with * connecvity checks. */ - bool checkIceReinviteNeedsDeferedResponse(SalMediaDescription *md); + bool checkIceReinviteNeedsDeferedResponse (SalMediaDescription *md); private: void addLocalIceCandidates (int family, const char *addr, IceCheckList *audioCl, IceCheckList *videoCl, IceCheckList *textCl); From 503dd1391e7af8e936c1b35dea6f8c7b12caab00 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 3 May 2018 10:50:53 +0200 Subject: [PATCH 123/143] Some cleaning in register tester. --- tester/register_tester.c | 58 +++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/tester/register_tester.c b/tester/register_tester.c index 3b051089c..e69ec1937 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -89,7 +89,7 @@ static void register_with_refresh_base_3_for_algo( reset_counters(counters); linphone_core_set_transports(lc, transport); - proxy_cfg = linphone_proxy_config_new(); + proxy_cfg = linphone_core_create_proxy_config(lc); from = create_linphone_address_for_algo(domain, username); @@ -475,50 +475,42 @@ static void authenticated_register_with_provided_credentials(void){ BC_ASSERT_PTR_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "passwd", NULL)); BC_ASSERT_PTR_NOT_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "ha1", NULL)); - linphone_proxy_config_destroy(cfg); + linphone_proxy_config_unref(cfg); linphone_core_manager_destroy(lcm); } -static void authenticated_register_with_provided_credentials_and_username_with_espace(void){ - LinphoneCoreManager *lcm; - stats* counters; - LinphoneProxyConfig *cfg; - char route[256]; - LinphoneAddress *from; - char *addr; - LinphoneAuthInfo *ai; - const char* username = "test username"; - sprintf(route,"sip:%s",test_route); - - lcm = linphone_core_manager_new(NULL); - - counters = get_stats(lcm->lc); - cfg = linphone_core_create_proxy_config(lcm->lc); - from = create_linphone_address_for_algo(auth_domain,username); - - linphone_proxy_config_set_identity(cfg, addr=linphone_address_as_string(from)); +static void authenticated_register_with_provided_credentials_and_username_with_space(void) { + LinphoneCoreManager *lcm = linphone_core_manager_new(NULL); + stats *counters = get_stats(lcm->lc); + LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(lcm->lc); + const char *username = "test username"; + LinphoneAddress *from = create_linphone_address_for_algo(auth_domain, username); + + char *addr = linphone_address_as_string(from); + linphone_proxy_config_set_identity(cfg, addr); ms_free(addr); - - linphone_proxy_config_enable_register(cfg,TRUE); - linphone_proxy_config_set_expires(cfg,1); + + linphone_proxy_config_enable_register(cfg, TRUE); + linphone_proxy_config_set_expires(cfg, 1); linphone_proxy_config_set_route(cfg, test_route); - linphone_proxy_config_set_server_addr(cfg,test_route); + linphone_proxy_config_set_server_addr(cfg, test_route); linphone_address_unref(from); - - ai = linphone_auth_info_new(username, NULL, test_password, NULL, NULL, NULL); + + LinphoneAuthInfo *ai = linphone_auth_info_new(username, NULL, test_password, NULL, NULL, test_route); linphone_core_add_auth_info(lcm->lc, ai); linphone_auth_info_unref(ai); linphone_core_add_proxy_config(lcm->lc, cfg); - - BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1)); - BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,0, int, "%d"); - + + BC_ASSERT_TRUE(wait_for(lcm->lc, lcm->lc, &counters->number_of_LinphoneRegistrationOk, 1)); + BC_ASSERT_EQUAL(counters->number_of_auth_info_requested, 0, int, "%d"); + BC_ASSERT_PTR_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "passwd", NULL)); BC_ASSERT_PTR_NOT_NULL(lp_config_get_string(linphone_core_get_config(lcm->lc), "auth_info_0", "ha1", NULL)); - - linphone_proxy_config_destroy(cfg); + + linphone_proxy_config_unref(cfg); linphone_core_manager_destroy(lcm); } + static void authenticated_register_with_wrong_late_credentials(void){ LinphoneCoreManager *lcm; stats* counters; @@ -1352,7 +1344,7 @@ test_t register_tests[] = { TEST_NO_TAG("Authenticated register with wrong late credentials", authenticated_register_with_wrong_late_credentials), TEST_NO_TAG("Authenticated register with late credentials", authenticated_register_with_late_credentials), TEST_NO_TAG("Authenticated register with provided credentials", authenticated_register_with_provided_credentials), - TEST_NO_TAG("Authenticated register with provided credentials, username with espace", authenticated_register_with_provided_credentials_and_username_with_espace), + TEST_NO_TAG("Authenticated register with provided credentials, username with space", authenticated_register_with_provided_credentials_and_username_with_space), TEST_NO_TAG("Register with refresh", simple_register_with_refresh), TEST_NO_TAG("Authenticated register with refresh", simple_auth_register_with_refresh), TEST_NO_TAG("Register with refresh and send error", register_with_refresh_with_send_error), From 73ab3fda4c5910dc30e20b708880081dc9420421 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 3 May 2018 11:32:33 +0200 Subject: [PATCH 124/143] Fix quality reporting tester. --- tester/quality_reporting_tester.c | 371 +++++++++++++++--------------- 1 file changed, 186 insertions(+), 185 deletions(-) diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 0c0b640fe..92b5c4e0e 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -21,40 +21,39 @@ #include "tester_utils.h" #include "quality_reporting.h" -/*avoid crash if x is NULL on libc versions <4.5.26 */ +/* Avoid crash if x is NULL on libc versions <4.5.26 */ #define __strstr(x, y) ((x==NULL)?NULL:strstr(x,y)) -void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ +static void on_report_send_mandatory (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { const char *body = linphone_content_get_string_buffer(content); - char * remote_metrics_start = __strstr(body, "RemoteMetrics:"); - BC_ASSERT_TRUE( - __strstr(body, "VQIntervalReport\r\n") == body || - __strstr(body, "VQSessionReport\r\n") == body || - __strstr(body, "VQSessionReport: CallTerm\r\n") == body + char *remote_metrics_start = __strstr(body, "RemoteMetrics:"); + BC_ASSERT_TRUE((__strstr(body, "VQIntervalReport\r\n") == body) + || (__strstr(body, "VQSessionReport\r\n") == body) + || (__strstr(body, "VQSessionReport: CallTerm\r\n") == body) ); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "CallID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "OrigID:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalGroup:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteGroup:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalAddr:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "IP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PORT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SSRC=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteAddr:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "IP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PORT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SSRC=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "LocalMetrics:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Timestamps:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "START=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "STOP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "CallID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "OrigID:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalGroup:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteGroup:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalAddr:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "IP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PORT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SSRC=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteAddr:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "IP=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PORT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SSRC=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "LocalMetrics:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Timestamps:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "START=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "STOP=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SessionDesc:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PT=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "PD=")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "SR=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SessionDesc:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PT=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PD=")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SR=")); /* We should have not reached RemoteMetrics section yet */ BC_ASSERT_TRUE(!remote_metrics_start || body < remote_metrics_start); @@ -62,23 +61,21 @@ void on_report_send_mandatory(const LinphoneCall *call, SalStreamType stream_typ BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "DialogID:")); } -const char *on_report_send_verify_metrics (const reporting_content_metrics_t *metrics, const char *body) { +static const char *on_report_send_verify_metrics (const reporting_content_metrics_t *metrics, const char *body) { if (metrics->rtcp_xr_count) { BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "SessionDesc:")); BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "JitterBuffer:")); BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "PacketLoss:")); } - if (metrics->rtcp_sr_count + metrics->rtcp_xr_count > 0) { + if (metrics->rtcp_sr_count + metrics->rtcp_xr_count > 0) BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Delay:")); - } - if (metrics->rtcp_xr_count){ + if (metrics->rtcp_xr_count) BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "QualityEst:")); - } return body; } -void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { +static void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { char *remote_metrics_start = __strstr(linphone_content_get_string_buffer(content), "RemoteMetrics:"); reporting_session_report_t *report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; on_report_send_mandatory(call, stream_type, content); @@ -88,33 +85,32 @@ void on_report_send_with_rtcp_xr_local (const LinphoneCall *call, SalStreamType BC_ASSERT_TRUE(!remote_metrics_start || on_report_send_verify_metrics(&report->local_metrics, body) < remote_metrics_start); } -void on_report_send_with_rtcp_xr_remote(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char * body = (char*)linphone_content_get_buffer(content); - reporting_session_report_t * report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; +static void on_report_send_with_rtcp_xr_remote (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + char *body = (char *)linphone_content_get_buffer(content); + reporting_session_report_t *report = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call)))[stream_type]; - on_report_send_mandatory(call,stream_type,content); - if (report->remote_metrics.rtcp_sr_count+report->remote_metrics.rtcp_xr_count>0){ - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "RemoteMetrics:")); - BC_ASSERT_PTR_NOT_NULL(body=__strstr(body, "Timestamps:")); - on_report_send_verify_metrics(&report->remote_metrics,body); + on_report_send_mandatory(call, stream_type, content); + if ((report->remote_metrics.rtcp_sr_count + report->remote_metrics.rtcp_xr_count) > 0) { + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "RemoteMetrics:")); + BC_ASSERT_PTR_NOT_NULL(body = __strstr(body, "Timestamps:")); + on_report_send_verify_metrics(&report->remote_metrics, body); } } -void on_report_send_with_rtcp_xr_both(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - on_report_send_with_rtcp_xr_local(call,stream_type,content); - on_report_send_with_rtcp_xr_remote(call,stream_type,content); + +static void on_report_send_with_rtcp_xr_both (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + on_report_send_with_rtcp_xr_local(call, stream_type, content); + on_report_send_with_rtcp_xr_remote(call, stream_type, content); } -bool_t create_call_for_quality_reporting_tests( - LinphoneCoreManager* marie, - LinphoneCoreManager* pauline, - LinphoneCall** call_marie, - LinphoneCall** call_pauline, - LinphoneCallParams * params_marie, - LinphoneCallParams * params_pauline - ) { - - - bool_t call_succeeded = call_with_params(marie,pauline,params_marie,params_pauline); +static bool_t create_call_for_quality_reporting_tests ( + LinphoneCoreManager *marie, + LinphoneCoreManager *pauline, + LinphoneCall **call_marie, + LinphoneCall **call_pauline, + LinphoneCallParams *params_marie, + LinphoneCallParams *params_pauline +) { + bool_t call_succeeded = call_with_params(marie, pauline, params_marie, params_pauline); BC_ASSERT_TRUE(call_succeeded); if (call_succeeded) { if (call_marie) { @@ -129,24 +125,23 @@ bool_t create_call_for_quality_reporting_tests( return call_succeeded; } -static void quality_reporting_not_used_without_config(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_not_used_without_config (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; reporting_session_report_t **quality_reports = NULL; - - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { - // marie has stats collection enabled but pauline has not + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { + // Marie has stats collection enabled but Pauline has not BC_ASSERT_TRUE(linphone_proxy_config_quality_reporting_enabled(linphone_call_get_dest_proxy(call_marie))); BC_ASSERT_FALSE(linphone_proxy_config_quality_reporting_enabled(linphone_call_get_dest_proxy(call_pauline))); - // this field should be already filled + // This field should be already filled quality_reports = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call_marie))); BC_ASSERT_PTR_NOT_NULL(quality_reports[0]->info.local_addr.ip); - // but not this one since it is updated at the end of call + // But not this one since it is updated at the end of call BC_ASSERT_PTR_NULL(quality_reports[0]->dialog_id); end_call(marie, pauline); } @@ -155,89 +150,92 @@ static void quality_reporting_not_used_without_config(void) { linphone_core_manager_destroy(pauline); } -static void quality_reporting_not_sent_if_call_not_started(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCallLog* out_call_log; - LinphoneCall* out_call; +static void quality_reporting_not_sent_if_call_not_started (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCallLog *out_call_log; + LinphoneCall *out_call; - linphone_core_set_max_calls(pauline->lc,0); - out_call = linphone_core_invite(marie->lc,"pauline"); + linphone_core_set_max_calls(pauline->lc, 0); + out_call = linphone_core_invite(marie->lc, "pauline"); BC_ASSERT_PTR_NOT_NULL(out_call); - if(out_call == NULL) goto end; + if (!out_call) + goto end; linphone_call_ref(out_call); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1, 10000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d"); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallError, 1, 10000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError, 1, int, "%d"); - if (bctbx_list_size(linphone_core_get_call_logs(marie->lc))>0) { - out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data); + if (bctbx_list_size(linphone_core_get_call_logs(marie->lc)) > 0) { + out_call_log = (LinphoneCallLog *)(linphone_core_get_call_logs(marie->lc)->data); BC_ASSERT_PTR_NOT_NULL(out_call_log); - BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d"); + BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log), LinphoneCallAborted, int, "%d"); } linphone_call_unref(out_call); - // wait a few time... - wait_for_until(marie->lc,NULL,NULL,0,1000); + // Wait a few time... + wait_for_until(marie->lc, NULL, NULL, 0, 1000); + + // Since the callee was busy, there should be no publish to do + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); - // since the callee was busy, there should be no publish to do - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_not_sent_if_low_bandwidth(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCallParams* marie_params; - - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_low_bandwidth(marie_params,TRUE); +static void quality_reporting_not_sent_if_low_bandwidth (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCallParams *marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_low_bandwidth(marie_params, TRUE); if (create_call_for_quality_reporting_tests(marie, pauline, NULL, NULL, marie_params, NULL)) { end_call(marie, pauline); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } linphone_call_params_unref(marie_params); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -void on_report_send_remove_fields(const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content){ - char *body = (char *)linphone_content_get_string_buffer(content); - /*corrupt start of the report*/ +static void on_report_send_remove_fields (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { + char *body = bctbx_strdup(linphone_content_get_string_buffer(content)); + /* Corrupt start of the report */ strncpy(body, "corrupted report is corrupted", strlen("corrupted report is corrupted")); + linphone_content_set_string_buffer((LinphoneContent *)content, body); + bctbx_free(body); } -static void quality_reporting_invalid_report(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_invalid_report (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_remove_fields); end_call(marie, pauline); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishError,1, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishError, 1, 3000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishError, 1, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_at_call_termination(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_at_call_termination (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; reporting_session_report_t **quality_reports = NULL; if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { @@ -245,32 +243,33 @@ static void quality_reporting_at_call_termination(void) { linphone_core_terminate_all_calls(marie->lc); - // now dialog id should be filled + // Now dialog id should be filled quality_reports = linphone_quality_reporting_get_reports(linphone_call_log_get_quality_reporting(linphone_call_get_log(call_marie))); BC_ASSERT_PTR_NOT_NULL(quality_reports[0]->dialog_id); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1, 10000)); - BC_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1, 10000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1, 10000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneCallReleased, 1, 10000)); BC_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc)); BC_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,1, int, "%d"); - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1)); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 1, int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishOk, 1)); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void quality_reporting_interval_report(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; +static void quality_reporting_interval_report (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory); linphone_proxy_config_set_quality_reporting_interval(linphone_call_get_dest_proxy(call_marie), 1); @@ -278,67 +277,67 @@ static void quality_reporting_interval_report(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,60000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,60000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1, 60000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 1, 60000)); end_call(marie, pauline); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #ifdef VIDEO_ENABLED -static void quality_reporting_session_report_if_video_stopped(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_pauline = NULL; - LinphoneCall* call_marie = NULL; - LinphoneCallParams* pauline_params; - LinphoneCallParams* marie_params; +static void quality_reporting_session_report_if_video_stopped (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_pauline = NULL; + LinphoneCall *call_marie = NULL; + LinphoneCallParams *pauline_params; + LinphoneCallParams *marie_params; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, FALSE); - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(marie_params,TRUE); - pauline_params=linphone_core_create_call_params(pauline->lc, NULL); - linphone_call_params_enable_video(pauline_params,TRUE); + marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(marie_params, TRUE); + pauline_params = linphone_core_create_call_params(pauline->lc, NULL); + linphone_call_params_enable_video(pauline_params, TRUE); if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_local); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0, int, "%d"); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 0, int, "%d"); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, NULL, 0, 3000)); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); - /*remove video*/ + /* Remove video */ linphone_call_params_unref(pauline_params); - pauline_params=linphone_core_create_call_params(pauline->lc, call_pauline); - linphone_call_params_enable_video(pauline_params,FALSE); - linphone_call_update(call_pauline,pauline_params); + pauline_params = linphone_core_create_call_params(pauline->lc, call_pauline); + linphone_call_params_enable_video(pauline_params, FALSE); + linphone_call_update(call_pauline, pauline_params); linphone_call_params_unref(pauline_params); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,10000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,10000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1, 10000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 1, 10000)); BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); end_call(marie, pauline); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 2, 5000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 2, 5000)); } linphone_call_params_unref(marie_params); - linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #endif -void publish_report_with_route_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){ +static void publish_report_with_route_state_changed (LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state) { if (state == LinphonePublishProgress) { char *uri = linphone_address_as_string(linphone_event_get_resource(ev)); BC_ASSERT_STRING_EQUAL(uri, linphone_proxy_config_get_quality_reporting_collector(linphone_core_get_default_proxy_config(lc))); @@ -347,58 +346,59 @@ void publish_report_with_route_state_changed(LinphoneCore *lc, LinphoneEvent *ev } static void quality_reporting_sent_using_custom_route(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; + LinphoneCoreManager *marie = linphone_core_manager_new("marie_quality_reporting_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get()); linphone_core_cbs_set_publish_state_changed(cbs, publish_report_with_route_state_changed); linphone_core_add_callbacks(marie->lc, cbs); linphone_core_cbs_unref(cbs); - //INVALID collector: sip.linphone.org do not collect reports, so it will throw a 404 Not Found error + // INVALID collector: sip.linphone.org do not collect reports, so it will throw a 404 Not Found error linphone_proxy_config_set_quality_reporting_collector(linphone_core_get_default_proxy_config(marie->lc), "sip:sip.linphone.org"); if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) { end_call(marie, pauline); // PUBLISH submission to the collector should be ERROR since route is not valid - BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,1, int, "%d"); - BC_ASSERT_TRUE(wait_for_until(marie->lc,NULL,&marie->stat.number_of_LinphonePublishError,1,10000)); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0,int, "%d"); + BC_ASSERT_TRUE(wait_for(marie->lc, NULL, &marie->stat.number_of_LinphonePublishProgress, 1)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress, 1, int, "%d"); + BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphonePublishError, 1, 10000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk, 0, int, "%d"); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } #ifdef VIDEO_ENABLED -static void quality_reporting_interval_report_video_and_rtt(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr"); - LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr"); - LinphoneCall* call_marie = NULL; - LinphoneCall* call_pauline = NULL; - LinphoneCallParams* pauline_params; - LinphoneCallParams* marie_params; +static void quality_reporting_interval_report_video_and_rtt (void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc_rtcp_xr"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc_rtcp_xr"); + LinphoneCall *call_marie = NULL; + LinphoneCall *call_pauline = NULL; + LinphoneCallParams *pauline_params; + LinphoneCallParams *marie_params; LinphoneChatRoom *pauline_chat_room; linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, FALSE); - marie_params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(marie_params,TRUE); - linphone_call_params_enable_realtime_text(marie_params,TRUE); - pauline_params=linphone_core_create_call_params(pauline->lc, NULL); - linphone_call_params_enable_video(pauline_params,TRUE); - linphone_call_params_enable_realtime_text(pauline_params,TRUE); + marie_params = linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(marie_params, TRUE); + linphone_call_params_enable_realtime_text(marie_params, TRUE); + pauline_params = linphone_core_create_call_params(pauline->lc, NULL); + linphone_call_params_enable_video(pauline_params, TRUE); + linphone_call_params_enable_realtime_text(pauline_params, TRUE); - if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { + if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) { linphone_reporting_set_on_report_send(call_marie, on_report_send_mandatory); linphone_proxy_config_set_quality_reporting_interval(linphone_call_get_dest_proxy(call_marie), 3); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, NULL, 0, 3000)); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call_pauline))); @@ -406,29 +406,29 @@ static void quality_reporting_interval_report_video_and_rtt(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); // PUBLISH submission to the collector should be ok - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000)); - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,10000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishProgress, 1, 5000)); + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, 1, 10000)); pauline_chat_room = linphone_call_get_chat_room(call_pauline); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); LinphoneChatMessage *rtt_message = NULL; if (pauline_chat_room) { - const char* message = "Lorem Ipsum Belledonnum Communicatum"; + const char *message = "Lorem Ipsum Belledonnum Communicatum"; size_t i; - rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); + rtt_message = linphone_chat_room_create_message(pauline_chat_room, NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(call_marie); for (i = 0; i < strlen(message); i++) { linphone_chat_message_put_char(rtt_message, message[i]); - BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)i+1, 1000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, (int)(i + 1), 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } - linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); + linphone_chat_message_send(rtt_message); } end_call(marie, pauline); - /*wait that all publish complete*/ - BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,marie->stat.number_of_LinphonePublishProgress,60000)); + /* Wait that all publish complete */ + BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphonePublishOk, marie->stat.number_of_LinphonePublishProgress, 60000)); if (rtt_message) linphone_chat_message_unref(rtt_message); @@ -442,10 +442,10 @@ static void quality_reporting_interval_report_video_and_rtt(void) { } #endif -static void video_bandwidth_estimation(void){ +static void video_bandwidth_estimation (void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); - LinphoneVideoPolicy pol = {0}; + LinphoneVideoPolicy pol = { 0 }; OrtpNetworkSimulatorParams simparams = { 0 }; linphone_core_set_video_device(marie->lc, "Mire: Mire (synthetic moving picture)"); @@ -465,14 +465,15 @@ static void video_bandwidth_estimation(void){ simparams.max_bandwidth = 300000; linphone_core_set_network_simulator_params(marie->lc, &simparams); - if (BC_ASSERT_TRUE(call(marie, pauline))){ - /*wait for the first TMMBR*/ + if (BC_ASSERT_TRUE(call(marie, pauline))) { + /* Wait for the first TMMBR */ BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_tmmbr_received, 1, 50000)); BC_ASSERT_GREATER((float)marie->stat.last_tmmbr_value_received, 270000.f, float, "%f"); BC_ASSERT_LOWER((float)marie->stat.last_tmmbr_value_received, 330000.f, float, "%f"); end_call(marie, pauline); } + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } From 9d0963cfb88ebd46cc1a2ff8593ce09f72db3527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 31 Jan 2018 14:23:39 +0100 Subject: [PATCH 125/143] linphone-daemon: fixes bad 'From' address in 'call-state-changed' events while doing outgoing calls --- daemon/daemon.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 57dbe3b4e..634fa95d3 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -122,13 +122,18 @@ void *Daemon::iterateThread(void *arg) { } EventResponse::EventResponse(Daemon *daemon, LinphoneCall *call, LinphoneCallState state) { + LinphoneCallLog *callLog = linphone_call_get_call_log(call); + LinphoneAddress *fromAddr = linphone_call_log_get_from_address(callLog); + char *fromStr = linphone_address_as_string(fromAddr); + ostringstream ostr; - char *remote = linphone_call_get_remote_address_as_string(call); - ostr << "Event-type: call-state-changed\nEvent: " << linphone_call_state_to_string(state) << "\n"; - ostr << "From: " << remote << "\n"; + ostr << "Event-type: call-state-changed" << "\n"; + ostr << "Event: " << linphone_call_state_to_string(state) << "\n"; + ostr << "From: " << fromStr << "\n"; ostr << "Id: " << daemon->updateCallId(call) << "\n"; setBody(ostr.str().c_str()); - ms_free(remote); + + bctbx_free(fromStr); } DtmfResponse::DtmfResponse(Daemon *daemon, LinphoneCall *call, int dtmf) { From 49d27bfaa04bc50dd096cb2c3175a78aa1252041 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 May 2018 22:23:55 +0200 Subject: [PATCH 126/143] Add -no-error=suggest-override because xerces-c and soci have hundreds of missing overrides. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18a57418a..c0d68149e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,7 +291,7 @@ else() ) CHECK_CXX_COMPILER_FLAG("-Wsuggest-override" SUGGEST_OVERRIDE) if (SUGGEST_OVERRIDE) - list(APPEND STRICT_OPTIONS_CXX "-Wsuggest-override" "-Werror=suggest-override") + list(APPEND STRICT_OPTIONS_CXX "-Wsuggest-override" "-Wno-error=suggest-override" ) endif () list(APPEND STRICT_OPTIONS_C "-Wstrict-prototypes" "-Werror=strict-prototypes") if(CMAKE_C_COMPILER_ID STREQUAL "GNU") From f09f500fd36412b6a17f235f7d605a0903f73582 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 May 2018 22:28:26 +0200 Subject: [PATCH 127/143] Fix compilation errors. --- daemon/daemon.cc | 2 +- tester/quality_reporting_tester.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 634fa95d3..5e79f3298 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -123,7 +123,7 @@ void *Daemon::iterateThread(void *arg) { EventResponse::EventResponse(Daemon *daemon, LinphoneCall *call, LinphoneCallState state) { LinphoneCallLog *callLog = linphone_call_get_call_log(call); - LinphoneAddress *fromAddr = linphone_call_log_get_from_address(callLog); + const LinphoneAddress *fromAddr = linphone_call_log_get_from_address(callLog); char *fromStr = linphone_address_as_string(fromAddr); ostringstream ostr; diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 92b5c4e0e..6870791a8 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -97,10 +97,12 @@ static void on_report_send_with_rtcp_xr_remote (const LinphoneCall *call, SalStr } } +/* static void on_report_send_with_rtcp_xr_both (const LinphoneCall *call, SalStreamType stream_type, const LinphoneContent *content) { on_report_send_with_rtcp_xr_local(call, stream_type, content); on_report_send_with_rtcp_xr_remote(call, stream_type, content); } +*/ static bool_t create_call_for_quality_reporting_tests ( LinphoneCoreManager *marie, From 7a751bcbc1d8827c4bac395cb185e7cbee147b19 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 2 Feb 2018 15:24:51 +0100 Subject: [PATCH 128/143] improve forking with gruu test --- tester/flexisip_tester.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index dcb1a0688..c98380d85 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -207,19 +207,28 @@ static void message_forking_with_all_recipients_unreachable(void) { } static void message_forking_with_unreachable_recipients_with_gruu(void) { - LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager *marie = ms_new0(LinphoneCoreManager, 1); + LinphoneCoreManager *pauline = ms_new0(LinphoneCoreManager, 1); + LinphoneCoreManager *marie2 = ms_new0(LinphoneCoreManager, 1); + + linphone_core_manager_init(marie, "marie_rc", NULL); + linphone_core_manager_init(pauline, transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc", NULL); + linphone_core_manager_init(marie2, "marie_rc", NULL); + + linphone_core_add_supported_tag(marie->lc,"gruu"); + linphone_core_add_supported_tag(pauline->lc,"gruu"); + linphone_core_add_supported_tag(marie2->lc,"gruu"); + + linphone_core_manager_start(marie,TRUE); + linphone_core_manager_start(pauline,TRUE); + linphone_core_manager_start(marie2,TRUE); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); LinphoneProxyConfig *marie_proxy_config = linphone_core_get_default_proxy_config(marie->lc); - LinphoneProxyConfig *marie2_proxy_config = linphone_core_get_default_proxy_config(marie2->lc); const LinphoneAddress *marie_address = linphone_proxy_config_get_contact(marie_proxy_config); - const LinphoneAddress *marie2_address = linphone_proxy_config_get_contact(marie2_proxy_config); LinphoneChatRoom* chat_room_1 = linphone_core_get_chat_room(pauline->lc, marie_address); LinphoneChatMessage* message_1 = linphone_chat_room_create_message(chat_room_1,"Bli bli bli \n blu"); - LinphoneChatRoom* chat_room_2 = linphone_core_get_chat_room(pauline->lc, marie2_address); - LinphoneChatMessage* message_2 = linphone_chat_room_create_message(chat_room_2,"Bla bla bla \n bli"); lcs=bctbx_list_append(lcs,pauline->lc); lcs=bctbx_list_append(lcs,marie2->lc); @@ -234,25 +243,24 @@ static void message_forking_with_unreachable_recipients_with_gruu(void) { linphone_core_set_network_reachable(marie->lc,FALSE); linphone_core_set_network_reachable(marie2->lc,FALSE); - linphone_chat_message_send(message_1); - linphone_chat_message_send(message_2); + linphone_chat_room_send_chat_message(chat_room_1, message_1); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceived, 0, int, "%d"); BC_ASSERT_EQUAL(marie2->stat.number_of_LinphoneMessageReceived, 0, int, "%d"); /*marie 2 goes online */ linphone_core_set_network_reachable(marie2->lc,TRUE); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,3000)); + BC_ASSERT_FALSE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,3000)); /*wait a long time so that all transactions are expired*/ wait_for_list(lcs,NULL,0,32000); /*marie goes online now*/ linphone_core_set_network_reachable(marie->lc,TRUE); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000)); - + if (BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000))) { + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie->stat.last_received_chat_message), linphone_chat_message_get_text(message_1)); + } linphone_chat_message_unref(message_1); - linphone_chat_message_unref(message_2); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); From 36aa0bfd0e18a2ff7316ea0013ea7313b5f09b6c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 May 2018 14:39:33 +0200 Subject: [PATCH 129/143] Added in LinphoneFactory method to create a TunnelConfig --- coreapi/factory.c | 4 ++++ include/linphone/factory.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/coreapi/factory.c b/coreapi/factory.c index 5138534a4..a9434159b 100644 --- a/coreapi/factory.c +++ b/coreapi/factory.c @@ -439,3 +439,7 @@ void linphone_factory_set_log_collection_path(LinphoneFactory *factory, const ch void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLogCollectionState state) { linphone_core_enable_log_collection(state); } + +LinphoneTunnelConfig *linphone_factory_create_tunnel_config(LinphoneFactory *factory) { + return linphone_tunnel_config_new(); +} diff --git a/include/linphone/factory.h b/include/linphone/factory.h index 2389b9793..6a1fbbbf0 100644 --- a/include/linphone/factory.h +++ b/include/linphone/factory.h @@ -466,6 +466,13 @@ LINPHONE_PUBLIC void linphone_factory_set_log_collection_path(LinphoneFactory *f */ LINPHONE_PUBLIC void linphone_factory_enable_log_collection(LinphoneFactory *factory, LinphoneLogCollectionState state); +/** + * Creates an object #LinphoneTunnelConfig + * @param[in] factory the #LinphoneFactory + * @return a #LinphoneTunnelConfig + */ +LINPHONE_PUBLIC LinphoneTunnelConfig *linphone_factory_create_tunnel_config(LinphoneFactory *factory); + /** * @} */ From db008cd32f829b64577052786d1ca75a72ee765c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 May 2018 15:33:56 +0200 Subject: [PATCH 130/143] Fixed tunnel compilation issues --- coreapi/TunnelManager.cc | 18 +++++++++--------- coreapi/linphone_tunnel.cc | 13 +++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 8a51c392c..d7348c093 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -33,7 +33,7 @@ void TunnelManager::addServer(const char *ip, int port,unsigned int udpMirrorPor return; } addServer(ip,port); - mUdpMirrorClients.push_back(UdpMirrorClient(ServerAddr(ip,udpMirrorPort),delay)); + mUdpMirrorClients.push_back(UdpMirrorClient(ServerAddr(ip, (int)udpMirrorPort), delay)); } void TunnelManager::addServer(const char *ip, int port) { @@ -58,7 +58,7 @@ void TunnelManager::addServerPair(const char *ip1, int port1, const char *ip2, i return; } addServerPair(ip1, port1, ip2, port2); - mUdpMirrorClients.push_back(UdpMirrorClient(ServerAddr(ip1, udpMirrorPort), delay)); + mUdpMirrorClients.push_back(UdpMirrorClient(ServerAddr(ip1, (int)udpMirrorPort), delay)); } void TunnelManager::addServerPair(const char *ip1, int port1, const char *ip2, int port2) { @@ -159,7 +159,7 @@ void TunnelManager::startClient() { mTunnelClient = TunnelClient::create(TRUE); } - sal_set_tunnel(mCore->sal, mTunnelClient); + mCore->sal->set_tunnel(mTunnelClient); if (!mUseDualClient) { static_cast(mTunnelClient)->setCallback(tunnelCallback,this); } else { @@ -220,21 +220,21 @@ bool TunnelManager::isConnected() const { int TunnelManager::customSendto(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen){ int size; DualSocket *ds = (DualSocket *)t->data; - msgpullup(msg,-1); - size=msgdsize(msg); - ds->sendSocket->sendto(msg->b_rptr,size,to,tolen); + msgpullup(msg, (size_t)-1); + size = (int)msgdsize(msg); + ds->sendSocket->sendto(msg->b_rptr, (size_t)size, to, tolen); return size; } int TunnelManager::customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen){ DualSocket *ds = (DualSocket *)t->data; memset(&msg->recv_addr,0,sizeof(msg->recv_addr)); - int err=ds->recvSocket->recvfrom(msg->b_wptr,dblk_lim(msg->b_datap)-dblk_base(msg->b_datap),from,*fromlen); + long err=ds->recvSocket->recvfrom(msg->b_wptr, (size_t)(dblk_lim(msg->b_datap) - dblk_base(msg->b_datap)), from, *fromlen); //to make ice happy inet_aton(((TunnelManager*)(ds->recvSocket)->getUserPointer())->mLocalAddr,&msg->recv_addr.addr.ipi_addr); msg->recv_addr.family = AF_INET; msg->recv_addr.port = htons((unsigned short)(ds->recvSocket)->getPort()); - if (err>0) return err; + if (err>0) return (int)err; return 0; } @@ -281,7 +281,7 @@ TunnelManager::~TunnelManager(){ mTunnelClient->stop(); delete mTunnelClient; } - sal_set_tunnel(mCore->sal,NULL); + mCore->sal->set_tunnel(NULL); linphone_core_remove_listener(mCore, mVTable); linphone_core_v_table_destroy(mVTable); } diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index c82876105..6c3589147 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -28,6 +28,7 @@ #include "linphone/core.h" #include "private.h" #include "linphone/lpconfig.h" +#include "c-wrapper/c-wrapper.h" LinphoneTunnel* linphone_core_get_tunnel(const LinphoneCore *lc){ return lc->tunnel; @@ -42,13 +43,13 @@ struct _LinphoneTunnel { static void _linphone_tunnel_uninit(LinphoneTunnel *tunnel); BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneTunnel); -BELLE_SIP_DECLARE_VPTR(LinphoneTunnel); +BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneTunnel); BELLE_SIP_INSTANCIATE_VPTR(LinphoneTunnel, belle_sip_object_t, _linphone_tunnel_uninit, // uninit NULL, // clone NULL, // marshal FALSE // unowned -) +); extern "C" LinphoneTunnel* linphone_core_tunnel_new(LinphoneCore *lc){ LinphoneTunnel* tunnel = belle_sip_object_new(LinphoneTunnel); @@ -231,13 +232,13 @@ static void linphone_tunnel_add_server_intern(LinphoneTunnel *tunnel, LinphoneTu linphone_tunnel_config_get_port(tunnel_config), linphone_tunnel_config_get_host2(tunnel_config), linphone_tunnel_config_get_port2(tunnel_config), - linphone_tunnel_config_get_remote_udp_mirror_port(tunnel_config), - linphone_tunnel_config_get_delay(tunnel_config)); + (unsigned int)linphone_tunnel_config_get_remote_udp_mirror_port(tunnel_config), + (unsigned int)linphone_tunnel_config_get_delay(tunnel_config)); } else { bcTunnel(tunnel)->addServer(linphone_tunnel_config_get_host(tunnel_config), linphone_tunnel_config_get_port(tunnel_config), - linphone_tunnel_config_get_remote_udp_mirror_port(tunnel_config), - linphone_tunnel_config_get_delay(tunnel_config)); + (unsigned int)linphone_tunnel_config_get_remote_udp_mirror_port(tunnel_config), + (unsigned int)linphone_tunnel_config_get_delay(tunnel_config)); } } else if (linphone_tunnel_config_get_host2(tunnel_config) != NULL) { bcTunnel(tunnel)->addServerPair(linphone_tunnel_config_get_host(tunnel_config), From d9df13ba3d89e298f5fc1915a69073b05366e348 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 May 2018 15:54:38 +0200 Subject: [PATCH 131/143] Fixed missing tunnel definition in src/ --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 013e84a7f..def6b37f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,7 +62,9 @@ endif() if(BELCARD_FOUND) list(APPEND LIBS ${BELCARD_LIBRARIES}) endif() - +if(ENABLE_TUNNEL) + add_definitions(-DTUNNEL_ENABLED) +endif() set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES address/address-p.h From 6a5190d9475681451f029d76969c0718286868a0 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 4 May 2018 15:54:43 +0200 Subject: [PATCH 132/143] fix IMDN, do not clear imdn to be sent until we receive the 200OK --- src/chat/chat-message/imdn-message-p.h | 3 +++ src/chat/notification/imdn.cpp | 13 ++++++++++--- src/chat/notification/imdn.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/chat/chat-message/imdn-message-p.h b/src/chat/chat-message/imdn-message-p.h index edd994c40..31262e9db 100644 --- a/src/chat/chat-message/imdn-message-p.h +++ b/src/chat/chat-message/imdn-message-p.h @@ -28,6 +28,9 @@ LINPHONE_BEGIN_NAMESPACE class ImdnMessagePrivate : public NotificationMessagePrivate { +public: + ImdnMessage::Context getContext () {return context;} + private: ImdnMessagePrivate (const ImdnMessage::Context &context) : NotificationMessagePrivate(context.chatRoom, ChatMessage::Direction::Outgoing), context(context) {} diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 7c8269b3d..5549a876a 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -86,6 +86,16 @@ void Imdn::notifyDisplay (const shared_ptr &message) { void Imdn::onImdnMessageDelivered (const std::shared_ptr &message) { // If an IMDN has been successfully delivered, remove it from the list so that // it does not get sent again + ImdnMessage::Context context = message->getPrivate()->getContext(); + for (const auto &deliveredMsg : context.deliveredMessages) + deliveredMessages.remove(deliveredMsg); + + for (const auto &displayedMsg : context.displayedMessages) + displayedMessages.remove(displayedMsg); + + for (const auto &nonDeliveredMsg : context.nonDeliveredMessages) + nonDeliveredMessages.remove(nonDeliveredMsg); + sentImdnMessages.remove(message); } @@ -205,15 +215,12 @@ void Imdn::send () { sentImdnMessages.push_back(imdnMessage); if (networkReachable) imdnMessage->getPrivate()->send(); - deliveredMessages.clear(); - displayedMessages.clear(); } if (!nonDeliveredMessages.empty()) { auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages); sentImdnMessages.push_back(imdnMessage); if (networkReachable) imdnMessage->getPrivate()->send(); - nonDeliveredMessages.clear(); } } diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index 1fd44caf8..789cd4854 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -46,6 +46,8 @@ public: MessageReason (const std::shared_ptr &message, LinphoneReason reason) : message(message), reason(reason) {} + bool operator== (const MessageReason &other) const {return message == other.message && reason == other.reason;} + const std::shared_ptr message; LinphoneReason reason; }; From 1cadac2187c36802e89945a89efa58acb5f81765 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 21 Feb 2018 14:13:07 +0100 Subject: [PATCH 133/143] fix(Proxy): remove useless affectation on linphone_nat_policy_ref return --- coreapi/proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index cd815de65..fad3b0147 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1538,7 +1538,7 @@ LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConf void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy) { if (policy != NULL) { - policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ + linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ policy->lc = cfg->lc; } if (cfg->nat_policy != NULL) linphone_nat_policy_unref(cfg->nat_policy); From 49cbc7ce24144bdbdf9b01d55173ad2cce1d59ba Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 4 May 2018 11:29:13 +0200 Subject: [PATCH 134/143] Fix call with network switch test. --- tester/call_single_tester.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 8a97f5f3e..a6287f1fe 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -5314,11 +5314,13 @@ static void _call_with_network_switch(bool_t use_ice, bool_t with_socket_refresh linphone_call_pause(pauline_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPausedByRemote, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPaused, 1)); + wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000); } else if (callee_pause) { marie_call = linphone_core_get_current_call(marie->lc); linphone_call_pause(marie_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1)); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1)); + wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000); } /*marie looses the network and reconnects*/ From 4170acf9e61400f784f3555a9a5305e6a9f9db4f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 4 May 2018 16:44:51 +0200 Subject: [PATCH 135/143] Terminate client group chat rooms only when the call session reaches the released state. --- coreapi/callbacks.c | 3 +++ src/chat/chat-room/client-group-chat-room.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 3c1717904..5c66826bb 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -62,6 +62,7 @@ static void call_received(SalCallOp *h) { if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { h->decline(SalReasonServiceUnavailable, nullptr); + h->release(); return; } @@ -101,6 +102,7 @@ static void call_received(SalCallOp *h) { list identAddresses = ServerGroupChatRoom::parseResourceLists(h->get_remote_body()); if (identAddresses.size() != 1) { h->decline(SalReasonNotAcceptable, nullptr); + h->release(); return; } IdentityAddress confAddr = L_GET_PRIVATE_FROM_C_OBJECT(lc)->mainDb->findOneToOneConferenceChatRoomAddress(from, identAddresses.front()); @@ -126,6 +128,7 @@ static void call_received(SalCallOp *h) { } else { //invite is for an unknown chatroom h->decline(SalReasonNotFound, nullptr); + h->release(); } } else { shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 0635c833b..ced42e15e 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -170,7 +170,7 @@ void ClientGroupChatRoomPrivate::onCallSessionStateChanged ( } else if (q->getState() == ChatRoom::State::TerminationPending) qConference->getPrivate()->focus->getPrivate()->getSession()->terminate(); } else if (newState == CallSession::State::End) { - q->onConferenceTerminated(q->getConferenceAddress()); + setState(ChatRoom::State::TerminationPending); } else if (newState == CallSession::State::Released) { if (q->getState() == ChatRoom::State::TerminationPending) { if (session->getReason() == LinphoneReasonNone) { @@ -548,6 +548,11 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) { void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) { L_D(); + if (getState() != ChatRoom::State::Created) { + lWarning() << "First notify received in ClientGroupChatRoom that is not in the Created state, ignoring it!"; + return; + } + bool performMigration = false; shared_ptr chatRoom; if (getParticipantCount() == 1) { From 9a4cdb305d5b3b551d5c117598ec36a2160b181a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 7 May 2018 10:51:15 +0200 Subject: [PATCH 136/143] Fix some memory leaks in group chat tester. --- tester/group_chat_tester.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index 1990453bf..8f1238653 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -1427,22 +1427,21 @@ static void group_chat_room_create_room_with_disconnected_friends_base (bool_t i const LinphoneAddress *confAddr = linphone_chat_room_get_conference_address(marieCr); if (initial_message) { - LinphoneChatMessage* msg = linphone_chat_room_create_message(marieCr, "Salut"); + LinphoneChatMessage *msg = linphone_chat_room_create_message(marieCr, "Salut"); linphone_chat_message_send(msg); linphone_chat_message_unref(msg); } wait_for_list(coresList, &dummy, 1, 4000); - // Reconnect pauline and laure + // Reconnect Pauline and check that the chat room is correctly created on Pauline's side and that the participants are added linphone_core_set_network_reachable(pauline->lc, TRUE); - linphone_core_set_network_reachable(laure->lc, TRUE); - - // Check that the chat room is correctly created on Pauline's side and that the participants are added paulineCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 2, FALSE); if (!BC_ASSERT_PTR_NOT_NULL(paulineCr)) goto end; - // Check that the chat room is correctly created on Laure's side and that the participants are added + + // Reconnect Laure and check that the chat room is correctly created on Laure's side and that the participants are added + linphone_core_set_network_reachable(laure->lc, TRUE); laureCr = check_creation_chat_room_client_side(coresList, laure, &initialLaureStats, confAddr, initialSubject, 2, FALSE); if (!BC_ASSERT_PTR_NOT_NULL(laureCr)) goto end; @@ -2385,6 +2384,7 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { // Send a message and check that a basic chat room is created on Pauline's side LinphoneChatMessage *msg = linphone_chat_room_create_message(marieCr, "Hey Pauline!"); linphone_chat_message_send(msg); + linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 1000)); BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message); if (pauline->stat.last_received_chat_message) @@ -2396,17 +2396,19 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { // Enable chat room migration and restart core for Marie _linphone_chat_room_enable_migration(marieCr, TRUE); + linphone_chat_room_unref(marieCr); coresList = bctbx_list_remove(coresList, marie->lc); linphone_core_manager_reinit(marie); bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, marie); - init_core_for_conference(tmpCoresManagerList); + bctbx_list_t *tmpCoresList = init_core_for_conference(tmpCoresManagerList); bctbx_list_free(tmpCoresManagerList); - coresList = bctbx_list_append(coresList, marie->lc); + coresList = bctbx_list_concat(coresList, tmpCoresList); linphone_core_manager_start(marie, TRUE); // Send a new message to initiate chat room migration LinphoneAddress *paulineAddr = linphone_address_new(linphone_core_get_identity(pauline->lc)); marieCr = linphone_core_get_chat_room(marie->lc, paulineAddr); + linphone_address_unref(paulineAddr); BC_ASSERT_PTR_NOT_NULL(marieCr); if (marieCr) { initialMarieStats = marie->stat; @@ -2414,6 +2416,7 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { BC_ASSERT_EQUAL(linphone_chat_room_get_capabilities(marieCr), LinphoneChatRoomCapabilitiesBasic | LinphoneChatRoomCapabilitiesProxy | LinphoneChatRoomCapabilitiesMigratable | LinphoneChatRoomCapabilitiesOneToOne, int, "%d"); msg = linphone_chat_room_create_message(marieCr, "Did you migrate?"); linphone_chat_message_send(msg); + linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 1, 3000)); BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 3000)); BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesBasic); @@ -2429,18 +2432,20 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { msg = linphone_chat_room_create_message(marieCr, "Let's go drink a beer"); linphone_chat_message_send(msg); + linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 2, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(marieCr), 3, int, "%d"); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(paulineCr), 3, int, "%d"); msg = linphone_chat_room_create_message(paulineCr, "Let's go drink mineral water instead"); linphone_chat_message_send(msg); + linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageReceived, initialMarieStats.number_of_LinphoneMessageReceived + 1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(marieCr), 4, int, "%d"); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(paulineCr), 4, int, "%d"); // Activate groupchat on Pauline's side and wait for 5 seconds, the migration should now be done on next message sending - lp_config_set_int(linphone_core_get_config(marie->lc),"misc","basic_to_client_group_chat_room_migration_timer",5); + lp_config_set_int(linphone_core_get_config(marie->lc), "misc", "basic_to_client_group_chat_room_migration_timer", 5); linphone_core_set_linphone_specs(pauline->lc, "groupchat"); linphone_core_set_network_reachable(pauline->lc, FALSE); wait_for_list(coresList, &dummy, 1, 1000); @@ -2448,6 +2453,7 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { wait_for_list(coresList, &dummy, 1, 5000); msg = linphone_chat_room_create_message(marieCr, "And now, did you migrate?"); linphone_chat_message_send(msg); + linphone_chat_message_unref(msg); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 2, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomAllInformationReceived, initialMarieStats.number_of_LinphoneChatRoomAllInformationReceived + 1, 10000)); @@ -3496,7 +3502,7 @@ test_t group_chat_tests[] = { TEST_NO_TAG("Send message with a participant removed", group_chat_room_send_message_with_participant_removed), TEST_NO_TAG("Leave group chat room", group_chat_room_leave), TEST_NO_TAG("Come back on a group chat room after a disconnection", group_chat_room_come_back_after_disconnection), - TEST_NO_TAG("Create chat room with disconnected friends", group_chat_room_create_room_with_disconnected_friends), + TEST_ONE_TAG("Create chat room with disconnected friends", group_chat_room_create_room_with_disconnected_friends, "LeaksMemory"), TEST_ONE_TAG("Create chat room with disconnected friends and initial message", group_chat_room_create_room_with_disconnected_friends_and_initial_message, "LeaksMemory"), TEST_NO_TAG("Reinvited after removed from group chat room", group_chat_room_reinvited_after_removed), TEST_ONE_TAG("Reinvited after removed from group chat room while offline", group_chat_room_reinvited_after_removed_while_offline, "LeaksMemory"), @@ -3518,9 +3524,9 @@ test_t group_chat_tests[] = { TEST_NO_TAG("Unique one-to-one chatroom", group_chat_room_unique_one_to_one_chat_room), TEST_NO_TAG("Unique one-to-one chatroom recreated from message", group_chat_room_unique_one_to_one_chat_room_recreated_from_message), TEST_ONE_TAG("Unique one-to-one chatroom recreated from message with app restart", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_with_app_restart, "LeaksMemory"), - TEST_ONE_TAG("Join one-to-one chat room with a new device", group_chat_room_join_one_to_one_chat_room_with_a_new_device, "LeaksMemory"), + TEST_NO_TAG("Join one-to-one chat room with a new device", group_chat_room_join_one_to_one_chat_room_with_a_new_device), TEST_NO_TAG("New unique one-to-one chatroom after both participants left", group_chat_room_new_unique_one_to_one_chat_room_after_both_participants_left), - TEST_NO_TAG("Unique one-to-one chatroom re-created from the party that deleted it, with inactive devices", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2), + TEST_ONE_TAG("Unique one-to-one chatroom re-created from the party that deleted it, with inactive devices", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2, "LeaksMemory"), TEST_NO_TAG("IMDN for group chat room", imdn_for_group_chat_room), TEST_NO_TAG("Aggregated IMDN for group chat room", aggregated_imdn_for_group_chat_room), TEST_NO_TAG("Aggregated IMDN for group chat room read while offline", aggregated_imdn_for_group_chat_room_read_while_offline), From baa4eebbe17a8ad8c79bb2d6fe48852ee84b7364 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 7 May 2018 15:35:33 +0200 Subject: [PATCH 137/143] Use correct naming convention in sal API. --- coreapi/TunnelManager.cc | 2 +- coreapi/authentication.c | 6 +- coreapi/callbacks.c | 128 +-- coreapi/carddav.c | 2 +- coreapi/chat.c | 6 +- coreapi/error_info.c | 4 +- coreapi/event.c | 30 +- coreapi/friend.c | 6 +- coreapi/friendlist.c | 2 +- coreapi/linphonecore.c | 178 ++-- coreapi/misc.c | 2 +- coreapi/presence.c | 6 +- coreapi/proxy.c | 20 +- coreapi/quality_reporting.c | 8 +- coreapi/vcard.cc | 2 +- src/c-wrapper/api/c-call.cpp | 6 +- src/chat/chat-message/chat-message.cpp | 12 +- src/chat/chat-room/chat-room.cpp | 6 +- src/chat/chat-room/client-group-chat-room.cpp | 10 +- .../chat-room/server-group-chat-room-stub.cpp | 4 +- src/chat/notification/imdn.cpp | 4 +- src/chat/notification/is-composing.cpp | 12 +- .../remote-conference-event-handler.cpp | 2 +- src/conference/session/call-session.cpp | 135 +-- src/conference/session/media-session.cpp | 136 +-- src/core/core-call.cpp | 10 +- src/nat/ice-agent.cpp | 4 +- src/sal/call-op.cpp | 890 +++++++++--------- src/sal/call-op.h | 154 ++- src/sal/event-op.cpp | 264 +++--- src/sal/event-op.h | 54 +- src/sal/message-op-interface.h | 2 +- src/sal/message-op.cpp | 52 +- src/sal/message-op.h | 18 +- src/sal/op.cpp | 695 +++++++------- src/sal/op.h | 327 ++++--- src/sal/presence-op.cpp | 250 ++--- src/sal/presence-op.h | 42 +- src/sal/refer-op.cpp | 60 +- src/sal/refer-op.h | 22 +- src/sal/register-op.cpp | 58 +- src/sal/register-op.h | 19 +- src/sal/sal.cpp | 608 ++++++------ src/sal/sal.h | 448 ++++----- src/utils/background-task.cpp | 4 +- 45 files changed, 2373 insertions(+), 2337 deletions(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index d7348c093..c9a14f865 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -281,7 +281,7 @@ TunnelManager::~TunnelManager(){ mTunnelClient->stop(); delete mTunnelClient; } - mCore->sal->set_tunnel(NULL); + mCore->sal->setTunnel(NULL); linphone_core_remove_listener(mCore, mVTable); linphone_core_v_table_destroy(mVTable); } diff --git a/coreapi/authentication.c b/coreapi/authentication.c index 9d310da3c..63eb4d8c1 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -472,10 +472,10 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) lc->auth_info=bctbx_list_append(lc->auth_info,linphone_auth_info_clone(info)); /* retry pending authentication operations */ - for(l=elem=lc->sal->get_pending_auths();elem!=NULL;elem=elem->next){ + for(l=elem=lc->sal->getPendingAuths();elem!=NULL;elem=elem->next){ LinphonePrivate::SalOp *op= static_cast(elem->data); LinphoneAuthInfo *ai; - const SalAuthInfo *req_sai=op->get_auth_requested(); + const SalAuthInfo *req_sai=op->getAuthRequested(); ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE); if (ai){ SalAuthInfo sai; @@ -495,7 +495,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) } /*proxy case*/ for (proxy=(bctbx_list_t*)linphone_core_get_proxy_config_list(lc);proxy!=NULL;proxy=proxy->next) { - if (proxy->data == op->get_user_pointer()) { + if (proxy->data == op->getUserPointer()) { linphone_proxy_config_set_state((LinphoneProxyConfig*)(proxy->data),LinphoneRegistrationProgress,"Authentication..."); break; } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 5c66826bb..f13c24e87 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -58,7 +58,7 @@ using namespace LinphonePrivate; static void register_failure(SalOp *op); static void call_received(SalCallOp *h) { - LinphoneCore *lc = reinterpret_cast(h->get_sal()->get_user_pointer()); + LinphoneCore *lc = reinterpret_cast(h->getSal()->getUserPointer()); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { h->decline(SalReasonServiceUnavailable, nullptr); @@ -71,13 +71,13 @@ static void call_received(SalCallOp *h) { return; LinphoneAddress *fromAddr = nullptr; - const char *pAssertedId = sal_custom_header_find(h->get_recv_custom_header(), "P-Asserted-Identity"); + const char *pAssertedId = sal_custom_header_find(h->getRecvCustomHeaders(), "P-Asserted-Identity"); /* In some situation, better to trust the network rather than the UAC */ if (lp_config_get_int(linphone_core_get_config(lc), "sip", "call_logs_use_asserted_id_instead_of_from", 0)) { if (pAssertedId) { LinphoneAddress *pAssertedIdAddr = linphone_address_new(pAssertedId); if (pAssertedIdAddr) { - ms_message("Using P-Asserted-Identity [%s] instead of from [%s] for op [%p]", pAssertedId, h->get_from(), h); + ms_message("Using P-Asserted-Identity [%s] instead of from [%s] for op [%p]", pAssertedId, h->getFrom(), h); fromAddr = pAssertedIdAddr; } else ms_warning("Unsupported P-Asserted-Identity header for op [%p] ", h); @@ -86,20 +86,20 @@ static void call_received(SalCallOp *h) { } if (!fromAddr) - fromAddr = linphone_address_new(h->get_from()); - LinphoneAddress *toAddr = linphone_address_new(h->get_to()); + fromAddr = linphone_address_new(h->getFrom()); + LinphoneAddress *toAddr = linphone_address_new(h->getTo()); if (_linphone_core_is_conference_creation(lc, toAddr)) { linphone_address_unref(toAddr); linphone_address_unref(fromAddr); - if (sal_address_has_param(h->get_remote_contact_address(), "text")) { + if (sal_address_has_param(h->getRemoteContactAddress(), "text")) { bool oneToOneChatRoom = false; - const char *oneToOneChatRoomStr = sal_custom_header_find(h->get_recv_custom_header(), "One-To-One-Chat-Room"); + const char *oneToOneChatRoomStr = sal_custom_header_find(h->getRecvCustomHeaders(), "One-To-One-Chat-Room"); if (oneToOneChatRoomStr && (strcmp(oneToOneChatRoomStr, "true") == 0)) oneToOneChatRoom = true; if (oneToOneChatRoom) { - IdentityAddress from(h->get_from()); - list identAddresses = ServerGroupChatRoom::parseResourceLists(h->get_remote_body()); + IdentityAddress from(h->getFrom()); + list identAddresses = ServerGroupChatRoom::parseResourceLists(h->getRemoteBody()); if (identAddresses.size() != 1) { h->decline(SalReasonNotAcceptable, nullptr); h->release(); @@ -116,12 +116,12 @@ static void call_received(SalCallOp *h) { } // TODO: handle media conference creation if the "text" feature tag is not present return; - } else if (sal_address_has_param(h->get_remote_contact_address(), "text")) { + } else if (sal_address_has_param(h->getRemoteContactAddress(), "text")) { linphone_address_unref(toAddr); linphone_address_unref(fromAddr); if (linphone_core_conference_server_enabled(lc)) { shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( - ChatRoomId(IdentityAddress(h->get_to()), IdentityAddress(h->get_to())) + ChatRoomId(IdentityAddress(h->getTo()), IdentityAddress(h->getTo())) ); if (chatRoom) { L_GET_PRIVATE(static_pointer_cast(chatRoom))->confirmJoining(h); @@ -132,11 +132,11 @@ static void call_received(SalCallOp *h) { } } else { shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( - ChatRoomId(IdentityAddress(h->get_from()), IdentityAddress(h->get_to())) + ChatRoomId(IdentityAddress(h->getFrom()), IdentityAddress(h->getTo())) ); if (!chatRoom) { chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom( - L_C_TO_STRING(h->get_subject()), h->get_remote_contact(), h->get_remote_body(), false + L_C_TO_STRING(h->getSubject()), h->getRemoteContact(), h->getRemoteBody(), false ); } L_GET_PRIVATE(static_pointer_cast(chatRoom))->confirmJoining(h); @@ -159,7 +159,7 @@ static void call_received(SalCallOp *h) { memset(&sei, 0, sizeof(sei)); sal_error_info_set(&sei, SalReasonRedirect, "SIP", 0, nullptr, nullptr); SalAddress *altAddr = sal_address_new(altContact); - h->decline_with_error_info(&sei, altAddr); + h->declineWithErrorInfo(&sei, altAddr); ms_free(altContact); sal_address_unref(altAddr); LinphoneErrorInfo *ei = linphone_error_info_new(); @@ -187,7 +187,7 @@ static void call_received(SalCallOp *h) { /* Check if I'm the caller */ LinphoneAddress *fromAddressToSearchIfMe = nullptr; - if (h->get_privacy() == SalPrivacyNone) + if (h->getPrivacy() == SalPrivacyNone) fromAddressToSearchIfMe = linphone_address_clone(fromAddr); else if (pAssertedId) fromAddressToSearchIfMe = linphone_address_new(pAssertedId); @@ -215,14 +215,14 @@ static void call_received(SalCallOp *h) { } static void call_rejected(SalCallOp *h){ - LinphoneCore *lc=(LinphoneCore *)h->get_sal()->get_user_pointer(); + LinphoneCore *lc = reinterpret_cast(h->getSal()->getUserPointer()); LinphoneErrorInfo *ei = linphone_error_info_new(); linphone_error_info_from_sal_op(ei, h); - linphone_core_report_early_failed_call(lc, LinphoneCallIncoming, linphone_address_new(h->get_from()), linphone_address_new(h->get_to()), ei); + linphone_core_report_early_failed_call(lc, LinphoneCallIncoming, linphone_address_new(h->getFrom()), linphone_address_new(h->getTo()), ei); } static void call_ringing(SalOp *h) { - LinphonePrivate::CallSession *session = reinterpret_cast(h->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(h->getUserPointer()); if (!session) return; auto sessionRef = session->getSharedFromThis(); L_GET_PRIVATE(sessionRef)->remoteRinging(); @@ -234,7 +234,7 @@ static void call_ringing(SalOp *h) { * - when a request is accepted (pause, resume) */ static void call_accepted(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("call_accepted: CallSession no longer exists"); return; @@ -245,7 +245,7 @@ static void call_accepted(SalOp *op) { /* this callback is called when an incoming re-INVITE/ SIP UPDATE modifies the session*/ static void call_updating(SalOp *op, bool_t is_update) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("call_updating: CallSession no longer exists"); return; @@ -256,7 +256,7 @@ static void call_updating(SalOp *op, bool_t is_update) { static void call_ack_received(SalOp *op, SalCustomHeader *ack) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("call_ack_received(): no CallSession for which an ack is expected"); return; @@ -267,7 +267,7 @@ static void call_ack_received(SalOp *op, SalCustomHeader *ack) { static void call_ack_being_sent(SalOp *op, SalCustomHeader *ack) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("call_ack_being_sent(): no CallSession for which an ack is supposed to be sent"); return; @@ -277,7 +277,7 @@ static void call_ack_being_sent(SalOp *op, SalCustomHeader *ack) { } static void call_terminated(SalOp *op, const char *from) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) return; auto sessionRef = session->getSharedFromThis(); @@ -285,7 +285,7 @@ static void call_terminated(SalOp *op, const char *from) { } static void call_failure(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("Failure reported on already terminated CallSession"); return; @@ -295,7 +295,7 @@ static void call_failure(SalOp *op) { } static void call_released(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { /* We can get here when the core manages call at Sal level without creating a Call object. Typicially, * when declining an incoming call with busy because maximum number of calls is reached. */ @@ -306,7 +306,7 @@ static void call_released(SalOp *op) { } static void call_cancel_done(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("Cancel done reported on already terminated CallSession"); return; @@ -316,7 +316,7 @@ static void call_cancel_done(SalOp *op) { } static void auth_failure(SalOp *op, SalAuthInfo* info) { - LinphoneCore *lc = reinterpret_cast(op->get_sal()->get_user_pointer()); + LinphoneCore *lc = reinterpret_cast(op->getSal()->getUserPointer()); LinphoneAuthInfo *ai = NULL; if (info != NULL) { @@ -335,7 +335,7 @@ static void auth_failure(SalOp *op, SalAuthInfo* info) { } static void register_success(SalOp *op, bool_t registered){ - LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)op->get_user_pointer(); + LinphoneProxyConfig *cfg=(LinphoneProxyConfig *)op->getUserPointer(); if (!cfg){ ms_message("Registration success for deleted proxy config, ignored"); return; @@ -345,8 +345,8 @@ static void register_success(SalOp *op, bool_t registered){ } static void register_failure(SalOp *op){ - LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)op->get_user_pointer(); - const SalErrorInfo *ei=op->get_error_info(); + LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)op->getUserPointer(); + const SalErrorInfo *ei=op->getErrorInfo(); const char *details=ei->full_string; if (cfg==NULL){ @@ -371,7 +371,7 @@ static void register_failure(SalOp *op){ } static void vfu_request(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) return; auto sessionRef = session->getSharedFromThis(); @@ -384,7 +384,7 @@ static void vfu_request(SalOp *op) { } static void dtmf_received(SalOp *op, char dtmf) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) return; auto sessionRef = session->getSharedFromThis(); @@ -397,7 +397,7 @@ static void dtmf_received(SalOp *op, char dtmf) { } static void call_refer_received(SalOp *op, const SalAddress *referTo) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); char *addrStr = sal_address_as_string_uri_only(referTo); Address referToAddr(addrStr); string method; @@ -407,21 +407,21 @@ static void call_refer_received(SalOp *op, const SalAddress *referTo) { auto sessionRef = session->getSharedFromThis(); L_GET_PRIVATE(sessionRef)->referred(referToAddr); } else { - LinphoneCore *lc = reinterpret_cast(op->get_sal()->get_user_pointer()); + LinphoneCore *lc = reinterpret_cast(op->getSal()->getUserPointer()); linphone_core_notify_refer_received(lc, addrStr); } bctbx_free(addrStr); } static void message_received(SalOp *op, const SalMessage *msg){ - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { static_cast(op)->reply(SalReasonServiceUnavailable); return; } - LinphoneCall *call=(LinphoneCall*)op->get_user_pointer(); + LinphoneCall *call=(LinphoneCall*)op->getUserPointer(); LinphoneReason reason = lc->chat_deny_code; if (reason == LinphoneReasonNone) { linphone_core_message_received(lc, op, msg); @@ -447,12 +447,12 @@ static void convert_presence_to_xml_requested(SalOp *op, SalPresenceModel *prese } static void notify_presence(SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model, const char *msg){ - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); linphone_notify_recv(lc,op,ss,model); } static void subscribe_presence_received(SalPresenceOp *op, const char *from){ - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { op->decline(SalReasonServiceUnavailable); return; @@ -461,12 +461,12 @@ static void subscribe_presence_received(SalPresenceOp *op, const char *from){ } static void subscribe_presence_closed(SalPresenceOp *op, const char *from){ - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); linphone_subscription_closed(lc,op); } static void ping_reply(SalOp *op) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("Ping reply without CallSession attached..."); return; @@ -552,7 +552,7 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) { } } static bool_t auth_requested(Sal* sal, SalAuthInfo* sai) { - LinphoneCore *lc = (LinphoneCore *)sal->get_user_pointer(); + LinphoneCore *lc = (LinphoneCore *)sal->getUserPointer(); if (fill_auth_info(lc,sai)) { return TRUE; } else { @@ -570,7 +570,7 @@ static bool_t auth_requested(Sal* sal, SalAuthInfo* sai) { } static void notify_refer(SalOp *op, SalReferStatus status) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) { ms_warning("Receiving notify_refer for unknown CallSession"); return; @@ -607,13 +607,13 @@ static LinphoneChatMessageState chatStatusSal2Linphone(SalMessageDeliveryStatus } static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status) { - auto lc = reinterpret_cast(op->get_sal()->get_user_pointer()); + auto lc = reinterpret_cast(op->getSal()->getUserPointer()); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { static_cast(op)->reply(SalReasonDeclined); return; } - LinphonePrivate::ChatMessage *msg = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::ChatMessage *msg = reinterpret_cast(op->getUserPointer()); if (!msg) return; // Do not handle delivery status for isComposing messages. @@ -623,7 +623,7 @@ static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status) } static void info_received(SalOp *op, SalBodyHandler *body_handler) { - LinphonePrivate::CallSession *session = reinterpret_cast(op->get_user_pointer()); + LinphonePrivate::CallSession *session = reinterpret_cast(op->getUserPointer()); if (!session) return; auto sessionRef = session->getSharedFromThis(); @@ -631,7 +631,7 @@ static void info_received(SalOp *op, SalBodyHandler *body_handler) { } static void subscribe_response(SalOp *op, SalSubscribeStatus status, int will_retry){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); if (lev==NULL) return; @@ -648,8 +648,8 @@ static void subscribe_response(SalOp *op, SalSubscribeStatus status, int will_re } static void notify(SalSubscribeOp *op, SalSubscribeStatus st, const char *eventname, SalBodyHandler *body_handler){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); bool_t out_of_dialog = (lev==NULL); if (out_of_dialog) { /*out of dialog notify */ @@ -671,8 +671,8 @@ static void notify(SalSubscribeOp *op, SalSubscribeStatus st, const char *eventn } static void subscribe_received(SalSubscribeOp *op, const char *eventname, const SalBodyHandler *body_handler){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); - LinphoneCore *lc=(LinphoneCore *)op->get_sal()->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); + LinphoneCore *lc=(LinphoneCore *)op->getSal()->getUserPointer(); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { op->decline(SalReasonServiceUnavailable); @@ -689,14 +689,14 @@ static void subscribe_received(SalSubscribeOp *op, const char *eventname, const } static void incoming_subscribe_closed(SalOp *op){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); linphone_event_set_state(lev,LinphoneSubscriptionTerminated); } static void on_publish_response(SalOp* op){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); - const SalErrorInfo *ei=op->get_error_info(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); + const SalErrorInfo *ei=op->getErrorInfo(); if (lev==NULL) return; if (ei->reason==SalReasonNone){ @@ -715,7 +715,7 @@ static void on_publish_response(SalOp* op){ static void on_expire(SalOp *op){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); if (lev==NULL) return; @@ -727,14 +727,14 @@ static void on_expire(SalOp *op){ } static void on_notify_response(SalOp *op){ - LinphoneEvent *lev=(LinphoneEvent*)op->get_user_pointer(); + LinphoneEvent *lev=(LinphoneEvent*)op->getUserPointer(); if (!lev) return; if (lev->is_out_of_dialog_op) { switch (linphone_event_get_subscription_state(lev)) { case LinphoneSubscriptionIncomingReceived: - if (op->get_error_info()->reason == SalReasonNone) + if (op->getErrorInfo()->reason == SalReasonNone) linphone_event_set_state(lev, LinphoneSubscriptionTerminated); else linphone_event_set_state(lev, LinphoneSubscriptionError); @@ -756,7 +756,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ LinphonePrivate::Address addr(refer_uri); bctbx_free(refer_uri); if (addr.isValid()) { - LinphoneCore *lc = reinterpret_cast(op->get_sal()->get_user_pointer()); + LinphoneCore *lc = reinterpret_cast(op->getSal()->getUserPointer()); if (linphone_core_get_global_state(lc) != LinphoneGlobalOn) { static_cast(op)->reply(SalReasonDeclined); @@ -767,10 +767,10 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ if (linphone_core_conference_server_enabled(lc)) { // Removal of a participant at the server side shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( - ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to())) + ChatRoomId(IdentityAddress(op->getTo()), IdentityAddress(op->getTo())) ); if (chatRoom) { - std::shared_ptr participant = chatRoom->findParticipant(IdentityAddress(op->get_from())); + std::shared_ptr participant = chatRoom->findParticipant(IdentityAddress(op->getFrom())); if (!participant || !participant->isAdmin()) { static_cast(op)->reply(SalReasonDeclined); return; @@ -784,7 +784,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ } else { // The server asks a participant to leave a chat room LinphoneChatRoom *cr = L_GET_C_BACK_PTR( - L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(ChatRoomId(addr, IdentityAddress(op->get_to()))) + L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(ChatRoomId(addr, IdentityAddress(op->getTo()))) ); if (cr) { L_GET_CPP_PTR_FROM_C_OBJECT(cr)->leave(); @@ -796,11 +796,11 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ } else { if (linphone_core_conference_server_enabled(lc)) { shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( - ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to())) + ChatRoomId(IdentityAddress(op->getTo()), IdentityAddress(op->getTo())) ); LinphoneChatRoom *cr = L_GET_C_BACK_PTR(chatRoom); if (cr) { - Address fromAddr(op->get_from()); + Address fromAddr(op->getFrom()); shared_ptr participant = chatRoom->findParticipant(fromAddr); if (!participant || !participant->isAdmin()) { static_cast(op)->reply(SalReasonDeclined); @@ -820,7 +820,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ list identAddresses; identAddresses.push_back(addr); L_GET_PRIVATE(static_pointer_cast(chatRoom))->checkCompatibleParticipants( - IdentityAddress(op->get_remote_contact()), + IdentityAddress(op->getRemoteContact()), identAddresses ); static_cast(op)->reply(SalReasonNone); @@ -830,7 +830,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){ } } else { shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( - ChatRoomId(addr, IdentityAddress(op->get_to())) + ChatRoomId(addr, IdentityAddress(op->getTo())) ); if (!chatRoom) chatRoom = L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom("", addr.asString(), Content(), false); diff --git a/coreapi/carddav.c b/coreapi/carddav.c index 880d778e2..912da2b87 100644 --- a/coreapi/carddav.c +++ b/coreapi/carddav.c @@ -573,7 +573,7 @@ static char* generate_url_from_server_address_and_uid(const char *server_url) { char *result = NULL; if (server_url) { char *uuid = reinterpret_cast(ms_malloc(64)); - if (LinphonePrivate::Sal::generate_uuid(uuid, 64) == 0) { + if (LinphonePrivate::Sal::generateUuid(uuid, 64) == 0) { char *url = reinterpret_cast(ms_malloc(300)); snprintf(url, 300, "%s/linphone-%s.vcf", server_url, uuid); ms_debug("Generated url is %s", url); diff --git a/coreapi/chat.c b/coreapi/chat.c index edc8b861b..9e3c3b100 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -127,10 +127,10 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const char *peerAddress; const char *localAddress; if (linphone_core_conference_server_enabled(lc)) { - localAddress = peerAddress = op->get_to(); + localAddress = peerAddress = op->getTo(); } else { - peerAddress = op->get_from(); - localAddress = op->get_to(); + peerAddress = op->getFrom(); + localAddress = op->getTo(); } shared_ptr chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom( diff --git a/coreapi/error_info.c b/coreapi/error_info.c index a4c29c7f3..fe619e4df 100644 --- a/coreapi/error_info.c +++ b/coreapi/error_info.c @@ -207,9 +207,9 @@ void linphone_error_info_from_sal_op(LinphoneErrorInfo *ei, const LinphonePrivat }else{ const SalErrorInfo *sei; linphone_error_info_reset(ei); - sei = op->get_error_info(); + sei = op->getErrorInfo(); linphone_error_info_from_sal(ei, sei); - sei = op->get_reason_error_info(); + sei = op->getReasonErrorInfo(); linphone_error_info_from_sal_reason_ei(ei, sei); } } diff --git a/coreapi/event.c b/coreapi/event.c index 582774843..149eda87c 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -119,7 +119,7 @@ void linphone_event_cbs_set_notify_response(LinphoneEventCbs *cbs, LinphoneEvent static void linphone_event_release(LinphoneEvent *lev){ if (lev->op) { /*this will stop the refresher*/ - lev->op->stop_refreshing(); + lev->op->stopRefreshing(); } linphone_event_unref(lev); } @@ -133,7 +133,7 @@ static LinphoneEvent * linphone_event_new_base(LinphoneCore *lc, LinphoneSubscri lev->name=ms_strdup(name); if (strcmp(lev->name, "conference") == 0) lev->internal = TRUE; - lev->op->set_user_pointer(lev); + lev->op->setUserPointer(lev); return lev; } @@ -221,7 +221,7 @@ LinphoneReason linphone_event_get_reason(const LinphoneEvent *lev){ LinphoneEvent *linphone_core_create_subscribe(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires){ LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionOutgoing, event, expires); linphone_configure_op(lc,lev->op,resource,NULL,TRUE); - lev->op->set_manual_refresher_mode(!lp_config_get_int(lc->config,"sip","refresh_generic_subscribe",1)); + lev->op->setManualRefresherMode(!lp_config_get_int(lc->config,"sip","refresh_generic_subscribe",1)); return lev; } @@ -229,7 +229,7 @@ LinphoneEvent *linphone_core_create_notify(LinphoneCore *lc, const LinphoneAddre LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionIncoming, event, -1); linphone_configure_op(lc,lev->op,resource,NULL,TRUE); lev->subscription_state = LinphoneSubscriptionIncomingReceived; - lev->op->set_event(event); + lev->op->setEvent(event); lev->is_out_of_dialog_op = TRUE; return lev; } @@ -265,10 +265,10 @@ LinphoneStatus linphone_event_send_subscribe(LinphoneEvent *lev, const LinphoneC } if (lev->send_custom_headers){ - lev->op->set_sent_custom_header(lev->send_custom_headers); + lev->op->setSentCustomHeaders(lev->send_custom_headers); sal_custom_header_free(lev->send_custom_headers); lev->send_custom_headers=NULL; - }else lev->op->set_sent_custom_header(NULL); + }else lev->op->setSentCustomHeaders(NULL); body_handler = sal_body_handler_from_content(body); auto subscribeOp = dynamic_cast(lev->op); @@ -347,7 +347,7 @@ static LinphoneEvent *_linphone_core_create_publish(LinphoneCore *core, Linphone lev = linphone_event_new_with_op(lc, new SalPublishOp(lc->sal), LinphoneSubscriptionInvalidDir, event); lev->expires = expires; linphone_configure_op_with_proxy(lc,lev->op,resource,NULL, !!lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0),cfg); - lev->op->set_manual_refresher_mode(!lp_config_get_int(lc->config,"sip","refresh_generic_publish",1)); + lev->op->setManualRefresherMode(!lp_config_get_int(lc->config,"sip","refresh_generic_publish",1)); return lev; } LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires){ @@ -374,10 +374,10 @@ static int _linphone_event_send_publish(LinphoneEvent *lev, const LinphoneConten return -1; } if (lev->send_custom_headers){ - lev->op->set_sent_custom_header(lev->send_custom_headers); + lev->op->setSentCustomHeaders(lev->send_custom_headers); sal_custom_header_free(lev->send_custom_headers); lev->send_custom_headers=NULL; - }else lev->op->set_sent_custom_header(NULL); + }else lev->op->setSentCustomHeaders(NULL); body_handler = sal_body_handler_from_content(body); auto publishOp = dynamic_cast(lev->op); err=publishOp->publish(NULL,NULL,lev->name,lev->expires,body_handler); @@ -413,7 +413,7 @@ LinphoneStatus linphone_event_refresh_publish(LinphoneEvent *lev) { return lev->op->refresh(); } void linphone_event_pause_publish(LinphoneEvent *lev) { - if (lev->op) lev->op->stop_refreshing(); + if (lev->op) lev->op->stopRefreshing(); } void linphone_event_unpublish(LinphoneEvent *lev) { lev->terminating = TRUE; /* needed to get clear event*/ @@ -435,7 +435,7 @@ void linphone_event_add_custom_header(LinphoneEvent *ev, const char *name, const } const char* linphone_event_get_custom_header(LinphoneEvent* ev, const char* name){ - const SalCustomHeader *ch=ev->op->get_recv_custom_header(); + const SalCustomHeader *ch=ev->op->getRecvCustomHeaders(); return sal_custom_header_find(ch,name); } @@ -453,7 +453,7 @@ void linphone_event_terminate(LinphoneEvent *lev){ lev->terminating=TRUE; if (lev->dir==LinphoneSubscriptionIncoming){ auto op = dynamic_cast(lev->op); - op->close_notify(); + op->closeNotify(); }else if (lev->dir==LinphoneSubscriptionOutgoing){ auto op = dynamic_cast(lev->op); op->unsubscribe(); @@ -511,7 +511,7 @@ const char *linphone_event_get_name(const LinphoneEvent *lev){ static const LinphoneAddress *_linphone_event_cache_to (const LinphoneEvent *lev) { if (lev->to_address) linphone_address_unref(lev->to_address); - char *buf = sal_address_as_string(lev->op->get_to_address()); + char *buf = sal_address_as_string(lev->op->getToAddress()); ((LinphoneEvent *)lev)->to_address = linphone_address_new(buf); ms_free(buf); return lev->to_address; @@ -520,7 +520,7 @@ static const LinphoneAddress *_linphone_event_cache_to (const LinphoneEvent *lev static const LinphoneAddress *_linphone_event_cache_from (const LinphoneEvent *lev) { if (lev->from_address) linphone_address_unref(lev->from_address); - char *buf = sal_address_as_string(lev->op->get_from_address()); + char *buf = sal_address_as_string(lev->op->getFromAddress()); ((LinphoneEvent *)lev)->from_address = linphone_address_new(buf); ms_free(buf); return lev->from_address; @@ -529,7 +529,7 @@ static const LinphoneAddress *_linphone_event_cache_from (const LinphoneEvent *l static const LinphoneAddress *_linphone_event_cache_remote_contact (const LinphoneEvent *lev) { if (lev->remote_contact_address) linphone_address_unref(lev->remote_contact_address); - char *buf = sal_address_as_string(lev->op->get_remote_contact_address()); + char *buf = sal_address_as_string(lev->op->getRemoteContactAddress()); ((LinphoneEvent *)lev)->remote_contact_address = linphone_address_new(buf); ms_free(buf); return lev->remote_contact_address; diff --git a/coreapi/friend.c b/coreapi/friend.c index b865256db..6b3b175ff 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -478,7 +478,7 @@ void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence) } for(elem=lf->insubs; elem!=NULL; elem=bctbx_list_next(elem)){ auto op = reinterpret_cast(bctbx_list_get_data(elem)); - op->notify_presence((SalPresenceModel *)presence); + op->notifyPresence((SalPresenceModel *)presence); } } @@ -531,7 +531,7 @@ void linphone_friend_invalidate_subscription(LinphoneFriend *lf){ } static void close_presence_notification(SalPresenceOp *op) { - op->notify_presence_close(); + op->notifyPresenceClose(); } static void release_sal_op(SalOp *op) { @@ -773,7 +773,7 @@ void linphone_friend_update_subscribes(LinphoneFriend *fr, bool_t only_when_regi linphone_friend_unsubscribe(fr); }else if (!can_subscribe && fr->outsub){ fr->subscribe_active=FALSE; - fr->outsub->stop_refreshing(); + fr->outsub->stopRefreshing(); } } diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 878fc14f0..e55892a21 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -834,7 +834,7 @@ LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe ( const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = bctbx_list_next(elem)) { LinphoneFriend *lf = (LinphoneFriend *)bctbx_list_get_data(elem); - if (lf->outsub && ((lf->outsub == op) || lf->outsub->is_forked_of(op))) return lf; + if (lf->outsub && ((lf->outsub == op) || lf->outsub->isForkedOf(op))) return lf; } return NULL; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ce420c6c7..45513f430 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1296,12 +1296,12 @@ static void sip_config_read(LinphoneCore *lc) { int ipv6_default = TRUE; if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){ - lc->sal->use_session_timers(200); + lc->sal->useSessionTimers(200); } - lc->sal->use_no_initial_route(!!lp_config_get_int(lc->config,"sip","use_no_initial_route",0)); - lc->sal->use_rport(!!lp_config_get_int(lc->config,"sip","use_rport",1)); - lc->sal->set_contact_linphone_specs(lp_config_get_string(lc->config, "sip", "linphone_specs", NULL)); + lc->sal->useNoInitialRoute(!!lp_config_get_int(lc->config,"sip","use_no_initial_route",0)); + lc->sal->useRport(!!lp_config_get_int(lc->config,"sip","use_rport",1)); + lc->sal->setContactLinphoneSpecs(lp_config_get_string(lc->config, "sip", "linphone_specs", NULL)); if (!lp_config_get_int(lc->config,"sip","ipv6_migration_done",FALSE) && lp_config_has_entry(lc->config,"sip","use_ipv6")) { lp_config_clean_entry(lc->config,"sip","use_ipv6"); @@ -1320,7 +1320,7 @@ static void sip_config_read(LinphoneCore *lc) { certificates_config_read(lc); /*setting the dscp must be done before starting the transports, otherwise it is not taken into effect*/ - lc->sal->set_dscp(linphone_core_get_sip_dscp(lc)); + lc->sal->setDscp(linphone_core_get_sip_dscp(lc)); /*start listening on ports*/ linphone_core_set_sip_transports(lc,&tr); @@ -1386,7 +1386,7 @@ static void sip_config_read(LinphoneCore *lc) { linphone_core_set_media_encryption(lc,linphone_core_get_media_encryption(lc)); /*enable the reconnection to the primary server when it is up again asap*/ - lc->sal->enable_reconnect_to_primary_asap(!!lp_config_get_int(lc->config,"sip","reconnect_to_primary_asap",0)); + lc->sal->enableReconnectToPrimaryAsap(!!lp_config_get_int(lc->config,"sip","reconnect_to_primary_asap",0)); /*for tuning or test*/ lc->sip_conf.sdp_200_ack = !!lp_config_get_int(lc->config,"sip","sdp_200_ack",0); @@ -1399,12 +1399,12 @@ static void sip_config_read(LinphoneCore *lc) { lc->sip_conf.keepalive_period = (unsigned int)lp_config_get_int(lc->config,"sip","keepalive_period",10000); lc->sip_conf.tcp_tls_keepalive = !!lp_config_get_int(lc->config,"sip","tcp_tls_keepalive",0); linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); - lc->sal->use_one_matching_codec_policy(!!lp_config_get_int(lc->config,"sip","only_one_codec",0)); - lc->sal->use_dates(!!lp_config_get_int(lc->config,"sip","put_date",0)); - lc->sal->enable_sip_update_method(!!lp_config_get_int(lc->config,"sip","sip_update",1)); + lc->sal->useOneMatchingCodecPolicy(!!lp_config_get_int(lc->config,"sip","only_one_codec",0)); + lc->sal->useDates(!!lp_config_get_int(lc->config,"sip","put_date",0)); + lc->sal->enableSipUpdateMethod(!!lp_config_get_int(lc->config,"sip","sip_update",1)); lc->sip_conf.vfu_with_info = !!lp_config_get_int(lc->config,"sip","vfu_with_info",1); linphone_core_set_sip_transport_timeout(lc, lp_config_get_int(lc->config, "sip", "transport_timeout", 63000)); - lc->sal->set_supported_tags(lp_config_get_string(lc->config,"sip","supported","replaces, outbound, gruu")); + lc->sal->setSupportedTags(lp_config_get_string(lc->config,"sip","supported","replaces, outbound, gruu")); lc->sip_conf.save_auth_info = !!lp_config_get_int(lc->config, "sip", "save_auth_info", 1); linphone_core_create_im_notif_policy(lc); } @@ -1851,13 +1851,13 @@ void linphone_core_set_expected_bandwidth(LinphoneCore *lc, int bw){ } void linphone_core_set_sip_transport_timeout(LinphoneCore *lc, int timeout_ms) { - lc->sal->set_transport_timeout(timeout_ms); + lc->sal->setTransportTimeout(timeout_ms); if (linphone_core_ready(lc)) lp_config_set_int(lc->config, "sip", "transport_timeout", timeout_ms); } int linphone_core_get_sip_transport_timeout(LinphoneCore *lc) { - return lc->sal->get_transport_timeout(); + return lc->sal->getTransportTimeout(); } bool_t linphone_core_get_dns_set_by_app(LinphoneCore *lc) { @@ -1870,27 +1870,27 @@ void linphone_core_set_dns_servers_app(LinphoneCore *lc, const bctbx_list_t *ser } void linphone_core_set_dns_servers(LinphoneCore *lc, const bctbx_list_t *servers){ - lc->sal->set_dns_servers(servers); + lc->sal->setDnsServers(servers); } void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enable) { - lc->sal->enable_dns_srv(enable); + lc->sal->enableDnsSrv(enable); if (linphone_core_ready(lc)) lp_config_set_int(lc->config, "net", "dns_srv_enabled", enable ? 1 : 0); } bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc) { - return lc->sal->dns_srv_enabled(); + return lc->sal->dnsSrvEnabled(); } void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable) { - lc->sal->enable_dns_search(enable); + lc->sal->enableDnsSearch(enable); if (linphone_core_ready(lc)) lp_config_set_int(lc->config, "net", "dns_search_enabled", enable ? 1 : 0); } bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc) { - return lc->sal->dns_search_enabled(); + return lc->sal->dnsSearchEnabled(); } int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ @@ -2228,12 +2228,12 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig image_resources_dir = linphone_factory_get_image_resources_dir(lfactory); lc->sal=new Sal(NULL); - lc->sal->set_refresher_retry_after(lp_config_get_int(lc->config, "sip", "refresher_retry_after", 60000)); - lc->sal->set_http_proxy_host(linphone_core_get_http_proxy_host(lc)); - lc->sal->set_http_proxy_port(linphone_core_get_http_proxy_port(lc)); + lc->sal->setRefresherRetryAfter(lp_config_get_int(lc->config, "sip", "refresher_retry_after", 60000)); + lc->sal->setHttpProxyHost(linphone_core_get_http_proxy_host(lc)); + lc->sal->setHttpProxyPort(linphone_core_get_http_proxy_port(lc)); - lc->sal->set_user_pointer(lc); - lc->sal->set_callbacks(&linphone_sal_callbacks); + lc->sal->setUserPointer(lc); + lc->sal->setCallbacks(&linphone_sal_callbacks); #ifdef __ANDROID__ if (system_context) @@ -2244,7 +2244,7 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig // MS Factory MUST be created after Android has been set, otherwise no camera will be detected ! lc->factory = ms_factory_new_with_voip_and_directories(msplugins_dir, image_resources_dir); - lc->sal->set_factory(lc->factory); + lc->sal->setFactory(lc->factory); belr::GrammarLoader::get().addPath(getPlatformHelpers(lc)->getDataPath()); @@ -2283,7 +2283,7 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig /* Create the http provider in dual stack mode (ipv4 and ipv6. * If this creates problem, we may need to implement parallel ipv6/ ipv4 http requests in belle-sip. */ - lc->http_provider = belle_sip_stack_create_http_provider(reinterpret_cast(lc->sal->get_stack_impl()), "::0"); + lc->http_provider = belle_sip_stack_create_http_provider(reinterpret_cast(lc->sal->getStackImpl()), "::0"); lc->http_crypto_config = belle_tls_crypto_config_new(); belle_http_provider_set_tls_crypto_config(lc->http_provider,lc->http_crypto_config); @@ -2321,13 +2321,13 @@ void linphone_core_start (LinphoneCore *lc) { const char* uuid=lp_config_get_string(lc->config,"misc","uuid",NULL); if (!uuid){ char tmp[64]; - lc->sal->create_uuid(tmp,sizeof(tmp)); + lc->sal->createUuid(tmp,sizeof(tmp)); lp_config_set_string(lc->config,"misc","uuid",tmp); }else if (strcmp(uuid,"0")!=0) /*to allow to disable sip.instance*/ - lc->sal->set_uuid(uuid); + lc->sal->setUuid(uuid); - if (lc->sal->get_root_ca()) { - belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->get_root_ca()); + if (lc->sal->getRootCa()) { + belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->getRootCa()); belle_http_provider_set_tls_crypto_config(lc->http_provider, lc->http_crypto_config); } @@ -2857,12 +2857,12 @@ void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char char ua_string[256]; snprintf(ua_string, sizeof(ua_string) - 1, "%s/%s", name?name:"", ver?ver:""); if (lc->sal) { - lc->sal->set_user_agent(ua_string); - lc->sal->append_stack_string_to_user_agent(); + lc->sal->setUserAgent(ua_string); + lc->sal->appendStackStringToUserAgent(); } } const char *linphone_core_get_user_agent(LinphoneCore *lc){ - return lc->sal->get_user_agent(); + return lc->sal->getUserAgent(); } const char *linphone_core_get_user_agent_name(void){ @@ -2905,32 +2905,32 @@ int _linphone_core_apply_transports(LinphoneCore *lc){ else anyaddr="0.0.0.0"; - sal->unlisten_ports(); + sal->unlistenPorts(); listening_address = lp_config_get_string(lc->config,"sip","bind_address",anyaddr); if (linphone_core_get_http_proxy_host(lc)) { - sal->set_http_proxy_host(linphone_core_get_http_proxy_host(lc)); - sal->set_http_proxy_port(linphone_core_get_http_proxy_port(lc)); + sal->setHttpProxyHost(linphone_core_get_http_proxy_host(lc)); + sal->setHttpProxyPort(linphone_core_get_http_proxy_port(lc)); } if (lc->tunnel && linphone_tunnel_sip_enabled(lc->tunnel) && linphone_tunnel_get_activated(lc->tunnel)){ - sal->set_listen_port(anyaddr,tr->udp_port,SalTransportUDP,TRUE); + sal->setListenPort(anyaddr,tr->udp_port,SalTransportUDP,TRUE); }else{ if (tr->udp_port!=0){ - sal->set_listen_port(listening_address,tr->udp_port,SalTransportUDP,FALSE); + sal->setListenPort(listening_address,tr->udp_port,SalTransportUDP,FALSE); } if (tr->tcp_port!=0){ - sal->set_listen_port (listening_address,tr->tcp_port,SalTransportTCP,FALSE); + sal->setListenPort (listening_address,tr->tcp_port,SalTransportTCP,FALSE); } if (linphone_core_sip_transport_supported(lc,LinphoneTransportTls)){ if (tr->tls_port!=0) - sal->set_listen_port (listening_address,tr->tls_port,SalTransportTLS,FALSE); + sal->setListenPort (listening_address,tr->tls_port,SalTransportTLS,FALSE); } } return 0; } bool_t linphone_core_sip_transport_supported(const LinphoneCore *lc, LinphoneTransportType tp){ - return !!lc->sal->transport_available((SalTransport)tp); + return !!lc->sal->isTransportAvailable((SalTransport)tp); } BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneTransports); @@ -3070,17 +3070,17 @@ LinphoneTransports *linphone_core_get_transports(LinphoneCore *lc){ } void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTransports *tr){ - tr->udp_port=lc->sal->get_listening_port(SalTransportUDP); - tr->tcp_port=lc->sal->get_listening_port(SalTransportTCP); - tr->tls_port=lc->sal->get_listening_port(SalTransportTLS); + tr->udp_port=lc->sal->getListeningPort(SalTransportUDP); + tr->tcp_port=lc->sal->getListeningPort(SalTransportTCP); + tr->tls_port=lc->sal->getListeningPort(SalTransportTLS); } LinphoneTransports *linphone_core_get_transports_used(LinphoneCore *lc){ LinphoneTransports *transports = linphone_transports_new(); - transports->udp_port = lc->sal->get_listening_port(SalTransportUDP); - transports->tcp_port = lc->sal->get_listening_port(SalTransportTCP); - transports->tls_port = lc->sal->get_listening_port(SalTransportTLS); - transports->dtls_port = lc->sal->get_listening_port(SalTransportDTLS); + transports->udp_port = lc->sal->getListeningPort(SalTransportUDP); + transports->tcp_port = lc->sal->getListeningPort(SalTransportTCP); + transports->tls_port = lc->sal->getListeningPort(SalTransportTLS); + transports->dtls_port = lc->sal->getListeningPort(SalTransportDTLS); return transports; } @@ -3112,7 +3112,7 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){ bool_t linphone_core_content_encoding_supported(const LinphoneCore *lc, const char *content_encoding) { const char *handle_content_encoding = lp_config_get_string(lc->config, "sip", "handle_content_encoding", "deflate"); - return (strcmp(handle_content_encoding, content_encoding) == 0) && lc->sal->content_encoding_available(content_encoding); + return (strcmp(handle_content_encoding, content_encoding) == 0) && lc->sal->isContentEncodingAvailable(content_encoding); } static void monitor_network_state(LinphoneCore *lc, time_t curtime){ @@ -3523,7 +3523,7 @@ static void linphone_transfer_routes_to_op(bctbx_list_t *routes, SalOp *op){ bctbx_list_t *it; for(it=routes;it!=NULL;it=it->next){ SalAddress *addr=(SalAddress*)it->data; - op->add_route_address(addr); + op->addRouteAddress(addr); sal_address_destroy(addr); } bctbx_list_free(routes); @@ -3536,7 +3536,7 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon if (proxy){ identity=linphone_proxy_config_get_identity(proxy); if (linphone_proxy_config_get_privacy(proxy)!=LinphonePrivacyDefault) { - op->set_privacy(linphone_proxy_config_get_privacy(proxy)); + op->setPrivacy(linphone_proxy_config_get_privacy(proxy)); } }else identity=linphone_core_get_primary_contact(lc); /*sending out of calls*/ @@ -3545,21 +3545,21 @@ void linphone_configure_op_with_proxy(LinphoneCore *lc, SalOp *op, const Linphon linphone_transfer_routes_to_op(routes,op); } - op->set_to_address(L_GET_PRIVATE_FROM_C_OBJECT(dest)->getInternalAddress()); - op->set_from(identity); - op->set_sent_custom_header(headers); - op->set_realm(linphone_proxy_config_get_realm(proxy)); + op->setToAddress(L_GET_PRIVATE_FROM_C_OBJECT(dest)->getInternalAddress()); + op->setFrom(identity); + op->setSentCustomHeaders(headers); + op->setRealm(linphone_proxy_config_get_realm(proxy)); if (with_contact && proxy && proxy->op){ const LinphoneAddress *contact = linphone_proxy_config_get_contact(proxy); SalAddress *salAddress = nullptr; if (contact) salAddress = sal_address_clone(const_cast(L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress())); - op->set_contact_address(salAddress); + op->setContactAddress(salAddress); if (salAddress) sal_address_unref(salAddress); } - op->enable_cnx_ip_to_0000_if_sendonly(!!lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0)); /*also set in linphone_call_new_incoming*/ + op->enableCnxIpTo0000IfSendOnly(!!lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0)); /*also set in linphone_call_new_incoming*/ } void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact) { linphone_configure_op_with_proxy(lc, op, dest, headers,with_contact,linphone_core_lookup_known_proxy(lc,dest)); @@ -4304,7 +4304,7 @@ const char *linphone_core_get_ring(const LinphoneCore *lc){ } void linphone_core_set_root_ca(LinphoneCore *lc, const char *path) { - lc->sal->set_root_ca(path); + lc->sal->setRootCa(path); if (lc->http_crypto_config) { belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, path); } @@ -4312,8 +4312,8 @@ void linphone_core_set_root_ca(LinphoneCore *lc, const char *path) { } void linphone_core_set_root_ca_data(LinphoneCore *lc, const char *data) { - lc->sal->set_root_ca(NULL); - lc->sal->set_root_ca_data(data); + lc->sal->setRootCa(NULL); + lc->sal->setRootCaData(data); if (lc->http_crypto_config) { belle_tls_crypto_config_set_root_ca_data(lc->http_crypto_config, data); } @@ -4324,7 +4324,7 @@ const char *linphone_core_get_root_ca(LinphoneCore *lc){ } void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno){ - lc->sal->verify_server_certificates(yesno); + lc->sal->verifyServerCertificates(yesno); if (lc->http_crypto_config){ belle_tls_crypto_config_set_verify_exceptions(lc->http_crypto_config, yesno ? 0 : BELLE_TLS_VERIFY_ANY_REASON); } @@ -4332,7 +4332,7 @@ void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno){ } void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){ - lc->sal->verify_server_cn(yesno); + lc->sal->verifyServerCn(yesno); if (lc->http_crypto_config){ belle_tls_crypto_config_set_verify_exceptions(lc->http_crypto_config, yesno ? 0 : BELLE_TLS_VERIFY_CN_MISMATCH); } @@ -4340,7 +4340,7 @@ void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){ } void linphone_core_set_ssl_config(LinphoneCore *lc, void *ssl_config) { - lc->sal->set_ssl_config(ssl_config); + lc->sal->setSslConfig(ssl_config); if (lc->http_crypto_config) { belle_tls_crypto_config_set_ssl_config(lc->http_crypto_config, ssl_config); } @@ -4637,9 +4637,9 @@ void linphone_core_set_nat_policy(LinphoneCore *lc, LinphoneNatPolicy *policy) { linphone_nat_policy_save_to_config(lc->nat_policy); } - lc->sal->enable_nat_helper(!!lp_config_get_int(lc->config, "net", "enable_nat_helper", 1)); - lc->sal->enable_auto_contacts(TRUE); - lc->sal->use_rport(!!lp_config_get_int(lc->config, "sip", "use_rport", 1)); + lc->sal->enableNatHelper(!!lp_config_get_int(lc->config, "net", "enable_nat_helper", 1)); + lc->sal->enableAutoContacts(TRUE); + lc->sal->useRport(!!lp_config_get_int(lc->config, "sip", "use_rport", 1)); if (lc->sip_conf.contact) update_primary_contact(lc); } @@ -5844,8 +5844,8 @@ void sip_config_uninit(LinphoneCore *lc) linphone_vcard_context_destroy(lc->vcard_context); } - lc->sal->reset_transports(); - lc->sal->unlisten_ports(); /*to make sure no new messages are received*/ + lc->sal->resetTransports(); + lc->sal->unlistenPorts(); /*to make sure no new messages are received*/ if (lc->http_provider) { belle_sip_object_unref(lc->http_provider); lc->http_provider=NULL; @@ -6152,7 +6152,7 @@ static void set_sip_network_reachable(LinphoneCore* lc,bool_t is_sip_reachable, if (!lc->sip_network_reachable){ linphone_core_invalidate_friend_subscriptions(lc); - lc->sal->reset_transports(); + lc->sal->resetTransports(); } } @@ -6217,7 +6217,7 @@ bool_t linphone_core_is_network_reachable(LinphoneCore* lc) { } ortp_socket_t linphone_core_get_sip_socket(LinphoneCore *lc){ - return lc->sal->get_socket(); + return lc->sal->getSocket(); } void linphone_core_destroy(LinphoneCore *lc){ @@ -6337,15 +6337,15 @@ const char *linphone_error_to_string(LinphoneReason err){ void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) { if (enable > 0) { - lc->sal->use_tcp_tls_keepalive(lc->sip_conf.tcp_tls_keepalive); - lc->sal->set_keepalive_period(lc->sip_conf.keepalive_period); + lc->sal->useTcpTlsKeepAlive(lc->sip_conf.tcp_tls_keepalive); + lc->sal->setKeepAlivePeriod(lc->sip_conf.keepalive_period); } else { - lc->sal->set_keepalive_period(0); + lc->sal->setKeepAlivePeriod(0); } } bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc) { - return lc->sal->get_keepalive_period() > 0; + return lc->sal->getKeepAlivePeriod() > 0; } void linphone_core_start_dtmf_stream(LinphoneCore* lc) { @@ -6707,7 +6707,7 @@ const char* linphone_core_get_device_identifier(const LinphoneCore *lc) { } void linphone_core_set_sip_dscp(LinphoneCore *lc, int dscp){ - lc->sal->set_dscp(dscp); + lc->sal->setDscp(dscp); if (linphone_core_ready(lc)){ lp_config_set_int_hex(lc->config,"sip","dscp",dscp); _linphone_core_apply_transports(lc); @@ -6771,13 +6771,13 @@ const char * linphone_core_get_file_transfer_server(LinphoneCore *core) { } void linphone_core_add_supported_tag(LinphoneCore *lc, const char *tag){ - lc->sal->add_supported_tag(tag); - lp_config_set_string(lc->config,"sip","supported",lc->sal->get_supported_tags()); + lc->sal->addSupportedTag(tag); + lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags()); } void linphone_core_remove_supported_tag(LinphoneCore *lc, const char *tag){ - lc->sal->remove_supported_tag(tag); - lp_config_set_string(lc->config,"sip","supported",lc->sal->get_supported_tags()); + lc->sal->removeSupportedTag(tag); + lp_config_set_string(lc->config,"sip","supported",lc->sal->getSupportedTags()); } void linphone_core_set_avpf_mode(LinphoneCore *lc, LinphoneAVPFMode mode){ @@ -6905,15 +6905,15 @@ void linphone_core_enable_realtime_text(LinphoneCore *lc, bool_t value) { void linphone_core_set_http_proxy_host(LinphoneCore *lc, const char *host) { lp_config_set_string(lc->config,"sip","http_proxy_host",host); if (lc->sal) { - lc->sal->set_http_proxy_host(host); - lc->sal->set_http_proxy_port(linphone_core_get_http_proxy_port(lc)); /*to make sure default value is set*/ + lc->sal->setHttpProxyHost(host); + lc->sal->setHttpProxyPort(linphone_core_get_http_proxy_port(lc)); /*to make sure default value is set*/ } } void linphone_core_set_http_proxy_port(LinphoneCore *lc, int port) { lp_config_set_int(lc->config,"sip","http_proxy_port",port); if (lc->sal) - lc->sal->set_http_proxy_port(port); + lc->sal->setHttpProxyPort(port); } const char *linphone_core_get_http_proxy_host(const LinphoneCore *lc) { @@ -7159,23 +7159,23 @@ LinphoneImEncryptionEngine *linphone_core_get_im_encryption_engine(const Linphon } void linphone_core_initialize_supported_content_types(LinphoneCore *lc) { - lc->sal->add_content_type_support("text/plain"); - lc->sal->add_content_type_support("message/external-body"); - lc->sal->add_content_type_support("application/vnd.gsma.rcs-ft-http+xml"); - lc->sal->add_content_type_support("application/im-iscomposing+xml"); - lc->sal->add_content_type_support("message/imdn+xml"); + lc->sal->addContentTypeSupport("text/plain"); + lc->sal->addContentTypeSupport("message/external-body"); + lc->sal->addContentTypeSupport("application/vnd.gsma.rcs-ft-http+xml"); + lc->sal->addContentTypeSupport("application/im-iscomposing+xml"); + lc->sal->addContentTypeSupport("message/imdn+xml"); } bool_t linphone_core_is_content_type_supported(const LinphoneCore *lc, const char *content_type) { - return lc->sal->is_content_type_supported(content_type); + return lc->sal->isContentTypeSupported(content_type); } void linphone_core_add_content_type_support(LinphoneCore *lc, const char *content_type) { - lc->sal->add_content_type_support(content_type); + lc->sal->addContentTypeSupport(content_type); } void linphone_core_remove_content_type_support(LinphoneCore *lc, const char *content_type) { - lc->sal->remove_content_type_support(content_type); + lc->sal->removeContentTypeSupport(content_type); } #ifdef ENABLE_UPDATE_CHECK @@ -7333,5 +7333,5 @@ const char *linphone_core_get_linphone_specs (const LinphoneCore *core) { void linphone_core_set_linphone_specs (LinphoneCore *core, const char *specs) { lp_config_set_string(linphone_core_get_config(core), "sip", "linphone_specs", specs); - core->sal->set_contact_linphone_specs(specs); + core->sal->setContactLinphoneSpecs(specs); } diff --git a/coreapi/misc.c b/coreapi/misc.c index f0e225112..0467dcfea 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -476,7 +476,7 @@ const char * linphone_core_get_echo_canceller_filter_name(const LinphoneCore *lc * task_fun must return BELLE_SIP_STOP when job is finished. **/ void linphone_core_queue_task(LinphoneCore *lc, belle_sip_source_func_t task_fun, void *data, const char *task_description){ - belle_sip_source_t *s=lc->sal->create_timer(task_fun,data, 20, task_description); + belle_sip_source_t *s=lc->sal->createTimer(task_fun,data, 20, task_description); belle_sip_object_unref(s); } diff --git a/coreapi/presence.c b/coreapi/presence.c index d8a78ecde..381f3e294 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1563,7 +1563,7 @@ void linphone_subscription_new(LinphoneCore *lc, SalSubscribeOp *op, const char linphone_friend_add_incoming_subscription(lf, op); lf->inc_subscribe_pending=TRUE; if (lp_config_get_int(lc->config,"sip","notify_pending_state",0)) { - op->notify_pending_state(); + op->notifyPendingState(); } op->accept(); } else { @@ -1936,7 +1936,7 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, Sa if (linphone_core_get_default_friend_list(lc) != NULL) lf=linphone_core_find_friend_by_out_subscribe(lc, op); if (lf==NULL && lp_config_get_int(lc->config,"sip","allow_out_of_subscribe_presence",0)){ - char *buf = sal_address_as_string_uri_only(op->get_from_address()); + char *buf = sal_address_as_string_uri_only(op->getFromAddress()); LinphoneAddress *addr = linphone_address_new(buf); lf = linphone_core_find_friend(lc, addr); ms_free(buf); @@ -2000,7 +2000,7 @@ void linphone_subscription_closed(LinphoneCore *lc, SalOp *op){ linphone_friend_remove_incoming_subscription(lf, op); }else{ /*case of an op that we already released because the friend was destroyed*/ - ms_message("Receiving unsuscribe for unknown in-subscribtion from %s", op->get_from()); + ms_message("Receiving unsuscribe for unknown in-subscribtion from %s", op->getFrom()); } } diff --git a/coreapi/proxy.c b/coreapi/proxy.c index fad3b0147..11972d9d1 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -436,7 +436,7 @@ void linphone_proxy_config_enable_publish(LinphoneProxyConfig *cfg, bool_t val){ } void linphone_proxy_config_pause_register(LinphoneProxyConfig *cfg){ - if (cfg->op) cfg->op->stop_refreshing(); + if (cfg->op) cfg->op->stopRefreshing(); } void linphone_proxy_config_edit(LinphoneProxyConfig *cfg){ @@ -457,7 +457,7 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *cfg,LinphoneCore *lc){ void linphone_proxy_config_stop_refreshing(LinphoneProxyConfig * cfg){ LinphoneAddress *contact_addr = NULL; - const SalAddress *sal_addr = cfg->op && cfg->state == LinphoneRegistrationOk ? cfg->op->get_contact_address() : NULL; + const SalAddress *sal_addr = cfg->op && cfg->state == LinphoneRegistrationOk ? cfg->op->getContactAddress() : NULL; if (sal_addr) { char *buf = sal_address_as_string(sal_addr); contact_addr = buf ? linphone_address_new(buf) : NULL; @@ -538,10 +538,10 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *cfg){ guess_contact_for_register(cfg); if (cfg->contact_address) - cfg->op->set_contact_address(L_GET_PRIVATE_FROM_C_OBJECT(cfg->contact_address)->getInternalAddress()); - cfg->op->set_user_pointer(cfg); + cfg->op->setContactAddress(L_GET_PRIVATE_FROM_C_OBJECT(cfg->contact_address)->getInternalAddress()); + cfg->op->setUserPointer(cfg); - if (cfg->op->register_( + if (cfg->op->sendRegister( proxy_string, cfg->reg_identity, cfg->expires, @@ -568,7 +568,7 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *cfg){ void linphone_proxy_config_refresh_register(LinphoneProxyConfig *cfg){ if (cfg->reg_sendregister && cfg->op && cfg->state!=LinphoneRegistrationProgress){ - if (cfg->op->register_refresh(cfg->expires) == 0) { + if (cfg->op->refreshRegister(cfg->expires) == 0) { linphone_proxy_config_set_state(cfg,LinphoneRegistrationProgress, "Refresh registration"); } } @@ -850,7 +850,7 @@ LinphoneStatus linphone_proxy_config_done(LinphoneProxyConfig *cfg) if (res == LinphoneProxyConfigAddressDifferent) { _linphone_proxy_config_unregister(cfg); } - cfg->op->set_user_pointer(NULL); /*we don't want to receive status for this un register*/ + cfg->op->setUserPointer(NULL); /*we don't want to receive status for this un register*/ cfg->op->unref(); /*but we keep refresher to handle authentication if needed*/ cfg->op=NULL; } @@ -1045,7 +1045,7 @@ struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, const char *header_name){ const SalCustomHeader *ch; if (!cfg->op) return NULL; - ch = cfg->op->get_recv_custom_header(); + ch = cfg->op->getRecvCustomHeaders(); return sal_custom_header_find(ch, header_name); } @@ -1416,7 +1416,7 @@ const LinphoneErrorInfo *linphone_proxy_config_get_error_info(const LinphoneProx } const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg) { - return cfg->op?(const LinphoneAddress*) cfg->op->get_service_route():NULL; + return cfg->op?(const LinphoneAddress*) cfg->op->getServiceRoute():NULL; } const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg) { const char* addr=NULL; @@ -1496,7 +1496,7 @@ const LinphoneAddress *linphone_proxy_config_get_contact (const LinphoneProxyCon // Warning : Do not remove, the op can change its contact_address if (!cfg->op) return NULL; - const SalAddress *salAddr = cfg->op->get_contact_address(); + const SalAddress *salAddr = cfg->op->getContactAddress(); if (!salAddr) return NULL; if (cfg->contact_address) diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index a20b03b8e..52e80e991 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -380,7 +380,7 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, sal_address_has_uri_param(salAddress, "maddr") || linphone_address_get_port(request_uri) != 0) { ms_message("Publishing report with custom route %s", collector_uri); - lev->op->set_route(collector_uri); + lev->op->setRoute(collector_uri); } if (linphone_event_send_publish(lev, content) != 0){ @@ -424,7 +424,7 @@ static const SalStreamDescription * get_media_stream_for_desc(const SalMediaDesc static void update_ip(LinphoneCall * call, int stats_type) { SalStreamType sal_stream_type = stats_type == LINPHONE_CALL_STATS_AUDIO ? SalAudio : stats_type == LINPHONE_CALL_STATS_VIDEO ? SalVideo : SalText; const SalStreamDescription * local_desc = get_media_stream_for_desc(_linphone_call_get_local_desc(call), sal_stream_type); - const SalStreamDescription * remote_desc = get_media_stream_for_desc(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->get_remote_media_description(), sal_stream_type); + const SalStreamDescription * remote_desc = get_media_stream_for_desc(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getRemoteMediaDescription(), sal_stream_type); LinphoneCallLog *log = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog(); if (local_desc != NULL) { @@ -444,7 +444,7 @@ static void update_ip(LinphoneCall * call, int stats_type) { if (strlen(remote_desc->rtp_addr) > 0) { STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(remote_desc->rtp_addr)); } else { - STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->get_remote_media_description()->addr)); + STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getRemoteMediaDescription()->addr)); } } } @@ -511,7 +511,7 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) { if (!media_report_enabled(call, stats_type) || !L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()) return; - dialog_id = L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->get_dialog_id(); + dialog_id = L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getDialogId(); STR_REASSIGN(report->info.call_id, ms_strdup(log->call_id)); diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index 336ecf050..36488137f 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -367,7 +367,7 @@ bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) { if (linphone_vcard_get_uid(vCard)) { return FALSE; } - if (LinphonePrivate::Sal::generate_uuid(uuid, sizeof(uuid)) == 0) { + if (LinphonePrivate::Sal::generateUuid(uuid, sizeof(uuid)) == 0) { char vcard_uuid[sizeof(uuid)+4]; snprintf(vcard_uuid, sizeof(vcard_uuid), "urn:%s", uuid); linphone_vcard_set_uid(vCard, vcard_uuid); diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index c0b3cb235..a714340ce 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -207,7 +207,7 @@ LinphoneCallState linphone_call_get_state (const LinphoneCall *call) { bool_t linphone_call_asked_to_autoanswer (LinphoneCall *call) { //return TRUE if the unique(for the moment) incoming call asked to be autoanswered if (call) - return linphone_call_get_op(call)->autoanswer_asked(); + return linphone_call_get_op(call)->autoAnswerAsked(); return FALSE; } @@ -575,8 +575,8 @@ void linphone_call_ogl_render (const LinphoneCall *call) { LinphoneStatus linphone_call_send_info_message (LinphoneCall *call, const LinphoneInfoMessage *info) { SalBodyHandler *body_handler = sal_body_handler_from_content(linphone_info_message_get_content(info)); - linphone_call_get_op(call)->set_sent_custom_header(linphone_info_message_get_headers(info)); - return linphone_call_get_op(call)->send_info(nullptr, nullptr, body_handler); + linphone_call_get_op(call)->setSentCustomHeaders(linphone_info_message_get_headers(info)); + return linphone_call_get_op(call)->sendInfo(nullptr, nullptr, body_handler); } LinphoneCallStats *linphone_call_get_stats (LinphoneCall *call, LinphoneStreamType type) { diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index a60ff9d90..ff2a48399 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -680,11 +680,11 @@ void ChatMessagePrivate::send () { core->getCCore(), op, peer, getSalCustomHeaders(), !!lp_config_get_int(core->getCCore()->config, "sip", "chat_msg_with_contact", 0) ); - op->set_user_pointer(q); /* If out of call, directly store msg */ + op->setUserPointer(q); /* If out of call, directly store msg */ linphone_address_unref(peer); } - op->set_from(q->getFromAddress().asString().c_str()); - op->set_to(q->getToAddress().asString().c_str()); + op->setFrom(q->getFromAddress().asString().c_str()); + op->setTo(q->getToAddress().asString().c_str()); // --------------------------------------- // Start of message modification @@ -721,7 +721,7 @@ void ChatMessagePrivate::send () { EncryptionChatMessageModifier ecmm; ChatMessageModifier::Result result = ecmm.encode(q->getSharedFromThis(), errorCode); if (result == ChatMessageModifier::Result::Error) { - sal_error_info_set((SalErrorInfo *)op->get_error_info(), SalReasonNotAcceptable, "SIP", errorCode, "Unable to encrypt IM", nullptr); + sal_error_info_set((SalErrorInfo *)op->getErrorInfo(), SalReasonNotAcceptable, "SIP", errorCode, "Unable to encrypt IM", nullptr); setState(ChatMessage::State::NotDelivered); return; } else if (result == ChatMessageModifier::Result::Suspended) { @@ -783,7 +783,7 @@ void ChatMessagePrivate::send () { currentSendStep = ChatMessagePrivate::Step::None; if (imdnId.empty()) - setImdnMessageId(op->get_call_id()); /* must be known at that time */ + setImdnMessageId(op->getCallId()); /* must be known at that time */ if (lcall && linphone_call_get_op(lcall) == op) { /* In this case, chat delivery status is not notified, so unrefing chat message right now */ @@ -890,7 +890,7 @@ ChatMessage::~ChatMessage () { } if (d->salOp) { - d->salOp->set_user_pointer(nullptr); + d->salOp->setUserPointer(nullptr); d->salOp->unref(); } if (d->salCustomHeaders) diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp index 50a48b567..6b70da34d 100644 --- a/src/chat/chat-room/chat-room.cpp +++ b/src/chat/chat-room/chat-room.cpp @@ -235,7 +235,7 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag LinphoneCore *cCore = core->getCCore(); msg = createChatMessage( - IdentityAddress(op->get_from()) == q->getLocalAddress() + IdentityAddress(op->getFrom()) == q->getLocalAddress() ? ChatMessage::Direction::Outgoing : ChatMessage::Direction::Incoming ); @@ -252,9 +252,9 @@ LinphoneReason ChatRoomPrivate::onSipMessageReceived (SalOp *op, const SalMessag msg->setInternalContent(content); msg->getPrivate()->setTime(message->time); - msg->getPrivate()->setImdnMessageId(op->get_call_id()); + msg->getPrivate()->setImdnMessageId(op->getCallId()); - const SalCustomHeader *ch = op->get_recv_custom_header(); + const SalCustomHeader *ch = op->getRecvCustomHeaders(); if (ch) msg->getPrivate()->setSalCustomHeaders(sal_custom_header_clone(ch)); diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index ced42e15e..67b27a4df 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -110,13 +110,13 @@ void ClientGroupChatRoomPrivate::confirmJoining (SalCallOp *op) { auto focus = qConference->getPrivate()->focus; bool previousSession = (focus->getPrivate()->getSession() != nullptr); auto session = focus->getPrivate()->createSession(*q, nullptr, false, this); - session->configure(LinphoneCallIncoming, nullptr, op, Address(op->get_from()), Address(op->get_to())); + session->configure(LinphoneCallIncoming, nullptr, op, Address(op->getFrom()), Address(op->getTo())); session->startIncomingNotification(false); if (!previousSession) { setState(ClientGroupChatRoom::State::CreationPending); // Handle participants addition - list identAddresses = ClientGroupChatRoom::parseResourceLists(op->get_remote_body()); + list identAddresses = ClientGroupChatRoom::parseResourceLists(op->getRemoteBody()); for (const auto &addr : identAddresses) { auto participant = q->findParticipant(addr); if (!participant) { @@ -351,7 +351,7 @@ void ClientGroupChatRoom::addParticipant (const IdentityAddress &addr, const Cal linphone_address_unref(lAddr); Address referToAddr = addr; referToAddr.setParam("text"); - referOp->send_refer(referToAddr.getPrivate()->getInternalAddress()); + referOp->sendRefer(referToAddr.getPrivate()->getInternalAddress()); referOp->unref(); } } @@ -402,7 +402,7 @@ void ClientGroupChatRoom::removeParticipant (const shared_ptr &part Address referToAddr = participant->getAddress(); referToAddr.setParam("text"); referToAddr.setUriParam("method", "BYE"); - referOp->send_refer(referToAddr.getPrivate()->getInternalAddress()); + referOp->sendRefer(referToAddr.getPrivate()->getInternalAddress()); referOp->unref(); } @@ -444,7 +444,7 @@ void ClientGroupChatRoom::setParticipantAdminStatus (const shared_ptrgetAddress(); referToAddr.setParam("text"); referToAddr.setParam("admin", Utils::toString(isAdmin)); - referOp->send_refer(referToAddr.getPrivate()->getInternalAddress()); + referOp->sendRefer(referToAddr.getPrivate()->getInternalAddress()); referOp->unref(); } diff --git a/src/chat/chat-room/server-group-chat-room-stub.cpp b/src/chat/chat-room/server-group-chat-room-stub.cpp index 5630256b3..3e6b1710f 100644 --- a/src/chat/chat-room/server-group-chat-room-stub.cpp +++ b/src/chat/chat-room/server-group-chat-room-stub.cpp @@ -139,8 +139,8 @@ void ServerGroupChatRoomPrivate::onCallSessionSetReleased (const shared_ptr &core, SalCallOp *op) -: ChatRoom(*new ServerGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))), -LocalConference(core, IdentityAddress(op->get_to()), nullptr) { +: ChatRoom(*new ServerGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(op->getTo()), IdentityAddress(op->getTo()))), +LocalConference(core, IdentityAddress(op->getTo()), nullptr) { L_D(); d->chatRoomListener = d; } diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 5549a876a..fd56b7013 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -235,7 +235,7 @@ void Imdn::startTimer () { unsigned int duration = 500; if (!timer) - timer = chatRoom->getCore()->getCCore()->sal->create_timer(timerExpired, this, duration, "imdn timeout"); + timer = chatRoom->getCore()->getCCore()->sal->createTimer(timerExpired, this, duration, "imdn timeout"); else belle_sip_source_set_timeout(timer, duration); bgTask.start(chatRoom->getCore(), 1); @@ -245,7 +245,7 @@ void Imdn::stopTimer () { if (timer) { auto core = chatRoom->getCore()->getCCore(); if (core && core->sal) - core->sal->cancel_timer(timer); + core->sal->cancelTimer(timer); belle_sip_object_unref(timer); timer = nullptr; } diff --git a/src/chat/notification/is-composing.cpp b/src/chat/notification/is-composing.cpp index e6e6c70ae..6cb8d29da 100644 --- a/src/chat/notification/is-composing.cpp +++ b/src/chat/notification/is-composing.cpp @@ -85,7 +85,7 @@ void IsComposing::parse (const Address &remoteAddr, const string &text) { void IsComposing::startIdleTimer () { unsigned int duration = getIdleTimerDuration(); if (!idleTimer) { - idleTimer = core->sal->create_timer(idleTimerExpired, this, + idleTimer = core->sal->createTimer(idleTimerExpired, this, duration * 1000, "composing idle timeout"); } else { belle_sip_source_set_timeout(idleTimer, duration * 1000); @@ -95,7 +95,7 @@ void IsComposing::startIdleTimer () { void IsComposing::startRefreshTimer () { unsigned int duration = getRefreshTimerDuration(); if (!refreshTimer) { - refreshTimer = core->sal->create_timer(refreshTimerExpired, this, + refreshTimer = core->sal->createTimer(refreshTimerExpired, this, duration * 1000, "composing refresh timeout"); } else { belle_sip_source_set_timeout(refreshTimer, duration * 1000); @@ -113,7 +113,7 @@ void IsComposing::stopTimers () { void IsComposing::stopIdleTimer () { if (idleTimer) { if (core && core->sal) - core->sal->cancel_timer(idleTimer); + core->sal->cancelTimer(idleTimer); belle_sip_object_unref(idleTimer); idleTimer = nullptr; } @@ -122,7 +122,7 @@ void IsComposing::stopIdleTimer () { void IsComposing::stopRefreshTimer () { if (refreshTimer) { if (core && core->sal) - core->sal->cancel_timer(refreshTimer); + core->sal->cancelTimer(refreshTimer); belle_sip_object_unref(refreshTimer); refreshTimer = nullptr; } @@ -176,7 +176,7 @@ void IsComposing::startRemoteRefreshTimer (const string &uri, unsigned long long auto it = remoteRefreshTimers.find(uri); if (it == remoteRefreshTimers.end()) { IsRemoteComposingData *data = new IsRemoteComposingData(this, uri); - belle_sip_source_t *timer = core->sal->create_timer(remoteRefreshTimerExpired, data, + belle_sip_source_t *timer = core->sal->createTimer(remoteRefreshTimerExpired, data, duration * 1000, "composing remote refresh timeout"); pair p(uri, timer); remoteRefreshTimers.insert(p); @@ -192,7 +192,7 @@ void IsComposing::stopAllRemoteRefreshTimers () { unordered_map::iterator IsComposing::stopRemoteRefreshTimer (const unordered_map::const_iterator it) { belle_sip_source_t *timer = it->second; if (core && core->sal) { - core->sal->cancel_timer(timer); + core->sal->cancelTimer(timer); delete reinterpret_cast(belle_sip_source_get_user_data(timer)); } belle_sip_object_unref(timer); diff --git a/src/conference/handlers/remote-conference-event-handler.cpp b/src/conference/handlers/remote-conference-event-handler.cpp index 090c81ff6..d2a05836f 100644 --- a/src/conference/handlers/remote-conference-event-handler.cpp +++ b/src/conference/handlers/remote-conference-event-handler.cpp @@ -208,7 +208,7 @@ void RemoteConferenceEventHandlerPrivate::subscribe () { } lev = linphone_event_ref(linphone_core_create_subscribe(conf->getCore()->getCCore(), lAddr, "conference", 600)); - lev->op->set_from(chatRoomId.getLocalAddress().asString().c_str()); + lev->op->setFrom(chatRoomId.getLocalAddress().asString().c_str()); const string &lastNotifyStr = Utils::toString(lastNotify); linphone_event_add_custom_header(lev, "Last-Notify-Version", lastNotifyStr.c_str()); linphone_address_unref(lAddr); diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index ea125826e..87b8b9ac5 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -50,13 +50,13 @@ int CallSessionPrivate::computeDuration () const { * end apparently does not support. This features are: privacy, video... */ void CallSessionPrivate::initializeParamsAccordingToIncomingCallParams () { - currentParams->setPrivacy((LinphonePrivacyMask)op->get_privacy()); + currentParams->setPrivacy((LinphonePrivacyMask)op->getPrivacy()); } void CallSessionPrivate::notifyReferState () { SalCallOp *refererOp = referer->getPrivate()->getOp(); if (refererOp) - refererOp->notify_refer_state(op); + refererOp->notifyReferState(op); } void CallSessionPrivate::setState (CallSession::State newState, const string &message) { @@ -177,10 +177,10 @@ bool CallSessionPrivate::startPing () { pingReplied = false; pingOp = new SalOp(q->getCore()->getCCore()->sal); if (direction == LinphoneCallIncoming) { - const char *from = pingOp->get_from(); - const char *to = pingOp->get_to(); + const char *from = pingOp->getFrom(); + const char *to = pingOp->getTo(); linphone_configure_op(q->getCore()->getCCore(), pingOp, log->from, nullptr, false); - pingOp->set_route(op->get_network_origin()); + pingOp->setRoute(op->getNetworkOrigin()); pingOp->ping(from, to); } else if (direction == LinphoneCallOutgoing) { char *from = linphone_address_as_string(log->from); @@ -189,7 +189,7 @@ bool CallSessionPrivate::startPing () { ms_free(from); ms_free(to); } - pingOp->set_user_pointer(this); + pingOp->setUserPointer(this); return true; } return false; @@ -230,7 +230,7 @@ void CallSessionPrivate::accepted () { default: break; } - currentParams->setPrivacy((LinphonePrivacyMask)op->get_privacy()); + currentParams->setPrivacy((LinphonePrivacyMask)op->getPrivacy()); } void CallSessionPrivate::ackBeingSent (LinphoneHeaders *headers) { @@ -254,12 +254,12 @@ void CallSessionPrivate::cancelDone () { bool CallSessionPrivate::failure () { L_Q(); - const SalErrorInfo *ei = op->get_error_info(); + const SalErrorInfo *ei = op->getErrorInfo(); switch (ei->reason) { case SalReasonRedirect: if ((state == CallSession::State::OutgoingInit) || (state == CallSession::State::OutgoingProgress) || (state == CallSession::State::OutgoingRinging) /* Push notification case */ || (state == CallSession::State::OutgoingEarlyMedia)) { - const SalAddress *redirectionTo = op->get_remote_contact_address(); + const SalAddress *redirectionTo = op->getRemoteContactAddress(); if (redirectionTo) { char *url = sal_address_as_string(redirectionTo); lWarning() << "Redirecting CallSession [" << q << "] to " << url; @@ -312,7 +312,7 @@ bool CallSessionPrivate::failure () { void CallSessionPrivate::infoReceived (SalBodyHandler *bodyHandler) { L_Q(); LinphoneInfoMessage *info = linphone_core_create_info_message(q->getCore()->getCCore()); - linphone_info_message_set_headers(info, op->get_recv_custom_header()); + linphone_info_message_set_headers(info, op->getRecvCustomHeaders()); if (bodyHandler) { LinphoneContent *content = linphone_content_from_sal_body_handler(bodyHandler); linphone_info_message_set_content(info, content); @@ -344,7 +344,7 @@ void CallSessionPrivate::referred (const Address &referToAddr) { void CallSessionPrivate::remoteRinging () { L_Q(); /* Set privacy */ - currentParams->setPrivacy((LinphonePrivacyMask)op->get_privacy()); + currentParams->setPrivacy((LinphonePrivacyMask)op->getPrivacy()); if (listener) listener->onStartRinging(q->getSharedFromThis()); lInfo() << "Remote ringing..."; @@ -356,12 +356,12 @@ void CallSessionPrivate::replaceOp (SalCallOp *newOp) { SalCallOp *oldOp = op; CallSession::State oldState = state; op = newOp; - op->set_user_pointer(q); - op->set_local_media_description(oldOp->get_local_media_description()); + op->setUserPointer(q); + op->setLocalMediaDescription(oldOp->getLocalMediaDescription()); switch (state) { case CallSession::State::IncomingEarlyMedia: case CallSession::State::IncomingReceived: - op->notify_ringing((state == CallSession::State::IncomingEarlyMedia) ? true : false); + op->notifyRinging((state == CallSession::State::IncomingEarlyMedia) ? true : false); break; case CallSession::State::Connected: case CallSession::State::StreamsRunning: @@ -374,17 +374,17 @@ void CallSessionPrivate::replaceOp (SalCallOp *newOp) { switch (oldState) { case CallSession::State::IncomingEarlyMedia: case CallSession::State::IncomingReceived: - oldOp->set_user_pointer(nullptr); // In order for the call session to not get terminated by terminating this op + oldOp->setUserPointer(nullptr); // In order for the call session to not get terminated by terminating this op // Do not terminate a forked INVITE - if (op->get_replaces()) + if (op->getReplaces()) oldOp->terminate(); else - oldOp->kill_dialog(); + oldOp->killDialog(); break; case CallSession::State::Connected: case CallSession::State::StreamsRunning: oldOp->terminate(); - oldOp->kill_dialog(); + oldOp->killDialog(); break; default: break; @@ -401,7 +401,7 @@ void CallSessionPrivate::terminated () { return; case CallSession::State::IncomingReceived: case CallSession::State::IncomingEarlyMedia: - if (!op->get_reason_error_info()->protocol || strcmp(op->get_reason_error_info()->protocol, "") == 0) { + if (!op->getReasonErrorInfo()->protocol || strcmp(op->getReasonErrorInfo()->protocol, "") == 0) { linphone_error_info_set(ei, nullptr, LinphoneReasonNotAnswered, 0, "Incoming call cancelled", nullptr); nonOpError = true; } @@ -447,7 +447,7 @@ void CallSessionPrivate::updated (bool isUpdate) { case CallSession::State::Pausing: case CallSession::State::Resuming: sal_error_info_set(&sei, SalReasonInternalError, "SIP", 0, nullptr, nullptr); - op->decline_with_error_info(&sei, nullptr); + op->declineWithErrorInfo(&sei, nullptr); BCTBX_NO_BREAK; /* no break */ case CallSession::State::Idle: case CallSession::State::OutgoingInit: @@ -501,7 +501,7 @@ void CallSessionPrivate::accept (const CallSessionParams *csp) { if (csp) setParams(new CallSessionParams(*csp)); if (params) - op->set_sent_custom_header(params->getPrivate()->getCustomHeaders()); + op->setSentCustomHeaders(params->getPrivate()->getCustomHeaders()); op->accept(); if (listener) @@ -527,9 +527,9 @@ LinphoneStatus CallSessionPrivate::checkForAcceptation () { listener->onCheckForAcceptation(q->getSharedFromThis()); /* Check if this call is supposed to replace an already running one */ - SalOp *replaced = op->get_replaces(); + SalOp *replaced = op->getReplaces(); if (replaced) { - CallSession *session = reinterpret_cast(replaced->get_user_pointer()); + CallSession *session = reinterpret_cast(replaced->getUserPointer()); if (session) { lInfo() << "CallSession " << q << " replaces CallSession " << session << ". This last one is going to be terminated automatically"; session->terminate(); @@ -543,8 +543,8 @@ void CallSessionPrivate::handleIncomingReceivedStateInIncomingNotification () { /* Try to be best-effort in giving real local or routable contact address for 100Rel case */ setContactOp(); if (notifyRinging) - op->notify_ringing(false); - if (op->get_replaces() && lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "auto_answer_replacing_calls", 1)) + op->notifyRinging(false); + if (op->getReplaces() && lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "auto_answer_replacing_calls", 1)) q->accept(); } @@ -647,9 +647,9 @@ LinphoneStatus CallSessionPrivate::startUpdate (const string &subject) { } if (destProxy && destProxy->op) { /* Give a chance to update the contact address if connectivity has changed */ - op->set_contact_address(destProxy->op->get_contact_address()); + op->setContactAddress(destProxy->op->getContactAddress()); } else - op->set_contact_address(nullptr); + op->setContactAddress(nullptr); return op->update(newSubject.c_str(), q->getParams()->getPrivate()->getNoUserConsent()); } @@ -703,7 +703,7 @@ void CallSessionPrivate::setContactOp () { for (auto it = contactParams.begin(); it != contactParams.end(); it++) linphone_address_set_param(contact, it->first.c_str(), it->second.empty() ? nullptr : it->second.c_str()); salAddress = const_cast(L_GET_PRIVATE_FROM_C_OBJECT(contact)->getInternalAddress()); - op->set_contact_address(salAddress); + op->setContactAddress(salAddress); linphone_address_unref(contact); } } @@ -737,12 +737,12 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) { if (op) op->release(); op = new SalCallOp(q->getCore()->getCCore()->sal); - op->set_user_pointer(q); + op->setUserPointer(q); if (params->getPrivate()->getReferer()) - op->set_referer(params->getPrivate()->getReferer()->getPrivate()->getOp()); + op->setReferrer(params->getPrivate()->getReferer()->getPrivate()->getOp()); linphone_configure_op(q->getCore()->getCCore(), op, to, q->getParams()->getPrivate()->getCustomHeaders(), false); if (q->getParams()->getPrivacy() != LinphonePrivacyDefault) - op->set_privacy((SalPrivacyMask)q->getParams()->getPrivacy()); + op->setPrivacy((SalPrivacyMask)q->getParams()->getPrivacy()); /* else privacy might be set by proxy */ } @@ -751,13 +751,13 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) { LinphoneAddress * CallSessionPrivate::getFixedContact () const { L_Q(); LinphoneAddress *result = nullptr; - if (op && op->get_contact_address()) { + if (op && op->getContactAddress()) { /* If already choosed, don't change it */ return nullptr; - } else if (pingOp && pingOp->get_contact_address()) { + } else if (pingOp && pingOp->getContactAddress()) { /* If the ping OPTIONS request succeeded use the contact guessed from the received, rport */ lInfo() << "Contact has been fixed using OPTIONS"; - char *addr = sal_address_as_string(pingOp->get_contact_address()); + char *addr = sal_address_as_string(pingOp->getContactAddress()); result = linphone_address_new(addr); ms_free(addr); } else if (destProxy && destProxy->op && linphone_proxy_config_get_contact(destProxy)) { @@ -786,12 +786,12 @@ void CallSessionPrivate::reinviteToRecoverFromConnectionLoss () { void CallSessionPrivate::repairByInviteWithReplaces () { L_Q(); - const char *callId = op->get_call_id(); - const char *fromTag = op->get_local_tag(); - const char *toTag = op->get_remote_tag(); - op->kill_dialog(); + const char *callId = op->getCallId(); + const char *fromTag = op->getLocalTag(); + const char *toTag = op->getRemoteTag(); + op->killDialog(); createOp(); - op->set_replaces(callId, fromTag, toTag); + op->setReplaces(callId, fromTag, toTag); q->startInvite(nullptr); } @@ -819,9 +819,9 @@ void CallSessionPrivate::repairIfBroken () { switch (state) { case CallSession::State::Updating: case CallSession::State::Pausing: - if (op->dialog_request_pending()) { + if (op->dialogRequestPending()) { // Need to cancel first re-INVITE as described in section 5.5 of RFC 6141 - if (op->cancel_invite() == 0){ + if (op->cancelInvite() == 0){ reinviteOnCancelResponseRequested = true; } } @@ -829,19 +829,19 @@ void CallSessionPrivate::repairIfBroken () { case CallSession::State::StreamsRunning: case CallSession::State::Paused: case CallSession::State::PausedByRemote: - if (!op->dialog_request_pending()) + if (!op->dialogRequestPending()) reinviteToRecoverFromConnectionLoss(); break; case CallSession::State::UpdatedByRemote: - if (op->dialog_request_pending()) { + if (op->dialogRequestPending()) { sal_error_info_set(&sei, SalReasonServiceUnavailable, "SIP", 0, nullptr, nullptr); - op->decline_with_error_info(&sei, nullptr); + op->declineWithErrorInfo(&sei, nullptr); } reinviteToRecoverFromConnectionLoss(); break; case CallSession::State::OutgoingInit: case CallSession::State::OutgoingProgress: - if (op->cancel_invite() == 0){ + if (op->cancelInvite() == 0){ reinviteOnCancelResponseRequested = true; } break; @@ -931,10 +931,13 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg if (op) { /* We already have an op for incoming calls */ d->op = op; - d->op->set_user_pointer(this); - op->enable_cnx_ip_to_0000_if_sendonly(!!lp_config_get_default_int(linphone_core_get_config(getCore()->getCCore()), - "sip", "cnx_ip_to_0000_if_sendonly_enabled", 0)); - d->log->call_id = ms_strdup(op->get_call_id()); /* Must be known at that time */ + d->op->setUserPointer(this); + op->enableCnxIpTo0000IfSendOnly( + !!lp_config_get_default_int( + linphone_core_get_config(getCore()->getCCore()), "sip", "cnx_ip_to_0000_if_sendonly_enabled", 0 + ) + ); + d->log->call_id = ms_strdup(op->getCallId()); /* Must be known at that time */ } if (direction == LinphoneCallOutgoing) { @@ -968,7 +971,7 @@ LinphoneStatus CallSession::decline (const LinphoneErrorInfo *ei) { } if (ei) { linphone_error_info_to_sal(ei, &sei); - d->op->decline_with_error_info(&sei , nullptr); + d->op->declineWithErrorInfo(&sei , nullptr); } else d->op->decline(SalReasonDeclined, nullptr); sal_error_info_reset(&sei); @@ -1053,7 +1056,7 @@ LinphoneStatus CallSession::redirect (const Address &redirectAddr) { SalErrorInfo sei; memset(&sei, 0, sizeof(sei)); sal_error_info_set(&sei, SalReasonRedirect, "SIP", 0, nullptr, nullptr); - d->op->decline_with_error_info(&sei, redirectAddr.getPrivate()->getInternalAddress()); + d->op->declineWithErrorInfo(&sei, redirectAddr.getPrivate()->getInternalAddress()); linphone_error_info_set(d->ei, nullptr, LinphoneReasonMovedPermanently, 302, "Call redirected", nullptr); d->nonOpError = true; d->terminate(); @@ -1096,7 +1099,7 @@ int CallSession::startInvite (const Address *destination, const string &subject, /* Take a ref because sal_call() may destroy the CallSession if no SIP transport is available */ shared_ptr ref = getSharedFromThis(); if (content) - d->op->set_local_body(*content); + d->op->setLocalBody(*content); int result = d->op->call(from, destinationStr.c_str(), subject.empty() ? nullptr : subject.c_str()); ms_free(from); if (result < 0) { @@ -1106,7 +1109,7 @@ int CallSession::startInvite (const Address *destination, const string &subject, d->setState(CallSession::State::Error, "Call failed"); } } else { - d->log->call_id = ms_strdup(d->op->get_call_id()); /* Must be known at that time */ + d->log->call_id = ms_strdup(d->op->getCallId()); /* Must be known at that time */ d->setState(CallSession::State::OutgoingProgress, "Outgoing call in progress"); } return result; @@ -1134,7 +1137,7 @@ LinphoneStatus CallSession::terminate (const LinphoneErrorInfo *ei) { default: if (ei) { linphone_error_info_to_sal(ei, &sei); - d->op->terminate_with_error(&sei); + d->op->terminate(&sei); sal_error_info_reset(&sei); } else d->op->terminate(); @@ -1147,7 +1150,7 @@ LinphoneStatus CallSession::terminate (const LinphoneErrorInfo *ei) { LinphoneStatus CallSession::transfer (const shared_ptr &dest) { L_D(); - int result = d->op->refer_with_replaces(dest->getPrivate()->op); + int result = d->op->referWithReplaces(dest->getPrivate()->op); d->setTransferState(CallSession::State::OutgoingInit); return result; } @@ -1175,7 +1178,7 @@ LinphoneStatus CallSession::update (const CallSessionParams *csp, const string & lWarning() << "CallSession::update() is given the current params, this is probably not what you intend to do!"; if (csp) d->setParams(new CallSessionParams(*csp)); - d->op->set_local_body(content ? *content : Content()); + d->op->setLocalBody(content ? *content : Content()); LinphoneStatus result = d->startUpdate(subject); if (result && (d->state != initialState)) { /* Restore initial state */ @@ -1194,7 +1197,7 @@ LinphoneCallDir CallSession::getDirection () const { const Address& CallSession::getDiversionAddress () const { L_D(); if (d->op) { - char *addrStr = sal_address_as_string(d->op->get_diversion_address()); + char *addrStr = sal_address_as_string(d->op->getDiversionAddress()); d->diversionAddress = Address(addrStr); bctbx_free(addrStr); } else { @@ -1257,7 +1260,7 @@ string CallSession::getRemoteContact () const { L_D(); if (d->op) { /* sal_op_get_remote_contact preserves header params */ - return d->op->get_remote_contact(); + return d->op->getRemoteContact(); } return string(); } @@ -1267,7 +1270,7 @@ const Address *CallSession::getRemoteContactAddress () const { if (!d->op) { return nullptr; } - char *addrStr = sal_address_as_string(d->op->get_remote_contact_address()); + char *addrStr = sal_address_as_string(d->op->getRemoteContactAddress()); d->remoteContactAddress = Address(addrStr); bctbx_free(addrStr); return &d->remoteContactAddress; @@ -1276,7 +1279,7 @@ const Address *CallSession::getRemoteContactAddress () const { const CallSessionParams * CallSession::getRemoteParams () { L_D(); if (d->op){ - const SalCustomHeader *ch = d->op->get_recv_custom_header(); + const SalCustomHeader *ch = d->op->getRecvCustomHeaders(); if (ch) { /* Instanciate a remote_params only if a SIP message was received before (custom headers indicates this) */ if (!d->remoteParams) @@ -1300,7 +1303,7 @@ CallSession::State CallSession::getPreviousState () const { const Address& CallSession::getToAddress () const { L_D(); - d->toAddress = Address(d->op->get_to()); + d->toAddress = Address(d->op->getTo()); return d->toAddress; } @@ -1316,24 +1319,24 @@ shared_ptr CallSession::getTransferTarget () const { string CallSession::getToHeader (const string &name) const { L_D(); - return L_C_TO_STRING(sal_custom_header_find(d->op->get_recv_custom_header(), name.c_str())); + return L_C_TO_STRING(sal_custom_header_find(d->op->getRecvCustomHeaders(), name.c_str())); } // ----------------------------------------------------------------------------- string CallSession::getRemoteUserAgent () const { L_D(); - if (d->op && d->op->get_remote_ua()) - return d->op->get_remote_ua(); + if (d->op && d->op->getRemoteUserAgent()) + return d->op->getRemoteUserAgent(); return string(); } shared_ptr CallSession::getReplacedCallSession () const { L_D(); - SalOp *replacedOp = d->op->get_replaces(); + SalOp *replacedOp = d->op->getReplaces(); if (!replacedOp) return nullptr; - return reinterpret_cast(replacedOp->get_user_pointer())->getSharedFromThis(); + return reinterpret_cast(replacedOp->getUserPointer())->getSharedFromThis(); } CallSessionParams * CallSession::getCurrentParams () const { diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 08535ea08..f62e8bdd5 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -83,8 +83,8 @@ void MediaSessionPrivate::accepted () { linphone_task_list_init(&tl); /* Reset the internal call update flag, so it doesn't risk to be copied and used in further re-INVITEs */ getParams()->getPrivate()->setInternalCallUpdate(false); - SalMediaDescription *rmd = op->get_remote_media_description(); - SalMediaDescription *md = op->get_final_media_description(); + SalMediaDescription *rmd = op->getRemoteMediaDescription(); + SalMediaDescription *md = op->getFinalMediaDescription(); if (!md && (prevState == CallSession::State::OutgoingEarlyMedia) && resultDesc) { lInfo() << "Using early media SDP since none was received with the 200 OK"; md = resultDesc; @@ -95,7 +95,7 @@ void MediaSessionPrivate::accepted () { /* There is a valid SDP in the response, either offer or answer, and we're able to start/update the streams */ if (rmd) { /* Handle remote ICE attributes if any. */ - iceAgent->updateFromRemoteMediaDescription(localDesc, rmd, !op->is_offerer()); + iceAgent->updateFromRemoteMediaDescription(localDesc, rmd, !op->isOfferer()); } CallSession::State nextState = CallSession::State::Idle; string nextStateMsg; @@ -199,7 +199,7 @@ void MediaSessionPrivate::dtmfReceived (char dtmf) { bool MediaSessionPrivate::failure () { L_Q(); - const SalErrorInfo *ei = op->get_error_info(); + const SalErrorInfo *ei = op->getErrorInfo(); switch (ei->reason) { case SalReasonRedirect: stopStreams(); @@ -276,10 +276,10 @@ void MediaSessionPrivate::pausedByRemote () { void MediaSessionPrivate::remoteRinging () { L_Q(); /* Set privacy */ - getCurrentParams()->setPrivacy((LinphonePrivacyMask)op->get_privacy()); - SalMediaDescription *md = op->get_final_media_description(); + getCurrentParams()->setPrivacy((LinphonePrivacyMask)op->getPrivacy()); + SalMediaDescription *md = op->getFinalMediaDescription(); if (md) { - SalMediaDescription *rmd = op->get_remote_media_description(); + SalMediaDescription *rmd = op->getRemoteMediaDescription(); /* Initialize the remote call params by invoking linphone_call_get_remote_params(). This is useful as the SDP may not be present in the 200Ok */ q->getRemoteParams(); /* Accept early media */ @@ -301,7 +301,7 @@ void MediaSessionPrivate::remoteRinging () { if (listener) listener->onStopRinging(q->getSharedFromThis()); lInfo() << "Doing early media..."; - iceAgent->updateFromRemoteMediaDescription(localDesc, rmd, !op->is_offerer()); + iceAgent->updateFromRemoteMediaDescription(localDesc, rmd, !op->isOfferer()); updateStreams(md, state); if ((q->getCurrentParams()->getAudioDirection() == LinphoneMediaDirectionInactive) && audioStream) { if (listener) @@ -325,7 +325,7 @@ int MediaSessionPrivate::resumeAfterFailedTransfer () { if (automaticallyPaused && (state == CallSession::State::Pausing)) return BELLE_SIP_CONTINUE; // Was still in pausing state if (automaticallyPaused && (state == CallSession::State::Paused)) { - if (op->is_idle()) + if (op->isIdle()) q->resume(); else { lInfo() << "MediaSessionPrivate::resumeAfterFailedTransfer(), op was busy"; @@ -361,7 +361,7 @@ void MediaSessionPrivate::terminated () { /* This callback is called when an incoming re-INVITE/ SIP UPDATE modifies the session */ void MediaSessionPrivate::updated (bool isUpdate) { - SalMediaDescription *rmd = op->get_remote_media_description(); + SalMediaDescription *rmd = op->getRemoteMediaDescription(); switch (state) { case CallSession::State::PausedByRemote: if (sal_media_description_has_dir(rmd, SalStreamSendRecv) || sal_media_description_has_dir(rmd, SalStreamRecvOnly)) { @@ -388,7 +388,7 @@ void MediaSessionPrivate::updated (bool isUpdate) { void MediaSessionPrivate::updating (bool isUpdate) { L_Q(); - SalMediaDescription *rmd = op->get_remote_media_description(); + SalMediaDescription *rmd = op->getRemoteMediaDescription(); fixCallParams(rmd); if (state != CallSession::State::Paused) { /* Refresh the local description, but in paused state, we don't change anything. */ @@ -398,16 +398,16 @@ void MediaSessionPrivate::updating (bool isUpdate) { params->initDefault(q->getCore()); } makeLocalMediaDescription(); - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); } if (rmd) { SalErrorInfo sei; memset(&sei, 0, sizeof(sei)); expectMediaInAck = false; - SalMediaDescription *md = op->get_final_media_description(); + SalMediaDescription *md = op->getFinalMediaDescription(); if (md && (sal_media_description_empty(md) || linphone_core_incompatible_security(q->getCore()->getCCore(), md))) { sal_error_info_set(&sei, SalReasonNotAcceptable, "SIP", 0, nullptr, nullptr); - op->decline_with_error_info(&sei, nullptr); + op->declineWithErrorInfo(&sei, nullptr); sal_error_info_reset(&sei); return; } @@ -417,7 +417,7 @@ void MediaSessionPrivate::updating (bool isUpdate) { if (diff & (SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED | SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED)) { lWarning() << "Cannot accept this update, it is changing parameters that require user approval"; sal_error_info_set(&sei, SalReasonUnknown, "SIP", 504, "Cannot change the session parameters without prompting the user", nullptr); - op->decline_with_error_info(&sei, nullptr); + op->declineWithErrorInfo(&sei, nullptr); sal_error_info_reset(&sei); return; } @@ -719,7 +719,7 @@ void MediaSessionPrivate::setState (CallSession::State newState, const string &m case CallSession::State::UpdatedByRemote: // Handle specifically the case of an incoming ICE-concluded reINVITE lInfo() << "Checking for ICE reINVITE"; - rmd = op->get_remote_media_description(); + rmd = op->getRemoteMediaDescription(); if (iceAgent && rmd && iceAgent->checkIceReinviteNeedsDeferedResponse(rmd)) { deferUpdate = true; deferUpdateInternal = true; @@ -880,12 +880,12 @@ void MediaSessionPrivate::initializeParamsAccordingToIncomingCallParams () { CallSessionPrivate::initializeParamsAccordingToIncomingCallParams(); getCurrentParams()->getPrivate()->setUpdateCallWhenIceCompleted(getParams()->getPrivate()->getUpdateCallWhenIceCompleted()); getParams()->enableVideo(linphone_core_video_enabled(q->getCore()->getCCore()) && q->getCore()->getCCore()->video_policy.automatically_accept); - SalMediaDescription *md = op->get_remote_media_description(); + SalMediaDescription *md = op->getRemoteMediaDescription(); if (md) { /* It is licit to receive an INVITE without SDP, in this case WE choose the media parameters according to policy */ setCompatibleIncomingCallParams(md); /* Set multicast role & address if any */ - if (!op->is_offerer()) { + if (!op->isOfferer()) { for (int i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) { if (md->streams[i].dir == SalStreamInactive) continue; @@ -938,7 +938,7 @@ void MediaSessionPrivate::updateBiggestDesc (SalMediaDescription *md) { } void MediaSessionPrivate::updateRemoteSessionIdAndVer () { - SalMediaDescription *desc = op->get_remote_media_description(); + SalMediaDescription *desc = op->getRemoteMediaDescription(); if (desc) { remoteSessionId = desc->session_id; remoteSessionVer = desc->session_ver; @@ -1155,7 +1155,7 @@ void MediaSessionPrivate::getLocalIp (const Address &remoteAddr) { /* If a known proxy was identified for this call, then we may have a chance to take the local ip address * from the socket that connects to this proxy */ if (destProxy && destProxy->op) { - ip = destProxy->op->get_local_address(nullptr); + ip = destProxy->op->getLocalAddress(nullptr); if (ip) { lInfo() << "Found media local-ip from signaling."; mediaLocalIp = ip; @@ -1216,9 +1216,9 @@ void MediaSessionPrivate::selectIncomingIpVersion () { L_Q(); if (linphone_core_ipv6_enabled(q->getCore()->getCCore())) { if (destProxy && destProxy->op) - af = destProxy->op->get_address_family(); + af = destProxy->op->getAddressFamily(); else - af = op->get_address_family(); + af = op->getAddressFamily(); } else af = AF_INET; } @@ -1242,7 +1242,7 @@ void MediaSessionPrivate::selectOutgoingIpVersion () { if (sal_address_is_ipv6(L_GET_PRIVATE_FROM_C_OBJECT(to)->getInternalAddress())) af = AF_INET6; else if (destProxy && destProxy->op) - af = destProxy->op->get_address_family(); + af = destProxy->op->getAddressFamily(); else { char ipv4[LINPHONE_IPADDR_SIZE]; char ipv6[LINPHONE_IPADDR_SIZE]; @@ -1667,15 +1667,15 @@ SalMulticastRole MediaSessionPrivate::getMulticastRole (SalStreamType type) { SalMulticastRole multicastRole = SalMulticastInactive; if (op) { SalStreamDescription *streamDesc = nullptr; - SalMediaDescription *remoteDesc = op->get_remote_media_description(); + SalMediaDescription *remoteDesc = op->getRemoteMediaDescription(); if (!localDesc && !remoteDesc && (direction == LinphoneCallOutgoing)) { /* Well using call dir */ if (((type == SalAudio) && getParams()->audioMulticastEnabled()) || ((type == SalVideo) && getParams()->videoMulticastEnabled())) multicastRole = SalMulticastSender; - } else if (localDesc && (!remoteDesc || op->is_offerer())) { + } else if (localDesc && (!remoteDesc || op->isOfferer())) { streamDesc = sal_media_description_find_best_stream(localDesc, type); - } else if (!op->is_offerer() && remoteDesc) { + } else if (!op->isOfferer() && remoteDesc) { streamDesc = sal_media_description_find_best_stream(remoteDesc, type); } @@ -1717,8 +1717,8 @@ void MediaSessionPrivate::setDtlsFingerprint (MSMediaStreamSessions *sessions, c } void MediaSessionPrivate::setDtlsFingerprintOnAllStreams () { - SalMediaDescription *remote = op->get_remote_media_description(); - SalMediaDescription *result = op->get_final_media_description(); + SalMediaDescription *remote = op->getRemoteMediaDescription(); + SalMediaDescription *result = op->getFinalMediaDescription(); if (!remote || !result) { /* This can happen in some tricky cases (early-media without SDP in the 200). In that case, simply skip DTLS code */ return; @@ -1830,8 +1830,8 @@ void MediaSessionPrivate::startDtls (MSMediaStreamSessions *sessions, const SalS } void MediaSessionPrivate::startDtlsOnAllStreams () { - SalMediaDescription *remote = op->get_remote_media_description(); - SalMediaDescription *result = op->get_final_media_description(); + SalMediaDescription *remote = op->getRemoteMediaDescription(); + SalMediaDescription *result = op->getFinalMediaDescription(); if (!remote || !result) { /* This can happen in some tricky cases (early-media without SDP in the 200). In that case, simply skip DTLS code */ return; @@ -2100,7 +2100,7 @@ void MediaSessionPrivate::configureRtpSessionForRtcpFb (const SalStreamDescripti } void MediaSessionPrivate::configureRtpSessionForRtcpXr (SalStreamType type) { - SalMediaDescription *remote = op->get_remote_media_description(); + SalMediaDescription *remote = op->getRemoteMediaDescription(); if (!remote) return; const SalStreamDescription *localStream = sal_media_description_find_best_stream(localDesc, type); @@ -2242,7 +2242,7 @@ void MediaSessionPrivate::handleIceEvents (OrtpEvent *ev) { case CallSession::State::Idle: stopStreamsForIceGathering(); updateLocalMediaDescriptionFromIce(); - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); deferIncomingNotification = false; startIncomingNotification(); break; @@ -2356,7 +2356,7 @@ void MediaSessionPrivate::initializeAudioStream () { SalMediaDescription *remoteDesc = nullptr; SalStreamDescription *streamDesc = nullptr; if (op) - remoteDesc = op->get_remote_media_description(); + remoteDesc = op->getRemoteMediaDescription(); if (remoteDesc) streamDesc = sal_media_description_find_best_stream(remoteDesc, SalAudio); @@ -2462,7 +2462,7 @@ void MediaSessionPrivate::initializeTextStream () { SalMediaDescription *remoteDesc = nullptr; SalStreamDescription *streamDesc = nullptr; if (op) - remoteDesc = op->get_remote_media_description(); + remoteDesc = op->getRemoteMediaDescription(); if (remoteDesc) streamDesc = sal_media_description_find_best_stream(remoteDesc, SalText); @@ -2506,7 +2506,7 @@ void MediaSessionPrivate::initializeVideoStream () { SalMediaDescription *remoteDesc = nullptr; SalStreamDescription *streamDesc = nullptr; if (op) - remoteDesc = op->get_remote_media_description(); + remoteDesc = op->getRemoteMediaDescription(); if (remoteDesc) streamDesc = sal_media_description_find_best_stream(remoteDesc, SalVideo); @@ -2746,7 +2746,7 @@ void MediaSessionPrivate::startAudioStream (CallSession::State targetState, bool getCurrentParams()->getPrivate()->setInConference(getParams()->getPrivate()->getInConference()); getCurrentParams()->enableLowBandwidth(getParams()->lowBandwidthEnabled()); // Start ZRTP engine if needed : set here or remote have a zrtp-hash attribute - SalMediaDescription *remote = op->get_remote_media_description(); + SalMediaDescription *remote = op->getRemoteMediaDescription(); const SalStreamDescription *remoteStream = sal_media_description_find_best_stream(remote, SalAudio); if (linphone_core_media_encryption_supported(q->getCore()->getCCore(), LinphoneMediaEncryptionZRTP) && ((getParams()->getMediaEncryption() == LinphoneMediaEncryptionZRTP) || (remoteStream->haveZrtpHash == 1))) { @@ -2998,7 +2998,7 @@ void MediaSessionPrivate::startVideoStream (CallSession::State targetState) { if (listener) listener->onResetFirstVideoFrameDecoded(q->getSharedFromThis()); /* Start ZRTP engine if needed : set here or remote have a zrtp-hash attribute */ - SalMediaDescription *remote = op->get_remote_media_description(); + SalMediaDescription *remote = op->getRemoteMediaDescription(); const SalStreamDescription *remoteStream = sal_media_description_find_best_stream(remote, SalVideo); if ((getParams()->getMediaEncryption() == LinphoneMediaEncryptionZRTP) || (remoteStream->haveZrtpHash == 1)) { /* Audio stream is already encrypted and video stream is active */ @@ -3344,7 +3344,7 @@ uint16_t MediaSessionPrivate::getAvpfRrInterval () const { unsigned int MediaSessionPrivate::getNbActiveStreams () const { SalMediaDescription *md = nullptr; if (op) - md = op->get_remote_media_description(); + md = op->getRemoteMediaDescription(); if (!md) return 0; return sal_media_description_nb_active_streams_of_type(md, SalAudio) + sal_media_description_nb_active_streams_of_type(md, SalVideo) + sal_media_description_nb_active_streams_of_type(md, SalText); @@ -3528,8 +3528,8 @@ void MediaSessionPrivate::handleIncomingReceivedStateInIncomingNotification () { if (proposeEarlyMedia) q->acceptEarlyMedia(); else - op->notify_ringing(false); - if (op->get_replaces() && !!lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "auto_answer_replacing_calls", 1)) + op->notifyRinging(false); + if (op->getReplaces() && !!lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "auto_answer_replacing_calls", 1)) q->accept(); } @@ -3562,7 +3562,7 @@ LinphoneStatus MediaSessionPrivate::pause () { broken = false; setState(CallSession::State::Pausing, "Pausing call"); makeLocalMediaDescription(); - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); op->update(subject.c_str(), false); if (listener) listener->onResetCurrentSession(q->getSharedFromThis()); @@ -3590,9 +3590,9 @@ LinphoneStatus MediaSessionPrivate::startAcceptUpdate (CallSession::State nextSt } makeLocalMediaDescription(); updateRemoteSessionIdAndVer(); - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); op->accept(); - SalMediaDescription *md = op->get_final_media_description(); + SalMediaDescription *md = op->getFinalMediaDescription(); iceAgent->stopIceForInactiveStreams(md); if (md && !sal_media_description_empty(md)) updateStreams(md, nextState); @@ -3606,14 +3606,14 @@ LinphoneStatus MediaSessionPrivate::startUpdate (const string &subject) { if (!getParams()->getPrivate()->getNoUserConsent()) makeLocalMediaDescription(); if (!q->getCore()->getCCore()->sip_conf.sdp_200_ack) - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); else - op->set_local_media_description(nullptr); + op->setLocalMediaDescription(nullptr); LinphoneStatus result = CallSessionPrivate::startUpdate(subject); if (q->getCore()->getCCore()->sip_conf.sdp_200_ack) { /* We are NOT offering, set local media description after sending the call so that we are ready to * process the remote offer when it will arrive. */ - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); } return result; } @@ -3725,7 +3725,7 @@ void MediaSessionPrivate::accept (const MediaSessionParams *msp, bool wasRinging setParams(new MediaSessionParams(*msp)); iceAgent->prepare(localDesc, true); makeLocalMediaDescription(); - op->set_local_media_description(localDesc); + op->setLocalMediaDescription(localDesc); } updateRemoteSessionIdAndVer(); @@ -3746,7 +3746,7 @@ void MediaSessionPrivate::accept (const MediaSessionParams *msp, bool wasRinging CallSessionPrivate::accept(nullptr); - SalMediaDescription *newMd = op->get_final_media_description(); + SalMediaDescription *newMd = op->getFinalMediaDescription(); iceAgent->stopIceForInactiveStreams(newMd); if (newMd) { updateStreams(newMd, CallSession::State::StreamsRunning); @@ -3757,7 +3757,7 @@ void MediaSessionPrivate::accept (const MediaSessionParams *msp, bool wasRinging LinphoneStatus MediaSessionPrivate::acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const string &stateInfo) { L_Q(); - SalMediaDescription *desc = op->get_remote_media_description(); + SalMediaDescription *desc = op->getRemoteMediaDescription(); bool keepSdpVersion = !!lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "keep_sdp_version", 0); if (keepSdpVersion && (desc->session_id == remoteSessionId) && (desc->session_ver == remoteSessionVer)) { /* Remote has sent an INVITE with the same SDP as before, so send a 200 OK with the same SDP as before. */ @@ -3769,7 +3769,7 @@ LinphoneStatus MediaSessionPrivate::acceptUpdate (const CallSessionParams *csp, if (csp) setParams(new MediaSessionParams(*static_cast(csp))); else { - if (!op->is_offerer()) { + if (!op->isOfferer()) { /* Reset call params for multicast because this param is only relevant when offering */ getParams()->enableAudioMulticast(false); getParams()->enableVideoMulticast(false); @@ -3870,7 +3870,7 @@ int MediaSessionPrivate::sendDtmf () { } if (linphone_core_get_use_info_for_dtmf(lc)) { // Out of Band DTMF (use INFO method) - op->send_dtmf(dtmfSequence.front()); + op->sendDtmf(dtmfSequence.front()); } dtmfSequence.erase(0, 1); @@ -4019,12 +4019,12 @@ LinphoneStatus MediaSession::acceptEarlyMedia (const MediaSessionParams *msp) { if (msp) { d->setParams(new MediaSessionParams(*msp)); d->makeLocalMediaDescription(); - d->op->set_local_media_description(d->localDesc); - d->op->set_sent_custom_header(d->getParams()->getPrivate()->getCustomHeaders()); + d->op->setLocalMediaDescription(d->localDesc); + d->op->setSentCustomHeaders(d->getParams()->getPrivate()->getCustomHeaders()); } - d->op->notify_ringing(true); + d->op->notifyRinging(true); d->setState(CallSession::State::IncomingEarlyMedia, "Incoming call early media"); - SalMediaDescription *md = d->op->get_final_media_description(); + SalMediaDescription *md = d->op->getFinalMediaDescription(); if (md) d->updateStreams(md, d->state); return 0; @@ -4044,7 +4044,7 @@ void MediaSession::cancelDtmfs () { if (!d->dtmfTimer) return; - getCore()->getCCore()->sal->cancel_timer(d->dtmfTimer); + getCore()->getCCore()->sal->cancelTimer(d->dtmfTimer); belle_sip_object_unref(d->dtmfTimer); d->dtmfTimer = nullptr; d->dtmfSequence.clear(); @@ -4080,7 +4080,7 @@ void MediaSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cf d->setParams(new MediaSessionParams()); d->params->initDefault(getCore()); d->initializeParamsAccordingToIncomingCallParams(); - SalMediaDescription *md = d->op->get_remote_media_description(); + SalMediaDescription *md = d->op->getRemoteMediaDescription(); if (d->natPolicy && linphone_nat_policy_ice_enabled(d->natPolicy)) { if (md) { /* Create the ice session now if ICE is required */ @@ -4181,9 +4181,9 @@ LinphoneStatus MediaSession::resume () { d->makeLocalMediaDescription(); sal_media_description_set_dir(d->localDesc, SalStreamSendRecv); if (!getCore()->getCCore()->sip_conf.sdp_200_ack) - d->op->set_local_media_description(d->localDesc); + d->op->setLocalMediaDescription(d->localDesc); else - d->op->set_local_media_description(nullptr); + d->op->setLocalMediaDescription(nullptr); string subject = "Call resuming"; if (d->getParams()->getPrivate()->getInConference() && !getCurrentParams()->getPrivate()->getInConference()) subject = "Conference"; @@ -4195,7 +4195,7 @@ LinphoneStatus MediaSession::resume () { if (getCore()->getCCore()->sip_conf.sdp_200_ack) { /* We are NOT offering, set local media description after sending the call so that we are ready to * process the remote offer when it will arrive. */ - d->op->set_local_media_description(d->localDesc); + d->op->setLocalMediaDescription(d->localDesc); } return 0; } @@ -4218,7 +4218,7 @@ LinphoneStatus MediaSession::sendDtmfs (const std::string &dtmfs) { if (delayMs < 0) delayMs = 0; d->dtmfSequence = dtmfs; - d->dtmfTimer = getCore()->getCCore()->sal->create_timer(MediaSessionPrivate::sendDtmf, this, static_cast(delayMs), "DTMF sequence timer"); + d->dtmfTimer = getCore()->getCCore()->sal->createTimer(MediaSessionPrivate::sendDtmf, this, static_cast(delayMs), "DTMF sequence timer"); } return 0; } @@ -4239,7 +4239,7 @@ void MediaSession::sendVfuRequest () { } else if (getCore()->getCCore()->sip_conf.vfu_with_info) { lInfo() << "Request SIP INFO FIR on CallSession [" << this << "]"; if (d->state == CallSession::State::StreamsRunning) - d->op->send_vfu_request(); + d->op->sendVfuRequest(); } else lInfo() << "vfu request using sip disabled from config [sip,vfu_with_info]"; #endif @@ -4248,8 +4248,8 @@ void MediaSession::sendVfuRequest () { void MediaSession::startIncomingNotification (bool notifyRinging) { L_D(); d->makeLocalMediaDescription(); - d->op->set_local_media_description(d->localDesc); - SalMediaDescription *md = d->op->get_final_media_description(); + d->op->setLocalMediaDescription(d->localDesc); + SalMediaDescription *md = d->op->getFinalMediaDescription(); if (md) { if (sal_media_description_empty(md) || linphone_core_incompatible_security(getCore()->getCCore(), md)) { LinphoneErrorInfo *ei = linphone_error_info_new(); @@ -4277,7 +4277,7 @@ int MediaSession::startInvite (const Address *destination, const string &subject } if (!getCore()->getCCore()->sip_conf.sdp_200_ack) { /* We are offering, set local media description before sending the call */ - d->op->set_local_media_description(d->localDesc); + d->op->setLocalMediaDescription(d->localDesc); } int result = CallSession::startInvite(destination, subject, content); @@ -4289,7 +4289,7 @@ int MediaSession::startInvite (const Address *destination, const string &subject if (getCore()->getCCore()->sip_conf.sdp_200_ack) { /* We are NOT offering, set local media description after sending the call so that we are ready to process the remote offer when it will arrive. */ - d->op->set_local_media_description(d->localDesc); + d->op->setLocalMediaDescription(d->localDesc); } return result; } @@ -4631,7 +4631,7 @@ float MediaSession::getRecordVolume () const { const MediaSessionParams * MediaSession::getRemoteParams () { L_D(); if (d->op){ - SalMediaDescription *md = d->op->get_remote_media_description(); + SalMediaDescription *md = d->op->getRemoteMediaDescription(); if (md) { d->setRemoteParams(new MediaSessionParams()); unsigned int nbAudioStreams = sal_media_description_nb_active_streams_of_type(md, SalAudio); @@ -4667,7 +4667,7 @@ const MediaSessionParams * MediaSession::getRemoteParams () { d->getRemoteParams()->getPrivate()->setCustomSdpMediaAttributes(LinphoneStreamTypeVideo, md->streams[d->mainVideoStreamIndex].custom_sdp_attributes); d->getRemoteParams()->getPrivate()->setCustomSdpMediaAttributes(LinphoneStreamTypeText, md->streams[d->mainTextStreamIndex].custom_sdp_attributes); } - const SalCustomHeader *ch = d->op->get_recv_custom_header(); + const SalCustomHeader *ch = d->op->getRecvCustomHeaders(); if (ch) { /* Instanciate a remote_params only if a SIP message was received before (custom headers indicates this) */ if (!d->remoteParams) diff --git a/src/core/core-call.cpp b/src/core/core-call.cpp index 53d33ab35..26e914ba0 100644 --- a/src/core/core-call.cpp +++ b/src/core/core-call.cpp @@ -59,16 +59,16 @@ bool CorePrivate::canWeAddCall () const { bool CorePrivate::inviteReplacesABrokenCall (SalCallOp *op) { CallSession *replacedSession = nullptr; - SalCallOp *replacedOp = op->get_replaces(); + SalCallOp *replacedOp = op->getReplaces(); if (replacedOp) - replacedSession = reinterpret_cast(replacedOp->get_user_pointer()); + replacedSession = reinterpret_cast(replacedOp->getUserPointer()); for (const auto &call : calls) { shared_ptr session = call->getPrivate()->getActiveSession(); if (session - && ((session->getPrivate()->isBroken() && op->compare_op(session->getPrivate()->getOp())) + && ((session->getPrivate()->isBroken() && op->compareOp(session->getPrivate()->getOp())) || ((replacedSession == session.get()) - && (strcmp(op->get_from(), replacedOp->get_from()) == 0) - && (strcmp(op->get_to(), replacedOp->get_to()) == 0))) + && (strcmp(op->getFrom(), replacedOp->getFrom()) == 0) + && (strcmp(op->getTo(), replacedOp->getTo()) == 0))) ) { session->getPrivate()->replaceOp(op); return true; diff --git a/src/nat/ice-agent.cpp b/src/nat/ice-agent.cpp index 48f15b5f2..8a2124f08 100644 --- a/src/nat/ice-agent.cpp +++ b/src/nat/ice-agent.cpp @@ -81,7 +81,7 @@ void IceAgent::deleteSession () { } void IceAgent::gatheringFinished () { - const SalMediaDescription *rmd = mediaSession.getPrivate()->getOp()->get_remote_media_description(); + const SalMediaDescription *rmd = mediaSession.getPrivate()->getOp()->getRemoteMediaDescription(); if (rmd) clearUnusedIceCandidates(mediaSession.getPrivate()->getLocalDesc(), rmd); if (!iceSession) @@ -134,7 +134,7 @@ bool IceAgent::prepare (const SalMediaDescription *localDesc, bool incomingOffer SalMediaDescription *remoteDesc = nullptr; bool hasVideo = false; if (incomingOffer) { - remoteDesc = mediaSession.getPrivate()->getOp()->get_remote_media_description(); + remoteDesc = mediaSession.getPrivate()->getOp()->getRemoteMediaDescription(); hasVideo = linphone_core_video_enabled(mediaSession.getCore()->getCCore()) && linphone_core_media_description_contains_video_stream(remoteDesc); } else diff --git a/src/sal/call-op.cpp b/src/sal/call-op.cpp index 3773585d3..5e9114f0a 100644 --- a/src/sal/call-op.cpp +++ b/src/sal/call-op.cpp @@ -32,46 +32,46 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE SalCallOp::~SalCallOp() { - if (this->local_media) sal_media_description_unref(this->local_media); - if (this->remote_media) sal_media_description_unref(this->remote_media); + if (mLocalMedia) sal_media_description_unref(mLocalMedia); + if (mRemoteMedia) sal_media_description_unref(mRemoteMedia); } -int SalCallOp::set_local_media_description(SalMediaDescription *desc) { +int SalCallOp::setLocalMediaDescription(SalMediaDescription *desc) { if (desc) { sal_media_description_ref(desc); belle_sip_error_code error; belle_sdp_session_description_t *sdp = media_description_to_sdp(desc); - vector buffer = marshal_media_description(sdp, error); + vector buffer = marshalMediaDescription(sdp, error); if (error != BELLE_SIP_OK) return -1; - this->local_body.setContentType(ContentType::Sdp); - this->local_body.setBody(move(buffer)); + mLocalBody.setContentType(ContentType::Sdp); + mLocalBody.setBody(move(buffer)); } else { - this->local_body = Content(); + mLocalBody = Content(); } - if (this->local_media) - sal_media_description_unref(this->local_media); - this->local_media=desc; + if (mLocalMedia) + sal_media_description_unref(mLocalMedia); + mLocalMedia=desc; - if (this->remote_media){ + if (mRemoteMedia){ /*case of an incoming call where we modify the local capabilities between the time * the call is ringing and it is accepted (for example if you want to accept without video*/ /*reset the sdp answer so that it is computed again*/ - if (this->sdp_answer){ - belle_sip_object_unref(this->sdp_answer); - this->sdp_answer=NULL; + if (mSdpAnswer){ + belle_sip_object_unref(mSdpAnswer); + mSdpAnswer=NULL; } } return 0; } -int SalCallOp::set_local_body(const Content &body) { +int SalCallOp::setLocalBody(const Content &body) { Content bodyCopy = body; - return set_local_body(move(bodyCopy)); + return setLocalBody(move(bodyCopy)); } -int SalCallOp::set_local_body(const Content &&body) { +int SalCallOp::setLocalBody(const Content &&body) { if (!body.isValid()) return -1; if (body.getContentType() == ContentType::Sdp) { @@ -85,15 +85,15 @@ int SalCallOp::set_local_body(const Content &&body) { return -1; } } - if (this->local_media) sal_media_description_unref(this->local_media); - this->local_media = desc; + if (mLocalMedia) sal_media_description_unref(mLocalMedia); + mLocalMedia = desc; } - this->local_body = body; + mLocalBody = body; return 0; } -belle_sip_header_allow_t *SalCallOp::create_allow(bool_t enable_update) { +belle_sip_header_allow_t *SalCallOp::createAllow(bool_t enable_update) { belle_sip_header_allow_t* header_allow; char allow [256]; snprintf(allow,sizeof(allow),"INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO%s",(enable_update?", UPDATE":"")); @@ -101,7 +101,7 @@ belle_sip_header_allow_t *SalCallOp::create_allow(bool_t enable_update) { return header_allow; } -int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { +int SalCallOp::setCustomBody(belle_sip_message_t *msg, const Content &body) { ContentType contentType = body.getContentType(); auto contentDisposition = body.getContentDisposition(); string contentEncoding = body.getContentEncoding(); @@ -137,7 +137,7 @@ int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) { return 0; } -std::vector SalCallOp::marshal_media_description(belle_sdp_session_description_t *session_desc, belle_sip_error_code &error) { +std::vector SalCallOp::marshalMediaDescription(belle_sdp_session_description_t *session_desc, belle_sip_error_code &error) { size_t length = 0; size_t bufLen = 2048; vector buff(bufLen); @@ -163,65 +163,65 @@ std::vector SalCallOp::marshal_media_description(belle_sdp_session_descrip return buff; } -int SalCallOp::set_sdp(belle_sip_message_t *msg,belle_sdp_session_description_t* session_desc) { +int SalCallOp::setSdp(belle_sip_message_t *msg,belle_sdp_session_description_t* session_desc) { belle_sip_error_code error; if (session_desc == NULL) return -1; - vector buff = marshal_media_description(session_desc, error); + vector buff = marshalMediaDescription(session_desc, error); if (error != BELLE_SIP_OK) return -1; Content body; body.setContentType(ContentType::Sdp); body.setBody(move(buff)); - set_custom_body(msg, body); + setCustomBody(msg, body); return 0; } -int SalCallOp::set_sdp_from_desc(belle_sip_message_t *msg, const SalMediaDescription *desc) { +int SalCallOp::setSdpFromDesc(belle_sip_message_t *msg, const SalMediaDescription *desc) { int err; belle_sdp_session_description_t *sdp=media_description_to_sdp(desc); - err=set_sdp(msg,sdp); + err=setSdp(msg,sdp); belle_sip_object_unref(sdp); return err; } -void SalCallOp::fill_invite(belle_sip_request_t* invite) { - belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(create_allow(this->root->enable_sip_update))); - if (this->root->session_expires!=0){ +void SalCallOp::fillInvite(belle_sip_request_t* invite) { + belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(createAllow(mRoot->mEnableSipUpdate))); + if (mRoot->mSessionExpires!=0){ belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),belle_sip_header_create( "Session-expires", "600;refresher=uas")); belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),belle_sip_header_create( "Supported", "timer")); } - this->sdp_offering = (this->local_body.getContentType() == ContentType::Sdp); - set_custom_body(BELLE_SIP_MESSAGE(invite), this->local_body); + mSdpOffering = (mLocalBody.getContentType() == ContentType::Sdp); + setCustomBody(BELLE_SIP_MESSAGE(invite), mLocalBody); } -void SalCallOp::set_released() { - if (!this->call_released){ - this->state=State::Terminated; - this->root->callbacks.call_released(this); - this->call_released=TRUE; +void SalCallOp::setReleased() { + if (!mCallReleased){ + mState=State::Terminated; + mRoot->mCallbacks.call_released(this); + mCallReleased=TRUE; /*be aware that the following line may destroy the op*/ - set_or_update_dialog(NULL); + setOrUpdateDialog(NULL); } } -void SalCallOp::process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event) { +void SalCallOp::processIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event) { SalCallOp *op = (SalCallOp *)user_ctx; - if (op->state == State::Terminated) return; + if (op->mState == State::Terminated) return; - if (op->pending_client_trans && (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(op->pending_client_trans)) == BELLE_SIP_TRANSACTION_INIT)) { + if (op->mPendingClientTransaction && (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(op->mPendingClientTransaction)) == BELLE_SIP_TRANSACTION_INIT)) { - sal_error_info_set(&op->error_info, SalReasonIOError, "SIP", 503, "IO error", NULL); - op->root->callbacks.call_failure(op); + sal_error_info_set(&op->mErrorInfo, SalReasonIOError, "SIP", 503, "IO error", NULL); + op->mRoot->mCallbacks.call_failure(op); - if (!op->dialog || belle_sip_dialog_get_state(op->dialog) != BELLE_SIP_DIALOG_CONFIRMED){ + if (!op->mDialog || belle_sip_dialog_get_state(op->mDialog) != BELLE_SIP_DIALOG_CONFIRMED){ /* Call terminated very very early, before INVITE is even sent, probably DNS resolution timeout. */ - op->state = State::Terminating; - op->set_released(); + op->mState = State::Terminating; + op->setReleased(); } } else { /* Nothing to be done. If the error comes from a connectivity loss, @@ -229,12 +229,12 @@ void SalCallOp::process_io_error_cb(void *user_ctx, const belle_sip_io_error_eve } } -void SalCallOp::cancelling_invite(const SalErrorInfo *info) { - cancel_invite_with_info(info); - this->state=State::Terminating; +void SalCallOp::cancellingInvite(const SalErrorInfo *info) { + cancelInvite(info); + mState=State::Terminating; } -Content SalCallOp::extract_body(belle_sip_message_t *message) { +Content SalCallOp::extractBody(belle_sip_message_t *message) { Content body; belle_sip_header_content_type_t *content_type = belle_sip_message_get_header_by_type(message, belle_sip_header_content_type_t); belle_sip_header_content_disposition_t *contentDispositionHeader = belle_sip_message_get_header_by_type(message, belle_sip_header_content_disposition_t); @@ -256,17 +256,17 @@ Content SalCallOp::extract_body(belle_sip_message_t *message) { return body; } -int SalCallOp::parse_sdp_body(const Content &body,belle_sdp_session_description_t** session_desc, SalReason *error) { +int SalCallOp::parseSdpBody(const Content &body,belle_sdp_session_description_t** session_desc, SalReason *error) { *session_desc = NULL; *error = SalReasonNone; - if (this->sdp_handling == SalOpSDPSimulateError) { + if (mSdpHandling == SalOpSDPSimulateError) { ms_error("Simulating SDP parsing error for op %p", this); *error = SalReasonNotAcceptable; return -1; } - if (this->sdp_handling == SalOpSDPSimulateRemove) { + if (mSdpHandling == SalOpSDPSimulateRemove) { ms_error("Simulating no SDP for op %p", this); return 0; } @@ -284,7 +284,7 @@ int SalCallOp::parse_sdp_body(const Content &body,belle_sdp_session_description_ return 0; } -void SalCallOp::set_addr_to_0000(char value[], size_t sz) { +void SalCallOp::setAddrTo0000(char value[], size_t sz) { if (ms_is_ipv6(value)) { strncpy(value,"::0", sz); } else { @@ -293,97 +293,97 @@ void SalCallOp::set_addr_to_0000(char value[], size_t sz) { return; } -void SalCallOp::sdp_process(){ - ms_message("Doing SDP offer/answer process of type %s", this->sdp_offering ? "outgoing" : "incoming"); - if (this->result){ - sal_media_description_unref(this->result); - this->result = NULL; +void SalCallOp::sdpProcess(){ + ms_message("Doing SDP offer/answer process of type %s", mSdpOffering ? "outgoing" : "incoming"); + if (mResult){ + sal_media_description_unref(mResult); + mResult = NULL; } /* if SDP was invalid */ - if (this->remote_media == NULL) return; + if (mRemoteMedia == NULL) return; - this->result=sal_media_description_new(); - if (this->sdp_offering){ - offer_answer_initiate_outgoing(this->root->factory, this->local_media,this->remote_media,this->result); + mResult=sal_media_description_new(); + if (mSdpOffering){ + offer_answer_initiate_outgoing(mRoot->mFactory, mLocalMedia,mRemoteMedia,mResult); }else{ int i; - if (this->sdp_answer){ - belle_sip_object_unref(this->sdp_answer); + if (mSdpAnswer){ + belle_sip_object_unref(mSdpAnswer); } - offer_answer_initiate_incoming(this->root->factory, this->local_media,this->remote_media,this->result,this->root->one_matching_codec); + offer_answer_initiate_incoming(mRoot->mFactory, mLocalMedia,mRemoteMedia,mResult,mRoot->mOneMatchingCodec); /*for backward compatibility purpose*/ - if(this->_cnx_ip_to_0000_if_sendonly_enabled && sal_media_description_has_dir(this->result,SalStreamSendOnly)) { - set_addr_to_0000(this->result->addr, sizeof(this->result->addr)); + if(mCnxIpTo0000IfSendOnlyEnabled && sal_media_description_has_dir(mResult,SalStreamSendOnly)) { + setAddrTo0000(mResult->addr, sizeof(mResult->addr)); for(i=0;iresult->streams[i].dir == SalStreamSendOnly) { - set_addr_to_0000(this->result->streams[i].rtp_addr, sizeof(this->result->streams[i].rtp_addr)); - set_addr_to_0000(this->result->streams[i].rtcp_addr, sizeof(this->result->streams[i].rtcp_addr)); + if (mResult->streams[i].dir == SalStreamSendOnly) { + setAddrTo0000(mResult->streams[i].rtp_addr, sizeof(mResult->streams[i].rtp_addr)); + setAddrTo0000(mResult->streams[i].rtcp_addr, sizeof(mResult->streams[i].rtcp_addr)); } } } - this->sdp_answer=(belle_sdp_session_description_t *)belle_sip_object_ref(media_description_to_sdp(this->result)); + mSdpAnswer=(belle_sdp_session_description_t *)belle_sip_object_ref(media_description_to_sdp(mResult)); /*once we have generated the SDP answer, we modify the result description for processing by the upper layer. It should contains media parameters constraint from the remote offer, not our response*/ - strcpy(this->result->addr,this->remote_media->addr); - this->result->bandwidth=this->remote_media->bandwidth; + strcpy(mResult->addr,mRemoteMedia->addr); + mResult->bandwidth=mRemoteMedia->bandwidth; for(i=0;iresult->streams[i].rtp_port!=0){ /*if stream was accepted*/ - strcpy(this->result->streams[i].rtp_addr,this->remote_media->streams[i].rtp_addr); - this->result->streams[i].ptime=this->remote_media->streams[i].ptime; - this->result->streams[i].bandwidth=this->remote_media->streams[i].bandwidth; - this->result->streams[i].rtp_port=this->remote_media->streams[i].rtp_port; - strcpy(this->result->streams[i].rtcp_addr,this->remote_media->streams[i].rtcp_addr); - this->result->streams[i].rtcp_port=this->remote_media->streams[i].rtcp_port; + if (mResult->streams[i].rtp_port!=0){ /*if stream was accepted*/ + strcpy(mResult->streams[i].rtp_addr,mRemoteMedia->streams[i].rtp_addr); + mResult->streams[i].ptime=mRemoteMedia->streams[i].ptime; + mResult->streams[i].bandwidth=mRemoteMedia->streams[i].bandwidth; + mResult->streams[i].rtp_port=mRemoteMedia->streams[i].rtp_port; + strcpy(mResult->streams[i].rtcp_addr,mRemoteMedia->streams[i].rtcp_addr); + mResult->streams[i].rtcp_port=mRemoteMedia->streams[i].rtcp_port; - if (sal_stream_description_has_srtp(&this->result->streams[i])) { - this->result->streams[i].crypto[0] = this->remote_media->streams[i].crypto[0]; + if (sal_stream_description_has_srtp(&mResult->streams[i])) { + mResult->streams[i].crypto[0] = mRemoteMedia->streams[i].crypto[0]; } } } } } -void SalCallOp::handle_body_from_response(belle_sip_response_t* response) { +void SalCallOp::handleBodyFromResponse(belle_sip_response_t* response) { SalReason reason; belle_sdp_session_description_t* sdp = nullptr; - Content body = extract_body(BELLE_SIP_MESSAGE(response)); - if (this->remote_media){ - sal_media_description_unref(this->remote_media); - this->remote_media=NULL; + Content body = extractBody(BELLE_SIP_MESSAGE(response)); + if (mRemoteMedia){ + sal_media_description_unref(mRemoteMedia); + mRemoteMedia=NULL; } if (body.getContentType() == ContentType::Sdp) { - if (parse_sdp_body(body, &sdp, &reason) == 0) { + if (parseSdpBody(body, &sdp, &reason) == 0) { if (sdp) { - this->remote_media = sal_media_description_new(); - sdp_to_media_description(sdp, this->remote_media); - this->remote_body = move(body); + mRemoteMedia = sal_media_description_new(); + sdp_to_media_description(sdp, mRemoteMedia); + mRemoteBody = move(body); }/*if no sdp in response, what can we do ?*/ } /* process sdp in any case to reset result media description*/ - if (this->local_media) sdp_process(); + if (mLocalMedia) sdpProcess(); } else { - this->remote_body = move(body); + mRemoteBody = move(body); } } -void SalCallOp::set_error(belle_sip_response_t* response, bool_t fatal){ - set_error_info_from_response(response); - if (fatal) this->state = State::Terminating; - this->root->callbacks.call_failure(this); +void SalCallOp::setError(belle_sip_response_t* response, bool_t fatal){ + setErrorInfoFromResponse(response); + if (fatal) mState = State::Terminating; + mRoot->mCallbacks.call_failure(this); } -int SalCallOp::vfu_retry_cb (void *user_data, unsigned int events) { +int SalCallOp::vfuRetryCb (void *user_data, unsigned int events) { SalCallOp *op=(SalCallOp *)user_data; - op->send_vfu_request(); + op->sendVfuRequest(); op->unref(); return BELLE_SIP_STOP; } -void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_event_t *event) { +void SalCallOp::processResponseCb(void *op_base, const belle_sip_response_event_t *event) { SalCallOp * op = (SalCallOp *)op_base; belle_sip_request_t* ack; belle_sip_dialog_state_t dialog_state; @@ -400,7 +400,7 @@ void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_even return; } req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)); - op->set_or_update_dialog(dialog); + op->setOrUpdateDialog(dialog); dialog_state=dialog ? belle_sip_dialog_get_state(dialog) : BELLE_SIP_DIALOG_NULL; method=belle_sip_request_get_method(req); ms_message("Op [%p] receiving call response [%i], dialog is [%p] in state [%s]",op,code,dialog,belle_sip_dialog_state_to_string(dialog_state)); @@ -410,67 +410,67 @@ void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_even case BELLE_SIP_DIALOG_NULL: case BELLE_SIP_DIALOG_EARLY: { if (strcmp("INVITE",method)==0 ) { - if (op->state == State::Terminating) { + if (op->mState == State::Terminating) { /*check if CANCEL was sent before*/ - if (strcmp("CANCEL",belle_sip_request_get_method(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(op->pending_client_trans))))!=0) { + if (strcmp("CANCEL",belle_sip_request_get_method(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(op->mPendingClientTransaction))))!=0) { /*it wasn't sent */ if (code<200) { - op->cancelling_invite(NULL); + op->cancellingInvite(NULL); }else{ /* no need to send the INVITE because the UAS rejected the INVITE*/ - if (op->dialog==NULL) op->set_released(); + if (op->mDialog==NULL) op->setReleased(); } } else { /*it was sent already, so just expect the 487 or any error response to send the call_released() notification*/ if (code>=300){ - if (op->dialog==NULL) op->set_released(); + if (op->mDialog==NULL) op->setReleased(); } } } else if (code >= 180 && code<200) { belle_sip_response_t *prev_response=reinterpret_cast(belle_sip_object_data_get(BELLE_SIP_OBJECT(dialog),"early_response")); if (!prev_response || code>belle_sip_response_get_status_code(prev_response)){ - op->handle_body_from_response(response); - op->root->callbacks.call_ringing(op); + op->handleBodyFromResponse(response); + op->mRoot->mCallbacks.call_ringing(op); } belle_sip_object_data_set(BELLE_SIP_OBJECT(dialog),"early_response",belle_sip_object_ref(response),belle_sip_object_unref); } else if (code>=300){ - op->set_error(response, TRUE); - if (op->dialog==NULL) op->set_released(); + op->setError(response, TRUE); + if (op->mDialog==NULL) op->setReleased(); } } else if (code >=200 && code<300) { if (strcmp("UPDATE",method)==0) { - op->handle_body_from_response(response); - op->root->callbacks.call_accepted(op); + op->handleBodyFromResponse(response); + op->mRoot->mCallbacks.call_accepted(op); } else if (strcmp("CANCEL", method) == 0) { - op->root->callbacks.call_cancel_done(op); + op->mRoot->mCallbacks.call_cancel_done(op); } } } break; case BELLE_SIP_DIALOG_CONFIRMED: { - switch (op->state) { + switch (op->mState) { case State::Early:/*invite case*/ case State::Active: /*re-invite, INFO, UPDATE case*/ if (strcmp("INVITE",method)==0){ if (code >=200 && code<300) { - op->handle_body_from_response(response); - ack=belle_sip_dialog_create_ack(op->dialog,belle_sip_dialog_get_local_seq_number(op->dialog)); + op->handleBodyFromResponse(response); + ack=belle_sip_dialog_create_ack(op->mDialog,belle_sip_dialog_get_local_seq_number(op->mDialog)); if (ack == NULL) { ms_error("This call has been already terminated."); return ; } - if (op->sdp_answer){ - set_sdp(BELLE_SIP_MESSAGE(ack),op->sdp_answer); - belle_sip_object_unref(op->sdp_answer); - op->sdp_answer=NULL; + if (op->mSdpAnswer){ + setSdp(BELLE_SIP_MESSAGE(ack),op->mSdpAnswer); + belle_sip_object_unref(op->mSdpAnswer); + op->mSdpAnswer=NULL; } - belle_sip_message_add_header(BELLE_SIP_MESSAGE(ack),BELLE_SIP_HEADER(op->root->user_agent)); - op->root->callbacks.call_accepted(op); /*INVITE*/ - op->root->callbacks.call_ack_being_sent(op, (SalCustomHeader*)ack); - belle_sip_dialog_send_ack(op->dialog,ack); - op->state=State::Active; + belle_sip_message_add_header(BELLE_SIP_MESSAGE(ack),BELLE_SIP_HEADER(op->mRoot->mUserAgent)); + op->mRoot->mCallbacks.call_accepted(op); /*INVITE*/ + op->mRoot->mCallbacks.call_ack_being_sent(op, (SalCustomHeader*)ack); + belle_sip_dialog_send_ack(op->mDialog,ack); + op->mState=State::Active; }else if (code >= 300){ - op->set_error(response, FALSE); + op->setError(response, FALSE); } }else if (strcmp("INFO",method)==0){ if (code == 491 @@ -478,24 +478,24 @@ void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_even && strcmp("application",belle_sip_header_content_type_get_type(header_content_type))==0 && strcmp("media_control+xml",belle_sip_header_content_type_get_subtype(header_content_type))==0) { unsigned int retry_in = rand() % 1001; // [0;1000] - belle_sip_source_t *s=op->root->create_timer(vfu_retry_cb,op->ref(), retry_in, "vfu request retry"); + belle_sip_source_t *s=op->mRoot->createTimer(vfuRetryCb,op->ref(), retry_in, "vfu request retry"); ms_message("Rejected vfu request on op [%p], just retry in [%u] ms",op,retry_in); belle_sip_object_unref(s); }else { /*ignoring*/ } }else if (strcmp("UPDATE",method)==0){ - op->root->callbacks.call_accepted(op); /*INVITE*/ + op->mRoot->mCallbacks.call_accepted(op); /*INVITE*/ }else if (strcmp("CANCEL",method)==0){ - op->root->callbacks.call_cancel_done(op); + op->mRoot->mCallbacks.call_cancel_done(op); } break; case State::Terminating: - op->send_request(belle_sip_dialog_create_request(op->dialog,"BYE")); + op->sendRequest(belle_sip_dialog_create_request(op->mDialog,"BYE")); break; case State::Terminated: default: - ms_error("Call op [%p] receives unexpected answer [%i] while in state [%s].",op,code, to_string(op->state)); + ms_error("Call op [%p] receives unexpected answer [%i] while in state [%s].",op,code, toString(op->mState)); } } break; @@ -503,7 +503,7 @@ void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_even if ((code >= 300) && ((strcmp("INVITE", method) == 0) || (strcmp("BYE", method) == 0)) ) { - op->set_error(response, TRUE); + op->setError(response, TRUE); } } break; @@ -515,23 +515,23 @@ void SalCallOp::process_response_cb(void *op_base, const belle_sip_response_even op->unref(); } -void SalCallOp::process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void SalCallOp::processTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { SalCallOp * op=(SalCallOp *)user_ctx; - if (op->state==State::Terminated) return; + if (op->mState==State::Terminated) return; - if (!op->dialog) { + if (!op->mDialog) { /*call terminated very early*/ - sal_error_info_set(&op->error_info, SalReasonRequestTimeout, "SIP", 408, "Request timeout", NULL); - op->root->callbacks.call_failure(op); - op->state = State::Terminating; - op->set_released(); + sal_error_info_set(&op->mErrorInfo, SalReasonRequestTimeout, "SIP", 408, "Request timeout", NULL); + op->mRoot->mCallbacks.call_failure(op); + op->mState = State::Terminating; + op->setReleased(); } else { /*dialog will terminated shortly, nothing to do*/ } } -void SalCallOp::process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { +void SalCallOp::processTransactionTerminatedCb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { SalCallOp * op = (SalCallOp *)user_ctx; belle_sip_client_transaction_t *client_transaction=belle_sip_transaction_terminated_event_get_client_transaction(event); belle_sip_server_transaction_t *server_transaction=belle_sip_transaction_terminated_event_get_server_transaction(event); @@ -549,33 +549,33 @@ void SalCallOp::process_transaction_terminated_cb(void *user_ctx, const belle_si } if (resp) code = belle_sip_response_get_status_code(resp); - if (op->state == State::Terminating + if (op->mState == State::Terminating && strcmp("BYE",belle_sip_request_get_method(req))==0 && (!resp || (belle_sip_response_get_status_code(resp) != 401 && belle_sip_response_get_status_code(resp) != 407)) - && op->dialog==NULL) { + && op->mDialog==NULL) { release_call=TRUE; - }else if (op->state == State::Early && code < 200){ + }else if (op->mState == State::Early && code < 200){ /*call terminated early*/ - sal_error_info_set(&op->error_info, SalReasonIOError, "SIP", 503, "I/O error", NULL); - op->state = State::Terminating; - op->root->callbacks.call_failure(op); + sal_error_info_set(&op->mErrorInfo, SalReasonIOError, "SIP", 503, "I/O error", NULL); + op->mState = State::Terminating; + op->mRoot->mCallbacks.call_failure(op); release_call=TRUE; } if (server_transaction){ - if (op->pending_server_trans==server_transaction){ - belle_sip_object_unref(op->pending_server_trans); - op->pending_server_trans=NULL; + if (op->mPendingServerTransaction==server_transaction){ + belle_sip_object_unref(op->mPendingServerTransaction); + op->mPendingServerTransaction=NULL; } - if (op->pending_update_server_trans==server_transaction){ - belle_sip_object_unref(op->pending_update_server_trans); - op->pending_update_server_trans=NULL; + if (op->mPendingUpdateServerTransaction==server_transaction){ + belle_sip_object_unref(op->mPendingUpdateServerTransaction); + op->mPendingUpdateServerTransaction=NULL; } } - if (release_call) op->set_released(); + if (release_call) op->setReleased(); } -int SalCallOp::is_media_description_acceptable(SalMediaDescription *md) { +int SalCallOp::isMediaDescriptionAcceptable(SalMediaDescription *md) { if (md->nb_streams==0){ ms_warning("Media description does not define any stream."); return FALSE; @@ -583,94 +583,94 @@ int SalCallOp::is_media_description_acceptable(SalMediaDescription *md) { return TRUE; } -SalReason SalCallOp::process_body_for_invite(belle_sip_request_t* invite) { +SalReason SalCallOp::processBodyForInvite(belle_sip_request_t* invite) { SalReason reason = SalReasonNone; - Content body = extract_body(BELLE_SIP_MESSAGE(invite)); + Content body = extractBody(BELLE_SIP_MESSAGE(invite)); if (!body.isValid()) return SalReasonUnsupportedContent; if ((body.getContentType() == ContentType::Sdp) || (body.getContentType().isEmpty() && body.isEmpty())) { belle_sdp_session_description_t* sdp; - if (parse_sdp_body(body, &sdp, &reason) == 0) { + if (parseSdpBody(body, &sdp, &reason) == 0) { if (sdp) { - this->sdp_offering = FALSE; - if (this->remote_media) sal_media_description_unref(this->remote_media); - this->remote_media = sal_media_description_new(); - sdp_to_media_description(sdp, this->remote_media); + mSdpOffering = FALSE; + if (mRemoteMedia) sal_media_description_unref(mRemoteMedia); + mRemoteMedia = sal_media_description_new(); + sdp_to_media_description(sdp, mRemoteMedia); /*make some sanity check about the SDP received*/ - if (!is_media_description_acceptable(this->remote_media)) { + if (!isMediaDescriptionAcceptable(mRemoteMedia)) { reason = SalReasonNotAcceptable; } belle_sip_object_unref(sdp); - } else this->sdp_offering = TRUE; /*INVITE without SDP*/ + } else mSdpOffering = TRUE; /*INVITE without SDP*/ } if (reason != SalReasonNone) { SalErrorInfo sei; memset(&sei, 0, sizeof(sei)); sal_error_info_set(&sei, reason, "SIP", 0, NULL, NULL); - decline_with_error_info(&sei, NULL); + declineWithErrorInfo(&sei, NULL); sal_error_info_reset(&sei); } } - this->remote_body = move(body); + mRemoteBody = move(body); return reason; } -SalReason SalCallOp::process_body_for_ack(belle_sip_request_t *ack) { +SalReason SalCallOp::processBodyForAck(belle_sip_request_t *ack) { SalReason reason = SalReasonNone; - Content body = extract_body(BELLE_SIP_MESSAGE(ack)); + Content body = extractBody(BELLE_SIP_MESSAGE(ack)); if (!body.isValid()) return SalReasonUnsupportedContent; if (body.getContentType() == ContentType::Sdp) { belle_sdp_session_description_t *sdp; - if (parse_sdp_body(body, &sdp, &reason) == 0) { + if (parseSdpBody(body, &sdp, &reason) == 0) { if (sdp) { - if (this->remote_media) sal_media_description_unref(this->remote_media); - this->remote_media = sal_media_description_new(); - sdp_to_media_description(sdp, this->remote_media); - this->sdp_process(); + if (mRemoteMedia) sal_media_description_unref(mRemoteMedia); + mRemoteMedia = sal_media_description_new(); + sdp_to_media_description(sdp, mRemoteMedia); + sdpProcess(); belle_sip_object_unref(sdp); } else { ms_warning("SDP expected in ACK but not found."); } } } - this->remote_body = move(body); + mRemoteBody = move(body); return reason; } -void SalCallOp::call_terminated(belle_sip_server_transaction_t* server_transaction, int status_code, belle_sip_request_t* cancel_request) { +void SalCallOp::callTerminated(belle_sip_server_transaction_t* server_transaction, int status_code, belle_sip_request_t* cancel_request) { belle_sip_response_t* resp; belle_sip_request_t* server_req = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction)); - this->state = State::Terminating; - set_reason_error_info(BELLE_SIP_MESSAGE(cancel_request ? cancel_request : server_req)); - resp=create_response_from_request(server_req,status_code); + mState = State::Terminating; + setReasonErrorInfo(BELLE_SIP_MESSAGE(cancel_request ? cancel_request : server_req)); + resp=createResponseFromRequest(server_req,status_code); belle_sip_server_transaction_send_response(server_transaction,resp); - this->root->callbacks.call_terminated(this,this->dir==Dir::Incoming?this->get_from():this->get_to()); + mRoot->mCallbacks.call_terminated(this,mDir==Dir::Incoming?getFrom():getTo()); } -void SalCallOp::reset_descriptions() { - if (this->remote_media){ - sal_media_description_unref(this->remote_media); - this->remote_media=NULL; +void SalCallOp::resetDescriptions() { + if (mRemoteMedia){ + sal_media_description_unref(mRemoteMedia); + mRemoteMedia=NULL; } - if (this->result){ - sal_media_description_unref(this->result); - this->result=NULL; + if (mResult){ + sal_media_description_unref(mResult); + mResult=NULL; } } -void SalCallOp::unsupported_method(belle_sip_server_transaction_t* server_transaction,belle_sip_request_t* request) { +void SalCallOp::unsupportedMethod(belle_sip_server_transaction_t* server_transaction,belle_sip_request_t* request) { belle_sip_response_t* resp; resp=belle_sip_response_create_from_request(request,501); belle_sip_server_transaction_send_response(server_transaction,resp); } -bool_t SalCallOp::is_a_pending_invite_incoming_transaction(belle_sip_transaction_t *tr){ +bool_t SalCallOp::isAPendingIncomingInviteTransaction(belle_sip_transaction_t *tr){ return BELLE_SIP_OBJECT_IS_INSTANCE_OF(tr, belle_sip_ist_t) && belle_sip_transaction_state_is_transient( belle_sip_transaction_get_state(tr)); } -void SalCallOp::process_request_event_cb(void *op_base, const belle_sip_request_event_t *event) { +void SalCallOp::processRequestEventCb(void *op_base, const belle_sip_request_event_t *event) { SalCallOp * op = (SalCallOp *)op_base; SalReason reason; belle_sip_server_transaction_t* server_transaction=NULL; @@ -683,50 +683,50 @@ void SalCallOp::process_request_event_cb(void *op_base, const belle_sip_request_ bool_t drop_op = FALSE; if (strcmp("ACK",method)!=0){ /*ACK doesn't create a server transaction*/ - server_transaction = belle_sip_provider_create_server_transaction(op->root->prov,belle_sip_request_event_get_request(event)); + server_transaction = belle_sip_provider_create_server_transaction(op->mRoot->mProvider,belle_sip_request_event_get_request(event)); belle_sip_object_ref(server_transaction); belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(server_transaction),op->ref()); } if (strcmp("INVITE",method)==0) { - if (op->pending_server_trans) belle_sip_object_unref(op->pending_server_trans); + if (op->mPendingServerTransaction) belle_sip_object_unref(op->mPendingServerTransaction); /*updating pending invite transaction*/ - op->pending_server_trans=server_transaction; - belle_sip_object_ref(op->pending_server_trans); + op->mPendingServerTransaction=server_transaction; + belle_sip_object_ref(op->mPendingServerTransaction); } if (strcmp("UPDATE",method)==0) { - if (op->pending_update_server_trans) belle_sip_object_unref(op->pending_update_server_trans); + if (op->mPendingUpdateServerTransaction) belle_sip_object_unref(op->mPendingUpdateServerTransaction); /*updating pending update transaction*/ - op->pending_update_server_trans=server_transaction; - belle_sip_object_ref(op->pending_update_server_trans); + op->mPendingUpdateServerTransaction=server_transaction; + belle_sip_object_ref(op->mPendingUpdateServerTransaction); } - if (!op->dialog) { - op->set_or_update_dialog(belle_sip_provider_create_dialog(op->root->prov, BELLE_SIP_TRANSACTION(op->pending_server_trans))); - ms_message("new incoming call from [%s] to [%s]",op->get_from(),op->get_to()); + if (!op->mDialog) { + op->setOrUpdateDialog(belle_sip_provider_create_dialog(op->mRoot->mProvider, BELLE_SIP_TRANSACTION(op->mPendingServerTransaction))); + ms_message("new incoming call from [%s] to [%s]",op->getFrom(),op->getTo()); } - dialog_state=belle_sip_dialog_get_state(op->dialog); + dialog_state=belle_sip_dialog_get_state(op->mDialog); switch(dialog_state) { case BELLE_SIP_DIALOG_NULL: { if (strcmp("INVITE",method)==0) { - if (!op->replaces && (op->replaces=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_replaces_t))) { - belle_sip_object_ref(op->replaces); - } else if(op->replaces) { + if (!op->mReplaces && (op->mReplaces=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_replaces_t))) { + belle_sip_object_ref(op->mReplaces); + } else if(op->mReplaces) { ms_warning("replace header already set"); } - if ( (reason = op->process_body_for_invite(req)) == SalReasonNone) { + if ( (reason = op->processBodyForInvite(req)) == SalReasonNone) { if ((call_info=belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),"Call-Info"))) { if( strstr(belle_sip_header_get_unparsed_value(call_info),"answer-after=") != NULL) { - op->auto_answer_asked=TRUE; + op->mAutoAnswerAsked=TRUE; ms_message("The caller asked to automatically answer the call(Emergency?)\n"); } } - op->root->callbacks.call_received(op); + op->mRoot->mCallbacks.call_received(op); }else{ - sal_error_info_set(&op->error_info, reason, "SIP", 0, NULL, NULL); - op->root->callbacks.call_rejected(op); + sal_error_info_set(&op->mErrorInfo, reason, "SIP", 0, NULL, NULL); + op->mRoot->mCallbacks.call_rejected(op); /*the INVITE was declined by process_sdp_for_invite(). As we are not inside an established dialog, we can drop the op immediately*/ drop_op = TRUE; } @@ -738,68 +738,68 @@ void SalCallOp::process_request_event_cb(void *op_base, const belle_sip_request_ if(belle_sip_request_event_get_server_transaction(event)) { /*first answer 200 ok to cancel*/ belle_sip_server_transaction_send_response(server_transaction - ,op->create_response_from_request(req,200)); + ,op->createResponseFromRequest(req,200)); /*terminate invite transaction*/ - op->call_terminated(op->pending_server_trans,487,req); + op->callTerminated(op->mPendingServerTransaction,487,req); } else { /*call leg does not exist*/ belle_sip_server_transaction_send_response(server_transaction - ,op->create_response_from_request(req,481)); + ,op->createResponseFromRequest(req,481)); } } else if (strcmp("PRACK",method)==0) { - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); } else if (strcmp("UPDATE",method)==0) { - op->reset_descriptions(); - if (op->process_body_for_invite(req)==SalReasonNone) - op->root->callbacks.call_updating(op,TRUE); + op->resetDescriptions(); + if (op->processBodyForInvite(req)==SalReasonNone) + op->mRoot->mCallbacks.call_updating(op,TRUE); } else { belle_sip_error("Unexpected method [%s] for dialog state BELLE_SIP_DIALOG_EARLY",belle_sip_request_get_method(req)); - unsupported_method(server_transaction,req); + unsupportedMethod(server_transaction,req); } break; } case BELLE_SIP_DIALOG_CONFIRMED: /*great ACK received*/ if (strcmp("ACK",method)==0) { - if (!op->pending_client_trans || - !belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state((belle_sip_transaction_t*)op->pending_client_trans))){ - if (op->sdp_offering){ - op->process_body_for_ack(req); + if (!op->mPendingClientTransaction || + !belle_sip_transaction_state_is_transient(belle_sip_transaction_get_state((belle_sip_transaction_t*)op->mPendingClientTransaction))){ + if (op->mSdpOffering){ + op->processBodyForAck(req); } - op->root->callbacks.call_ack_received(op, (SalCustomHeader*)req); + op->mRoot->mCallbacks.call_ack_received(op, (SalCustomHeader*)req); }else{ ms_message("Ignored received ack since a new client transaction has been started since."); } } else if(strcmp("BYE",method)==0) { - op->call_terminated(server_transaction,200,req); + op->callTerminated(server_transaction,200,req); /*call end not notified by dialog deletion because transaction can end before dialog*/ } else if(strcmp("INVITE",method)==0 || (is_update=(strcmp("UPDATE",method)==0)) ) { if (is_update && !belle_sip_message_get_body(BELLE_SIP_MESSAGE(req))) { /*session timer case*/ /*session expire should be handled. to be done when real session timer (rfc4028) will be implemented*/ - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); - belle_sip_object_unref(op->pending_update_server_trans); - op->pending_update_server_trans=NULL; + belle_sip_object_unref(op->mPendingUpdateServerTransaction); + op->mPendingUpdateServerTransaction=NULL; } else { /*re-invite*/ - op->reset_descriptions(); - if (op->process_body_for_invite(req)==SalReasonNone) - op->root->callbacks.call_updating(op,is_update); + op->resetDescriptions(); + if (op->processBodyForInvite(req)==SalReasonNone) + op->mRoot->mCallbacks.call_updating(op,is_update); } } else if (strcmp("INFO",method)==0){ if (belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)) && strstr(belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)),"picture_fast_update")) { /*vfu request*/ ms_message("Receiving VFU request on op [%p]",op); - if (op->root->callbacks.vfu_request){ - op->root->callbacks.vfu_request(op); + if (op->mRoot->mCallbacks.vfu_request){ + op->mRoot->mCallbacks.vfu_request(op); } }else{ belle_sip_message_t *msg = BELLE_SIP_MESSAGE(req); - belle_sip_body_handler_t *body_handler = BELLE_SIP_BODY_HANDLER(op->get_body_handler(msg)); + belle_sip_body_handler_t *body_handler = BELLE_SIP_BODY_HANDLER(op->getBodyHandler(msg)); if (body_handler) { belle_sip_header_content_type_t *content_type = belle_sip_message_get_header_by_type(msg, belle_sip_header_content_type_t); if (content_type @@ -807,39 +807,39 @@ void SalCallOp::process_request_event_cb(void *op_base, const belle_sip_request_ && (strcmp(belle_sip_header_content_type_get_subtype(content_type), "dtmf-relay") == 0)) { char tmp[10]; if (sal_lines_get_value(belle_sip_message_get_body(msg), "Signal",tmp, sizeof(tmp))){ - op->root->callbacks.dtmf_received(op,tmp[0]); + op->mRoot->mCallbacks.dtmf_received(op,tmp[0]); } }else - op->root->callbacks.info_received(op, (SalBodyHandler *)body_handler); + op->mRoot->mCallbacks.info_received(op, (SalBodyHandler *)body_handler); } else { - op->root->callbacks.info_received(op,NULL); + op->mRoot->mCallbacks.info_received(op,NULL); } } - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); }else if (strcmp("REFER",method)==0) { - op->process_refer(event,server_transaction); + op->processRefer(event,server_transaction); } else if (strcmp("NOTIFY",method)==0) { - op->process_notify(event,server_transaction); + op->processNotify(event,server_transaction); } else if (strcmp("OPTIONS",method)==0) { - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); } else if (strcmp("CANCEL",method)==0) { - belle_sip_transaction_t *last_transaction = belle_sip_dialog_get_last_transaction(op->dialog); - if (last_transaction == NULL || !is_a_pending_invite_incoming_transaction(last_transaction) ) { + belle_sip_transaction_t *last_transaction = belle_sip_dialog_get_last_transaction(op->mDialog); + if (last_transaction == NULL || !isAPendingIncomingInviteTransaction(last_transaction) ) { /*call leg does not exist because 200ok already sent*/ - belle_sip_server_transaction_send_response(server_transaction,op->create_response_from_request(req,481)); + belle_sip_server_transaction_send_response(server_transaction,op->createResponseFromRequest(req,481)); } else { /* CANCEL on re-INVITE for which a 200ok has not been sent yet */ - belle_sip_server_transaction_send_response(server_transaction, op->create_response_from_request(req, 200)); + belle_sip_server_transaction_send_response(server_transaction, op->createResponseFromRequest(req, 200)); belle_sip_server_transaction_send_response(BELLE_SIP_SERVER_TRANSACTION(last_transaction), - op->create_response_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_transaction)), 487)); + op->createResponseFromRequest(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_transaction)), 487)); } } else if (strcmp("MESSAGE",method)==0){ - op->process_incoming_message(event); + op->processIncomingMessage(event); }else{ - ms_error("unexpected method [%s] for dialog [%p]",belle_sip_request_get_method(req),op->dialog); - unsupported_method(server_transaction,req); + ms_error("unexpected method [%s] for dialog [%p]",belle_sip_request_get_method(req),op->mDialog); + unsupportedMethod(server_transaction,req); } break; default: @@ -851,95 +851,95 @@ void SalCallOp::process_request_event_cb(void *op_base, const belle_sip_request_ if (drop_op) op->release(); } -void SalCallOp::set_call_as_released(SalCallOp *op) { - op->set_released(); +void SalCallOp::setCallAsReleased(SalCallOp *op) { + op->setReleased(); } -void SalCallOp::process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { +void SalCallOp::processDialogTerminatedCb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { SalCallOp * op=(SalCallOp *)ctx; - if (op->dialog && op->dialog==belle_sip_dialog_terminated_event_get_dialog(event)) { + if (op->mDialog && op->mDialog==belle_sip_dialog_terminated_event_get_dialog(event)) { /*belle_sip_transaction_t* trans=belle_sip_dialog_get_last_transaction(op->dialog);*/ ms_message("Dialog [%p] terminated for op [%p]",belle_sip_dialog_terminated_event_get_dialog(event),op); - switch(belle_sip_dialog_get_previous_state(op->dialog)) { + switch(belle_sip_dialog_get_previous_state(op->mDialog)) { case BELLE_SIP_DIALOG_EARLY: case BELLE_SIP_DIALOG_NULL: - if (op->state!=State::Terminated && op->state!=State::Terminating) { + if (op->mState!=State::Terminated && op->mState!=State::Terminating) { /*this is an early termination due to incorrect response received*/ - op->root->callbacks.call_failure(op); - op->state=State::Terminating; + op->mRoot->mCallbacks.call_failure(op); + op->mState=State::Terminating; } break; case BELLE_SIP_DIALOG_CONFIRMED: - if (op->state!=State::Terminated && op->state!=State::Terminating) { + if (op->mState!=State::Terminated && op->mState!=State::Terminating) { /*this is probably a normal termination from a BYE*/ - op->root->callbacks.call_terminated(op,op->dir==Dir::Incoming?op->get_from():op->get_to()); - op->state=State::Terminating; + op->mRoot->mCallbacks.call_terminated(op,op->mDir==Dir::Incoming?op->getFrom():op->getTo()); + op->mState=State::Terminating; } break; default: break; } - belle_sip_main_loop_do_later(belle_sip_stack_get_main_loop(op->root->stack) - ,(belle_sip_callback_t) set_call_as_released + belle_sip_main_loop_do_later(belle_sip_stack_get_main_loop(op->mRoot->mStack) + ,(belle_sip_callback_t) setCallAsReleased , op); } else { ms_error("dialog unknown for op "); } } -void SalCallOp::fill_cbs() { +void SalCallOp::fillCallbacks() { static belle_sip_listener_callbacks_t call_op_callbacks = {0}; if (call_op_callbacks.process_response_event==NULL){ - call_op_callbacks.process_io_error=process_io_error_cb; - call_op_callbacks.process_response_event=process_response_cb; - call_op_callbacks.process_timeout=process_timeout_cb; - call_op_callbacks.process_transaction_terminated=process_transaction_terminated_cb; - call_op_callbacks.process_request_event=process_request_event_cb; - call_op_callbacks.process_dialog_terminated=process_dialog_terminated_cb; + call_op_callbacks.process_io_error=processIoErrorCb; + call_op_callbacks.process_response_event=processResponseCb; + call_op_callbacks.process_timeout=processTimeoutCb; + call_op_callbacks.process_transaction_terminated=processTransactionTerminatedCb; + call_op_callbacks.process_request_event=processRequestEventCb; + call_op_callbacks.process_dialog_terminated=processDialogTerminatedCb; } - this->callbacks=&call_op_callbacks; - this->type=Type::Call; + mCallbacks=&call_op_callbacks; + mType=Type::Call; } int SalCallOp::call(const char *from, const char *to, const char *subject) { belle_sip_request_t* invite; - this->dir=Dir::Outgoing; + mDir=Dir::Outgoing; - set_from(from); - set_to(to); + setFrom(from); + setTo(to); ms_message("[%s] calling [%s] on op [%p]", from, to, this); - invite=build_request("INVITE"); + invite=buildRequest("INVITE"); if( invite == NULL ){ /* can happen if the op has an invalid address */ return -1; } - fill_invite(invite); + fillInvite(invite); if (subject) belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite), belle_sip_header_create("Subject", subject)); - fill_cbs(); - if (this->replaces){ - belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(this->replaces)); + fillCallbacks(); + if (mReplaces){ + belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(mReplaces)); } - if (this->referred_by) - belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(this->referred_by)); + if (mReferredBy) + belle_sip_message_add_header(BELLE_SIP_MESSAGE(invite),BELLE_SIP_HEADER(mReferredBy)); - return send_request(invite); + return sendRequest(invite); } -int SalCallOp::notify_ringing(bool_t early_media){ +int SalCallOp::notifyRinging(bool_t early_media){ int status_code =early_media?183:180; - belle_sip_request_t* req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(this->pending_server_trans)); - belle_sip_response_t* ringing_response = create_response_from_request(req,status_code); + belle_sip_request_t* req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(mPendingServerTransaction)); + belle_sip_response_t* ringing_response = createResponseFromRequest(req,status_code); belle_sip_header_t *require; const char *tags=NULL; if (early_media){ - handle_offer_answer_response(ringing_response); + handleOfferAnswerResponse(ringing_response); } require=belle_sip_message_get_header((belle_sip_message_t*)req,"Require"); if (require) tags=belle_sip_header_get_unparsed_value(require); @@ -953,13 +953,13 @@ int SalCallOp::notify_ringing(bool_t early_media){ if (tags && strstr(tags,"100rel")!=0) #endif { - belle_sip_header_address_t* contact= (belle_sip_header_address_t*)get_contact_address(); + belle_sip_header_address_t* contact= (belle_sip_header_address_t*)getContactAddress(); belle_sip_header_contact_t* contact_header; if (contact && (contact_header=belle_sip_header_contact_create(contact))) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(ringing_response),BELLE_SIP_HEADER(contact_header)); } } - belle_sip_server_transaction_send_response(this->pending_server_trans,ringing_response); + belle_sip_server_transaction_send_response(mPendingServerTransaction,ringing_response); return 0; } @@ -969,11 +969,11 @@ int SalCallOp::accept() { belle_sip_server_transaction_t* transaction; /*first check if an UPDATE transaction need to be accepted*/ - if (this->pending_update_server_trans) { - transaction= this->pending_update_server_trans; - } else if (this->pending_server_trans) { + if (mPendingUpdateServerTransaction) { + transaction= mPendingUpdateServerTransaction; + } else if (mPendingServerTransaction) { /*so it must be an invite/re-invite*/ - transaction= this->pending_server_trans; + transaction= mPendingServerTransaction; } else { ms_error("No transaction to accept for op [%p]", this); return -1; @@ -981,39 +981,39 @@ int SalCallOp::accept() { ms_message("Accepting server transaction [%p] on op [%p]", transaction, this); /* sends a 200 OK */ - response = create_response_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(transaction)),200); + response = createResponseFromRequest(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(transaction)),200); if (response==NULL){ ms_error("Fail to build answer for call"); return -1; } - belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_HEADER(create_allow(this->root->enable_sip_update))); - if (this->root->session_expires!=0){ + belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_HEADER(createAllow(mRoot->mEnableSipUpdate))); + if (mRoot->mSessionExpires!=0){ /* if (h->supports_session_timers) {*/ belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),belle_sip_header_create("Supported", "timer")); belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),belle_sip_header_create( "Session-expires", "600;refresher=uac")); /*}*/ } - if ((contact_header=create_contact())) { + if ((contact_header=createContact())) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_HEADER(contact_header)); } - add_custom_headers(BELLE_SIP_MESSAGE(response)); + addCustomHeaders(BELLE_SIP_MESSAGE(response)); - handle_offer_answer_response(response); + handleOfferAnswerResponse(response); belle_sip_server_transaction_send_response(transaction,response); - if (this->pending_update_server_trans) { - belle_sip_object_unref(this->pending_update_server_trans); - this->pending_update_server_trans=NULL; + if (mPendingUpdateServerTransaction) { + belle_sip_object_unref(mPendingUpdateServerTransaction); + mPendingUpdateServerTransaction=NULL; } - if (this->state == State::Early){ - this->state = State::Active; + if (mState == State::Early){ + mState = State::Active; } return 0; } -int SalCallOp::decline(SalReason reason, const char *redirection /*optional*/){ +int SalCallOp::decline(SalReason reason, const char *redirection){ belle_sip_response_t* response; belle_sip_header_contact_t* contact=NULL; int status=to_sip_code(reason); @@ -1029,19 +1029,19 @@ int SalCallOp::decline(SalReason reason, const char *redirection /*optional*/){ ms_error("Cannot redirect to null"); } } - trans=(belle_sip_transaction_t*)this->pending_server_trans; - if (!trans) trans=(belle_sip_transaction_t*)this->pending_update_server_trans; + trans=(belle_sip_transaction_t*)mPendingServerTransaction; + if (!trans) trans=(belle_sip_transaction_t*)mPendingUpdateServerTransaction; if (!trans){ ms_error("sal_call_decline(): no pending transaction to decline."); return -1; } - response = create_response_from_request(belle_sip_transaction_get_request(trans),status); + response = createResponseFromRequest(belle_sip_transaction_get_request(trans),status); if (contact) belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_HEADER(contact)); belle_sip_server_transaction_send_response(BELLE_SIP_SERVER_TRANSACTION(trans),response); return 0; } -belle_sip_header_reason_t *SalCallOp::make_reason_header( const SalErrorInfo *info){ +belle_sip_header_reason_t *SalCallOp::makeReasonHeader( const SalErrorInfo *info){ if (info && info->reason != SalReasonNone) { belle_sip_header_reason_t* reason = BELLE_SIP_HEADER_REASON(belle_sip_header_reason_new()); belle_sip_header_reason_set_text(reason, info->status_string); @@ -1052,7 +1052,7 @@ belle_sip_header_reason_t *SalCallOp::make_reason_header( const SalErrorInfo *in return NULL; } -int SalCallOp::decline_with_error_info(const SalErrorInfo *info, const SalAddress *redirectionAddr /*optional*/){ +int SalCallOp::declineWithErrorInfo(const SalErrorInfo *info, const SalAddress *redirectionAddr){ belle_sip_response_t* response; belle_sip_header_contact_t* contact=NULL; int status = info->protocol_code; @@ -1066,14 +1066,14 @@ int SalCallOp::decline_with_error_info(const SalErrorInfo *info, const SalAddres ms_error("Cannot redirect to null"); } } - trans=(belle_sip_transaction_t*)this->pending_server_trans; - if (!trans) trans=(belle_sip_transaction_t*)this->pending_update_server_trans; + trans=(belle_sip_transaction_t*)mPendingServerTransaction; + if (!trans) trans=(belle_sip_transaction_t*)mPendingUpdateServerTransaction; if (!trans){ ms_error("sal_call_decline_with_error_info(): no pending transaction to decline."); return -1; } - response = create_response_from_request(belle_sip_transaction_get_request(trans),status); - belle_sip_header_reason_t* reason_header = make_reason_header(info->sub_sei); + response = createResponseFromRequest(belle_sip_transaction_get_request(trans),status); + belle_sip_header_reason_t* reason_header = makeReasonHeader(info->sub_sei); if (reason_header) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(response),BELLE_SIP_HEADER(reason_header)); } @@ -1089,69 +1089,69 @@ int SalCallOp::update(const char *subject, bool_t no_user_consent) { belle_sip_request_t *update; belle_sip_dialog_state_t state; - if (this->dialog == NULL) { + if (mDialog == NULL) { /* If the dialog does not exist, this is that we are trying to recover from a connection loss during a very early state of outgoing call initiation (the dialog has not been created yet). */ - const char *from = get_from(); - const char *to = get_to(); + const char *from = getFrom(); + const char *to = getTo(); return call(from, to, subject); } - state = belle_sip_dialog_get_state(this->dialog); - belle_sip_dialog_enable_pending_trans_checking(this->dialog,this->root->pending_trans_checking); + state = belle_sip_dialog_get_state(mDialog); + belle_sip_dialog_enable_pending_trans_checking(mDialog,mRoot->mPendingTransactionChecking); /*check for dialog state*/ if ( state == BELLE_SIP_DIALOG_CONFIRMED) { if (no_user_consent) - update=belle_sip_dialog_create_request(this->dialog,"UPDATE"); + update=belle_sip_dialog_create_request(mDialog,"UPDATE"); else - update=belle_sip_dialog_create_request(this->dialog,"INVITE"); + update=belle_sip_dialog_create_request(mDialog,"INVITE"); } else if (state == BELLE_SIP_DIALOG_EARLY) { - update=belle_sip_dialog_create_request(this->dialog,"UPDATE"); + update=belle_sip_dialog_create_request(mDialog,"UPDATE"); } else { - ms_error("Cannot update op [%p] with dialog [%p] in state [%s]", this, this->dialog,belle_sip_dialog_state_to_string(state)); + ms_error("Cannot update op [%p] with dialog [%p] in state [%s]", this, mDialog,belle_sip_dialog_state_to_string(state)); return -1; } if (update){ belle_sip_message_add_header(BELLE_SIP_MESSAGE(update),belle_sip_header_create( "Subject", subject)); - fill_invite(update); - return send_request(update); + fillInvite(update); + return sendRequest(update); } /*it failed why ?*/ - if (belle_sip_dialog_request_pending(this->dialog)) - sal_error_info_set(&this->error_info,SalReasonRequestPending, "SIP", 491,NULL,NULL); + if (belle_sip_dialog_request_pending(mDialog)) + sal_error_info_set(&mErrorInfo,SalReasonRequestPending, "SIP", 491,NULL,NULL); else - sal_error_info_set(&this->error_info,SalReasonUnknown, "SIP", 500,NULL,NULL); + sal_error_info_set(&mErrorInfo,SalReasonUnknown, "SIP", 500,NULL,NULL); return -1; } -int SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) { +int SalCallOp::cancelInvite(const SalErrorInfo *info) { belle_sip_request_t* cancel; - ms_message("Cancelling INVITE request from [%s] to [%s] ",get_from(), get_to()); + ms_message("Cancelling INVITE request from [%s] to [%s] ",getFrom(), getTo()); - if (this->pending_client_trans == NULL) { + if (mPendingClientTransaction == NULL) { ms_warning("There is no transaction to cancel."); return -1; } - cancel = belle_sip_client_transaction_create_cancel(this->pending_client_trans); + cancel = belle_sip_client_transaction_create_cancel(mPendingClientTransaction); if (cancel) { if (info && info->reason != SalReasonNone) { - belle_sip_header_reason_t* reason = make_reason_header(info); + belle_sip_header_reason_t* reason = makeReasonHeader(info); belle_sip_message_add_header(BELLE_SIP_MESSAGE(cancel),BELLE_SIP_HEADER(reason)); } - send_request(cancel); + sendRequest(cancel); return 0; - } else if (this->dialog) { - belle_sip_dialog_state_t state = belle_sip_dialog_get_state(this->dialog);; + } else if (mDialog) { + belle_sip_dialog_state_t state = belle_sip_dialog_get_state(mDialog);; /*case where the response received is invalid (could not establish a dialog), but the transaction is not cancellable * because already terminated*/ switch(state) { case BELLE_SIP_DIALOG_EARLY: case BELLE_SIP_DIALOG_NULL: /*force kill the dialog*/ - ms_warning("op [%p]: force kill of dialog [%p]", this, this->dialog); - belle_sip_dialog_delete(this->dialog); + ms_warning("op [%p]: force kill of dialog [%p]", this, mDialog); + belle_sip_dialog_delete(mDialog); break; default: break; @@ -1160,16 +1160,16 @@ int SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) { return -1; } -SalMediaDescription *SalCallOp::get_final_media_description() { - if (this->local_media && this->remote_media && !this->result){ - sdp_process(); +SalMediaDescription *SalCallOp::getFinalMediaDescription() { + if (mLocalMedia && mRemoteMedia && !mResult){ + sdpProcess(); } - return this->result; + return mResult; } -int SalCallOp::refer_to(belle_sip_header_refer_to_t* refer_to, belle_sip_header_referred_by_t* referred_by) { +int SalCallOp::referTo(belle_sip_header_refer_to_t* refer_to, belle_sip_header_referred_by_t* referred_by) { char* tmp; - belle_sip_request_t* req=this->dialog?belle_sip_dialog_create_request(this->dialog,"REFER"):build_request("REFER"); + belle_sip_request_t* req=mDialog?belle_sip_dialog_create_request(mDialog,"REFER"):buildRequest("REFER"); if (!req) { tmp=belle_sip_uri_to_string(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(refer_to))); ms_error("Cannot refer to [%s] for op [%p]",tmp, this); @@ -1178,25 +1178,25 @@ int SalCallOp::refer_to(belle_sip_header_refer_to_t* refer_to, belle_sip_header_ } belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(refer_to)); if (referred_by) belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(referred_by)); - return send_request(req); + return sendRequest(req); } int SalCallOp::refer(const char *refer_to_){ belle_sip_header_address_t *referred_by; belle_sip_header_refer_to_t* refer_to_header; - if (this->dialog) { - referred_by=(belle_sip_header_address_t*)belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_dialog_get_local_party(this->dialog))); + if (mDialog) { + referred_by=(belle_sip_header_address_t*)belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_dialog_get_local_party(mDialog))); }else{ - referred_by=BELLE_SIP_HEADER_ADDRESS(get_from_address()); + referred_by=BELLE_SIP_HEADER_ADDRESS(getFromAddress()); } refer_to_header=belle_sip_header_refer_to_create(belle_sip_header_address_parse(refer_to_)); - return refer_to(refer_to_header,belle_sip_header_referred_by_create(referred_by)); + return referTo(refer_to_header,belle_sip_header_referred_by_create(referred_by)); } -int SalCallOp::refer_with_replaces(SalCallOp *other_call_op) { - belle_sip_dialog_state_t other_call_dialog_state=other_call_op->dialog?belle_sip_dialog_get_state(other_call_op->dialog):BELLE_SIP_DIALOG_NULL; - belle_sip_dialog_state_t op_dialog_state= this->dialog?belle_sip_dialog_get_state(this->dialog):BELLE_SIP_DIALOG_NULL; +int SalCallOp::referWithReplaces(SalCallOp *other_call_op) { + belle_sip_dialog_state_t other_call_dialog_state=other_call_op->mDialog?belle_sip_dialog_get_state(other_call_op->mDialog):BELLE_SIP_DIALOG_NULL; + belle_sip_dialog_state_t op_dialog_state= mDialog?belle_sip_dialog_get_state(mDialog):BELLE_SIP_DIALOG_NULL; belle_sip_header_replaces_t* replaces; belle_sip_header_refer_to_t* refer_to_; belle_sip_header_referred_by_t* referred_by; @@ -1217,7 +1217,7 @@ int SalCallOp::refer_with_replaces(SalCallOp *other_call_op) { return -1; } - refer_to_ =belle_sip_header_refer_to_create(belle_sip_dialog_get_remote_party(other_call_op->dialog)); + refer_to_ =belle_sip_header_refer_to_create(belle_sip_dialog_get_remote_party(other_call_op->mDialog)); belle_sip_parameters_clean(BELLE_SIP_PARAMETERS(refer_to_)); /*rfc3891 ... @@ -1229,29 +1229,29 @@ int SalCallOp::refer_with_replaces(SalCallOp *other_call_op) { User Agent Client (UAC) places the Call-ID, to-tag, and from-tag information for the target dialog in a single Replaces header field and sends the new INVITE to the target.*/ - from_tag=belle_sip_dialog_get_local_tag(other_call_op->dialog); - to_tag=belle_sip_dialog_get_remote_tag(other_call_op->dialog); + from_tag=belle_sip_dialog_get_local_tag(other_call_op->mDialog); + to_tag=belle_sip_dialog_get_remote_tag(other_call_op->mDialog); - replaces=belle_sip_header_replaces_create(belle_sip_header_call_id_get_call_id(belle_sip_dialog_get_call_id(other_call_op->dialog)) + replaces=belle_sip_header_replaces_create(belle_sip_header_call_id_get_call_id(belle_sip_dialog_get_call_id(other_call_op->mDialog)) ,from_tag,to_tag); escaped_replaces=belle_sip_header_replaces_value_to_escaped_string(replaces); belle_sip_uri_set_header(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(refer_to_)),"Replaces",escaped_replaces); belle_sip_free(escaped_replaces); - referred_by=belle_sip_header_referred_by_create(belle_sip_dialog_get_local_party(this->dialog)); + referred_by=belle_sip_header_referred_by_create(belle_sip_dialog_get_local_party(mDialog)); belle_sip_parameters_clean(BELLE_SIP_PARAMETERS(referred_by)); - return refer_to(refer_to_,referred_by); + return referTo(refer_to_,referred_by); } -int SalCallOp::set_referer(SalCallOp *refered_call){ - if (refered_call->replaces) - SalOp::set_replaces(refered_call->replaces); - if (refered_call->referred_by) - set_referred_by(refered_call->referred_by); +int SalCallOp::setReferrer(SalCallOp *refered_call){ + if (refered_call->mReplaces) + SalOp::setReplaces(refered_call->mReplaces); + if (refered_call->mReferredBy) + setReferredBy(refered_call->mReferredBy); return 0; } -SalCallOp *SalCallOp::get_replaces() { - if (this->replaces){ +SalCallOp *SalCallOp::getReplaces() const { + if (mReplaces){ /*rfc3891 3. User Agent Server Behavior: Receiving a Replaces Header @@ -1264,17 +1264,17 @@ SalCallOp *SalCallOp::get_replaces() { is compared to the local tag, and the from-tag parameter is compared to the remote tag. */ - belle_sip_dialog_t* dialog=belle_sip_provider_find_dialog(this->root->prov - ,belle_sip_header_replaces_get_call_id(this->replaces) - ,belle_sip_header_replaces_get_to_tag(this->replaces) - ,belle_sip_header_replaces_get_from_tag(this->replaces)); + belle_sip_dialog_t* dialog=belle_sip_provider_find_dialog(mRoot->mProvider + ,belle_sip_header_replaces_get_call_id(mReplaces) + ,belle_sip_header_replaces_get_to_tag(mReplaces) + ,belle_sip_header_replaces_get_from_tag(mReplaces)); if (!dialog) { /*for backward compatibility with liblinphone <= 3.10.2-243 */ - dialog=belle_sip_provider_find_dialog(this->root->prov - ,belle_sip_header_replaces_get_call_id(this->replaces) - ,belle_sip_header_replaces_get_from_tag(this->replaces) - ,belle_sip_header_replaces_get_to_tag(this->replaces)); + dialog=belle_sip_provider_find_dialog(mRoot->mProvider + ,belle_sip_header_replaces_get_call_id(mReplaces) + ,belle_sip_header_replaces_get_from_tag(mReplaces) + ,belle_sip_header_replaces_get_to_tag(mReplaces)); } if (dialog) { return (SalCallOp*)belle_sip_dialog_get_application_data(dialog); @@ -1283,9 +1283,9 @@ SalCallOp *SalCallOp::get_replaces() { return NULL; } -int SalCallOp::send_dtmf(char dtmf){ - if (this->dialog && (belle_sip_dialog_get_state(this->dialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(this->dialog) == BELLE_SIP_DIALOG_EARLY)){ - belle_sip_request_t *req=belle_sip_dialog_create_queued_request(this->dialog,"INFO"); +int SalCallOp::sendDtmf(char dtmf){ + if (mDialog && (belle_sip_dialog_get_state(mDialog) == BELLE_SIP_DIALOG_CONFIRMED || belle_sip_dialog_get_state(mDialog) == BELLE_SIP_DIALOG_EARLY)){ + belle_sip_request_t *req=belle_sip_dialog_create_queued_request(mDialog,"INFO"); if (req){ size_t bodylen; char dtmf_body[128]={0}; @@ -1295,69 +1295,69 @@ int SalCallOp::send_dtmf(char dtmf){ belle_sip_message_set_body((belle_sip_message_t*)req,dtmf_body,bodylen); belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_length_create(bodylen)); belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*)belle_sip_header_content_type_create("application", "dtmf-relay")); - send_request(req); + sendRequest(req); }else ms_error("sal_call_send_dtmf(): could not build request"); }else ms_error("sal_call_send_dtmf(): no dialog"); return 0; } -int SalCallOp::terminate_with_error(const SalErrorInfo *info) { +int SalCallOp::terminate(const SalErrorInfo *info) { SalErrorInfo sei; const SalErrorInfo *p_sei; - belle_sip_dialog_state_t dialog_state = this->dialog ? belle_sip_dialog_get_state(this->dialog) : BELLE_SIP_DIALOG_NULL; + belle_sip_dialog_state_t dialog_state = mDialog ? belle_sip_dialog_get_state(mDialog) : BELLE_SIP_DIALOG_NULL; int ret = 0; memset(&sei, 0, sizeof(sei)); - if (info == NULL && dialog_state != BELLE_SIP_DIALOG_CONFIRMED && this->dir == Dir::Incoming) { + if (info == NULL && dialog_state != BELLE_SIP_DIALOG_CONFIRMED && mDir == Dir::Incoming) { /*the purpose of this line is to set a default SalErrorInfo for declining an incoming call (not yet established of course) */ sal_error_info_set(&sei,SalReasonDeclined, "SIP", 0, NULL, NULL); p_sei = &sei; } else{ p_sei = info; } - if (this->state==State::Terminating || this->state==State::Terminated) { - ms_error("Cannot terminate op [%p] in state [%s]",this,to_string(this->state)); + if (mState==State::Terminating || mState==State::Terminated) { + ms_error("Cannot terminate op [%p] in state [%s]",this,toString(mState)); ret = -1; goto end; } switch(dialog_state) { case BELLE_SIP_DIALOG_CONFIRMED: { - belle_sip_request_t * req = belle_sip_dialog_create_request(this->dialog,"BYE"); + belle_sip_request_t * req = belle_sip_dialog_create_request(mDialog,"BYE"); if (info && info->reason != SalReasonNone) { - belle_sip_header_reason_t* reason = make_reason_header(info); + belle_sip_header_reason_t* reason = makeReasonHeader(info); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(reason)); } - send_request(req); - this->state=State::Terminating; + sendRequest(req); + mState=State::Terminating; break; } case BELLE_SIP_DIALOG_NULL: { - if (this->dir == Dir::Incoming) { - decline_with_error_info(p_sei, NULL); - this->state=State::Terminated; - } else if (this->pending_client_trans){ - if (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(this->pending_client_trans)) == BELLE_SIP_TRANSACTION_PROCEEDING){ - cancelling_invite(p_sei); + if (mDir == Dir::Incoming) { + declineWithErrorInfo(p_sei, NULL); + mState=State::Terminated; + } else if (mPendingClientTransaction){ + if (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(mPendingClientTransaction)) == BELLE_SIP_TRANSACTION_PROCEEDING){ + cancellingInvite(p_sei); } else { /* Case where the CANCEL cannot be sent because no provisional response was received so far. * The Op must be kept for the time of the transaction in case a response is received later. * The state is passed to Terminating to remember to terminate later. */ - this->state=State::Terminating; + mState=State::Terminating; /* However, even if the transaction is kept alive, we can stop sending retransmissions to avoid flowing the network with no longer * necessary messages and avoid confusion in logs.*/ - belle_sip_client_transaction_stop_retransmissions(this->pending_client_trans); + belle_sip_client_transaction_stop_retransmissions(mPendingClientTransaction); } } break; } case BELLE_SIP_DIALOG_EARLY: { - if (this->dir == Dir::Incoming) { - decline_with_error_info(p_sei,NULL); - this->state=State::Terminated; + if (mDir == Dir::Incoming) { + declineWithErrorInfo(p_sei,NULL); + mState=State::Terminated; } else { - cancelling_invite(p_sei); + cancellingInvite(p_sei); } break; } @@ -1372,7 +1372,7 @@ end: return ret; } -void SalCallOp::send_vfu_request() { +void SalCallOp::sendVfuRequest() { char info_body[] = "" "" @@ -1383,30 +1383,30 @@ void SalCallOp::send_vfu_request() { " " ""; size_t content_lenth = sizeof(info_body) - 1; - belle_sip_dialog_state_t dialog_state= this->dialog?belle_sip_dialog_get_state(this->dialog):BELLE_SIP_DIALOG_NULL; /*no dialog = dialog in NULL state*/ + belle_sip_dialog_state_t dialog_state= mDialog?belle_sip_dialog_get_state(mDialog):BELLE_SIP_DIALOG_NULL; /*no dialog = dialog in NULL state*/ if (dialog_state == BELLE_SIP_DIALOG_CONFIRMED) { - belle_sip_request_t* info = belle_sip_dialog_create_queued_request(this->dialog,"INFO"); + belle_sip_request_t* info = belle_sip_dialog_create_queued_request(mDialog,"INFO"); int error=TRUE; if (info) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(info),BELLE_SIP_HEADER(belle_sip_header_content_type_create("application","media_control+xml"))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(info),BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_lenth))); belle_sip_message_set_body(BELLE_SIP_MESSAGE(info),info_body,content_lenth); - error=send_request(info); + error=sendRequest(info); } if (error) - ms_warning("Cannot send vfu request to [%s] ", get_to()); + ms_warning("Cannot send vfu request to [%s] ", getTo()); } else { - ms_warning("Cannot send vfu request to [%s] because dialog [%p] in wrong state [%s]",get_to() - ,this->dialog + ms_warning("Cannot send vfu request to [%s] because dialog [%p] in wrong state [%s]",getTo() + ,mDialog ,belle_sip_dialog_state_to_string(dialog_state)); } return ; } -int SalCallOp::send_notify_for_refer(int code, const char *reason) { - belle_sip_request_t* notify=belle_sip_dialog_create_queued_request(this->dialog,"NOTIFY"); +int SalCallOp::sendNotifyForRefer(int code, const char *reason) { + belle_sip_request_t* notify=belle_sip_dialog_create_queued_request(mDialog,"NOTIFY"); char *sipfrag=belle_sip_strdup_printf("SIP/2.0 %i %s\r\n",code,reason); size_t content_length=strlen(sipfrag); belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify) @@ -1416,54 +1416,54 @@ int SalCallOp::send_notify_for_refer(int code, const char *reason) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(belle_sip_header_content_type_create("message","sipfrag"))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_length))); belle_sip_message_assign_body(BELLE_SIP_MESSAGE(notify),sipfrag,content_length); - return send_request(notify); + return sendRequest(notify); } -void SalCallOp::notify_last_response(SalCallOp *newcall) { - belle_sip_client_transaction_t *tr=newcall->pending_client_trans; +void SalCallOp::notifyLastResponse(SalCallOp *newcall) { + belle_sip_client_transaction_t *tr=newcall->mPendingClientTransaction; belle_sip_response_t *resp=NULL; if (tr){ resp=belle_sip_transaction_get_response((belle_sip_transaction_t*)tr); } if (resp==NULL){ - send_notify_for_refer(100, "Trying"); + sendNotifyForRefer(100, "Trying"); }else{ - send_notify_for_refer(belle_sip_response_get_status_code(resp), belle_sip_response_get_reason_phrase(resp)); + sendNotifyForRefer(belle_sip_response_get_status_code(resp), belle_sip_response_get_reason_phrase(resp)); } } -int SalCallOp::notify_refer_state(SalCallOp *newcall) { +int SalCallOp::notifyReferState(SalCallOp *newcall) { belle_sip_dialog_state_t state; - if(belle_sip_dialog_get_state(this->dialog) == BELLE_SIP_DIALOG_TERMINATED){ + if(belle_sip_dialog_get_state(mDialog) == BELLE_SIP_DIALOG_TERMINATED){ return 0; } - state = newcall->dialog?belle_sip_dialog_get_state(newcall->dialog):BELLE_SIP_DIALOG_NULL; + state = newcall->mDialog?belle_sip_dialog_get_state(newcall->mDialog):BELLE_SIP_DIALOG_NULL; switch(state) { case BELLE_SIP_DIALOG_EARLY: - send_notify_for_refer(100, "Trying"); + sendNotifyForRefer(100, "Trying"); break; case BELLE_SIP_DIALOG_CONFIRMED: - send_notify_for_refer(200, "Ok"); + sendNotifyForRefer(200, "Ok"); break; case BELLE_SIP_DIALOG_TERMINATED: case BELLE_SIP_DIALOG_NULL: - notify_last_response(newcall); + notifyLastResponse(newcall); break; } return 0; } -void SalCallOp::set_replaces(const char *call_id, const char *from_tag, const char *to_tag) { +void SalCallOp::setReplaces(const char *call_id, const char *from_tag, const char *to_tag) { belle_sip_header_replaces_t *replaces = belle_sip_header_replaces_create(call_id, from_tag, to_tag); - SalOp::set_replaces(replaces); + SalOp::setReplaces(replaces); } -void SalCallOp::set_sdp_handling(SalOpSDPHandling handling) { +void SalCallOp::setSdpHandling(SalOpSDPHandling handling) { if (handling != SalOpSDPNormal) ms_message("Enabling special SDP handling for SalOp[%p]!", this); - this->sdp_handling = handling; + mSdpHandling = handling; } -void SalCallOp::process_refer(const belle_sip_request_event_t *event, belle_sip_server_transaction_t *server_transaction) { +void SalCallOp::processRefer(const belle_sip_request_event_t *event, belle_sip_server_transaction_t *server_transaction) { belle_sip_request_t* req = belle_sip_request_event_get_request(event); belle_sip_header_refer_to_t *refer_to= belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_refer_to_t); belle_sip_header_referred_by_t *referred_by= belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_referred_by_t); @@ -1475,24 +1475,24 @@ void SalCallOp::process_refer(const belle_sip_request_event_t *event, belle_sip_ refer_to_uri=belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(refer_to)); if (refer_to_uri && belle_sip_uri_get_header(refer_to_uri,"Replaces")) { - SalOp::set_replaces(belle_sip_header_replaces_create2(belle_sip_uri_get_header(refer_to_uri,"Replaces"))); + SalOp::setReplaces(belle_sip_header_replaces_create2(belle_sip_uri_get_header(refer_to_uri,"Replaces"))); belle_sip_uri_remove_header(refer_to_uri,"Replaces"); } if (referred_by){ - set_referred_by(referred_by); + setReferredBy(referred_by); } - resp = create_response_from_request(req,202); + resp = createResponseFromRequest(req,202); belle_sip_server_transaction_send_response(server_transaction,resp); - this->root->callbacks.call_refer_received(this,(SalAddress*)BELLE_SIP_HEADER_ADDRESS(refer_to)); + mRoot->mCallbacks.call_refer_received(this,(SalAddress*)BELLE_SIP_HEADER_ADDRESS(refer_to)); } else { ms_warning("cannot do anything with the refer without destination"); - resp = create_response_from_request(req,400); + resp = createResponseFromRequest(req,400); belle_sip_server_transaction_send_response(server_transaction,resp); } } -void SalCallOp::process_notify(const belle_sip_request_event_t *event, belle_sip_server_transaction_t* server_transaction) { +void SalCallOp::processNotify(const belle_sip_request_event_t *event, belle_sip_server_transaction_t* server_transaction) { belle_sip_request_t* req = belle_sip_request_event_get_request(event); const char* body = belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)); belle_sip_header_t* header_event=belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),"Event"); @@ -1519,49 +1519,49 @@ void SalCallOp::process_notify(const belle_sip_request_event_t *event, belle_sip status=SalReferFailed; } belle_sip_object_unref(sipfrag); - resp = create_response_from_request(req,200); + resp = createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); - this->root->callbacks.notify_refer(this,status); + mRoot->mCallbacks.notify_refer(this,status); } }else{ ms_error("Notify without sipfrag, trashing"); - resp = create_response_from_request(req,501); + resp = createResponseFromRequest(req,501); belle_sip_server_transaction_send_response(server_transaction,resp); } } int SalCallOp::sendMessage (const Content &content) { - if (!this->dialog) + if (!mDialog) return -1; - belle_sip_request_t *req = belle_sip_dialog_create_queued_request(this->dialog, "MESSAGE"); + belle_sip_request_t *req = belle_sip_dialog_create_queued_request(mDialog, "MESSAGE"); prepareMessageRequest(req, content); - return send_request(req); + return sendRequest(req); } -bool_t SalCallOp::compare_op(const SalCallOp *op2) const { - return (strcmp(this->call_id, op2->call_id) == 0); +bool_t SalCallOp::compareOp(const SalCallOp *op2) const { + return (strcmp(mCallId, op2->mCallId) == 0); } -void SalCallOp::handle_offer_answer_response(belle_sip_response_t* response) { - if (this->local_media){ +void SalCallOp::handleOfferAnswerResponse(belle_sip_response_t* response) { + if (mLocalMedia){ /*this is the case where we received an invite without SDP*/ - if (this->sdp_offering) { - set_sdp_from_desc(BELLE_SIP_MESSAGE(response),this->local_media); + if (mSdpOffering) { + setSdpFromDesc(BELLE_SIP_MESSAGE(response),mLocalMedia); }else{ - if ( this->sdp_answer==NULL ) + if ( mSdpAnswer==NULL ) { - if( this->sdp_handling == SalOpSDPSimulateRemove ){ + if( mSdpHandling == SalOpSDPSimulateRemove ){ ms_warning("Simulating SDP removal in answer for op %p", this); } else { - sdp_process(); + sdpProcess(); } } - if (this->sdp_answer){ - set_sdp(BELLE_SIP_MESSAGE(response),this->sdp_answer); - belle_sip_object_unref(this->sdp_answer); - this->sdp_answer=NULL; + if (mSdpAnswer){ + setSdp(BELLE_SIP_MESSAGE(response),mSdpAnswer); + belle_sip_object_unref(mSdpAnswer); + mSdpAnswer=NULL; } } }else{ diff --git a/src/sal/call-op.h b/src/sal/call-op.h index 8c1a484e3..df40d38df 100644 --- a/src/sal/call-op.h +++ b/src/sal/call-op.h @@ -25,105 +25,103 @@ LINPHONE_BEGIN_NAMESPACE -class SalCallOp: public SalOp, public SalMessageOpInterface { +class SalCallOp : public SalOp, public SalMessageOpInterface { public: - SalCallOp(Sal *sal): SalOp(sal) {} - ~SalCallOp() override; + SalCallOp (Sal *sal) : SalOp(sal) {} + ~SalCallOp () override; - SalMediaDescription *get_local_media_description () const { return local_media; } - int set_local_media_description(SalMediaDescription *desc); - int set_local_body(const Content &body); - int set_local_body(const Content &&body); + SalMediaDescription *getLocalMediaDescription () const { return mLocalMedia; } + int setLocalMediaDescription (SalMediaDescription *desc); + int setLocalBody (const Content &body); + int setLocalBody (const Content &&body); - SalMediaDescription *get_remote_media_description() {return this->remote_media;} - const Content &get_remote_body() const {return this->remote_body;} - SalMediaDescription *get_final_media_description(); + SalMediaDescription *getRemoteMediaDescription () { return mRemoteMedia; } + const Content &getRemoteBody () const { return mRemoteBody; } + SalMediaDescription *getFinalMediaDescription (); - int call(const char *from, const char *to, const char *subject); - int notify_ringing(bool_t early_media); - int accept(); - int decline(SalReason reason, const char *redirection /*optional*/); - int decline_with_error_info(const SalErrorInfo *info, const SalAddress *redirectionAddr /*optional*/); - int update(const char *subject, bool_t no_user_consent); - int cancel_invite() { return cancel_invite_with_info(NULL);} - int cancel_invite_with_info(const SalErrorInfo *info); - int refer(const char *refer_to_); - int refer_with_replaces(SalCallOp *other_call_op); - int set_referer(SalCallOp *refered_call); - SalCallOp *get_replaces(); - int send_dtmf(char dtmf); - int terminate() {return terminate_with_error(NULL);} - int terminate_with_error(const SalErrorInfo *info); - bool_t autoanswer_asked() const {return this->auto_answer_asked;} - void send_vfu_request(); - int is_offerer() const {return this->sdp_offering;} - int notify_refer_state(SalCallOp *newcall); - bool_t compare_op(const SalCallOp *op2) const; - bool_t dialog_request_pending() const {return (belle_sip_dialog_request_pending(this->dialog) != 0);} - const char *get_local_tag() {return belle_sip_dialog_get_local_tag(this->dialog);} - const char *get_remote_tag() {return belle_sip_dialog_get_remote_tag(this->dialog);} - void set_replaces(const char *call_id, const char *from_tag, const char *to_tag); - void set_sdp_handling(SalOpSDPHandling handling); + int call (const char *from, const char *to, const char *subject); + int notifyRinging (bool_t earlyMedia); + int accept (); + int decline (SalReason reason, const char *redirection = nullptr); + int declineWithErrorInfo (const SalErrorInfo *info, const SalAddress *redirectionAddr = nullptr); + int update (const char *subject, bool_t noUserConsent); + int cancelInvite (const SalErrorInfo *info = nullptr); + int refer (const char *referTo); + int referWithReplaces (SalCallOp *otherCallOp); + int setReferrer (SalCallOp *referredCall); + SalCallOp *getReplaces () const; + int sendDtmf (char dtmf); + int terminate (const SalErrorInfo *info = nullptr); + bool_t autoAnswerAsked () const { return mAutoAnswerAsked; } + void sendVfuRequest (); + int isOfferer () const { return mSdpOffering; } + int notifyReferState (SalCallOp *newCallOp); + bool_t compareOp (const SalCallOp *otherCallOp) const; + bool_t dialogRequestPending () const { return (belle_sip_dialog_request_pending(mDialog) != 0); } + const char *getLocalTag () { return belle_sip_dialog_get_local_tag(mDialog); } + const char *getRemoteTag () { return belle_sip_dialog_get_remote_tag(mDialog); } + void setReplaces (const char *callId, const char *fromTag, const char *toTag); + void setSdpHandling (SalOpSDPHandling handling); // Implementation of SalMessageOpInterface int sendMessage (const Content &content) override; - int reply(SalReason reason) override {return SalOp::reply_message(reason);} + int reply (SalReason reason) override { return SalOp::replyMessage(reason); } private: - virtual void fill_cbs() override; - void set_released(); + virtual void fillCallbacks () override; + void setReleased (); - void set_error(belle_sip_response_t* response, bool_t fatal); - void call_terminated(belle_sip_server_transaction_t* server_transaction, int status_code, belle_sip_request_t* cancel_request); - void reset_descriptions(); + void setError (belle_sip_response_t *response, bool_t fatal); + void callTerminated (belle_sip_server_transaction_t *serverTransaction, int statusCode, belle_sip_request_t *cancelRequest); + void resetDescriptions (); - int parse_sdp_body(const Content &body,belle_sdp_session_description_t** session_desc, SalReason *error); - void sdp_process(); - void handle_body_from_response(belle_sip_response_t* response); - SalReason process_body_for_invite(belle_sip_request_t* invite); - SalReason process_body_for_ack(belle_sip_request_t *ack); - void handle_offer_answer_response(belle_sip_response_t* response); + int parseSdpBody (const Content &body, belle_sdp_session_description_t **sessionDesc, SalReason *error); + void sdpProcess (); + void handleBodyFromResponse (belle_sip_response_t *response); + SalReason processBodyForInvite (belle_sip_request_t *invite); + SalReason processBodyForAck (belle_sip_request_t *ack); + void handleOfferAnswerResponse (belle_sip_response_t *response); - void fill_invite(belle_sip_request_t* invite); - void cancelling_invite(const SalErrorInfo *info); - int refer_to(belle_sip_header_refer_to_t* refer_to, belle_sip_header_referred_by_t* referred_by); - int send_notify_for_refer(int code, const char *reason); - void notify_last_response(SalCallOp *newcall); - void process_refer(const belle_sip_request_event_t *event, belle_sip_server_transaction_t *server_transaction); - void process_notify(const belle_sip_request_event_t *event, belle_sip_server_transaction_t* server_transaction); + void fillInvite (belle_sip_request_t *invite); + void cancellingInvite (const SalErrorInfo *info); + int referTo (belle_sip_header_refer_to_t *referToHeader, belle_sip_header_referred_by_t *referredByHeader); + int sendNotifyForRefer (int code, const char *reason); + void notifyLastResponse (SalCallOp *newCallOp); + void processRefer (const belle_sip_request_event_t *event, belle_sip_server_transaction_t *serverTransaction); + void processNotify (const belle_sip_request_event_t *event, belle_sip_server_transaction_t *serverTransaction); - static void set_addr_to_0000(char value[], size_t sz); - static int is_media_description_acceptable(SalMediaDescription *md); - static bool_t is_a_pending_invite_incoming_transaction(belle_sip_transaction_t *tr); - static void set_call_as_released(SalCallOp *op); - static void unsupported_method(belle_sip_server_transaction_t* server_transaction,belle_sip_request_t* request); - static belle_sip_header_reason_t *make_reason_header( const SalErrorInfo *info); - static belle_sip_header_allow_t *create_allow(bool_t enable_update); - static std::vector marshal_media_description(belle_sdp_session_description_t *session_desc, belle_sip_error_code &error); + static void setAddrTo0000 (char value[], size_t sz); + static int isMediaDescriptionAcceptable (SalMediaDescription *md); + static bool_t isAPendingIncomingInviteTransaction (belle_sip_transaction_t *tr); + static void setCallAsReleased (SalCallOp *op); + static void unsupportedMethod (belle_sip_server_transaction_t *serverTransaction, belle_sip_request_t *request); + static belle_sip_header_reason_t *makeReasonHeader (const SalErrorInfo *info); + static belle_sip_header_allow_t *createAllow (bool_t enableUpdate); + static std::vector marshalMediaDescription (belle_sdp_session_description_t *sessionDesc, belle_sip_error_code &error); // belle_sip_message handlers - static int set_custom_body(belle_sip_message_t *msg, const Content &body); - static int set_sdp(belle_sip_message_t *msg,belle_sdp_session_description_t* session_desc); - static int set_sdp_from_desc(belle_sip_message_t *msg, const SalMediaDescription *desc); - static void process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static Content extract_body(belle_sip_message_t *message); + static int setCustomBody (belle_sip_message_t *message, const Content &body); + static int setSdp (belle_sip_message_t *message, belle_sdp_session_description_t *sessionDesc); + static int setSdpFromDesc (belle_sip_message_t *message, const SalMediaDescription *desc); + static void processIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static Content extractBody (belle_sip_message_t *message); // Callbacks - static int vfu_retry_cb (void *user_data, unsigned int events); - static void process_response_cb(void *op_base, const belle_sip_response_event_t *event); - static void process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event); - static void process_request_event_cb(void *op_base, const belle_sip_request_event_t *event); - static void process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event); + static int vfuRetryCb (void *userCtx, unsigned int events); + static void processResponseCb (void *userCtx, const belle_sip_response_event_t *event); + static void processTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void processTransactionTerminatedCb (void *userCtx, const belle_sip_transaction_terminated_event_t *event); + static void processRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); + static void processDialogTerminatedCb (void *userCtx, const belle_sip_dialog_terminated_event_t *event); // Private constants - static const size_t SIP_MESSAGE_BODY_LIMIT = 16*1024; // 16kB + static const size_t SIP_MESSAGE_BODY_LIMIT = 16 * 1024; // 16kB // Attributes - SalMediaDescription *local_media = NULL; - SalMediaDescription *remote_media = NULL; - Content local_body; - Content remote_body; + SalMediaDescription *mLocalMedia = nullptr; + SalMediaDescription *mRemoteMedia = nullptr; + Content mLocalBody; + Content mRemoteBody; }; LINPHONE_END_NAMESPACE diff --git a/src/sal/event-op.cpp b/src/sal/event-op.cpp index 89cbdb5e7..86c6a3524 100644 --- a/src/sal/event-op.cpp +++ b/src/sal/event-op.cpp @@ -23,7 +23,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -void SalSubscribeOp::subscribe_process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event) { +void SalSubscribeOp::subscribeProcessIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event) { SalSubscribeOp *op = (SalSubscribeOp *)user_ctx; belle_sip_object_t *src = belle_sip_io_error_event_get_source(event); if (BELLE_SIP_OBJECT_IS_INSTANCE_OF(src, belle_sip_client_transaction_t)){ @@ -32,14 +32,14 @@ void SalSubscribeOp::subscribe_process_io_error_cb(void *user_ctx, const belle_s const char *method=belle_sip_request_get_method(req); if (strcmp(method,"NOTIFY")==0){ - SalErrorInfo *ei=&op->error_info; + SalErrorInfo *ei=&op->mErrorInfo; sal_error_info_set(ei,SalReasonIOError, "SIP", 0,NULL,NULL); - op->root->callbacks.on_notify_response(op); + op->mRoot->mCallbacks.on_notify_response(op); } } } -void SalSubscribeOp::subscribe_response_event_cb(void *op_base, const belle_sip_response_event_t *event){ +void SalSubscribeOp::subscribeResponseEventCb(void *op_base, const belle_sip_response_event_t *event){ SalSubscribeOp *op = (SalSubscribeOp *)op_base; belle_sip_request_t * req; const char *method; @@ -50,12 +50,12 @@ void SalSubscribeOp::subscribe_response_event_cb(void *op_base, const belle_sip_ method = belle_sip_request_get_method(req); if (strcmp(method,"NOTIFY")==0){ - op->set_error_info_from_response(belle_sip_response_event_get_response(event)); - op->root->callbacks.on_notify_response(op); + op->setErrorInfoFromResponse(belle_sip_response_event_get_response(event)); + op->mRoot->mCallbacks.on_notify_response(op); } } -void SalSubscribeOp::subscribe_process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void SalSubscribeOp::subscribeProcessTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { SalSubscribeOp *op = (SalSubscribeOp *)user_ctx; belle_sip_request_t * req; const char *method; @@ -66,33 +66,33 @@ void SalSubscribeOp::subscribe_process_timeout_cb(void *user_ctx, const belle_si method = belle_sip_request_get_method(req); if (strcmp(method,"NOTIFY")==0){ - SalErrorInfo *ei=&op->error_info; + SalErrorInfo *ei=&op->mErrorInfo; sal_error_info_set(ei,SalReasonRequestTimeout, "SIP", 0,NULL,NULL); - op->root->callbacks.on_notify_response(op); + op->mRoot->mCallbacks.on_notify_response(op); } } -void SalSubscribeOp::handle_notify(belle_sip_request_t *req, const char *eventname, SalBodyHandler* body_handler){ +void SalSubscribeOp::handleNotify(belle_sip_request_t *req, const char *eventname, SalBodyHandler* body_handler){ SalSubscribeStatus sub_state; belle_sip_header_subscription_state_t* subscription_state_header=belle_sip_message_get_header_by_type(req,belle_sip_header_subscription_state_t); belle_sip_response_t* resp; - belle_sip_server_transaction_t* server_transaction = this->pending_server_trans; + belle_sip_server_transaction_t* server_transaction = mPendingServerTransaction; if (!subscription_state_header || strcasecmp(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,belle_sip_header_subscription_state_get_state(subscription_state_header)) ==0) { sub_state=SalSubscribeTerminated; - ms_message("Outgoing subscription terminated by remote [%s]",get_to()); + ms_message("Outgoing subscription terminated by remote [%s]",getTo()); } else sub_state=SalSubscribeActive; ref(); - this->root->callbacks.notify(this,sub_state,eventname,body_handler); - resp=create_response_from_request(req,200); + mRoot->mCallbacks.notify(this,sub_state,eventname,body_handler); + resp=createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); unref(); } -void SalSubscribeOp::subscribe_process_request_event_cb(void *op_base, const belle_sip_request_event_t *event) { +void SalSubscribeOp::subscribeProcessRequestEventCb(void *op_base, const belle_sip_request_event_t *event) { SalSubscribeOp * op = (SalSubscribeOp *)op_base; - belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->root->prov,belle_sip_request_event_get_request(event)); + belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->mRoot->mProvider,belle_sip_request_event_get_request(event)); belle_sip_request_t* req = belle_sip_request_event_get_request(event); belle_sip_dialog_state_t dialog_state; belle_sip_header_expires_t* expires = belle_sip_message_get_header_by_type(req,belle_sip_header_expires_t); @@ -104,68 +104,68 @@ void SalSubscribeOp::subscribe_process_request_event_cb(void *op_base, const bel belle_sip_dialog_t *dialog = NULL; belle_sip_object_ref(server_transaction); - if (op->pending_server_trans) belle_sip_object_unref(op->pending_server_trans); - op->pending_server_trans=server_transaction; + if (op->mPendingServerTransaction) belle_sip_object_unref(op->mPendingServerTransaction); + op->mPendingServerTransaction=server_transaction; event_header=belle_sip_message_get_header_by_type(req,belle_sip_header_event_t); - body_handler = BELLE_SIP_BODY_HANDLER(op->get_body_handler(BELLE_SIP_MESSAGE(req))); + body_handler = BELLE_SIP_BODY_HANDLER(op->getBodyHandler(BELLE_SIP_MESSAGE(req))); if (event_header==NULL){ ms_warning("No event header in incoming SUBSCRIBE."); - resp=op->create_response_from_request(req,400); + resp=op->createResponseFromRequest(req,400); belle_sip_server_transaction_send_response(server_transaction,resp); - if (!op->dialog) op->release(); + if (!op->mDialog) op->release(); return; } - if (op->event==NULL) { - op->event=event_header; - belle_sip_object_ref(op->event); + if (op->mEvent==NULL) { + op->mEvent=event_header; + belle_sip_object_ref(op->mEvent); } eventname=belle_sip_header_event_get_package_name(event_header); - if (!op->dialog) { + if (!op->mDialog) { if (strcmp(method,"SUBSCRIBE")==0){ - dialog = belle_sip_provider_create_dialog(op->root->prov,BELLE_SIP_TRANSACTION(server_transaction)); + dialog = belle_sip_provider_create_dialog(op->mRoot->mProvider,BELLE_SIP_TRANSACTION(server_transaction)); if (!dialog){ - resp=op->create_response_from_request(req,481); + resp=op->createResponseFromRequest(req,481); belle_sip_server_transaction_send_response(server_transaction,resp); op->release(); return; } - op->set_or_update_dialog(dialog); - ms_message("new incoming subscription from [%s] to [%s]",op->get_from(),op->get_to()); + op->setOrUpdateDialog(dialog); + ms_message("new incoming subscription from [%s] to [%s]",op->getFrom(),op->getTo()); }else{ /*this is a NOTIFY*/ - op->handle_notify(req, eventname, (SalBodyHandler *)body_handler); + op->handleNotify(req, eventname, (SalBodyHandler *)body_handler); return; } } - dialog_state=belle_sip_dialog_get_state(op->dialog); + dialog_state=belle_sip_dialog_get_state(op->mDialog); switch(dialog_state) { case BELLE_SIP_DIALOG_NULL: { const char *type = NULL; belle_sip_header_content_type_t *content_type = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_content_type_t); if (content_type) type = belle_sip_header_content_type_get_type(content_type); - op->root->callbacks.subscribe_received(op, eventname, type ? (SalBodyHandler *)body_handler : NULL); + op->mRoot->mCallbacks.subscribe_received(op, eventname, type ? (SalBodyHandler *)body_handler : NULL); break; } case BELLE_SIP_DIALOG_EARLY: - ms_error("unexpected method [%s] for dialog [%p] in state BELLE_SIP_DIALOG_EARLY ",belle_sip_request_get_method(req),op->dialog); + ms_error("unexpected method [%s] for dialog [%p] in state BELLE_SIP_DIALOG_EARLY ",belle_sip_request_get_method(req),op->mDialog); break; case BELLE_SIP_DIALOG_CONFIRMED: if (strcmp("NOTIFY",method)==0) { - op->handle_notify(req, eventname, (SalBodyHandler *)body_handler); + op->handleNotify(req, eventname, (SalBodyHandler *)body_handler); } else if (strcmp("SUBSCRIBE",method)==0) { /*either a refresh of an unsubscribe*/ if (expires && belle_sip_header_expires_get_expires(expires)>0) { - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); } else if(expires) { - ms_message("Unsubscribe received from [%s]",op->get_from()); - resp=op->create_response_from_request(req,200); + ms_message("Unsubscribe received from [%s]",op->getFrom()); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); - op->root->callbacks.incoming_subscribe_closed(op); + op->mRoot->mCallbacks.incoming_subscribe_closed(op); } } break; @@ -175,52 +175,52 @@ void SalSubscribeOp::subscribe_process_request_event_cb(void *op_base, const bel } } -void SalSubscribeOp::subscribe_process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { +void SalSubscribeOp::subscribeProcessDialogTerminatedCb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { belle_sip_dialog_t *dialog = belle_sip_dialog_terminated_event_get_dialog(event); SalSubscribeOp * op= (SalSubscribeOp *)ctx; - if (op->dialog) { + if (op->mDialog) { if (belle_sip_dialog_terminated_event_is_expired(event)){ if (!belle_sip_dialog_is_server(dialog)){ /*notify the app that our subscription is dead*/ const char *eventname = NULL; - if (op->event){ - eventname = belle_sip_header_event_get_package_name(op->event); + if (op->mEvent){ + eventname = belle_sip_header_event_get_package_name(op->mEvent); } - op->root->callbacks.notify(op, SalSubscribeTerminated, eventname, NULL); + op->mRoot->mCallbacks.notify(op, SalSubscribeTerminated, eventname, NULL); }else{ - op->root->callbacks.incoming_subscribe_closed(op); + op->mRoot->mCallbacks.incoming_subscribe_closed(op); } } - op->set_or_update_dialog(NULL); + op->setOrUpdateDialog(NULL); } } -void SalSubscribeOp::_release_cb(SalOp *op_base) { +void SalSubscribeOp::releaseCb(SalOp *op_base) { auto *op =reinterpret_cast(op_base); - if(op->refresher) { - belle_sip_refresher_stop(op->refresher); - belle_sip_object_unref(op->refresher); - op->refresher=NULL; - op->set_or_update_dialog(NULL); /*only if we have refresher. else dialog terminated event will remove association*/ + if(op->mRefresher) { + belle_sip_refresher_stop(op->mRefresher); + belle_sip_object_unref(op->mRefresher); + op->mRefresher=NULL; + op->setOrUpdateDialog(NULL); /*only if we have refresher. else dialog terminated event will remove association*/ } } -void SalSubscribeOp::fill_cbs() { +void SalSubscribeOp::fillCallbacks() { static belle_sip_listener_callbacks_t op_subscribe_callbacks={0}; if (op_subscribe_callbacks.process_io_error==NULL){ - op_subscribe_callbacks.process_io_error=subscribe_process_io_error_cb; - op_subscribe_callbacks.process_response_event=subscribe_response_event_cb; - op_subscribe_callbacks.process_timeout=subscribe_process_timeout_cb; - op_subscribe_callbacks.process_transaction_terminated=subscribe_process_transaction_terminated_cb; - op_subscribe_callbacks.process_request_event=subscribe_process_request_event_cb; - op_subscribe_callbacks.process_dialog_terminated=subscribe_process_dialog_terminated_cb; + op_subscribe_callbacks.process_io_error=subscribeProcessIoErrorCb; + op_subscribe_callbacks.process_response_event=subscribeResponseEventCb; + op_subscribe_callbacks.process_timeout=subscribeProcessTimeoutCb; + op_subscribe_callbacks.process_transaction_terminated=subscribeProcessTransactionTerminatedCb; + op_subscribe_callbacks.process_request_event=subscribeProcessRequestEventCb; + op_subscribe_callbacks.process_dialog_terminated=subscribeProcessDialogTerminatedCb; } - this->callbacks=&op_subscribe_callbacks; - this->type=Type::Subscribe; - this->release_cb=_release_cb; + mCallbacks=&op_subscribe_callbacks; + mType=Type::Subscribe; + mReleaseCb=releaseCb; } -void SalSubscribeOp::subscribe_refresher_listener_cb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry) { +void SalSubscribeOp::subscribeRefresherListenerCb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry) { SalSubscribeOp * op = (SalSubscribeOp *)user_pointer; belle_sip_transaction_t *tr=BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher)); /*belle_sip_response_t* response=belle_sip_transaction_get_response(tr);*/ @@ -230,17 +230,17 @@ void SalSubscribeOp::subscribe_refresher_listener_cb (belle_sip_refresher_t* ref if (status_code>=200 && status_code<300){ if (status_code==200) sss=SalSubscribeActive; else if (status_code==202) sss=SalSubscribePending; - op->set_or_update_dialog(belle_sip_transaction_get_dialog(tr)); - op->root->callbacks.subscribe_response(op,sss, will_retry); + op->setOrUpdateDialog(belle_sip_transaction_get_dialog(tr)); + op->mRoot->mCallbacks.subscribe_response(op,sss, will_retry); } else if (status_code >= 300) { SalReason reason = SalReasonUnknown; if (status_code == 503) { /*refresher returns 503 for IO error*/ reason = SalReasonIOError; } - sal_error_info_set(&op->error_info, reason, "SIP", (int)status_code, reason_phrase, NULL); - op->root->callbacks.subscribe_response(op,sss, will_retry); + sal_error_info_set(&op->mErrorInfo, reason, "SIP", (int)status_code, reason_phrase, NULL); + op->mRoot->mCallbacks.subscribe_response(op,sss, will_retry); }else if (status_code==0){ - op->root->callbacks.on_expire(op); + op->mRoot->mCallbacks.on_expire(op); } } @@ -249,63 +249,63 @@ int SalSubscribeOp::subscribe(const char *from, const char *to, const char *even belle_sip_request_t *req=NULL; if (from) - set_from(from); + setFrom(from); if (to) - set_to(to); + setTo(to); - if (!this->dialog){ - fill_cbs(); - req=build_request("SUBSCRIBE"); + if (!mDialog){ + fillCallbacks(); + req=buildRequest("SUBSCRIBE"); if( req == NULL ) { return -1; } - set_event(eventname); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(this->event)); + setEvent(eventname); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(mEvent)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(expires))); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(body_handler)); - return send_and_create_refresher(req,expires,subscribe_refresher_listener_cb); - }else if (this->refresher){ - const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(this->refresher); + return sendRequestAndCreateRefresher(req,expires,subscribeRefresherListenerCb); + }else if (mRefresher){ + const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(mRefresher); belle_sip_request_t *last_req=belle_sip_transaction_get_request(tr); /* modify last request to update body*/ belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(last_req), BELLE_SIP_BODY_HANDLER(body_handler)); - return belle_sip_refresher_refresh(this->refresher,expires); + return belle_sip_refresher_refresh(mRefresher,expires); } ms_warning("sal_subscribe(): no dialog and no refresher ?"); return -1; } int SalSubscribeOp::accept() { - belle_sip_request_t* req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(this->pending_server_trans)); + belle_sip_request_t* req=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(mPendingServerTransaction)); belle_sip_header_expires_t* expires = belle_sip_message_get_header_by_type(req,belle_sip_header_expires_t); - belle_sip_response_t* resp = create_response_from_request(req,200); + belle_sip_response_t* resp = createResponseFromRequest(req,200); belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(expires)); - belle_sip_server_transaction_send_response(this->pending_server_trans,resp); + belle_sip_server_transaction_send_response(mPendingServerTransaction,resp); return 0; } int SalSubscribeOp::decline(SalReason reason) { - belle_sip_response_t* resp = belle_sip_response_create_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(this->pending_server_trans)), + belle_sip_response_t* resp = belle_sip_response_create_from_request(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(mPendingServerTransaction)), to_sip_code(reason)); - belle_sip_server_transaction_send_response(this->pending_server_trans,resp); + belle_sip_server_transaction_send_response(mPendingServerTransaction,resp); return 0; } -int SalSubscribeOp::notify_pending_state() { +int SalSubscribeOp::notifyPendingState() { - if (this->dialog != NULL && this->pending_server_trans) { + if (mDialog != NULL && mPendingServerTransaction) { belle_sip_request_t* notify; belle_sip_header_subscription_state_t* sub_state; ms_message("Sending NOTIFY with subscription state pending for op [%p]", this); - if (!(notify=belle_sip_dialog_create_request(this->dialog,"NOTIFY"))) { + if (!(notify=belle_sip_dialog_create_request(mDialog,"NOTIFY"))) { ms_error("Cannot create NOTIFY on op [%p]", this); return -1; } - if (this->event) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(this->event)); + if (mEvent) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(mEvent)); sub_state=belle_sip_header_subscription_state_new(); belle_sip_header_subscription_state_set_state(sub_state,BELLE_SIP_SUBSCRIPTION_STATE_PENDING); belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify), BELLE_SIP_HEADER(sub_state)); - return send_request(notify); + return sendRequest(notify); } else { ms_warning("NOTIFY with subscription state pending for op [%p] not implemented in this case (either dialog pending trans does not exist", this); } @@ -316,101 +316,101 @@ int SalSubscribeOp::notify_pending_state() { int SalSubscribeOp::notify(const SalBodyHandler *body_handler) { belle_sip_request_t* notify; - if (this->dialog){ - if (!(notify=belle_sip_dialog_create_queued_request(this->dialog,"NOTIFY"))) return -1; + if (mDialog){ + if (!(notify=belle_sip_dialog_create_queued_request(mDialog,"NOTIFY"))) return -1; }else{ - fill_cbs(); - notify = build_request("NOTIFY"); + fillCallbacks(); + notify = buildRequest("NOTIFY"); } - if (this->event) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(this->event)); + if (mEvent) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(mEvent)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify) - , this->dialog ? + , mDialog ? BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_ACTIVE,600)) : BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,0)) ); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(notify), BELLE_SIP_BODY_HANDLER(body_handler)); - return send_request(notify); + return sendRequest(notify); } -int SalSubscribeOp::close_notify() { +int SalSubscribeOp::closeNotify() { belle_sip_request_t* notify; - if (!this->dialog) return -1; - if (!(notify=belle_sip_dialog_create_queued_request(this->dialog,"NOTIFY"))) return -1; - if (this->event) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(this->event)); + if (!mDialog) return -1; + if (!(notify=belle_sip_dialog_create_queued_request(mDialog,"NOTIFY"))) return -1; + if (mEvent) belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify),BELLE_SIP_HEADER(mEvent)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify) ,BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,-1))); - return send_request(notify); + return sendRequest(notify); } -void SalPublishOp::publish_response_event_cb(void *userctx, const belle_sip_response_event_t *event) { +void SalPublishOp::publishResponseEventCb(void *userctx, const belle_sip_response_event_t *event) { SalPublishOp *op=(SalPublishOp *)userctx; - op->set_error_info_from_response(belle_sip_response_event_get_response(event)); - if (op->error_info.protocol_code>=200){ - op->root->callbacks.on_publish_response(op); + op->setErrorInfoFromResponse(belle_sip_response_event_get_response(event)); + if (op->mErrorInfo.protocol_code>=200){ + op->mRoot->mCallbacks.on_publish_response(op); } } -void SalPublishOp::fill_cbs() { +void SalPublishOp::fillCallbacks() { static belle_sip_listener_callbacks_t op_publish_callbacks={0}; if (op_publish_callbacks.process_response_event==NULL){ - op_publish_callbacks.process_response_event=publish_response_event_cb; + op_publish_callbacks.process_response_event=publishResponseEventCb; } - this->callbacks=&op_publish_callbacks; - this->type=Type::Publish; + mCallbacks=&op_publish_callbacks; + mType=Type::Publish; } -void SalPublishOp::publish_refresher_listener_cb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry) { +void SalPublishOp::publishRefresherListenerCb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry) { SalPublishOp * op = (SalPublishOp *)user_pointer; - const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher); + const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->mRefresher); belle_sip_response_t *response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(last_publish_trans)); - ms_message("Publish refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase?reason_phrase:"none",op->get_proxy()); + ms_message("Publish refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase?reason_phrase:"none",op->getProxy()); if (status_code==0){ - op->root->callbacks.on_expire(op); + op->mRoot->mCallbacks.on_expire(op); }else if (status_code>=200){ belle_sip_header_t *sip_etag; const char *sip_etag_string = NULL; if (response && (sip_etag = belle_sip_message_get_header(BELLE_SIP_MESSAGE(response), "SIP-ETag"))) { sip_etag_string = belle_sip_header_get_unparsed_value(sip_etag); } - op->set_entity_tag(sip_etag_string); - sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", (int)status_code, reason_phrase, NULL); - op->assign_recv_headers((belle_sip_message_t*)response); - op->root->callbacks.on_publish_response(op); + op->setEntityTag(sip_etag_string); + sal_error_info_set(&op->mErrorInfo,SalReasonUnknown, "SIP", (int)status_code, reason_phrase, NULL); + op->assignRecvHeaders((belle_sip_message_t*)response); + op->mRoot->mCallbacks.on_publish_response(op); } } int SalPublishOp::publish(const char *from, const char *to, const char *eventname, int expires, const SalBodyHandler *body_handler) { belle_sip_request_t *req=NULL; - if(!this->refresher || !belle_sip_refresher_get_transaction(this->refresher)) { + if(!mRefresher || !belle_sip_refresher_get_transaction(mRefresher)) { if (from) - set_from(from); + setFrom(from); if (to) - set_to(to); + setTo(to); - fill_cbs(); - req=build_request("PUBLISH"); + fillCallbacks(); + req=buildRequest("PUBLISH"); if( req == NULL ){ return -1; } - if (get_entity_tag()) { - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("SIP-If-Match", get_entity_tag())); + if (getEntityTag()) { + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("SIP-If-Match", getEntityTag())); } - if (get_contact_address()){ - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(create_contact())); + if (getContactAddress()){ + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(createContact())); } belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event",eventname)); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(body_handler)); if (expires!=-1) - return send_and_create_refresher(req,expires,publish_refresher_listener_cb); - else return send_request(req); + return sendRequestAndCreateRefresher(req,expires,publishRefresherListenerCb); + else return sendRequest(req); } else { /*update status*/ - const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(this->refresher); + const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(mRefresher); belle_sip_request_t* last_publish=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_publish_trans)); /*update body*/ if (expires == 0) { @@ -418,16 +418,16 @@ int SalPublishOp::publish(const char *from, const char *to, const char *eventnam } else { belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(last_publish), BELLE_SIP_BODY_HANDLER(body_handler)); } - return belle_sip_refresher_refresh(this->refresher,expires==-1 ? BELLE_SIP_REFRESHER_REUSE_EXPIRES : expires); + return belle_sip_refresher_refresh(mRefresher,expires==-1 ? BELLE_SIP_REFRESHER_REUSE_EXPIRES : expires); } } int SalPublishOp::unpublish() { - if (this->refresher){ - const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(this->refresher); + if (mRefresher){ + const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(mRefresher); belle_sip_request_t *last_req=belle_sip_transaction_get_request(tr); belle_sip_message_set_body(BELLE_SIP_MESSAGE(last_req), NULL, 0); - belle_sip_refresher_refresh(this->refresher,0); + belle_sip_refresher_refresh(mRefresher,0); return 0; } return -1; diff --git a/src/sal/event-op.h b/src/sal/event-op.h index 585adbbab..4b4f3b7f0 100644 --- a/src/sal/event-op.h +++ b/src/sal/event-op.h @@ -24,49 +24,49 @@ LINPHONE_BEGIN_NAMESPACE -class SalEventOp: public SalOp { +class SalEventOp : public SalOp { public: - SalEventOp(Sal *sal): SalOp(sal) {} + SalEventOp (Sal *sal) : SalOp(sal) {} }; class SalSubscribeOp: public SalEventOp { public: - SalSubscribeOp(Sal *sal): SalEventOp(sal) {} + SalSubscribeOp (Sal *sal): SalEventOp(sal) {} - int subscribe(const char *from, const char *to, const char *eventname, int expires, const SalBodyHandler *body_handler); - int unsubscribe() {return SalOp::unsubscribe();} - int accept(); - int decline(SalReason reason); - int notify_pending_state(); - int notify(const SalBodyHandler *body_handler); - int close_notify(); + int subscribe (const char *from, const char *to, const char *eventName, int expires, const SalBodyHandler *bodyHandler); + int unsubscribe () { return SalOp::unsubscribe(); } + int accept (); + int decline (SalReason reason); + int notifyPendingState (); + int notify (const SalBodyHandler *bodyHandler); + int closeNotify (); private: - virtual void fill_cbs() override; - void handle_notify(belle_sip_request_t *req, const char *eventname, SalBodyHandler* body_handler); + virtual void fillCallbacks () override; + void handleNotify (belle_sip_request_t *request, const char *eventName, SalBodyHandler *bodyHandler); - static void subscribe_process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static void subscribe_response_event_cb(void *op_base, const belle_sip_response_event_t *event); - static void subscribe_process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void subscribe_process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) {} - static void subscribe_process_request_event_cb(void *op_base, const belle_sip_request_event_t *event); - static void subscribe_process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event); - static void _release_cb(SalOp *op_base); - static void subscribe_refresher_listener_cb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry); + static void subscribeProcessIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static void subscribeResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void subscribeProcessTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void subscribeProcessTransactionTerminatedCb (void *userCtx, const belle_sip_transaction_terminated_event_t *event) {} + static void subscribeProcessRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); + static void subscribeProcessDialogTerminatedCb (void *userCtx, const belle_sip_dialog_terminated_event_t *event); + static void releaseCb (SalOp *op); + static void subscribeRefresherListenerCb (belle_sip_refresher_t *refresher, void *userCtx, unsigned int statusCode, const char *reasonPhrase, int willRetry); }; -class SalPublishOp: public SalEventOp { +class SalPublishOp : public SalEventOp { public: - SalPublishOp(Sal *sal): SalEventOp(sal) {} + SalPublishOp (Sal *sal) : SalEventOp(sal) {} - int publish(const char *from, const char *to, const char *eventname, int expires, const SalBodyHandler *body_handler); - int unpublish(); + int publish (const char *from, const char *to, const char *eventName, int expires, const SalBodyHandler *bodyHandler); + int unpublish (); private: - virtual void fill_cbs() override; + virtual void fillCallbacks () override; - static void publish_response_event_cb(void *userctx, const belle_sip_response_event_t *event); - static void publish_refresher_listener_cb (belle_sip_refresher_t* refresher,void* user_pointer,unsigned int status_code,const char* reason_phrase, int will_retry); + static void publishResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void publishRefresherListenerCb (belle_sip_refresher_t *refresher, void *userCtx, unsigned int statusCode, const char *reasonPhrase, int willRetry); }; LINPHONE_END_NAMESPACE diff --git a/src/sal/message-op-interface.h b/src/sal/message-op-interface.h index 981f20e1d..79ee4debd 100644 --- a/src/sal/message-op-interface.h +++ b/src/sal/message-op-interface.h @@ -32,7 +32,7 @@ public: virtual ~SalMessageOpInterface() = default; virtual int sendMessage (const Content &content) = 0; - virtual int reply(SalReason reason) = 0; + virtual int reply (SalReason reason) = 0; protected: void prepareMessageRequest (belle_sip_request_t *req, const Content &content) { diff --git a/src/sal/message-op.cpp b/src/sal/message-op.cpp index 29acdab93..c7d882b39 100644 --- a/src/sal/message-op.cpp +++ b/src/sal/message-op.cpp @@ -23,26 +23,26 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -void SalMessageOp::process_error() { - if (this->dir == Dir::Outgoing) { - this->root->callbacks.message_delivery_update(this, SalMessageDeliveryFailed); +void SalMessageOp::processError() { + if (mDir == Dir::Outgoing) { + mRoot->mCallbacks.message_delivery_update(this, SalMessageDeliveryFailed); } else { ms_warning("unexpected io error for incoming message on op [%p]", this); } - this->state=State::Terminated; + mState=State::Terminated; } -void SalMessageOp::process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event) { +void SalMessageOp::processIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event) { SalMessageOp * op = (SalMessageOp *)user_ctx; - sal_error_info_set(&op->error_info,SalReasonIOError, "SIP", 503,"IO Error",NULL); - op->process_error(); + sal_error_info_set(&op->mErrorInfo,SalReasonIOError, "SIP", 503,"IO Error",NULL); + op->processError(); } -void SalMessageOp::process_response_event_cb(void *op_base, const belle_sip_response_event_t *event) { +void SalMessageOp::processResponseEventCb(void *op_base, const belle_sip_response_event_t *event) { SalMessageOp * op = (SalMessageOp *)op_base; int code = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event)); SalMessageDeliveryStatus status; - op->set_error_info_from_response(belle_sip_response_event_get_response(event)); + op->setErrorInfoFromResponse(belle_sip_response_event_get_response(event)); if (code>=100 && code <200) status=SalMessageDeliveryInProgress; @@ -51,40 +51,40 @@ void SalMessageOp::process_response_event_cb(void *op_base, const belle_sip_resp else status=SalMessageDeliveryFailed; - op->root->callbacks.message_delivery_update(op,status); + op->mRoot->mCallbacks.message_delivery_update(op,status); } -void SalMessageOp::process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void SalMessageOp::processTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { SalMessageOp * op=(SalMessageOp *)user_ctx; - sal_error_info_set(&op->error_info,SalReasonRequestTimeout, "SIP", 408,"Request timeout",NULL); - op->process_error(); + sal_error_info_set(&op->mErrorInfo,SalReasonRequestTimeout, "SIP", 408,"Request timeout",NULL); + op->processError(); } -void SalMessageOp::process_request_event_cb(void *op_base, const belle_sip_request_event_t *event) { +void SalMessageOp::processRequestEventCb(void *op_base, const belle_sip_request_event_t *event) { SalMessageOp * op = (SalMessageOp *)op_base; - op->process_incoming_message(event); + op->processIncomingMessage(event); } -void SalMessageOp::fill_cbs() { +void SalMessageOp::fillCallbacks() { static belle_sip_listener_callbacks_t op_message_callbacks = {0}; if (op_message_callbacks.process_io_error==NULL) { - op_message_callbacks.process_io_error=process_io_error_cb; - op_message_callbacks.process_response_event=process_response_event_cb; - op_message_callbacks.process_timeout=process_timeout_cb; - op_message_callbacks.process_request_event=process_request_event_cb; + op_message_callbacks.process_io_error=processIoErrorCb; + op_message_callbacks.process_response_event=processResponseEventCb; + op_message_callbacks.process_timeout=processTimeoutCb; + op_message_callbacks.process_request_event=processRequestEventCb; } - this->callbacks=&op_message_callbacks; - this->type=Type::Message; + mCallbacks=&op_message_callbacks; + mType=Type::Message; } int SalMessageOp::sendMessage (const Content &content) { - fill_cbs(); - this->dir = Dir::Outgoing; - belle_sip_request_t *req = build_request("MESSAGE"); + fillCallbacks(); + mDir = Dir::Outgoing; + belle_sip_request_t *req = buildRequest("MESSAGE"); if (!req) return -1; prepareMessageRequest(req, content); - return send_request(req); + return sendRequest(req); } LINPHONE_END_NAMESPACE diff --git a/src/sal/message-op.h b/src/sal/message-op.h index 922cc0381..73cd9efae 100644 --- a/src/sal/message-op.h +++ b/src/sal/message-op.h @@ -25,21 +25,21 @@ LINPHONE_BEGIN_NAMESPACE -class SalMessageOp: public SalOp, public SalMessageOpInterface { +class SalMessageOp : public SalOp, public SalMessageOpInterface { public: - SalMessageOp(Sal *sal): SalOp(sal) {} + SalMessageOp (Sal *sal) : SalOp(sal) {} int sendMessage (const Content &content) override; - int reply(SalReason reason) override {return SalOp::reply_message(reason);} + int reply (SalReason reason) override { return SalOp::replyMessage(reason); } private: - virtual void fill_cbs() override; - void process_error(); + virtual void fillCallbacks () override; + void processError (); - static void process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static void process_response_event_cb(void *op_base, const belle_sip_response_event_t *event); - static void process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void process_request_event_cb(void *op_base, const belle_sip_request_event_t *event); + static void processIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static void processResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void processTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void processRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); }; LINPHONE_END_NAMESPACE diff --git a/src/sal/op.cpp b/src/sal/op.cpp index 33a641906..51a8112c5 100644 --- a/src/sal/op.cpp +++ b/src/sal/op.cpp @@ -27,135 +27,135 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE SalOp::SalOp(Sal *sal) { - this->root = sal; - this->sdp_handling = sal->default_sdp_handling; - memset(&this->error_info, 0, sizeof(this->error_info)); - memset(&this->reason_error_info, 0, sizeof(this->reason_error_info)); + mRoot = sal; + mSdpHandling = sal->mDefaultSdpHandling; + memset(&mErrorInfo, 0, sizeof(mErrorInfo)); + memset(&mReasonErrorInfo, 0, sizeof(mReasonErrorInfo)); ref(); } SalOp::~SalOp() { - ms_message("Destroying op [%p] of type [%s]",this,to_string(this->type)); + ms_message("Destroying op [%p] of type [%s]",this,toString(mType)); - if (this->pending_auth_transaction) belle_sip_object_unref(this->pending_auth_transaction); - this->root->remove_pending_auth(this); - if (this->auth_info) { - sal_auth_info_delete(this->auth_info); + if (mPendingAuthTransaction) belle_sip_object_unref(mPendingAuthTransaction); + mRoot->removePendingAuth(this); + if (mAuthInfo) { + sal_auth_info_delete(mAuthInfo); } - if (this->sdp_answer) belle_sip_object_unref(this->sdp_answer); - if (this->refresher) { - belle_sip_object_unref(this->refresher); - this->refresher=NULL; + if (mSdpAnswer) belle_sip_object_unref(mSdpAnswer); + if (mRefresher) { + belle_sip_object_unref(mRefresher); + mRefresher=NULL; } - if (this->result) - sal_media_description_unref(this->result); - if(this->replaces) belle_sip_object_unref(this->replaces); - if(this->referred_by) belle_sip_object_unref(this->referred_by); + if (mResult) + sal_media_description_unref(mResult); + if(mReplaces) belle_sip_object_unref(mReplaces); + if(mReferredBy) belle_sip_object_unref(mReferredBy); - if (this->pending_client_trans) belle_sip_object_unref(this->pending_client_trans); - if (this->pending_server_trans) belle_sip_object_unref(this->pending_server_trans); - if (this->pending_update_server_trans) belle_sip_object_unref(this->pending_update_server_trans); - if (this->event) belle_sip_object_unref(this->event); + if (mPendingClientTransaction) belle_sip_object_unref(mPendingClientTransaction); + if (mPendingServerTransaction) belle_sip_object_unref(mPendingServerTransaction); + if (mPendingUpdateServerTransaction) belle_sip_object_unref(mPendingUpdateServerTransaction); + if (mEvent) belle_sip_object_unref(mEvent); - sal_error_info_reset(&this->error_info); - if (this->from_address){ - sal_address_destroy(this->from_address); - this->from_address=NULL; + sal_error_info_reset(&mErrorInfo); + if (mFromAddress){ + sal_address_destroy(mFromAddress); + mFromAddress=NULL; } - if (this->to_address){ - sal_address_destroy(this->to_address); - this->to_address=NULL; + if (mToAddress){ + sal_address_destroy(mToAddress); + mToAddress=NULL; } - if (this->service_route){ - sal_address_destroy(this->service_route); - this->service_route=NULL; + if (mServiceRoute){ + sal_address_destroy(mServiceRoute); + mServiceRoute=NULL; } - if (this->origin_address){ - sal_address_destroy(this->origin_address); - this->origin_address=NULL; + if (mOriginAddress){ + sal_address_destroy(mOriginAddress); + mOriginAddress=NULL; } - if (this->from) { - ms_free(this->from); - this->from=NULL; + if (mFrom) { + ms_free(mFrom); + mFrom=NULL; } - if (this->to) { - ms_free(this->to); - this->to=NULL; + if (mTo) { + ms_free(mTo); + mTo=NULL; } - if (this->subject) { - ms_free(this->subject); - this->subject = NULL; + if (mSubject) { + ms_free(mSubject); + mSubject = NULL; } - if (this->route) { - ms_free(this->route); - this->route=NULL; + if (mRoute) { + ms_free(mRoute); + mRoute=NULL; } - if (this->realm) { - ms_free(this->realm); - this->realm=NULL; + if (mRealm) { + ms_free(mRealm); + mRealm=NULL; } - if (this->contact_address) { - sal_address_destroy(this->contact_address); + if (mContactAddress) { + sal_address_destroy(mContactAddress); } - if (this->origin){ - ms_free(this->origin); - this->origin=NULL; + if (mOrigin){ + ms_free(mOrigin); + mOrigin=NULL; } - if (this->remote_ua){ - ms_free(this->remote_ua); - this->remote_ua=NULL; + if (mRemoteUserAgent){ + ms_free(mRemoteUserAgent); + mRemoteUserAgent=NULL; } - if (this->remote_contact){ - ms_free(this->remote_contact); - this->remote_contact=NULL; + if (mRemoteContact){ + ms_free(mRemoteContact); + mRemoteContact=NULL; } - if (this->remote_contact_address){ - sal_address_destroy(this->remote_contact_address); + if (mRemoteContactAddress){ + sal_address_destroy(mRemoteContactAddress); } - if (this->call_id) - ms_free(this->call_id); - if (this->service_route) { - sal_address_destroy(this->service_route); + if (mCallId) + ms_free(mCallId); + if (mServiceRoute) { + sal_address_destroy(mServiceRoute); } - if (this->route_addresses){ - bctbx_list_for_each(this->route_addresses,(void (*)(void*)) sal_address_destroy); - this->route_addresses=bctbx_list_free(this->route_addresses); + if (mRouteAddresses){ + bctbx_list_for_each(mRouteAddresses,(void (*)(void*)) sal_address_destroy); + mRouteAddresses=bctbx_list_free(mRouteAddresses); } - if (this->recv_custom_headers) - sal_custom_header_free(this->recv_custom_headers); - if (this->sent_custom_headers) - sal_custom_header_free(this->sent_custom_headers); + if (mRecvCustomHeaders) + sal_custom_header_free(mRecvCustomHeaders); + if (mSentCustomHeaders) + sal_custom_header_free(mSentCustomHeaders); - if (this->entity_tag != NULL){ - ms_free(this->entity_tag); - this->entity_tag = NULL; + if (mEntityTag != NULL){ + ms_free(mEntityTag); + mEntityTag = NULL; } } SalOp *SalOp::ref() { - _ref++; + mRef++; return this; } void *SalOp::unref() { - _ref--; - if (_ref==0) { + mRef--; + if (mRef==0) { delete this; - } else if (_ref<0) { + } else if (mRef<0) { ms_fatal("SalOp [%p]: too many unrefs.",this); } return NULL; } -void SalOp::set_contact_address(const SalAddress *address) { - if (this->contact_address) sal_address_destroy(this->contact_address); - this->contact_address=address?sal_address_clone(address):NULL; +void SalOp::setContactAddress(const SalAddress *address) { + if (mContactAddress) sal_address_destroy(mContactAddress); + mContactAddress=address?sal_address_clone(address):NULL; } -void SalOp::assign_address(SalAddress** address, const char *value) { +void SalOp::assignAddress(SalAddress** address, const char *value) { if (*address){ sal_address_destroy(*address); *address=NULL; @@ -164,7 +164,7 @@ void SalOp::assign_address(SalAddress** address, const char *value) { *address=sal_address_new(value); } -void SalOp::assign_string(char **str, const char *arg) { +void SalOp::assignString(char **str, const char *arg) { if (*str){ ms_free(*str); *str=NULL; @@ -173,126 +173,129 @@ void SalOp::assign_string(char **str, const char *arg) { *str=ms_strdup(arg); } -void SalOp::set_route(const char *route) { +void SalOp::setRoute(const char *route) { char* route_string=NULL; - if (this->route_addresses) { - bctbx_list_for_each(this->route_addresses,(void (*)(void *))sal_address_destroy); - this->route_addresses=bctbx_list_free(this->route_addresses); + if (mRouteAddresses) { + bctbx_list_for_each(mRouteAddresses,(void (*)(void *))sal_address_destroy); + mRouteAddresses=bctbx_list_free(mRouteAddresses); } if (route) { - this->route_addresses=bctbx_list_append(NULL,NULL); - assign_address((SalAddress**)&(this->route_addresses->data),route); - route_string=sal_address_as_string((SalAddress*)this->route_addresses->data); + mRouteAddresses=bctbx_list_append(NULL,NULL); + assignAddress((SalAddress**)&(mRouteAddresses->data),route); + route_string=sal_address_as_string((SalAddress*)mRouteAddresses->data); } - assign_string(&this->route,route_string); + assignString(&mRoute,route_string); if(route_string) ms_free(route_string); } -void SalOp::set_route_address(const SalAddress *address){ +void SalOp::setRouteAddress(const SalAddress *address){ char* address_string=sal_address_as_string(address); /*can probably be optimized*/ - set_route(address_string); + setRoute(address_string); ms_free(address_string); } -void SalOp::add_route_address(const SalAddress *address) { - if (this->route_addresses) { - this->route_addresses=bctbx_list_append(this->route_addresses,(void*)sal_address_clone(address)); +void SalOp::addRouteAddress(const SalAddress *address) { + if (mRouteAddresses) { + mRouteAddresses=bctbx_list_append(mRouteAddresses,(void*)sal_address_clone(address)); } else { - set_route_address(address); + setRouteAddress(address); } } -void SalOp::set_realm(const char *realm) { - if (this->realm != NULL){ - ms_free(this->realm); +void SalOp::setRealm(const char *realm) { + if (mRealm != NULL){ + ms_free(mRealm); } - this->realm = ms_strdup(realm); + mRealm = ms_strdup(realm); } -#define SET_PARAM(name) \ - char* name##_string=NULL; \ - assign_address(&this->name##_address,name); \ - if (this->name##_address) { \ - name##_string=sal_address_as_string(this->name##_address); \ - }\ - assign_string(&this->name,name##_string); \ - if(name##_string) ms_free(name##_string); - -void SalOp::set_subject (const char *subject) { - assign_string(&this->subject, subject); +void SalOp::setSubject (const char *subject) { + assignString(&mSubject, subject); } -void SalOp::set_from(const char *from){ - SET_PARAM(from); +void SalOp::setFrom (const char *value) { + char *valueStr = nullptr; + assignAddress(&mFromAddress, value); + if (mFromAddress) + valueStr = sal_address_as_string(mFromAddress); + assignString(&mFrom, valueStr); + if (valueStr) + ms_free(valueStr); } -void SalOp::set_from_address(const SalAddress *from) { +void SalOp::setFromAddress(const SalAddress *from) { char* address_string=sal_address_as_string(from); /*can probably be optimized*/ - set_from(address_string); + setFrom(address_string); ms_free(address_string); } -void SalOp::set_to(const char *to) { - SET_PARAM(to); +void SalOp::setTo (const char *value) { + char *valueStr = nullptr; + assignAddress(&mToAddress, value); + if (mToAddress) + valueStr = sal_address_as_string(mToAddress); + assignString(&mTo, valueStr); + if (valueStr) + ms_free(valueStr); } -void SalOp::set_to_address(const SalAddress *to) { +void SalOp::setToAddress(const SalAddress *to) { char* address_string=sal_address_as_string(to); /*can probably be optimized*/ - set_to(address_string); + setTo(address_string); ms_free(address_string); } -void SalOp::set_diversion_address(const SalAddress *diversion) { - if (this->diversion_address) sal_address_destroy(this->diversion_address); - this->diversion_address=diversion ? sal_address_clone(diversion) : NULL; +void SalOp::setDiversionAddress(const SalAddress *diversion) { + if (mDiversionAddress) sal_address_destroy(mDiversionAddress); + mDiversionAddress=diversion ? sal_address_clone(diversion) : NULL; } int SalOp::refresh() { - if (this->refresher) { - belle_sip_refresher_refresh(this->refresher,belle_sip_refresher_get_expires(this->refresher)); + if (mRefresher) { + belle_sip_refresher_refresh(mRefresher,belle_sip_refresher_get_expires(mRefresher)); return 0; } - ms_warning("sal_refresh on op [%p] of type [%s] no refresher",this,to_string(this->type)); + ms_warning("sal_refresh on op [%p] of type [%s] no refresher",this,toString(mType)); return -1; } -void SalOp::kill_dialog() { - ms_warning("op [%p]: force kill of dialog [%p]", this, this->dialog); - belle_sip_dialog_delete(this->dialog); +void SalOp::killDialog() { + ms_warning("op [%p]: force kill of dialog [%p]", this, mDialog); + belle_sip_dialog_delete(mDialog); } void SalOp::release() { /*if in terminating state, keep this state because it means we are waiting for a response to be able to terminate the operation.*/ - if (this->state!=State::Terminating) - this->state=State::Terminated; - set_user_pointer(NULL);/*mandatory because releasing op doesn't not mean freeing op. Make sure back pointer will not be used later*/ - if (this->release_cb) - this->release_cb(this); - if (this->refresher) { - belle_sip_refresher_stop(this->refresher); + if (mState!=State::Terminating) + mState=State::Terminated; + setUserPointer(NULL);/*mandatory because releasing op doesn't not mean freeing op. Make sure back pointer will not be used later*/ + if (mReleaseCb) + mReleaseCb(this); + if (mRefresher) { + belle_sip_refresher_stop(mRefresher); } - this->op_released = TRUE; + mOpReleased = TRUE; unref(); } -int SalOp::send_request_with_contact(belle_sip_request_t* request, bool_t add_contact) { +int SalOp::sendRequestWithContact(belle_sip_request_t* request, bool_t add_contact) { belle_sip_client_transaction_t* client_transaction; - belle_sip_provider_t* prov=this->root->prov; + belle_sip_provider_t* prov=mRoot->mProvider; belle_sip_uri_t* outbound_proxy=NULL; belle_sip_header_contact_t* contact; int result =-1; belle_sip_uri_t *next_hop_uri=NULL; if (add_contact && !belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_contact_t)) { - contact = create_contact(); + contact = createContact(); belle_sip_message_set_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(contact)); } /*keep existing*/ - add_custom_headers((belle_sip_message_t*)request); + addCustomHeaders((belle_sip_message_t*)request); - if (!this->dialog || belle_sip_dialog_get_state(this->dialog) == BELLE_SIP_DIALOG_NULL) { + if (!mDialog || belle_sip_dialog_get_state(mDialog) == BELLE_SIP_DIALOG_NULL) { /*don't put route header if dialog is in confirmed state*/ - const MSList *elem=get_route_addresses(); + const MSList *elem=getRouteAddresses(); const char *transport; const char *method=belle_sip_request_get_method(request); belle_sip_listening_point_t *udplp=belle_sip_provider_get_listening_point(prov,"UDP"); @@ -341,31 +344,31 @@ int SalOp::send_request_with_contact(belle_sip_request_t* request, bool_t add_co client_transaction = belle_sip_provider_create_client_transaction(prov,request); belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),ref()); - if (this->pending_client_trans) belle_sip_object_unref(this->pending_client_trans); + if (mPendingClientTransaction) belle_sip_object_unref(mPendingClientTransaction); - this->pending_client_trans=client_transaction; /*update pending inv for being able to cancel*/ - belle_sip_object_ref(this->pending_client_trans); + mPendingClientTransaction=client_transaction; /*update pending inv for being able to cancel*/ + belle_sip_object_ref(mPendingClientTransaction); if (belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request),belle_sip_header_user_agent_t)==NULL) - belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(this->root->user_agent)); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(mRoot->mUserAgent)); if (!belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_AUTHORIZATION) && !belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_PROXY_AUTHORIZATION)) { /*hmm just in case we already have authentication param in cache*/ - belle_sip_provider_add_authorization(this->root->prov,request,NULL,NULL,NULL,this->realm); + belle_sip_provider_add_authorization(mRoot->mProvider,request,NULL,NULL,NULL,mRealm); } result = belle_sip_client_transaction_send_request_to(client_transaction,next_hop_uri/*might be null*/); /*update call id if not set yet for this OP*/ - if (result == 0 && !this->call_id) { - this->call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request), belle_sip_header_call_id_t)))); + if (result == 0 && !mCallId) { + mCallId=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(request), belle_sip_header_call_id_t)))); } return result; } -int SalOp::send_request(belle_sip_request_t* request) { +int SalOp::sendRequest(belle_sip_request_t* request) { bool_t need_contact=FALSE; if (request==NULL) { return -1; /*sanity check*/ @@ -382,18 +385,18 @@ int SalOp::send_request(belle_sip_request_t* request) { ||strcmp(belle_sip_request_get_method(request),"REFER")==0) /* Despite contact seems not mandatory, call flow example show a Contact in REFER requests*/ need_contact=TRUE; - return send_request_with_contact(request,need_contact); + return sendRequestWithContact(request,need_contact); } -void SalOp::resend_request(belle_sip_request_t* request) { +void SalOp::resendRequest(belle_sip_request_t* request) { belle_sip_header_cseq_t* cseq=(belle_sip_header_cseq_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_CSEQ); belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1); - send_request(request); + sendRequest(request); } -int SalOp::process_redirect(){ - belle_sip_request_t* request = belle_sip_transaction_get_request((belle_sip_transaction_t*)this->pending_client_trans); - belle_sip_response_t *response = belle_sip_transaction_get_response((belle_sip_transaction_t*)this->pending_client_trans); +int SalOp::processRedirect(){ + belle_sip_request_t* request = belle_sip_transaction_get_request((belle_sip_transaction_t*)mPendingClientTransaction); + belle_sip_response_t *response = belle_sip_transaction_get_response((belle_sip_transaction_t*)mPendingClientTransaction); belle_sip_header_contact_t *redirect_contact = belle_sip_message_get_header_by_type((belle_sip_message_t*)response, belle_sip_header_contact_t); belle_sip_uri_t *redirect_uri; belle_sip_header_call_id_t *callid = belle_sip_message_get_header_by_type((belle_sip_message_t*)request, belle_sip_header_call_id_t); @@ -411,46 +414,46 @@ int SalOp::process_redirect(){ return -1; } - if (this->dialog && belle_sip_dialog_get_state(this->dialog)==BELLE_SIP_DIALOG_CONFIRMED){ + if (mDialog && belle_sip_dialog_get_state(mDialog)==BELLE_SIP_DIALOG_CONFIRMED){ ms_warning("Redirect not handled within established dialogs. Does it make sense ?"); return -1; } - set_or_update_dialog(NULL); + setOrUpdateDialog(NULL); belle_sip_message_remove_header_from_ptr((belle_sip_message_t*)request, (belle_sip_header_t*)callid); - belle_sip_message_add_header((belle_sip_message_t*)request, (belle_sip_header_t*)(callid = belle_sip_provider_create_call_id(this->get_sal()->prov))); - if (this->call_id){ + belle_sip_message_add_header((belle_sip_message_t*)request, (belle_sip_header_t*)(callid = belle_sip_provider_create_call_id(getSal()->mProvider))); + if (mCallId){ /*reset the call-id of op, it will be set when new request will be sent*/ - ms_free(this->call_id); - this->call_id = NULL; + ms_free(mCallId); + mCallId = NULL; } belle_sip_request_set_uri(request, redirect_uri); redirect_uri = BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(redirect_uri))); belle_sip_uri_set_port(redirect_uri, 0); belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(redirect_uri), "transport"); belle_sip_header_address_set_uri((belle_sip_header_address_t*)to, redirect_uri); - send_request(request); + sendRequest(request); return 0; } -void SalOp::process_authentication() { - belle_sip_request_t* initial_request=belle_sip_transaction_get_request((belle_sip_transaction_t*)this->pending_auth_transaction); +void SalOp::processAuthentication() { + belle_sip_request_t* initial_request=belle_sip_transaction_get_request((belle_sip_transaction_t*)mPendingAuthTransaction); belle_sip_request_t* new_request; bool_t is_within_dialog=FALSE; belle_sip_list_t* auth_list=NULL; belle_sip_auth_event_t* auth_event; - belle_sip_response_t *response=belle_sip_transaction_get_response((belle_sip_transaction_t*)this->pending_auth_transaction); + belle_sip_response_t *response=belle_sip_transaction_get_response((belle_sip_transaction_t*)mPendingAuthTransaction); belle_sip_header_from_t *from=belle_sip_message_get_header_by_type(initial_request,belle_sip_header_from_t); belle_sip_uri_t *from_uri=belle_sip_header_address_get_uri((belle_sip_header_address_t*)from); if (strcasecmp(belle_sip_uri_get_host(from_uri),"anonymous.invalid")==0){ /*prefer using the from from the SalOp*/ - from_uri=belle_sip_header_address_get_uri((belle_sip_header_address_t*)get_from_address()); + from_uri=belle_sip_header_address_get_uri((belle_sip_header_address_t*)getFromAddress()); } - if (this->dialog && belle_sip_dialog_get_state(this->dialog)==BELLE_SIP_DIALOG_CONFIRMED) { - new_request = belle_sip_dialog_create_request_from(this->dialog,initial_request); + if (mDialog && belle_sip_dialog_get_state(mDialog)==BELLE_SIP_DIALOG_CONFIRMED) { + new_request = belle_sip_dialog_create_request_from(mDialog,initial_request); if (!new_request) - new_request = belle_sip_dialog_create_queued_request_from(this->dialog,initial_request); + new_request = belle_sip_dialog_create_queued_request_from(mDialog,initial_request); is_within_dialog=TRUE; } else { new_request=initial_request; @@ -462,56 +465,56 @@ void SalOp::process_authentication() { return; } - if (belle_sip_provider_add_authorization(this->root->prov,new_request,response,from_uri,&auth_list,this->realm)) { + if (belle_sip_provider_add_authorization(mRoot->mProvider,new_request,response,from_uri,&auth_list,mRealm)) { if (is_within_dialog) { - send_request(new_request); + sendRequest(new_request); } else { - resend_request(new_request); + resendRequest(new_request); } - this->root->remove_pending_auth(this); + mRoot->removePendingAuth(this); }else { belle_sip_header_from_t *from=belle_sip_message_get_header_by_type(response,belle_sip_header_from_t); char *tmp=belle_sip_object_to_string(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from))); ms_message("No auth info found for [%s]",tmp); belle_sip_free(tmp); - this->root->add_pending_auth(this); + mRoot->addPendingAuth(this); if (is_within_dialog) { belle_sip_object_unref(new_request); } } /*always store auth info, for case of wrong credential*/ - if (this->auth_info) { - sal_auth_info_delete(this->auth_info); - this->auth_info=NULL; + if (mAuthInfo) { + sal_auth_info_delete(mAuthInfo); + mAuthInfo=NULL; } if (auth_list){ auth_event=(belle_sip_auth_event_t*)(auth_list->data); - this->auth_info=sal_auth_info_create(auth_event); + mAuthInfo=sal_auth_info_create(auth_event); belle_sip_list_free_with_data(auth_list,(void (*)(void*))belle_sip_auth_event_destroy); } } -char *SalOp::get_dialog_id() const { - if (this->dialog != NULL) { - return ms_strdup_printf("%s;to-tag=%s;from-tag=%s", this->call_id, - belle_sip_dialog_get_remote_tag(this->dialog), belle_sip_dialog_get_local_tag(this->dialog)); +char *SalOp::getDialogId() const { + if (mDialog != NULL) { + return ms_strdup_printf("%s;to-tag=%s;from-tag=%s", mCallId, + belle_sip_dialog_get_remote_tag(mDialog), belle_sip_dialog_get_local_tag(mDialog)); } return NULL; } -int SalOp::get_address_family() const { +int SalOp::getAddressFamily() const { belle_sip_transaction_t *tr=NULL; belle_sip_header_address_t *contact; - if (this->refresher) - tr=(belle_sip_transaction_t *)belle_sip_refresher_get_transaction(this->refresher); + if (mRefresher) + tr=(belle_sip_transaction_t *)belle_sip_refresher_get_transaction(mRefresher); if (tr==NULL) - tr=(belle_sip_transaction_t *)this->pending_client_trans; + tr=(belle_sip_transaction_t *)mPendingClientTransaction; if (tr==NULL) - tr=(belle_sip_transaction_t *)this->pending_server_trans; + tr=(belle_sip_transaction_t *)mPendingServerTransaction; if (tr==NULL){ ms_error("Unable to determine IP version from signaling operation."); @@ -519,7 +522,7 @@ int SalOp::get_address_family() const { } - if (this->refresher) { + if (mRefresher) { belle_sip_response_t *resp = belle_sip_transaction_get_response(tr); belle_sip_header_via_t *via = resp ?belle_sip_message_get_header_by_type(resp,belle_sip_header_via_t):NULL; if (!via){ @@ -537,29 +540,29 @@ int SalOp::get_address_family() const { } } -bool_t SalOp::is_idle() const { - if (this->dialog){ - return !belle_sip_dialog_request_pending(this->dialog); +bool_t SalOp::isIdle() const { + if (mDialog){ + return !belle_sip_dialog_request_pending(mDialog); } return TRUE; } -void SalOp::set_entity_tag(const char* entity_tag) { - if (this->entity_tag != NULL) ms_free(this->entity_tag); - this->entity_tag = entity_tag ? ms_strdup(entity_tag) : NULL; +void SalOp::setEntityTag(const char* entity_tag) { + if (mEntityTag != NULL) ms_free(mEntityTag); + mEntityTag = entity_tag ? ms_strdup(entity_tag) : NULL; } -void SalOp::set_event(const char *eventname) { +void SalOp::setEvent(const char *eventname) { belle_sip_header_event_t *header = NULL; - if (this->event) belle_sip_object_unref(this->event); + if (mEvent) belle_sip_object_unref(mEvent); if (eventname){ header = belle_sip_header_event_create(eventname); belle_sip_object_ref(header); } - this->event = header; + mEvent = header; } -void SalOp::add_initial_route_set(belle_sip_request_t *request, const MSList *list) { +void SalOp::addInitialRouteSet(belle_sip_request_t *request, const MSList *list) { const MSList *elem; for (elem=list;elem!=NULL;elem=elem->next){ SalAddress *addr=(SalAddress*)elem->data; @@ -582,21 +585,21 @@ void SalOp::add_initial_route_set(belle_sip_request_t *request, const MSList *li } } -belle_sip_request_t* SalOp::build_request(const char* method) { +belle_sip_request_t* SalOp::buildRequest(const char* method) { belle_sip_header_from_t* from_header; belle_sip_header_to_t* to_header; - belle_sip_provider_t* prov=this->root->prov; + belle_sip_provider_t* prov=mRoot->mProvider; belle_sip_request_t *req; belle_sip_uri_t* req_uri; belle_sip_uri_t* to_uri; belle_sip_header_call_id_t *call_id_header; const SalAddress* to_address; - const MSList *elem=get_route_addresses(); + const MSList *elem=getRouteAddresses(); char token[10]; /* check that the op has a correct to address */ - to_address = get_to_address(); + to_address = getToAddress(); if( to_address == NULL ){ ms_error("No To: address, cannot build request"); return NULL; @@ -608,8 +611,8 @@ belle_sip_request_t* SalOp::build_request(const char* method) { return NULL; } - if (strcmp("REGISTER",method)==0 || this->privacy==SalPrivacyNone) { - from_header = belle_sip_header_from_create(BELLE_SIP_HEADER_ADDRESS(get_from_address()) + if (strcmp("REGISTER",method)==0 || mPrivacy==SalPrivacyNone) { + from_header = belle_sip_header_from_create(BELLE_SIP_HEADER_ADDRESS(getFromAddress()) ,belle_sip_random_token(token,sizeof(token))); } else { from_header=belle_sip_header_from_create2("Anonymous ",belle_sip_random_token(token,sizeof(token))); @@ -617,12 +620,12 @@ belle_sip_request_t* SalOp::build_request(const char* method) { /*make sure to preserve components like headers or port*/ req_uri = (belle_sip_uri_t*)belle_sip_object_clone((belle_sip_object_t*)to_uri); - belle_sip_uri_set_secure(req_uri,is_secure()); + belle_sip_uri_set_secure(req_uri,isSecure()); to_header = belle_sip_header_to_create(BELLE_SIP_HEADER_ADDRESS(to_address),NULL); call_id_header = belle_sip_provider_create_call_id(prov); - if (get_call_id()) { - belle_sip_header_call_id_set_call_id(call_id_header, get_call_id()); + if (getCallId()) { + belle_sip_header_call_id_set_call_id(call_id_header, getCallId()); } req=belle_sip_request_create( @@ -635,48 +638,48 @@ belle_sip_request_t* SalOp::build_request(const char* method) { belle_sip_header_via_new(), 70); - if (this->privacy & SalPrivacyId) { - belle_sip_header_p_preferred_identity_t* p_preferred_identity=belle_sip_header_p_preferred_identity_create(BELLE_SIP_HEADER_ADDRESS(get_from_address())); + if (mPrivacy & SalPrivacyId) { + belle_sip_header_p_preferred_identity_t* p_preferred_identity=belle_sip_header_p_preferred_identity_create(BELLE_SIP_HEADER_ADDRESS(getFromAddress())); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(p_preferred_identity)); } - if (elem && strcmp(method,"REGISTER")!=0 && !this->root->no_initial_route){ - add_initial_route_set(req,elem); + if (elem && strcmp(method,"REGISTER")!=0 && !mRoot->mNoInitialRoute){ + addInitialRouteSet(req,elem); } - if (strcmp("REGISTER",method)!=0 && this->privacy!=SalPrivacyNone ){ + if (strcmp("REGISTER",method)!=0 && mPrivacy!=SalPrivacyNone ){ belle_sip_header_privacy_t* privacy_header=belle_sip_header_privacy_new(); - if (this->privacy&SalPrivacyCritical) + if (mPrivacy&SalPrivacyCritical) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacyCritical)); - if (this->privacy&SalPrivacyHeader) + if (mPrivacy&SalPrivacyHeader) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacyHeader)); - if (this->privacy&SalPrivacyId) + if (mPrivacy&SalPrivacyId) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacyId)); - if (this->privacy&SalPrivacyNone) + if (mPrivacy&SalPrivacyNone) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacyNone)); - if (this->privacy&SalPrivacySession) + if (mPrivacy&SalPrivacySession) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacySession)); - if (this->privacy&SalPrivacyUser) + if (mPrivacy&SalPrivacyUser) belle_sip_header_privacy_add_privacy(privacy_header,sal_privacy_to_string(SalPrivacyUser)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(privacy_header)); } - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),this->root->supported); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),mRoot->mSupported); return req; } -void SalOp::set_error_info_from_response(belle_sip_response_t *response) { +void SalOp::setErrorInfoFromResponse(belle_sip_response_t *response) { int code = belle_sip_response_get_status_code(response); const char *reason_phrase=belle_sip_response_get_reason_phrase(response); belle_sip_header_t *warning=belle_sip_message_get_header(BELLE_SIP_MESSAGE(response),"Warning"); - SalErrorInfo *ei=&this->error_info; + SalErrorInfo *ei=&mErrorInfo; const char *warnings; warnings=warning ? belle_sip_header_get_unparsed_value(warning) : NULL; sal_error_info_set(ei,SalReasonUnknown,"SIP", code,reason_phrase,warnings); - set_reason_error_info(BELLE_SIP_MESSAGE(response)); + setReasonErrorInfo(BELLE_SIP_MESSAGE(response)); } -const char* SalOp::to_string(const State value) { +const char* SalOp::toString(const State value) { switch(value) { case State::Early: return"SalOpStateEarly"; case State::Active: return "SalOpStateActive"; @@ -687,10 +690,10 @@ const char* SalOp::to_string(const State value) { } } -void SalOp::set_reason_error_info(belle_sip_message_t *msg) { +void SalOp::setReasonErrorInfo(belle_sip_message_t *msg) { belle_sip_header_reason_t* reason_header = belle_sip_message_get_header_by_type(msg,belle_sip_header_reason_t); if (reason_header){ - SalErrorInfo *ei=&this->reason_error_info; // ?// + SalErrorInfo *ei=&mReasonErrorInfo; // ?// const char *protocol = belle_sip_header_reason_get_protocol(reason_header); int code = belle_sip_header_reason_get_cause(reason_header); const char *text = belle_sip_header_reason_get_text(reason_header); @@ -698,41 +701,41 @@ void SalOp::set_reason_error_info(belle_sip_message_t *msg) { } } -void SalOp::set_referred_by(belle_sip_header_referred_by_t* referred_by) { - if (this->referred_by){ - belle_sip_object_unref(this->referred_by); +void SalOp::setReferredBy(belle_sip_header_referred_by_t* referred_by) { + if (mReferredBy){ + belle_sip_object_unref(mReferredBy); } - this->referred_by=referred_by; - belle_sip_object_ref(this->referred_by); + mReferredBy=referred_by; + belle_sip_object_ref(mReferredBy); } -void SalOp::set_replaces(belle_sip_header_replaces_t* replaces) { - if (this->replaces){ - belle_sip_object_unref(this->replaces); +void SalOp::setReplaces(belle_sip_header_replaces_t* replaces) { + if (mReplaces){ + belle_sip_object_unref(mReplaces); } - this->replaces=replaces; - belle_sip_object_ref(this->replaces); + mReplaces=replaces; + belle_sip_object_ref(mReplaces); } -int SalOp::send_request_with_expires(belle_sip_request_t* request,int expires) { +int SalOp::sendRequestWithExpires(belle_sip_request_t* request,int expires) { belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_EXPIRES); if (!expires_header && expires>=0) { belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(expires_header=belle_sip_header_expires_new())); } if (expires_header) belle_sip_header_expires_set_expires(expires_header,expires); - return send_request(request); + return sendRequest(request); } -int SalOp::send_and_create_refresher(belle_sip_request_t* req, int expires,belle_sip_refresher_listener_t listener) { - if (send_request_with_expires(req,expires)==0) { - if (this->refresher) { - belle_sip_refresher_stop(this->refresher); - belle_sip_object_unref(this->refresher); +int SalOp::sendRequestAndCreateRefresher(belle_sip_request_t* req, int expires,belle_sip_refresher_listener_t listener) { + if (sendRequestWithExpires(req,expires)==0) { + if (mRefresher) { + belle_sip_refresher_stop(mRefresher); + belle_sip_object_unref(mRefresher); } - if ((this->refresher = belle_sip_client_transaction_create_refresher(this->pending_client_trans))) { + if ((mRefresher = belle_sip_client_transaction_create_refresher(mPendingClientTransaction))) { /*since refresher acquires the transaction, we should remove our context from the transaction, because we won't be notified * that it is terminated anymore.*/ unref();/*loose the reference that was given to the transaction when creating it*/ @@ -740,10 +743,10 @@ int SalOp::send_and_create_refresher(belle_sip_request_t* req, int expires,belle Something in the design is not very good here, it makes things complicated to the belle-sip user. Possible ideas to improve things: refresher shall not use belle_sip_transaction_set_application_data() internally, refresher should let the first transaction notify the user as a normal transaction*/ - belle_sip_refresher_set_listener(this->refresher,listener, this); - belle_sip_refresher_set_retry_after(this->refresher,this->root->refresher_retry_after); - belle_sip_refresher_set_realm(this->refresher,this->realm); - belle_sip_refresher_enable_manual_mode(this->refresher, this->manual_refresher); + belle_sip_refresher_set_listener(mRefresher,listener, this); + belle_sip_refresher_set_retry_after(mRefresher,mRoot->mRefresherRetryAfter); + belle_sip_refresher_set_realm(mRefresher,mRealm); + belle_sip_refresher_enable_manual_mode(mRefresher, mManualRefresher); return 0; } else { return -1; @@ -752,12 +755,12 @@ int SalOp::send_and_create_refresher(belle_sip_request_t* req, int expires,belle return -1; } -belle_sip_header_contact_t *SalOp::create_contact() { +belle_sip_header_contact_t *SalOp::createContact() { belle_sip_header_contact_t* contact_header; belle_sip_uri_t* contact_uri; - if (get_contact_address()) { - contact_header = belle_sip_header_contact_create(BELLE_SIP_HEADER_ADDRESS(get_contact_address())); + if (getContactAddress()) { + contact_header = belle_sip_header_contact_create(BELLE_SIP_HEADER_ADDRESS(getContactAddress())); } else { contact_header= belle_sip_header_contact_new(); } @@ -769,78 +772,78 @@ belle_sip_header_contact_t *SalOp::create_contact() { } belle_sip_uri_set_user_password(contact_uri,NULL); - belle_sip_uri_set_secure(contact_uri,is_secure()); - if (this->privacy!=SalPrivacyNone){ + belle_sip_uri_set_secure(contact_uri,isSecure()); + if (mPrivacy!=SalPrivacyNone){ belle_sip_uri_set_user(contact_uri,NULL); } /*don't touch contact in case of gruu*/ if (!belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(contact_header))),"gr")) { - belle_sip_header_contact_set_automatic(contact_header,this->root->auto_contacts); - if (this->root->uuid) { + belle_sip_header_contact_set_automatic(contact_header,mRoot->mAutoContacts); + if (mRoot->mUuid) { if (belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(contact_header),"+sip.instance")==0){ - char *instance_id=belle_sip_strdup_printf("\"\"",this->root->uuid); + char *instance_id=belle_sip_strdup_printf("\"\"",mRoot->mUuid); belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(contact_header),"+sip.instance",instance_id); belle_sip_free(instance_id); } } } - if (this->root->linphone_specs && strlen(this->root->linphone_specs) > 0) { + if (mRoot->mLinphoneSpecs && strlen(mRoot->mLinphoneSpecs) > 0) { if (belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(contact_header),"+org.linphone.specs") == 0) { - belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(contact_header), "+org.linphone.specs", this->root->linphone_specs); + belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(contact_header), "+org.linphone.specs", mRoot->mLinphoneSpecs); } } return contact_header; } -void SalOp::unlink_op_with_dialog(belle_sip_dialog_t* dialog) { +void SalOp::unlinkOpFromDialog(belle_sip_dialog_t* dialog) { belle_sip_dialog_set_application_data(dialog,NULL); unref(); belle_sip_object_unref(dialog); } -belle_sip_dialog_t *SalOp::link_op_with_dialog(belle_sip_dialog_t* dialog) { +belle_sip_dialog_t *SalOp::linkOpWithDialog(belle_sip_dialog_t* dialog) { belle_sip_dialog_set_application_data(dialog,ref()); belle_sip_object_ref(dialog); return dialog; } -void SalOp::set_or_update_dialog(belle_sip_dialog_t* dialog) { - ms_message("op [%p] : set_or_update_dialog() current=[%p] new=[%p]", this, this->dialog,dialog); +void SalOp::setOrUpdateDialog(belle_sip_dialog_t* dialog) { + ms_message("op [%p] : set_or_update_dialog() current=[%p] new=[%p]", this, mDialog,dialog); ref(); - if (this->dialog!=dialog){ - if (this->dialog){ + if (mDialog!=dialog){ + if (mDialog){ /*FIXME: shouldn't we delete unconfirmed dialogs ?*/ - unlink_op_with_dialog(this->dialog); - this->dialog=NULL; + unlinkOpFromDialog(mDialog); + mDialog=NULL; } if (dialog) { - this->dialog=link_op_with_dialog(dialog); - belle_sip_dialog_enable_pending_trans_checking(dialog,this->root->pending_trans_checking); + mDialog=linkOpWithDialog(dialog); + belle_sip_dialog_enable_pending_trans_checking(dialog,mRoot->mPendingTransactionChecking); } } unref(); } int SalOp::ping(const char *from, const char *to) { - set_from(from); - set_to(to); - return send_request(build_request("OPTIONS")); + setFrom(from); + setTo(to); + return sendRequest(buildRequest("OPTIONS")); } -int SalOp::send_info(const char *from, const char *to, const SalBodyHandler *body_handler) { - if (this->dialog && belle_sip_dialog_get_state(this->dialog) == BELLE_SIP_DIALOG_CONFIRMED) { +int SalOp::sendInfo(const char *from, const char *to, const SalBodyHandler *body_handler) { + if (mDialog && belle_sip_dialog_get_state(mDialog) == BELLE_SIP_DIALOG_CONFIRMED) { belle_sip_request_t *req; - belle_sip_dialog_enable_pending_trans_checking(this->dialog,this->root->pending_trans_checking); - req=belle_sip_dialog_create_queued_request(this->dialog,"INFO"); + belle_sip_dialog_enable_pending_trans_checking(mDialog,mRoot->mPendingTransactionChecking); + req=belle_sip_dialog_create_queued_request(mDialog,"INFO"); belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(body_handler)); - return send_request(req); + return sendRequest(req); }else{ ms_error("Cannot send INFO message on op [%p] because dialog is not in confirmed state yet.", this); } return -1; } -SalBodyHandler *SalOp::get_body_handler(belle_sip_message_t *msg) { +SalBodyHandler *SalOp::getBodyHandler(belle_sip_message_t *msg) { belle_sip_body_handler_t *body_handler = belle_sip_message_get_body_handler(msg); if (body_handler != NULL) { belle_sip_header_content_type_t *content_type = belle_sip_message_get_header_by_type(msg, belle_sip_header_content_type_t); @@ -853,30 +856,36 @@ SalBodyHandler *SalOp::get_body_handler(belle_sip_message_t *msg) { return (SalBodyHandler *)body_handler; } -void SalOp::assign_recv_headers(belle_sip_message_t *incoming) { +void SalOp::assignRecvHeaders(belle_sip_message_t *incoming) { if (incoming) belle_sip_object_ref(incoming); - if (this->recv_custom_headers){ - belle_sip_object_unref(this->recv_custom_headers); - this->recv_custom_headers=NULL; + if (mRecvCustomHeaders){ + belle_sip_object_unref(mRecvCustomHeaders); + mRecvCustomHeaders=NULL; } if (incoming){ - this->recv_custom_headers=(SalCustomHeader*)incoming; + mRecvCustomHeaders=(SalCustomHeader*)incoming; } } -void SalOp::set_remote_contact(const char* remote_contact) { - assign_address(&this->remote_contact_address,remote_contact); +void SalOp::setRemoteContact(const char* remote_contact) { + assignAddress(&mRemoteContactAddress,remote_contact); /*to preserve header params*/ - assign_string(&this->remote_contact,remote_contact); + assignString(&mRemoteContact,remote_contact); } -void SalOp::set_network_origin(const char *origin) { - SET_PARAM(origin); +void SalOp::setNetworkOrigin (const char *value) { + char *valueStr = nullptr; + assignAddress(&mOriginAddress, value); + if (mOriginAddress) + valueStr = sal_address_as_string(mOriginAddress); + assignString(&mOrigin, valueStr); + if (valueStr) + ms_free(valueStr); } -void SalOp::set_network_origin_address(SalAddress *origin){ +void SalOp::setNetworkOriginAddress(SalAddress *origin){ char* address_string=sal_address_as_string(origin); /*can probably be optimized*/ - set_network_origin(address_string); + setNetworkOrigin(address_string); ms_free(address_string); } @@ -888,45 +897,45 @@ When a Privacy header is constructed, it MUST consist of either the 'session' (each of which MUST appear at most once) which MAY in turn be followed by the 'critical' indicator. */ -void SalOp::set_privacy_from_message(belle_sip_message_t* msg) { +void SalOp::setPrivacyFromMessage(belle_sip_message_t* msg) { belle_sip_header_privacy_t* privacy = belle_sip_message_get_header_by_type(msg,belle_sip_header_privacy_t); if (!privacy) { - set_privacy(SalPrivacyNone); + setPrivacy(SalPrivacyNone); } else { belle_sip_list_t* privacy_list=belle_sip_header_privacy_get_privacy(privacy); - set_privacy(0); + setPrivacy(0); for (;privacy_list!=NULL;privacy_list=privacy_list->next) { char* privacy_value=(char*)privacy_list->data; if(strcmp(sal_privacy_to_string(SalPrivacyCritical),privacy_value) == 0) - set_privacy(get_privacy()|SalPrivacyCritical); + setPrivacy(getPrivacy()|SalPrivacyCritical); if(strcmp(sal_privacy_to_string(SalPrivacyHeader),privacy_value) == 0) - set_privacy(get_privacy()|SalPrivacyHeader); + setPrivacy(getPrivacy()|SalPrivacyHeader); if(strcmp(sal_privacy_to_string(SalPrivacyId),privacy_value) == 0) - set_privacy(get_privacy()|SalPrivacyId); + setPrivacy(getPrivacy()|SalPrivacyId); if(strcmp(sal_privacy_to_string(SalPrivacyNone),privacy_value) == 0) { - set_privacy(SalPrivacyNone); + setPrivacy(SalPrivacyNone); break; } if(strcmp(sal_privacy_to_string(SalPrivacySession),privacy_value) == 0) - set_privacy(get_privacy()|SalPrivacySession); + setPrivacy(getPrivacy()|SalPrivacySession); if(strcmp(sal_privacy_to_string(SalPrivacyUser),privacy_value) == 0) - set_privacy(get_privacy()|SalPrivacyUser); + setPrivacy(getPrivacy()|SalPrivacyUser); } } } -void SalOp::set_remote_ua(belle_sip_message_t* message) { +void SalOp::setRemoteUserAgent(belle_sip_message_t* message) { belle_sip_header_user_agent_t* user_agent=belle_sip_message_get_header_by_type(message,belle_sip_header_user_agent_t); char user_agent_string[256]; if (user_agent && belle_sip_header_user_agent_get_products_as_string(user_agent,user_agent_string,sizeof(user_agent_string))>0) { - if (this->remote_ua!=NULL){ - ms_free(this->remote_ua); + if (mRemoteUserAgent!=NULL){ + ms_free(mRemoteUserAgent); } - this->remote_ua=ms_strdup(user_agent_string); + mRemoteUserAgent=ms_strdup(user_agent_string); } } -const char *SalOp::to_string(const Type type) { +const char *SalOp::toString(const Type type) { switch(type) { case Type::Register: return "SalOpRegister"; case Type::Call: return "SalOpCall"; @@ -936,31 +945,31 @@ const char *SalOp::to_string(const Type type) { } } -bool_t SalOp::is_secure() const { - const SalAddress* from = get_from_address(); - const SalAddress* to = get_to_address(); +bool_t SalOp::isSecure() const { + const SalAddress* from = getFromAddress(); + const SalAddress* to = getToAddress(); return from && to && strcasecmp("sips",sal_address_get_scheme(from))==0 && strcasecmp("sips",sal_address_get_scheme(to))==0; } /* * Warning: this function takes owneship of the custom headers */ -void SalOp::set_sent_custom_header(SalCustomHeader* ch){ - if (this->sent_custom_headers){ - sal_custom_header_free(this->sent_custom_headers); - this->sent_custom_headers=NULL; +void SalOp::setSentCustomHeaders(SalCustomHeader* ch){ + if (mSentCustomHeaders){ + sal_custom_header_free(mSentCustomHeaders); + mSentCustomHeaders=NULL; } if (ch) belle_sip_object_ref((belle_sip_message_t*)ch); - this->sent_custom_headers=ch; + mSentCustomHeaders=ch; } -void SalOp::add_headers(belle_sip_header_t *h, belle_sip_message_t *msg){ +void SalOp::addHeaders(belle_sip_header_t *h, belle_sip_message_t *msg){ if (BELLE_SIP_OBJECT_IS_INSTANCE_OF(h,belle_sip_header_contact_t)){ belle_sip_header_contact_t* newct; /*special case for contact, we want to keep everything from the custom contact but set automatic mode and add our own parameters as well*/ - set_contact_address((SalAddress*)BELLE_SIP_HEADER_ADDRESS(h)); - newct = create_contact(); + setContactAddress((SalAddress*)BELLE_SIP_HEADER_ADDRESS(h)); + newct = createContact(); belle_sip_message_set_header(BELLE_SIP_MESSAGE(msg),BELLE_SIP_HEADER(newct)); return; } @@ -969,32 +978,32 @@ void SalOp::add_headers(belle_sip_header_t *h, belle_sip_message_t *msg){ } -void SalOp::add_custom_headers(belle_sip_message_t *msg){ - if (this->sent_custom_headers){ - belle_sip_message_t *ch=(belle_sip_message_t*)this->sent_custom_headers; +void SalOp::addCustomHeaders(belle_sip_message_t *msg){ + if (mSentCustomHeaders){ + belle_sip_message_t *ch=(belle_sip_message_t*)mSentCustomHeaders; belle_sip_list_t *l=belle_sip_message_get_all_headers(ch); belle_sip_list_t *elem; for(elem=l;elem!=NULL;elem=elem->next){ - add_headers((belle_sip_header_t*)elem->data,msg); + addHeaders((belle_sip_header_t*)elem->data,msg); } belle_sip_list_free(l); } } int SalOp::unsubscribe(){ - if (this->refresher){ - const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(this->refresher); + if (mRefresher){ + const belle_sip_transaction_t *tr=(const belle_sip_transaction_t*) belle_sip_refresher_get_transaction(mRefresher); belle_sip_request_t *last_req=belle_sip_transaction_get_request(tr); belle_sip_message_set_body(BELLE_SIP_MESSAGE(last_req), NULL, 0); - belle_sip_refresher_refresh(this->refresher,0); + belle_sip_refresher_refresh(mRefresher,0); return 0; } return -1; } -void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { +void SalOp::processIncomingMessage(const belle_sip_request_event_t *event) { belle_sip_request_t* req = belle_sip_request_event_get_request(event); - belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(this->root->prov,req); + belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(mRoot->mProvider,req); belle_sip_header_address_t* address; belle_sip_header_from_t* from_header; belle_sip_header_content_type_t* content_type; @@ -1013,12 +1022,12 @@ void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { SalMessage salmsg; char message_id[256]={0}; - if (this->pending_server_trans) belle_sip_object_unref(this->pending_server_trans); + if (mPendingServerTransaction) belle_sip_object_unref(mPendingServerTransaction); - this->pending_server_trans=server_transaction; - belle_sip_object_ref(this->pending_server_trans); + mPendingServerTransaction=server_transaction; + belle_sip_object_ref(mPendingServerTransaction); - external_body=is_external_body(content_type); + external_body=isExternalBody(content_type); address=belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(from_header)) ,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header))); from=belle_sip_object_to_string(BELLE_SIP_OBJECT(address)); @@ -1043,7 +1052,7 @@ void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { salmsg.message_id=message_id; salmsg.time=date ? belle_sip_header_date_get_time(date) : time(NULL); - this->root->callbacks.message_received(this,&salmsg); + mRoot->mCallbacks.message_received(this,&salmsg); belle_sip_object_unref(address); belle_sip_free(from); @@ -1052,35 +1061,35 @@ void SalOp::process_incoming_message(const belle_sip_request_event_t *event) { } else { ms_error("Unsupported MESSAGE (no Content-Type)"); resp = belle_sip_response_create_from_request(req, errcode); - add_message_accept((belle_sip_message_t*)resp); + addMessageAccept((belle_sip_message_t*)resp); belle_sip_server_transaction_send_response(server_transaction,resp); release(); } } -bool_t SalOp::is_external_body(belle_sip_header_content_type_t* content_type) { +bool_t SalOp::isExternalBody(belle_sip_header_content_type_t* content_type) { return strcmp("message",belle_sip_header_content_type_get_type(content_type))==0 && strcmp("external-body",belle_sip_header_content_type_get_subtype(content_type))==0; } -int SalOp::reply_message(SalReason reason) { - if (this->pending_server_trans){ +int SalOp::replyMessage(SalReason reason) { + if (mPendingServerTransaction){ int code=to_sip_code(reason); belle_sip_response_t *resp = belle_sip_response_create_from_request( - belle_sip_transaction_get_request((belle_sip_transaction_t*)this->pending_server_trans),code); - belle_sip_server_transaction_send_response(this->pending_server_trans,resp); + belle_sip_transaction_get_request((belle_sip_transaction_t*)mPendingServerTransaction),code); + belle_sip_server_transaction_send_response(mPendingServerTransaction,resp); return 0; }else ms_error("sal_message_reply(): no server transaction"); return -1; } -void SalOp::add_message_accept(belle_sip_message_t *msg) { +void SalOp::addMessageAccept(belle_sip_message_t *msg) { bctbx_list_t *item; const char *str; char *old; char *header = ms_strdup("xml/cipher, application/cipher.vnd.gsma.rcs-ft-http+xml"); - for (item = this->root->supported_content_types; item != NULL; item = bctbx_list_next(item)) { + for (item = mRoot->mSupportedContentTypes; item != NULL; item = bctbx_list_next(item)) { str = (const char *)bctbx_list_get_data(item); old = header; header = ms_strdup_printf("%s, %s", old, str); @@ -1091,11 +1100,11 @@ void SalOp::add_message_accept(belle_sip_message_t *msg) { ms_free(header); } -void SalOp::set_service_route(const SalAddress* service_route) { - if (this->service_route) - sal_address_destroy(this->service_route); +void SalOp::setServiceRoute(const SalAddress* service_route) { + if (mServiceRoute) + sal_address_destroy(mServiceRoute); - this->service_route=service_route?sal_address_clone(service_route):NULL; + mServiceRoute=service_route?sal_address_clone(service_route):NULL; } LINPHONE_END_NAMESPACE diff --git a/src/sal/op.h b/src/sal/op.h index 317d3f632..fb7549f8e 100644 --- a/src/sal/op.h +++ b/src/sal/op.h @@ -26,107 +26,118 @@ #include "c-wrapper/internal/c-sal.h" #include "content/content.h" +#include "logger/logger.h" #include "sal/sal.h" LINPHONE_BEGIN_NAMESPACE class SalOp { public: - SalOp(Sal *sal); - virtual ~SalOp(); + SalOp (Sal *sal); + virtual ~SalOp (); - SalOp *ref(); - void *unref(); + SalOp *ref (); + void *unref (); - Sal *get_sal() const {return this->root;} + Sal *getSal () const { return mRoot; } - void set_user_pointer(void *up) {this->user_pointer=up;} - void *get_user_pointer() const {return this->user_pointer;} + void setUserPointer (void *value) { mUserPointer = value; } + void *getUserPointer () const { return mUserPointer; } - void set_subject (const char *subject); - const char *get_subject () const { return this->subject; } + void setSubject (const char *value); + const char *getSubject () const { return mSubject; } - void set_from(const char *from); - void set_from_address(const SalAddress *from); - const char *get_from() const {return this->from;} - const SalAddress *get_from_address() const {return this->from_address;} + void setFrom (const char *value); + void setFromAddress (const SalAddress *value); + const char *getFrom () const { return mFrom; } + const SalAddress *getFromAddress () const { return mFromAddress; } - void set_to(const char *to); - void set_to_address(const SalAddress *to); - const char *get_to() const {return this->to;} - const SalAddress *get_to_address() const {return this->to_address;} + void setTo (const char *value); + void setToAddress (const SalAddress *value); + const char *getTo () const { return mTo; } + const SalAddress *getToAddress () const { return mToAddress; } - void set_contact_address(const SalAddress* address); - const SalAddress *get_contact_address() const {return this->contact_address;} + void setContactAddress (const SalAddress* value); + const SalAddress *getContactAddress() const { return mContactAddress; } - void set_route(const char *route); - void set_route_address(const SalAddress* address); - const bctbx_list_t *get_route_addresses() const {return this->route_addresses;} - void add_route_address(const SalAddress* address); + void setRoute (const char *value); + void setRouteAddress (const SalAddress *value); + const bctbx_list_t *getRouteAddresses () const { return mRouteAddresses; } + void addRouteAddress (const SalAddress *address); - void set_diversion_address(const SalAddress *diversion); - const SalAddress *get_diversion_address() const {return this->diversion_address;} + void setDiversionAddress (const SalAddress *value); + const SalAddress *getDiversionAddress () const { return mDiversionAddress; } - void set_service_route(const SalAddress* service_route); - const SalAddress *get_service_route() const {return this->service_route;} + void setServiceRoute (const SalAddress *value); + const SalAddress *getServiceRoute () const { return mServiceRoute; } - void set_manual_refresher_mode(bool_t enabled) {this->manual_refresher=enabled;} + void setManualRefresherMode (bool_t value) { mManualRefresher = value; } - void set_entity_tag(const char* entity_tag); - const char *get_entity_tag() const {return this->entity_tag;} + void setEntityTag (const char *value); + const char *getEntityTag() const { return mEntityTag; } - void set_event(const char *eventname); + void setEvent (const char *eventName); - void set_privacy(SalPrivacyMask privacy) {this->privacy=privacy;} - SalPrivacyMask get_privacy() const {return this->privacy;} + void setPrivacy (SalPrivacyMask value) { mPrivacy = value; } + SalPrivacyMask getPrivacy() const { return mPrivacy; } - void set_realm(const char *realm); + void setRealm (const char *value); - void set_sent_custom_header(SalCustomHeader* ch); + void setSentCustomHeaders (SalCustomHeader *ch); - void enable_cnx_ip_to_0000_if_sendonly(bool_t yesno) {this->_cnx_ip_to_0000_if_sendonly_enabled = yesno;} - bool_t cnx_ip_to_0000_if_sendonly_enabled() const {return this->_cnx_ip_to_0000_if_sendonly_enabled;} + void enableCnxIpTo0000IfSendOnly (bool_t value) { mCnxIpTo0000IfSendOnlyEnabled = value; } + bool_t cnxIpTo0000IfSendOnlyEnabled () const { return mCnxIpTo0000IfSendOnlyEnabled; } - const char *get_proxy() const {return this->route;} - const char *get_network_origin() const {return this->origin;} - const char* get_call_id() const {return this->call_id;} - char* get_dialog_id() const; - int get_address_family() const; - const SalCustomHeader *get_recv_custom_header() const {return this->recv_custom_headers;} - const char *get_remote_contact() const {return this->remote_contact;} - const SalAddress *get_remote_contact_address() const {return this->remote_contact_address;} - const char *get_remote_ua() const {return this->remote_ua;} + const char *getProxy () const { return mRoute; } + const char *getNetworkOrigin () const { return mOrigin; } + const char *getCallId () const { return mCallId; } + char *getDialogId () const; + int getAddressFamily () const; + const SalCustomHeader *getRecvCustomHeaders () const { return mRecvCustomHeaders; } + const char *getRemoteContact () const { return mRemoteContact; } + const SalAddress *getRemoteContactAddress () const { return mRemoteContactAddress; } + const char *getRemoteUserAgent () const { return mRemoteUserAgent; } - const char *get_public_address(int *port) {return this->refresher ? belle_sip_refresher_get_public_address(this->refresher, port) : NULL;} - const char *get_local_address(int *port) {return this->refresher ? belle_sip_refresher_get_local_address(this->refresher, port) : NULL;} + const char *getPublicAddress (int *port) { + return mRefresher ? belle_sip_refresher_get_public_address(mRefresher, port) : nullptr; + } + const char *getLocalAddress (int *port) { + return mRefresher ? belle_sip_refresher_get_local_address(mRefresher, port) : nullptr; + } - const SalErrorInfo *get_error_info() const {return &this->error_info;} - const SalErrorInfo *get_reason_error_info() const {return &this->reason_error_info;} + const SalErrorInfo *getErrorInfo () const { return &mErrorInfo; } + const SalErrorInfo *getReasonErrorInfo () const { return &mReasonErrorInfo; } - bool_t is_forked_of(const SalOp *op2) const {return this->call_id && op2->call_id && strcmp(this->call_id, op2->call_id) == 0;} - bool_t is_idle() const ; + bool_t isForkedOf (const SalOp *op) const { + return mCallId && op->mCallId && strcmp(mCallId, op->mCallId) == 0; + } + bool_t isIdle () const; - void stop_refreshing() {if (this->refresher) belle_sip_refresher_stop(this->refresher);} - int refresh(); - void kill_dialog(); - void release(); + void stopRefreshing () { + if (mRefresher) + belle_sip_refresher_stop(mRefresher); + } + int refresh (); + void killDialog (); + void release (); - virtual void authenticate(const SalAuthInfo *info) {process_authentication();} - void cancel_authentication() {ms_fatal("sal_op_cancel_authentication not implemented yet");} - SalAuthInfo *get_auth_requested() {return this->auth_info;} + virtual void authenticate (const SalAuthInfo *info) { + processAuthentication(); } + void cancelAuthentication () { lFatal() << "SalOp::cancelAuthentication not implemented yet"; } + SalAuthInfo *getAuthRequested () { return mAuthInfo; } - int ping(const char *from, const char *to); - int send_info(const char *from, const char *to, const SalBodyHandler *body_handler); + int ping (const char *from, const char *to); + int sendInfo (const char *from, const char *to, const SalBodyHandler *bodyHandler); protected: enum class State { Early = 0, Active, - Terminating, /*this state is used to wait until a proceeding state, so we can send the cancel*/ + Terminating, // This state is used to wait until a proceeding state, so we can send the cancel Terminated }; - static const char* to_string(const State value); + static const char *toString (const State value); enum class Dir { Incoming = 0, @@ -141,118 +152,120 @@ protected: Presence, Publish, Subscribe, - Refer /*for out of dialog refer only*/ + Refer // For out of dialog refer only }; - static const char *to_string(const SalOp::Type type); + static const char *toString (const Type type); - typedef void (*ReleaseCb)(SalOp *op); + using ReleaseCb = void (*) (SalOp *op); - virtual void fill_cbs() {} - void release_impl(); - void process_authentication(); - int process_redirect(); + virtual void fillCallbacks () {} + void releaseImpl (); + void processAuthentication (); + int processRedirect (); - belle_sip_request_t* build_request(const char* method); - int send_request(belle_sip_request_t* request); - int send_request_with_contact(belle_sip_request_t* request, bool_t add_contact); - int send_request_with_expires(belle_sip_request_t* request,int expires); - void resend_request(belle_sip_request_t* request); - int send_and_create_refresher(belle_sip_request_t* req, int expires,belle_sip_refresher_listener_t listener); + belle_sip_request_t *buildRequest (const char *method); + int sendRequest (belle_sip_request_t *request); + int sendRequestWithContact (belle_sip_request_t *request, bool_t addContact); + int sendRequestWithExpires (belle_sip_request_t *request, int expires); + void resendRequest (belle_sip_request_t *request); + int sendRequestAndCreateRefresher (belle_sip_request_t *request, int expires, belle_sip_refresher_listener_t listener); - void set_reason_error_info(belle_sip_message_t *msg); - void set_error_info_from_response(belle_sip_response_t *response); + void setReasonErrorInfo (belle_sip_message_t *message); + void setErrorInfoFromResponse (belle_sip_response_t *response); - void set_referred_by(belle_sip_header_referred_by_t* referred_by); - void set_replaces(belle_sip_header_replaces_t* replaces); + void setReferredBy (belle_sip_header_referred_by_t *referredByHeader); + void setReplaces (belle_sip_header_replaces_t *replacesHeader); - void set_remote_contact(const char* remote_contact); - void set_network_origin(const char *origin); - void set_network_origin_address(SalAddress *origin); - void set_privacy_from_message(belle_sip_message_t* msg); - void set_remote_ua(belle_sip_message_t* message); + void setRemoteContact (const char *value); + void setNetworkOrigin (const char *value); + void setNetworkOriginAddress (SalAddress *value); + void setPrivacyFromMessage (belle_sip_message_t *message); + void setRemoteUserAgent (belle_sip_message_t *message); - belle_sip_response_t *create_response_from_request(belle_sip_request_t *req, int code) {return this->root->create_response_from_request(req,code);} - belle_sip_header_contact_t *create_contact(); + belle_sip_response_t *createResponseFromRequest (belle_sip_request_t *request, int code) { + return mRoot->createResponseFromRequest(request, code); + } + belle_sip_header_contact_t *createContact (); - void set_or_update_dialog(belle_sip_dialog_t* dialog); - belle_sip_dialog_t *link_op_with_dialog(belle_sip_dialog_t* dialog); - void unlink_op_with_dialog(belle_sip_dialog_t* dialog); + void setOrUpdateDialog (belle_sip_dialog_t *dialog); + belle_sip_dialog_t *linkOpWithDialog (belle_sip_dialog_t *dialog); + void unlinkOpFromDialog (belle_sip_dialog_t *dialog); - SalBodyHandler *get_body_handler(belle_sip_message_t *msg); + SalBodyHandler *getBodyHandler (belle_sip_message_t *message); - void assign_recv_headers(belle_sip_message_t *incoming); + void assignRecvHeaders (belle_sip_message_t *message); - bool_t is_secure() const; - void add_headers(belle_sip_header_t *h, belle_sip_message_t *msg); - void add_custom_headers(belle_sip_message_t *msg); - int unsubscribe(); + bool_t isSecure () const; + void addHeaders (belle_sip_header_t *h, belle_sip_message_t *message); + void addCustomHeaders (belle_sip_message_t *message); + int unsubscribe (); - void process_incoming_message(const belle_sip_request_event_t *event); - int reply_message(SalReason reason); - void add_message_accept(belle_sip_message_t *msg); - static bool_t is_external_body(belle_sip_header_content_type_t* content_type); + void processIncomingMessage (const belle_sip_request_event_t *event); + int replyMessage (SalReason reason); + void addMessageAccept (belle_sip_message_t *message); - static void assign_address(SalAddress** address, const char *value); - static void assign_string(char **str, const char *arg); - static void add_initial_route_set(belle_sip_request_t *request, const MSList *list); + static bool_t isExternalBody (belle_sip_header_content_type_t* contentType); + + static void assignAddress (SalAddress **address, const char *value); + static void assignString (char **str, const char *arg); + static void addInitialRouteSet (belle_sip_request_t *request, const MSList *list); // SalOpBase - Sal *root = NULL; - char *route = NULL; /*or request-uri for REGISTER*/ - MSList* route_addresses = NULL; /*list of SalAddress* */ - SalAddress* contact_address = NULL; - char *subject = NULL; - char *from = NULL; - SalAddress* from_address = NULL; - char *to = NULL; - SalAddress* to_address = NULL; - char *origin = NULL; - SalAddress* origin_address = NULL; - SalAddress* diversion_address = NULL; - char *remote_ua = NULL; - SalAddress* remote_contact_address = NULL; - char *remote_contact = NULL; - void *user_pointer = NULL; - char* call_id = NULL; - char* realm = NULL; - SalAddress* service_route = NULL; /*as defined by rfc3608, might be a list*/ - SalCustomHeader *sent_custom_headers = NULL; - SalCustomHeader *recv_custom_headers = NULL; - char* entity_tag = NULL; /*as defined by rfc3903 (I.E publih)*/ - ReleaseCb release_cb = NULL; + Sal *mRoot = nullptr; + char *mRoute = nullptr; // Or request-uri for REGISTER + MSList *mRouteAddresses = nullptr; // List of SalAddress * + SalAddress *mContactAddress = nullptr; + char *mSubject = nullptr; + char *mFrom = nullptr; + SalAddress* mFromAddress = nullptr; + char *mTo = nullptr; + SalAddress *mToAddress = nullptr; + char *mOrigin = nullptr; + SalAddress *mOriginAddress = nullptr; + SalAddress *mDiversionAddress = nullptr; + char *mRemoteUserAgent = nullptr; + SalAddress *mRemoteContactAddress = nullptr; + char *mRemoteContact = nullptr; + void *mUserPointer = nullptr; + char *mCallId = nullptr; + char *mRealm = nullptr; + SalAddress *mServiceRoute = nullptr; // As defined by rfc3608, might be a list + SalCustomHeader *mSentCustomHeaders = nullptr; + SalCustomHeader *mRecvCustomHeaders = nullptr; + char *mEntityTag = nullptr; // As defined by rfc3903 (I.E publih) + ReleaseCb mReleaseCb = nullptr; - // BelleSip implementation - const belle_sip_listener_callbacks_t *callbacks = NULL; - SalErrorInfo error_info; - SalErrorInfo reason_error_info; - belle_sip_client_transaction_t *pending_auth_transaction = NULL; - belle_sip_server_transaction_t* pending_server_trans = NULL; - belle_sip_server_transaction_t* pending_update_server_trans = NULL; - belle_sip_client_transaction_t* pending_client_trans = NULL; - SalAuthInfo* auth_info = NULL; - belle_sip_dialog_t* dialog = NULL; - belle_sip_header_replaces_t *replaces = NULL; - belle_sip_header_referred_by_t *referred_by = NULL; - SalMediaDescription *result = NULL; - belle_sdp_session_description_t *sdp_answer = NULL; - State state = State::Early; - Dir dir = Dir::Incoming; - belle_sip_refresher_t* refresher = NULL; - int _ref = 0; - Type type = Type::Unknown; - SalPrivacyMask privacy = SalPrivacyNone; - belle_sip_header_event_t *event = NULL; /*used by SalOpSubscribe kinds*/ - SalOpSDPHandling sdp_handling = SalOpSDPNormal; - int auth_requests = 0; /*number of auth requested for this op*/ - bool_t _cnx_ip_to_0000_if_sendonly_enabled = FALSE; - bool_t auto_answer_asked = FALSE; - bool_t sdp_offering = FALSE; - bool_t call_released = FALSE; - bool_t manual_refresher = FALSE; - bool_t has_auth_pending = FALSE; - bool_t supports_session_timers = FALSE; - bool_t op_released = FALSE; + const belle_sip_listener_callbacks_t *mCallbacks = nullptr; + SalErrorInfo mErrorInfo; + SalErrorInfo mReasonErrorInfo; + belle_sip_client_transaction_t *mPendingAuthTransaction = nullptr; + belle_sip_server_transaction_t *mPendingServerTransaction = nullptr; + belle_sip_server_transaction_t *mPendingUpdateServerTransaction = nullptr; + belle_sip_client_transaction_t *mPendingClientTransaction = nullptr; + SalAuthInfo *mAuthInfo = nullptr; + belle_sip_dialog_t *mDialog = nullptr; + belle_sip_header_replaces_t *mReplaces = nullptr; + belle_sip_header_referred_by_t *mReferredBy = nullptr; + SalMediaDescription *mResult = nullptr; + belle_sdp_session_description_t *mSdpAnswer = nullptr; + State mState = State::Early; + Dir mDir = Dir::Incoming; + belle_sip_refresher_t *mRefresher = nullptr; + int mRef = 0; + Type mType = Type::Unknown; + SalPrivacyMask mPrivacy = SalPrivacyNone; + belle_sip_header_event_t *mEvent = nullptr; // Used by SalOpSubscribe kinds + SalOpSDPHandling mSdpHandling = SalOpSDPNormal; + int mAuthRequests = 0; // number of auth requested for this op + bool_t mCnxIpTo0000IfSendOnlyEnabled = FALSE; + bool_t mAutoAnswerAsked = FALSE; + bool_t mSdpOffering = FALSE; + bool_t mCallReleased = FALSE; + bool_t mManualRefresher = FALSE; + bool_t mHasAuthPending = FALSE; + bool_t mSupportsSessionTimers = FALSE; + bool_t mOpReleased = FALSE; friend class Sal; }; diff --git a/src/sal/presence-op.cpp b/src/sal/presence-op.cpp index 641352506..9425dc20b 100644 --- a/src/sal/presence-op.cpp +++ b/src/sal/presence-op.cpp @@ -23,7 +23,7 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -void SalPresenceOp::presence_process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event) { +void SalPresenceOp::presenceProcessIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event) { SalPresenceOp * op = (SalPresenceOp *)user_ctx; belle_sip_request_t* request; belle_sip_client_transaction_t* client_transaction = NULL; @@ -38,32 +38,32 @@ void SalPresenceOp::presence_process_io_error_cb(void *user_ctx, const belle_sip request = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)); if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){ - if (op->refresher){ + if (op->mRefresher){ ms_warning("presence_process_io_error() refresher is present, should not happen"); return; } - ms_message("subscription to [%s] io error",op->get_to()); - if (!op->op_released){ - op->root->callbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ + ms_message("subscription to [%s] io error",op->getTo()); + if (!op->mOpReleased){ + op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ } } } -void SalPresenceOp::presence_refresher_listener_cb(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry) { +void SalPresenceOp::presenceRefresherListenerCb(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry) { SalPresenceOp * op = (SalPresenceOp *)user_pointer; if (status_code >= 300) { ms_message("The SUBSCRIBE dialog no longer works. Let's restart a new one."); - belle_sip_refresher_stop(op->refresher); - if (op->dialog) { /*delete previous dialog if any*/ - op->set_or_update_dialog(NULL); + belle_sip_refresher_stop(op->mRefresher); + if (op->mDialog) { /*delete previous dialog if any*/ + op->setOrUpdateDialog(NULL); } - if (op->get_contact_address()) { + if (op->getContactAddress()) { /*contact is also probably not good*/ - SalAddress* contact=sal_address_clone(op->get_contact_address()); + SalAddress* contact=sal_address_clone(op->getContactAddress()); sal_address_set_port(contact,-1); sal_address_set_domain(contact,NULL); - op->set_contact_address(contact); + op->setContactAddress(contact); sal_address_destroy(contact); } /*send a new SUBSCRIBE, that will attempt to establish a new dialog*/ @@ -71,13 +71,13 @@ void SalPresenceOp::presence_refresher_listener_cb(belle_sip_refresher_t* refres } if (status_code == 0 || status_code == 503){ /*timeout or io error: the remote doesn't seem reachable.*/ - if (!op->op_released){ - op->root->callbacks.notify_presence(op,SalSubscribeActive, NULL,NULL); /*NULL = offline*/ + if (!op->mOpReleased){ + op->mRoot->mCallbacks.notify_presence(op,SalSubscribeActive, NULL,NULL); /*NULL = offline*/ } } } -void SalPresenceOp::presence_response_event_cb(void *op_base, const belle_sip_response_event_t *event) { +void SalPresenceOp::presenceResponseEventCb(void *op_base, const belle_sip_response_event_t *event) { SalPresenceOp * op = (SalPresenceOp *)op_base; belle_sip_dialog_state_t dialog_state; belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event); @@ -86,23 +86,23 @@ void SalPresenceOp::presence_response_event_cb(void *op_base, const belle_sip_re int code = belle_sip_response_get_status_code(response); belle_sip_header_expires_t* expires; - op->set_error_info_from_response(response); + op->setErrorInfoFromResponse(response); if (code>=300) { if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){ - ms_message("subscription to [%s] rejected",op->get_to()); - if (!op->op_released){ - op->root->callbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ + ms_message("subscription to [%s] rejected",op->getTo()); + if (!op->mOpReleased){ + op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ } return; } } - op->set_or_update_dialog(belle_sip_response_event_get_dialog(event)); - if (!op->dialog) { + op->setOrUpdateDialog(belle_sip_response_event_get_dialog(event)); + if (!op->mDialog) { ms_message("presence op [%p] receive out of dialog answer [%i]",op,code); return; } - dialog_state=belle_sip_dialog_get_state(op->dialog); + dialog_state=belle_sip_dialog_get_state(op->mDialog); switch(dialog_state) { case BELLE_SIP_DIALOG_NULL: @@ -113,15 +113,15 @@ void SalPresenceOp::presence_response_event_cb(void *op_base, const belle_sip_re case BELLE_SIP_DIALOG_CONFIRMED: { if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0) { expires=belle_sip_message_get_header_by_type(request,belle_sip_header_expires_t); - if(op->refresher) { - belle_sip_refresher_stop(op->refresher); - belle_sip_object_unref(op->refresher); - op->refresher=NULL; + if(op->mRefresher) { + belle_sip_refresher_stop(op->mRefresher); + belle_sip_object_unref(op->mRefresher); + op->mRefresher=NULL; } if ((expires != NULL) && (belle_sip_header_expires_get_expires(expires) > 0)) { - op->refresher=belle_sip_client_transaction_create_refresher(client_transaction); - belle_sip_refresher_set_listener(op->refresher,presence_refresher_listener_cb,op); - belle_sip_refresher_set_realm(op->refresher,op->realm); + op->mRefresher=belle_sip_client_transaction_create_refresher(client_transaction); + belle_sip_refresher_set_listener(op->mRefresher,presenceRefresherListenerCb,op); + belle_sip_refresher_set_realm(op->mRefresher,op->mRealm); } } break; @@ -133,7 +133,7 @@ void SalPresenceOp::presence_response_event_cb(void *op_base, const belle_sip_re } } -void SalPresenceOp::presence_process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void SalPresenceOp::presenceProcessTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { SalPresenceOp * op = (SalPresenceOp *)user_ctx; belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event); belle_sip_request_t* request; @@ -143,18 +143,18 @@ void SalPresenceOp::presence_process_timeout_cb(void *user_ctx, const belle_sip_ request = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)); if (strcmp("SUBSCRIBE",belle_sip_request_get_method(request))==0){ - ms_message("subscription to [%s] timeout",op->get_to()); - if (!op->op_released){ - op->root->callbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ + ms_message("subscription to [%s] timeout",op->getTo()); + if (!op->mOpReleased){ + op->mRoot->mCallbacks.notify_presence(op,SalSubscribeTerminated, NULL,NULL); /*NULL = offline*/ } } } -void SalPresenceOp::presence_process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { +void SalPresenceOp::presenceProcessTransactionTerminatedCb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { ms_message("presence_process_transaction_terminated not implemented yet"); } -SalPresenceModel *SalPresenceOp::process_presence_notification(belle_sip_request_t *req) { +SalPresenceModel *SalPresenceOp::processPresenceNotification(belle_sip_request_t *req) { belle_sip_header_content_type_t *content_type = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_content_type_t); belle_sip_header_content_length_t *content_length = belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_content_length_t); const char *body = belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)); @@ -166,8 +166,8 @@ SalPresenceModel *SalPresenceOp::process_presence_notification(belle_sip_request return NULL; if (body==NULL) return NULL; - if (!this->op_released){ - this->root->callbacks.parse_presence_requested(this, + if (!mOpReleased){ + mRoot->mCallbacks.parse_presence_requested(this, belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), body, @@ -177,9 +177,9 @@ SalPresenceModel *SalPresenceOp::process_presence_notification(belle_sip_request return result; } -void SalPresenceOp::handle_notify(belle_sip_request_t *req, belle_sip_dialog_t *dialog) { +void SalPresenceOp::handleNotify(belle_sip_request_t *req, belle_sip_dialog_t *dialog) { belle_sip_response_t* resp=NULL; - belle_sip_server_transaction_t* server_transaction= this->pending_server_trans; + belle_sip_server_transaction_t* server_transaction= mPendingServerTransaction; belle_sip_header_subscription_state_t* subscription_state_header=belle_sip_message_get_header_by_type(req,belle_sip_header_subscription_state_t); SalSubscribeStatus sub_state; @@ -187,100 +187,100 @@ void SalPresenceOp::handle_notify(belle_sip_request_t *req, belle_sip_dialog_t * SalPresenceModel *presence_model = NULL; const char* body = belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)); - if (this->dialog !=NULL && dialog != this->dialog){ - ms_warning("Receiving a NOTIFY from a dialog we haven't stored (op->dialog=%p dialog=%p)", this->dialog, dialog); + if (mDialog !=NULL && dialog != mDialog){ + ms_warning("Receiving a NOTIFY from a dialog we haven't stored (op->dialog=%p dialog=%p)", mDialog, dialog); } if (!subscription_state_header || strcasecmp(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,belle_sip_header_subscription_state_get_state(subscription_state_header)) ==0) { sub_state=SalSubscribeTerminated; - ms_message("Outgoing subscription terminated by remote [%s]",get_to()); + ms_message("Outgoing subscription terminated by remote [%s]",getTo()); } else { - sub_state=belle_sip_message_get_subscription_state(BELLE_SIP_MESSAGE(req)); + sub_state=getSubscriptionState(BELLE_SIP_MESSAGE(req)); } - presence_model = process_presence_notification(req); + presence_model = processPresenceNotification(req); if (presence_model != NULL || body==NULL) { /* Presence notification body parsed successfully. */ - resp = create_response_from_request(req, 200); /*create first because the op may be destroyed by notify_presence */ - if (!this->op_released){ - this->root->callbacks.notify_presence(this, sub_state, presence_model, NULL); + resp = createResponseFromRequest(req, 200); /*create first because the op may be destroyed by notify_presence */ + if (!mOpReleased){ + mRoot->mCallbacks.notify_presence(this, sub_state, presence_model, NULL); } } else if (body){ /* Formatting error in presence notification body. */ ms_warning("Wrongly formatted presence document."); - resp = create_response_from_request(req, 488); + resp = createResponseFromRequest(req, 488); } if (resp) belle_sip_server_transaction_send_response(server_transaction,resp); } } -void SalPresenceOp::presence_process_request_event_cb(void *op_base, const belle_sip_request_event_t *event) { +void SalPresenceOp::presenceProcessRequestEventCb(void *op_base, const belle_sip_request_event_t *event) { SalPresenceOp * op = (SalPresenceOp *)op_base; - belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->root->prov,belle_sip_request_event_get_request(event)); + belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->mRoot->mProvider,belle_sip_request_event_get_request(event)); belle_sip_request_t* req = belle_sip_request_event_get_request(event); belle_sip_dialog_state_t dialog_state; belle_sip_response_t* resp; const char *method=belle_sip_request_get_method(req); belle_sip_header_event_t *event_header; belle_sip_object_ref(server_transaction); - if (op->pending_server_trans) belle_sip_object_unref(op->pending_server_trans); - op->pending_server_trans=server_transaction; + if (op->mPendingServerTransaction) belle_sip_object_unref(op->mPendingServerTransaction); + op->mPendingServerTransaction=server_transaction; event_header=belle_sip_message_get_header_by_type(req,belle_sip_header_event_t); if (event_header==NULL){ ms_warning("No event header in incoming SUBSCRIBE."); - resp=op->create_response_from_request(req,400); + resp=op->createResponseFromRequest(req,400); belle_sip_server_transaction_send_response(server_transaction,resp); - if (!op->dialog) op->release(); + if (!op->mDialog) op->release(); return; } - if (op->event==NULL) { - op->event=event_header; - belle_sip_object_ref(op->event); + if (op->mEvent==NULL) { + op->mEvent=event_header; + belle_sip_object_ref(op->mEvent); } - if (!op->dialog) { + if (!op->mDialog) { if (strcmp(method,"SUBSCRIBE")==0){ - belle_sip_dialog_t *dialog = belle_sip_provider_create_dialog(op->root->prov,BELLE_SIP_TRANSACTION(server_transaction)); + belle_sip_dialog_t *dialog = belle_sip_provider_create_dialog(op->mRoot->mProvider,BELLE_SIP_TRANSACTION(server_transaction)); if (!dialog){ - resp=op->create_response_from_request(req,481); + resp=op->createResponseFromRequest(req,481); belle_sip_server_transaction_send_response(server_transaction,resp); op->release(); return; } - op->set_or_update_dialog(dialog); - ms_message("new incoming subscription from [%s] to [%s]",op->get_from(),op->get_to()); + op->setOrUpdateDialog(dialog); + ms_message("new incoming subscription from [%s] to [%s]",op->getFrom(),op->getTo()); }else if (strcmp(method,"NOTIFY")==0 && belle_sip_request_event_get_dialog(event)) { /*special case of dialog created by notify matching subscribe*/ - op->set_or_update_dialog(belle_sip_request_event_get_dialog(event)); + op->setOrUpdateDialog(belle_sip_request_event_get_dialog(event)); } else {/* this is a NOTIFY */ ms_message("Receiving out of dialog notify"); - op->handle_notify(req, belle_sip_request_event_get_dialog(event)); + op->handleNotify(req, belle_sip_request_event_get_dialog(event)); return; } } - dialog_state=belle_sip_dialog_get_state(op->dialog); + dialog_state=belle_sip_dialog_get_state(op->mDialog); switch(dialog_state) { case BELLE_SIP_DIALOG_NULL: { if (strcmp("NOTIFY",method)==0) { - op->handle_notify(req, belle_sip_request_event_get_dialog(event)); + op->handleNotify(req, belle_sip_request_event_get_dialog(event)); } else if (strcmp("SUBSCRIBE",method)==0) { - op->root->callbacks.subscribe_presence_received(op,op->get_from()); + op->mRoot->mCallbacks.subscribe_presence_received(op,op->getFrom()); } break; } case BELLE_SIP_DIALOG_EARLY: - ms_error("unexpected method [%s] for dialog [%p] in state BELLE_SIP_DIALOG_EARLY ",method,op->dialog); + ms_error("unexpected method [%s] for dialog [%p] in state BELLE_SIP_DIALOG_EARLY ",method,op->mDialog); break; case BELLE_SIP_DIALOG_CONFIRMED: if (strcmp("NOTIFY",method)==0) { - op->handle_notify(req, belle_sip_request_event_get_dialog(event)); + op->handleNotify(req, belle_sip_request_event_get_dialog(event)); } else if (strcmp("SUBSCRIBE",method)==0) { /*either a refresh or an unsubscribe. If it is a refresh there is nothing to notify to the app. If it is an unSUBSCRIBE, then the dialog will be terminated shortly, and this will be notified to the app through the dialog_terminated callback.*/ - resp=op->create_response_from_request(req,200); + resp=op->createResponseFromRequest(req,200); belle_sip_server_transaction_send_response(server_transaction,resp); } break; @@ -290,78 +290,78 @@ void SalPresenceOp::presence_process_request_event_cb(void *op_base, const belle } } -void SalPresenceOp::presence_process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { +void SalPresenceOp::presenceProcessDialogTerminatedCb(void *ctx, const belle_sip_dialog_terminated_event_t *event) { SalPresenceOp * op= (SalPresenceOp *)ctx; - if (op->dialog && belle_sip_dialog_is_server(op->dialog)) { - ms_message("Incoming subscribtion from [%s] terminated",op->get_from()); - if (!op->op_released){ - op->root->callbacks.subscribe_presence_closed(op, op->get_from()); + if (op->mDialog && belle_sip_dialog_is_server(op->mDialog)) { + ms_message("Incoming subscribtion from [%s] terminated",op->getFrom()); + if (!op->mOpReleased){ + op->mRoot->mCallbacks.subscribe_presence_closed(op, op->getFrom()); } - op->set_or_update_dialog(NULL); + op->setOrUpdateDialog(NULL); }/* else client dialog is managed by refresher*/ } -void SalPresenceOp::_release_cb(SalOp *op_base) { +void SalPresenceOp::releaseCb(SalOp *op_base) { SalPresenceOp *op =(SalPresenceOp *)op_base; - if(op->refresher) { - belle_sip_refresher_stop(op->refresher); - belle_sip_object_unref(op->refresher); - op->refresher=NULL; - op->set_or_update_dialog(NULL); /*only if we have refresher. else dialog terminated event will remove association*/ + if(op->mRefresher) { + belle_sip_refresher_stop(op->mRefresher); + belle_sip_object_unref(op->mRefresher); + op->mRefresher=NULL; + op->setOrUpdateDialog(NULL); /*only if we have refresher. else dialog terminated event will remove association*/ } } -void SalPresenceOp::fill_cbs() { +void SalPresenceOp::fillCallbacks() { static belle_sip_listener_callbacks_t op_presence_callbacks={0}; if (op_presence_callbacks.process_request_event==NULL){ - op_presence_callbacks.process_io_error=presence_process_io_error_cb; - op_presence_callbacks.process_response_event=presence_response_event_cb; - op_presence_callbacks.process_timeout= presence_process_timeout_cb; - op_presence_callbacks.process_transaction_terminated=presence_process_transaction_terminated_cb; - op_presence_callbacks.process_request_event=presence_process_request_event_cb; - op_presence_callbacks.process_dialog_terminated=presence_process_dialog_terminated_cb; + op_presence_callbacks.process_io_error=presenceProcessIoErrorCb; + op_presence_callbacks.process_response_event=presenceResponseEventCb; + op_presence_callbacks.process_timeout= presenceProcessTimeoutCb; + op_presence_callbacks.process_transaction_terminated=presenceProcessTransactionTerminatedCb; + op_presence_callbacks.process_request_event=presenceProcessRequestEventCb; + op_presence_callbacks.process_dialog_terminated=presenceProcessDialogTerminatedCb; } - this->callbacks=&op_presence_callbacks; - this->type=Type::Presence; - this->release_cb=_release_cb; + mCallbacks=&op_presence_callbacks; + mType=Type::Presence; + mReleaseCb=releaseCb; } int SalPresenceOp::subscribe(const char *from, const char *to, int expires) { belle_sip_request_t *req=NULL; if (from) - set_from(from); + setFrom(from); if (to) - set_to(to); + setTo(to); - fill_cbs(); + fillCallbacks(); if (expires==-1){ - if (this->refresher){ - expires=belle_sip_refresher_get_expires(this->refresher); - belle_sip_object_unref(this->refresher); - this->refresher=NULL; + if (mRefresher){ + expires=belle_sip_refresher_get_expires(mRefresher); + belle_sip_object_unref(mRefresher); + mRefresher=NULL; }else{ ms_error("sal_subscribe_presence(): cannot guess expires from previous refresher."); return -1; } } - if (!this->event){ - this->event=belle_sip_header_event_create("presence"); - belle_sip_object_ref(this->event); + if (!mEvent){ + mEvent=belle_sip_header_event_create("presence"); + belle_sip_object_ref(mEvent); } - belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(this->from_address),"tag"); - belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(this->to_address),"tag"); - req=build_request("SUBSCRIBE"); + belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(mFromAddress),"tag"); + belle_sip_parameters_remove_parameter(BELLE_SIP_PARAMETERS(mToAddress),"tag"); + req=buildRequest("SUBSCRIBE"); if( req ){ - belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(this->event)); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(mEvent)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(expires))); } - return send_request(req); + return sendRequest(req); } -int SalPresenceOp::check_dialog_state() { - belle_sip_dialog_state_t state= this->dialog?belle_sip_dialog_get_state(this->dialog): BELLE_SIP_DIALOG_NULL; +int SalPresenceOp::checkDialogState() { + belle_sip_dialog_state_t state= mDialog?belle_sip_dialog_get_state(mDialog): BELLE_SIP_DIALOG_NULL; if (state != BELLE_SIP_DIALOG_CONFIRMED) { ms_warning("Cannot notify presence for op [%p] because dialog in state [%s]", this, belle_sip_dialog_state_to_string(state)); return -1; @@ -369,15 +369,15 @@ int SalPresenceOp::check_dialog_state() { return 0; } -belle_sip_request_t *SalPresenceOp::create_presence_notify() { - belle_sip_request_t* notify=belle_sip_dialog_create_queued_request(this->dialog,"NOTIFY"); +belle_sip_request_t *SalPresenceOp::createPresenceNotify() { + belle_sip_request_t* notify=belle_sip_dialog_create_queued_request(mDialog,"NOTIFY"); if (!notify) return NULL; belle_sip_message_add_header((belle_sip_message_t*)notify,belle_sip_header_create("Event","presence")); return notify; } -void SalPresenceOp::add_presence_info(belle_sip_message_t *notify, SalPresenceModel *presence) { +void SalPresenceOp::addPresenceInfo(belle_sip_message_t *notify, SalPresenceModel *presence) { char *contact_info; char *content = NULL; size_t content_length; @@ -385,7 +385,7 @@ void SalPresenceOp::add_presence_info(belle_sip_message_t *notify, SalPresenceMo if (presence){ belle_sip_header_from_t *from=belle_sip_message_get_header_by_type(notify,belle_sip_header_from_t); contact_info=belle_sip_uri_to_string(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from))); - this->root->callbacks.convert_presence_to_xml_requested(this, presence, contact_info, &content); + mRoot->mCallbacks.convert_presence_to_xml_requested(this, presence, contact_info, &content); belle_sip_free(contact_info); if (content == NULL) return; } @@ -404,38 +404,38 @@ void SalPresenceOp::add_presence_info(belle_sip_message_t *notify, SalPresenceMo } } -int SalPresenceOp::notify_presence(SalPresenceModel *presence) { +int SalPresenceOp::notifyPresence(SalPresenceModel *presence) { belle_sip_request_t* notify=NULL; - if (check_dialog_state()) { + if (checkDialogState()) { return -1; } - notify=create_presence_notify(); + notify=createPresenceNotify(); if (!notify) return-1; - add_presence_info(BELLE_SIP_MESSAGE(notify),presence); /*FIXME, what about expires ??*/ + addPresenceInfo(BELLE_SIP_MESSAGE(notify),presence); /*FIXME, what about expires ??*/ belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify) ,BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_ACTIVE,600))); - return send_request(notify); + return sendRequest(notify); } -int SalPresenceOp::notify_presence_close() { +int SalPresenceOp::notifyPresenceClose() { belle_sip_request_t* notify=NULL; int status; - if (check_dialog_state()) { + if (checkDialogState()) { return -1; } - notify=create_presence_notify(); + notify=createPresenceNotify(); if (!notify) return-1; - add_presence_info(BELLE_SIP_MESSAGE(notify),NULL); /*FIXME, what about expires ??*/ + addPresenceInfo(BELLE_SIP_MESSAGE(notify),NULL); /*FIXME, what about expires ??*/ belle_sip_message_add_header(BELLE_SIP_MESSAGE(notify) ,BELLE_SIP_HEADER(belle_sip_header_subscription_state_create(BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED,-1))); - status = send_request(notify); - set_or_update_dialog(NULL); /*because we may be chalanged for the notify, so we must release dialog right now*/ + status = sendRequest(notify); + setOrUpdateDialog(NULL); /*because we may be chalanged for the notify, so we must release dialog right now*/ return status; } -SalSubscribeStatus SalPresenceOp::belle_sip_message_get_subscription_state(const belle_sip_message_t *msg) { +SalSubscribeStatus SalPresenceOp::getSubscriptionState(const belle_sip_message_t *msg) { belle_sip_header_subscription_state_t* subscription_state_header=belle_sip_message_get_header_by_type(msg,belle_sip_header_subscription_state_t); SalSubscribeStatus sss=SalSubscribeNone; if (subscription_state_header){ diff --git a/src/sal/presence-op.h b/src/sal/presence-op.h index d0cf26b9a..72e5238a5 100644 --- a/src/sal/presence-op.h +++ b/src/sal/presence-op.h @@ -24,33 +24,33 @@ LINPHONE_BEGIN_NAMESPACE -class SalPresenceOp: public SalSubscribeOp { +class SalPresenceOp : public SalSubscribeOp { public: - SalPresenceOp(Sal *sal): SalSubscribeOp(sal) {} + SalPresenceOp (Sal *sal) : SalSubscribeOp(sal) {} - int subscribe(const char *from, const char *to, int expires); - int unsubscribe() {return SalOp::unsubscribe();} - int notify_presence(SalPresenceModel *presence); - int notify_presence_close(); + int subscribe (const char *from, const char *to, int expires); + int unsubscribe () { return SalOp::unsubscribe(); } + int notifyPresence (SalPresenceModel *presence); + int notifyPresenceClose (); private: - virtual void fill_cbs() override; - void handle_notify(belle_sip_request_t *req, belle_sip_dialog_t *dialog); - SalPresenceModel * process_presence_notification(belle_sip_request_t *req); - int check_dialog_state(); - belle_sip_request_t *create_presence_notify(); - void add_presence_info(belle_sip_message_t *notify, SalPresenceModel *presence); + virtual void fillCallbacks () override; + void handleNotify (belle_sip_request_t *request, belle_sip_dialog_t *dialog); + SalPresenceModel *processPresenceNotification (belle_sip_request_t *request); + int checkDialogState (); + belle_sip_request_t *createPresenceNotify (); + void addPresenceInfo (belle_sip_message_t *notify, SalPresenceModel *presence); - static SalSubscribeStatus belle_sip_message_get_subscription_state(const belle_sip_message_t *msg); + static SalSubscribeStatus getSubscriptionState (const belle_sip_message_t *message); - static void presence_process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static void presence_response_event_cb(void *op_base, const belle_sip_response_event_t *event); - static void presence_refresher_listener_cb(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry); - static void presence_process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void presence_process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event); - static void presence_process_request_event_cb(void *op_base, const belle_sip_request_event_t *event); - static void presence_process_dialog_terminated_cb(void *ctx, const belle_sip_dialog_terminated_event_t *event); - static void _release_cb(SalOp *op_base); + static void presenceProcessIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static void presenceResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void presenceRefresherListenerCb (belle_sip_refresher_t *refresher, void *userCtx, unsigned int statusCode, const char *reasonPhrase, int willRetry); + static void presenceProcessTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void presenceProcessTransactionTerminatedCb (void *userCtx, const belle_sip_transaction_terminated_event_t *event); + static void presenceProcessRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); + static void presenceProcessDialogTerminatedCb (void *userCtx, const belle_sip_dialog_terminated_event_t *event); + static void releaseCb (SalOp *op); }; LINPHONE_END_NAMESPACE diff --git a/src/sal/refer-op.cpp b/src/sal/refer-op.cpp index 6cc1b34b1..93d36e1dd 100644 --- a/src/sal/refer-op.cpp +++ b/src/sal/refer-op.cpp @@ -23,38 +23,38 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -void SalReferOp::process_error() { - this->state=State::Terminated; +void SalReferOp::processError() { + mState=State::Terminated; } -void SalReferOp::process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event) { +void SalReferOp::processIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event) { SalReferOp * op = (SalReferOp *)user_ctx; - sal_error_info_set(&op->error_info,SalReasonIOError, "SIP", 503,"IO Error",NULL); - op->process_error(); + sal_error_info_set(&op->mErrorInfo,SalReasonIOError, "SIP", 503,"IO Error",NULL); + op->processError(); } -void SalReferOp::process_response_event_cb(void *op_base, const belle_sip_response_event_t *event) { +void SalReferOp::processResponseEventCb(void *op_base, const belle_sip_response_event_t *event) { SalReferOp * op = (SalReferOp *)op_base; - op->set_error_info_from_response(belle_sip_response_event_get_response(event)); + op->setErrorInfoFromResponse(belle_sip_response_event_get_response(event)); /*the response is not notified to the app*/ /*To be done when necessary*/ } -void SalReferOp::process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void SalReferOp::processTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { SalReferOp * op=(SalReferOp *)user_ctx; - sal_error_info_set(&op->error_info,SalReasonRequestTimeout, "SIP", 408,"Request timeout",NULL); - op->process_error(); + sal_error_info_set(&op->mErrorInfo,SalReasonRequestTimeout, "SIP", 408,"Request timeout",NULL); + op->processError(); } -void SalReferOp::process_request_event_cb(void *op_base, const belle_sip_request_event_t *event) { +void SalReferOp::processRequestEventCb(void *op_base, const belle_sip_request_event_t *event) { SalReferOp * op = (SalReferOp *)op_base; belle_sip_request_t *req = belle_sip_request_event_get_request(event); belle_sip_header_refer_to_t *refer_to= belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_refer_to_t); - belle_sip_server_transaction_t *server_transaction = belle_sip_provider_create_server_transaction(op->root->prov,belle_sip_request_event_get_request(event)); + belle_sip_server_transaction_t *server_transaction = belle_sip_provider_create_server_transaction(op->mRoot->mProvider,belle_sip_request_event_get_request(event)); belle_sip_object_ref(server_transaction); belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(server_transaction),op->ref()); - op->pending_server_trans = server_transaction; + op->mPendingServerTransaction = server_transaction; if (!refer_to){ ms_warning("cannot do anything with the refer without destination"); @@ -63,49 +63,49 @@ void SalReferOp::process_request_event_cb(void *op_base, const belle_sip_request return; } SalAddress *referToAddr = sal_address_new(belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(refer_to))); - op->root->callbacks.refer_received(op, referToAddr); + op->mRoot->mCallbacks.refer_received(op, referToAddr); /*the app is expected to reply in the callback*/ sal_address_unref(referToAddr); op->unref(); } -void SalReferOp::fill_cbs() { +void SalReferOp::fillCallbacks() { static belle_sip_listener_callbacks_t op_refer_callbacks = {0}; if (op_refer_callbacks.process_io_error==NULL) { - op_refer_callbacks.process_io_error=process_io_error_cb; - op_refer_callbacks.process_response_event=process_response_event_cb; - op_refer_callbacks.process_timeout=process_timeout_cb; - op_refer_callbacks.process_request_event=process_request_event_cb; + op_refer_callbacks.process_io_error=processIoErrorCb; + op_refer_callbacks.process_response_event=processResponseEventCb; + op_refer_callbacks.process_timeout=processTimeoutCb; + op_refer_callbacks.process_request_event=processRequestEventCb; } - this->callbacks=&op_refer_callbacks; - this->type=Type::Refer; + mCallbacks=&op_refer_callbacks; + mType=Type::Refer; } SalReferOp::SalReferOp(Sal *sal) : SalOp(sal){ - fill_cbs(); + fillCallbacks(); } -int SalReferOp::send_refer(const SalAddress *refer_to) { - this->dir=Dir::Outgoing; +int SalReferOp::sendRefer(const SalAddress *refer_to) { + mDir=Dir::Outgoing; - belle_sip_request_t* req=build_request("REFER"); + belle_sip_request_t* req=buildRequest("REFER"); if (req == NULL ) return -1; - if (get_contact_address()) belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(create_contact())); + if (getContactAddress()) belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(createContact())); belle_sip_header_address_t *address = BELLE_SIP_HEADER_ADDRESS(refer_to); belle_sip_uri_t *uri = belle_sip_header_address_get_uri(address); if (!belle_sip_uri_get_host(uri)) belle_sip_header_address_set_automatic(address, true); belle_sip_header_refer_to_t *refer_to_header = belle_sip_header_refer_to_create(address); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req), BELLE_SIP_HEADER(refer_to_header)); - return send_request(req); + return sendRequest(req); } int SalReferOp::reply(SalReason reason){ - if (this->pending_server_trans){ + if (mPendingServerTransaction){ int code=to_sip_code(reason); belle_sip_response_t *resp = belle_sip_response_create_from_request( - belle_sip_transaction_get_request((belle_sip_transaction_t*)this->pending_server_trans),code); - belle_sip_server_transaction_send_response(this->pending_server_trans,resp); + belle_sip_transaction_get_request((belle_sip_transaction_t*)mPendingServerTransaction),code); + belle_sip_server_transaction_send_response(mPendingServerTransaction,resp); return 0; }else ms_error("SalReferOp::reply: no server transaction"); return -1; diff --git a/src/sal/refer-op.h b/src/sal/refer-op.h index c69b4e362..74300e7f9 100644 --- a/src/sal/refer-op.h +++ b/src/sal/refer-op.h @@ -24,23 +24,23 @@ LINPHONE_BEGIN_NAMESPACE -class SalReferOp: public SalOp{ +class SalReferOp : public SalOp { public: - SalReferOp(Sal *sal); + SalReferOp (Sal *sal); - int send_refer(const SalAddress *refer_to); - int reply(SalReason reason); + int sendRefer (const SalAddress *referTo); + int reply (SalReason reason); private: - virtual void fill_cbs() override; - void process_error(); + virtual void fillCallbacks () override; + void processError (); - static void process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static void process_response_event_cb(void *op_base, const belle_sip_response_event_t *event); - static void process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void process_request_event_cb(void *op_base, const belle_sip_request_event_t *event); + static void processIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static void processResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void processTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void processRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); }; LINPHONE_END_NAMESPACE -#endif // ifndef _L_SAL_MESSAGE_OP_H_ +#endif // ifndef _L_SAL_REFER_OP_H_ diff --git a/src/sal/register-op.cpp b/src/sal/register-op.cpp index 4552bddf8..fe63de045 100644 --- a/src/sal/register-op.cpp +++ b/src/sal/register-op.cpp @@ -24,31 +24,31 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -int SalRegisterOp::register_(const char *proxy, const char *from, int expires, const SalAddress* old_contact) { +int SalRegisterOp::sendRegister(const char *proxy, const char *from, int expires, const SalAddress* old_contact) { belle_sip_request_t *req; belle_sip_uri_t* req_uri; belle_sip_header_t* accept_header; - if (this->refresher){ - belle_sip_refresher_stop(this->refresher); - belle_sip_object_unref(this->refresher); - this->refresher=NULL; + if (mRefresher){ + belle_sip_refresher_stop(mRefresher); + belle_sip_object_unref(mRefresher); + mRefresher=NULL; } - this->type=Type::Register; - set_from(from); - set_to(from); - set_route(proxy); - req = build_request("REGISTER"); + mType=Type::Register; + setFrom(from); + setTo(from); + setRoute(proxy); + req = buildRequest("REGISTER"); req_uri = belle_sip_request_get_uri(req); belle_sip_uri_set_user(req_uri,NULL); /*remove userinfo if any*/ - if (this->root->_use_dates) { + if (mRoot->mUseDates) { time_t curtime=time(NULL); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime))); } accept_header = belle_sip_header_create("Accept", "application/sdp, text/plain, application/vnd.gsma.rcs-ft-http+xml"); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req), accept_header); - belle_sip_message_set_header(BELLE_SIP_MESSAGE(req),(belle_sip_header_t*)create_contact()); + belle_sip_message_set_header(BELLE_SIP_MESSAGE(req),(belle_sip_header_t*)createContact()); if (old_contact) { belle_sip_header_contact_t *contact=belle_sip_header_contact_create((const belle_sip_header_address_t *)old_contact); if (contact) { @@ -62,22 +62,22 @@ int SalRegisterOp::register_(const char *proxy, const char *from, int expires, c ms_error("Cannot add old contact header to op [%p]",this); } } - return send_and_create_refresher(req,expires,register_refresher_listener); + return sendRequestAndCreateRefresher(req,expires,registerRefresherListener); } -void SalRegisterOp::register_refresher_listener(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry) { +void SalRegisterOp::registerRefresherListener(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry) { SalRegisterOp * op = (SalRegisterOp *)user_pointer; belle_sip_response_t* response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher))); - ms_message("Register refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase,op->get_proxy()); + ms_message("Register refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase,op->getProxy()); if (belle_sip_refresher_get_auth_events(refresher)) { - if (op->auth_info) sal_auth_info_delete(op->auth_info); + if (op->mAuthInfo) sal_auth_info_delete(op->mAuthInfo); /*only take first one for now*/ - op->auth_info=sal_auth_info_create((belle_sip_auth_event_t*)(belle_sip_refresher_get_auth_events(refresher)->data)); + op->mAuthInfo=sal_auth_info_create((belle_sip_auth_event_t*)(belle_sip_refresher_get_auth_events(refresher)->data)); } - sal_error_info_set(&op->error_info,SalReasonUnknown, "SIP", (int)status_code, reason_phrase, NULL); + sal_error_info_set(&op->mErrorInfo,SalReasonUnknown, "SIP", (int)status_code, reason_phrase, NULL); if (status_code>=200){ - op->assign_recv_headers((belle_sip_message_t*)response); + op->assignRecvHeaders((belle_sip_message_t*)response); } if(status_code == 200) { /*check service route rfc3608*/ @@ -87,24 +87,24 @@ void SalRegisterOp::register_refresher_listener(belle_sip_refresher_t* refresher if ((service_route=belle_sip_message_get_header_by_type(response,belle_sip_header_service_route_t))) { service_route_address=belle_sip_header_address_create(NULL,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(service_route))); } - op->set_service_route((const SalAddress*)service_route_address); + op->setServiceRoute((const SalAddress*)service_route_address); if (service_route_address) belle_sip_object_unref(service_route_address); - op->root->remove_pending_auth(op); /*just in case*/ + op->mRoot->removePendingAuth(op); /*just in case*/ if (contact) { const char *gruu; belle_sip_parameters_t* p = (BELLE_SIP_PARAMETERS(contact)); if((gruu = belle_sip_parameters_get_parameter(p, "pub-gruu"))) { char *unquoted = belle_sip_unquote_strdup(gruu); - op->set_contact_address((SalAddress*)belle_sip_header_address_parse(unquoted)); + op->setContactAddress((SalAddress*)belle_sip_header_address_parse(unquoted)); bctbx_free(unquoted); belle_sip_parameters_remove_parameter(p, "pub-gruu"); } else { - op->set_contact_address((SalAddress*)(BELLE_SIP_HEADER_ADDRESS(contact))); /*update contact with real value*/ + op->setContactAddress((SalAddress*)(BELLE_SIP_HEADER_ADDRESS(contact))); /*update contact with real value*/ } } - op->root->callbacks.register_success(op,belle_sip_refresher_get_expires(op->refresher)>0); + op->mRoot->mCallbacks.register_success(op,belle_sip_refresher_get_expires(op->mRefresher)>0); } else if (status_code>=400) { /* from rfc3608, 6.1. If the UA refreshes the registration, the stored value of the Service- @@ -115,14 +115,14 @@ void SalRegisterOp::register_refresher_listener(belle_sip_refresher_t* refresher request is refused or if an existing registration expires and the UA chooses not to re-register, the UA SHOULD discard any stored service route for that address-of-record. */ - op->set_service_route(NULL); + op->setServiceRoute(NULL); op->ref(); /*take a ref while invoking the callback to make sure the operations done after are valid*/ - op->root->callbacks.register_failure(op); - if (op->state!=State::Terminated && op->auth_info) { + op->mRoot->mCallbacks.register_failure(op); + if (op->mState!=State::Terminated && op->mAuthInfo) { /*add pending auth*/ - op->root->add_pending_auth(op); + op->mRoot->addPendingAuth(op); if (status_code==403 || status_code==401 || status_code==407 ) - op->root->callbacks.auth_failure(op,op->auth_info); + op->mRoot->mCallbacks.auth_failure(op,op->mAuthInfo); } op->unref(); } diff --git a/src/sal/register-op.h b/src/sal/register-op.h index d14b9612a..e7e06791c 100644 --- a/src/sal/register-op.h +++ b/src/sal/register-op.h @@ -24,19 +24,22 @@ LINPHONE_BEGIN_NAMESPACE -class SalRegisterOp: public SalOp { +class SalRegisterOp : public SalOp { public: - SalRegisterOp(Sal *sal): SalOp(sal) {} + SalRegisterOp(Sal *sal) : SalOp(sal) {} - int register_(const char *proxy, const char *from, int expires, const SalAddress* old_contact); - int register_refresh(int expires) {return this->refresher ? belle_sip_refresher_refresh(this->refresher,expires) : -1;} - int unregister() {return register_refresh(0);} + int sendRegister (const char *proxy, const char *from, int expires, const SalAddress *oldContact); + int refreshRegister (int expires) { + return mRefresher ? belle_sip_refresher_refresh(mRefresher, expires) : -1; + } + int unregister() { return refreshRegister(0); } - virtual void authenticate(const SalAuthInfo *info) override {register_refresh(-1);} + void authenticate (const SalAuthInfo *info) override { + refreshRegister(-1); } private: - virtual void fill_cbs() override {}; - static void register_refresher_listener(belle_sip_refresher_t* refresher, void* user_pointer, unsigned int status_code, const char* reason_phrase, int will_retry); + virtual void fillCallbacks () override {}; + static void registerRefresherListener (belle_sip_refresher_t *refresher, void *userCtx, unsigned int statusCode, const char *reasonPhrase, int willRetry); }; LINPHONE_END_NAMESPACE diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index 5c3a58385..13e71970e 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -31,26 +31,26 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -void Sal::process_dialog_terminated_cb(void *sal, const belle_sip_dialog_terminated_event_t *event) { +void Sal::processDialogTerminatedCb(void *sal, const belle_sip_dialog_terminated_event_t *event) { belle_sip_dialog_t* dialog = belle_sip_dialog_terminated_event_get_dialog(event); SalOp* op = reinterpret_cast(belle_sip_dialog_get_application_data(dialog)); - if (op && op->callbacks && op->callbacks->process_dialog_terminated) { - op->callbacks->process_dialog_terminated(op,event); + if (op && op->mCallbacks && op->mCallbacks->process_dialog_terminated) { + op->mCallbacks->process_dialog_terminated(op,event); } else { ms_error("sal process_dialog_terminated no op found for this dialog [%p], ignoring",dialog); } } -void Sal::process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event){ +void Sal::processIoErrorCb(void *user_ctx, const belle_sip_io_error_event_t *event){ belle_sip_client_transaction_t*client_transaction; SalOp* op; if (BELLE_SIP_OBJECT_IS_INSTANCE_OF(belle_sip_io_error_event_get_source(event),belle_sip_client_transaction_t)) { client_transaction=BELLE_SIP_CLIENT_TRANSACTION(belle_sip_io_error_event_get_source(event)); op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction)); /*also reset auth count on IO error*/ - op->auth_requests=0; - if (op->callbacks && op->callbacks->process_io_error) { - op->callbacks->process_io_error(op,event); + op->mAuthRequests=0; + if (op->mCallbacks && op->mCallbacks->process_io_error) { + op->mCallbacks->process_io_error(op,event); } } else { /*ms_error("sal process_io_error not implemented yet for non transaction");*/ @@ -58,7 +58,7 @@ void Sal::process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t * } } -void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *event) { +void Sal::processRequestEventCb (void *ud, const belle_sip_request_event_t *event) { Sal *sal = (Sal *)ud; SalOp *op = NULL; belle_sip_request_t *req = belle_sip_request_event_get_request(event); @@ -84,7 +84,7 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e belle_sip_transaction_t * sub_trans = belle_sip_dialog_get_last_transaction(dialog); op = (SalOp*)belle_sip_transaction_get_application_data(sub_trans); } - if (op == NULL || op->state == SalOp::State::Terminated){ + if (op == NULL || op->mState == SalOp::State::Terminated){ ms_warning("Receiving request for null or terminated op [%p], ignored",op); return; } @@ -94,7 +94,7 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e if ((strcmp("INVITE",method)==0 || strcmp("NOTIFY",method)==0) && (belle_sip_header_to_get_tag(to) != NULL)) { ms_warning("Receiving %s with to-tag but no know dialog here. Rejecting.", method); resp=belle_sip_response_create_from_request(req,481); - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; /* by default (eg. when a to-tag is present), out of dialog ACK are automatically handled in lower layers (belle-sip) but in case it misses, it will be forwarded to us */ @@ -105,52 +105,52 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e if (strcmp("INVITE",method)==0) { op=new SalCallOp(sal); - op->fill_cbs(); + op->fillCallbacks(); }else if ((strcmp("SUBSCRIBE",method)==0 || strcmp("NOTIFY",method)==0) && (evh=belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),"Event"))!=NULL) { if (strncmp(belle_sip_header_get_unparsed_value(evh),"presence",strlen("presence"))==0){ op=new SalPresenceOp(sal); } else { op=new SalSubscribeOp(sal); } - op->fill_cbs(); + op->fillCallbacks(); }else if (strcmp("MESSAGE",method)==0) { op=new SalMessageOp(sal); - op->fill_cbs(); + op->fillCallbacks(); }else if (strcmp("REFER",method)==0) { op=new SalReferOp(sal); }else if (strcmp("OPTIONS",method)==0) { resp=belle_sip_response_create_from_request(req,200); - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; }else if (strcmp("INFO",method)==0) { resp=belle_sip_response_create_from_request(req,481);/*INFO out of call dialogs are not allowed*/ - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; }else if (strcmp("BYE",method)==0) { resp=belle_sip_response_create_from_request(req,481);/*out of dialog BYE */ - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; }else if (strcmp("CANCEL",method)==0) { resp=belle_sip_response_create_from_request(req,481);/*out of dialog CANCEL */ - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; - }else if (sal->_enable_test_features && strcmp("PUBLISH",method)==0) { + }else if (sal->mEnableTestFeatures && strcmp("PUBLISH",method)==0) { resp=belle_sip_response_create_from_request(req,200);/*out of dialog PUBLISH */ belle_sip_message_add_header((belle_sip_message_t*)resp,belle_sip_header_create("SIP-Etag","4441929FFFZQOA")); - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; }else { ms_error("sal process_request_event not implemented yet for method [%s]",belle_sip_request_get_method(req)); resp=belle_sip_response_create_from_request(req,405); belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp) ,BELLE_SIP_HEADER(belle_sip_header_allow_create("INVITE, CANCEL, ACK, BYE, SUBSCRIBE, NOTIFY, MESSAGE, OPTIONS, INFO"))); - belle_sip_provider_send_response(sal->prov,resp); + belle_sip_provider_send_response(sal->mProvider,resp); return; } - op->dir=SalOp::Dir::Incoming; + op->mDir=SalOp::Dir::Incoming; } - if (!op->from_address) { + if (!op->mFromAddress) { if (belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header))) address=belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(from_header)) ,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header))); @@ -159,15 +159,15 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e ,belle_sip_header_address_get_absolute_uri(BELLE_SIP_HEADER_ADDRESS(from_header))); else ms_error("Cannot not find from uri from request [%p]",req); - op->set_from_address((SalAddress*)address); + op->setFromAddress((SalAddress*)address); belle_sip_object_unref(address); } if( remote_contact ){ - op->set_remote_contact(belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(remote_contact))); + op->setRemoteContact(belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(remote_contact))); } - if (!op->to_address) { + if (!op->mToAddress) { to=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_to_t); if (belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(to))) address=belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(to)) @@ -178,16 +178,16 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e else ms_error("Cannot not find to uri from request [%p]",req); - op->set_to_address((SalAddress*)address); + op->setToAddress((SalAddress*)address); belle_sip_object_unref(address); } if (subjectHeader) { const char *subject = belle_sip_header_get_unparsed_value(subjectHeader); - op->set_subject(subject); + op->setSubject(subject); } - if(!op->diversion_address){ + if(!op->mDiversionAddress){ diversion=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_diversion_t); if (diversion) { if (belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(diversion))) @@ -199,42 +199,42 @@ void Sal::process_request_event_cb (void *ud, const belle_sip_request_event_t *e else ms_warning("Cannot not find diversion header from request [%p]",req); if (address) { - op->set_diversion_address((SalAddress*)address); + op->setDiversionAddress((SalAddress*)address); belle_sip_object_unref(address); } } } - if (!op->origin) { + if (!op->mOrigin) { /*set origin uri*/ origin_address=belle_sip_header_address_create(NULL,belle_sip_request_extract_origin(req)); - op->set_network_origin_address((SalAddress*)origin_address); + op->setNetworkOriginAddress((SalAddress*)origin_address); belle_sip_object_unref(origin_address); } - if (!op->remote_ua) { - op->set_remote_ua(BELLE_SIP_MESSAGE(req)); + if (!op->mRemoteUserAgent) { + op->setRemoteUserAgent(BELLE_SIP_MESSAGE(req)); } - if (!op->call_id) { - op->call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_call_id_t)))); + if (!op->mCallId) { + op->mCallId=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_call_id_t)))); } /*It is worth noting that proxies can (and will) remove this header field*/ - op->set_privacy_from_message((belle_sip_message_t*)req); + op->setPrivacyFromMessage((belle_sip_message_t*)req); if (strcmp("ACK",method) != 0){ /*The ACK custom header is processed specifically later on*/ - op->assign_recv_headers((belle_sip_message_t*)req); + op->assignRecvHeaders((belle_sip_message_t*)req); } - if (op->callbacks && op->callbacks->process_request_event) { - op->callbacks->process_request_event(op,event); + if (op->mCallbacks && op->mCallbacks->process_request_event) { + op->mCallbacks->process_request_event(op,event); } else { ms_error("sal process_request_event not implemented yet"); } } -void Sal::process_response_event_cb(void *user_ctx, const belle_sip_response_event_t *event) { +void Sal::processResponseEventCb(void *user_ctx, const belle_sip_response_event_t *event) { belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event); belle_sip_response_t* response = belle_sip_response_event_get_response(event); int response_code = belle_sip_response_get_status_code(response); @@ -247,81 +247,81 @@ void Sal::process_response_event_cb(void *user_ctx, const belle_sip_response_eve belle_sip_request_t* request=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)); belle_sip_header_contact_t* remote_contact = belle_sip_message_get_header_by_type(response, belle_sip_header_contact_t); - if (op->state == SalOp::State::Terminated) { + if (op->mState == SalOp::State::Terminated) { belle_sip_message("Op [%p] is terminated, nothing to do with this [%i]", op, response_code); return; } /*do it all the time, since we can receive provisional responses from a different instance than the final one*/ - op->set_remote_ua(BELLE_SIP_MESSAGE(response)); + op->setRemoteUserAgent(BELLE_SIP_MESSAGE(response)); if(remote_contact) { - op->set_remote_contact(belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(remote_contact))); + op->setRemoteContact(belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(remote_contact))); } - if (!op->call_id) { - op->call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(response), belle_sip_header_call_id_t)))); + if (!op->mCallId) { + op->mCallId=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(response), belle_sip_header_call_id_t)))); } - op->assign_recv_headers((belle_sip_message_t*)response); + op->assignRecvHeaders((belle_sip_message_t*)response); - if (op->callbacks && op->callbacks->process_response_event) { + if (op->mCallbacks && op->mCallbacks->process_response_event) { /*handle authorization*/ switch (response_code) { case 200: break; case 401: case 407: - if (op->state == SalOp::State::Terminating && strcmp("BYE",belle_sip_request_get_method(request))!=0) { + if (op->mState == SalOp::State::Terminating && strcmp("BYE",belle_sip_request_get_method(request))!=0) { /*only bye are completed*/ belle_sip_message("Op is in state terminating, nothing else to do "); } else { - if (op->pending_auth_transaction){ - belle_sip_object_unref(op->pending_auth_transaction); - op->pending_auth_transaction=NULL; + if (op->mPendingAuthTransaction){ + belle_sip_object_unref(op->mPendingAuthTransaction); + op->mPendingAuthTransaction=NULL; } - if (++op->auth_requests > 2) { - ms_warning("Auth info cannot be found for op [%s/%s] after 2 attempts, giving up",op->get_from() - ,op->get_to()); - op->root->callbacks.auth_failure(op,op->auth_info); - op->root->remove_pending_auth(op); + if (++op->mAuthRequests > 2) { + ms_warning("Auth info cannot be found for op [%s/%s] after 2 attempts, giving up",op->getFrom() + ,op->getTo()); + op->mRoot->mCallbacks.auth_failure(op,op->mAuthInfo); + op->mRoot->removePendingAuth(op); } else { - op->pending_auth_transaction=(belle_sip_client_transaction_t*)belle_sip_object_ref(client_transaction); - op->process_authentication(); + op->mPendingAuthTransaction=(belle_sip_client_transaction_t*)belle_sip_object_ref(client_transaction); + op->processAuthentication(); return; } } break; case 403: - if (op->auth_info) op->root->callbacks.auth_failure(op,op->auth_info); + if (op->mAuthInfo) op->mRoot->mCallbacks.auth_failure(op,op->mAuthInfo); break; case 302: case 301: - if (op->process_redirect() == 0) + if (op->processRedirect() == 0) return; break; } if (response_code >= 180 && response_code !=401 && response_code !=407 && response_code !=403) { /*not an auth request*/ - op->auth_requests=0; + op->mAuthRequests=0; } - op->callbacks->process_response_event(op,event); + op->mCallbacks->process_response_event(op,event); } else { ms_error("Unhandled event response [%p]",event); } } } -void Sal::process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event) { +void Sal::processTimeoutCb(void *user_ctx, const belle_sip_timeout_event_t *event) { belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event); SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction)); - if (op && op->callbacks && op->callbacks->process_timeout) { - op->callbacks->process_timeout(op,event); + if (op && op->mCallbacks && op->mCallbacks->process_timeout) { + op->mCallbacks->process_timeout(op,event); } else { ms_error("Unhandled event timeout [%p]",event); } } -void Sal::process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { +void Sal::processTransactionTerminatedCb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) { belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event); belle_sip_server_transaction_t* server_transaction = belle_sip_transaction_terminated_event_get_server_transaction(event); belle_sip_transaction_t* trans; @@ -333,8 +333,8 @@ void Sal::process_transaction_terminated_cb(void *user_ctx, const belle_sip_tran trans=BELLE_SIP_TRANSACTION(server_transaction); op = (SalOp*)belle_sip_transaction_get_application_data(trans); - if (op && op->callbacks && op->callbacks->process_transaction_terminated) { - op->callbacks->process_transaction_terminated(op,event); + if (op && op->mCallbacks && op->mCallbacks->process_transaction_terminated) { + op->mCallbacks->process_transaction_terminated(op,event); } else { ms_message("Unhandled transaction terminated [%p]",trans); } @@ -344,9 +344,9 @@ void Sal::process_transaction_terminated_cb(void *user_ctx, const belle_sip_tran } } -void Sal::process_auth_requested_cb(void *sal, belle_sip_auth_event_t *event) { +void Sal::processAuthRequestedCb(void *sal, belle_sip_auth_event_t *event) { SalAuthInfo* auth_info = sal_auth_info_create(event); - ((Sal*)sal)->callbacks.auth_requested(reinterpret_cast(sal),auth_info); + ((Sal*)sal)->mCallbacks.auth_requested(reinterpret_cast(sal),auth_info); belle_sip_auth_event_set_passwd(event,(const char*)auth_info->password); belle_sip_auth_event_set_ha1(event,(const char*)auth_info->ha1); belle_sip_auth_event_set_userid(event,(const char*)auth_info->userid); @@ -359,117 +359,117 @@ Sal::Sal(MSFactory *factory){ belle_sip_listener_callbacks_t listener_callbacks = {0}; /*belle_sip_object_enable_marshal_check(TRUE);*/ - this->factory = factory; + mFactory = factory; /*first create the stack, which initializes the belle-sip object's pool for this thread*/ - this->stack = belle_sip_stack_new(NULL); + mStack = belle_sip_stack_new(NULL); - this->user_agent=belle_sip_header_user_agent_new(); + mUserAgent=belle_sip_header_user_agent_new(); #if defined(PACKAGE_NAME) && defined(LIBLINPHONE_VERSION) - belle_sip_header_user_agent_add_product(this->user_agent, PACKAGE_NAME "/" LIBLINPHONE_VERSION); + belle_sip_header_user_agent_add_product(user_agent, PACKAGE_NAME "/" LIBLINPHONE_VERSION); #else - belle_sip_header_user_agent_add_product(this->user_agent, "Unknown"); + belle_sip_header_user_agent_add_product(mUserAgent, "Unknown"); #endif - append_stack_string_to_user_agent(); - belle_sip_object_ref(this->user_agent); + appendStackStringToUserAgent(); + belle_sip_object_ref(mUserAgent); - this->prov = belle_sip_stack_create_provider(this->stack,NULL); - enable_nat_helper(TRUE); + mProvider = belle_sip_stack_create_provider(mStack,NULL); + enableNatHelper(TRUE); - listener_callbacks.process_dialog_terminated=process_dialog_terminated_cb; - listener_callbacks.process_io_error=process_io_error_cb; - listener_callbacks.process_request_event=process_request_event_cb; - listener_callbacks.process_response_event=process_response_event_cb; - listener_callbacks.process_timeout=process_timeout_cb; - listener_callbacks.process_transaction_terminated=process_transaction_terminated_cb; - listener_callbacks.process_auth_requested=process_auth_requested_cb; - this->listener=belle_sip_listener_create_from_callbacks(&listener_callbacks, this); - belle_sip_provider_add_sip_listener(this->prov, this->listener); + listener_callbacks.process_dialog_terminated=processDialogTerminatedCb; + listener_callbacks.process_io_error=processIoErrorCb; + listener_callbacks.process_request_event=processRequestEventCb; + listener_callbacks.process_response_event=processResponseEventCb; + listener_callbacks.process_timeout=processTimeoutCb; + listener_callbacks.process_transaction_terminated=processTransactionTerminatedCb; + listener_callbacks.process_auth_requested=processAuthRequestedCb; + mListener=belle_sip_listener_create_from_callbacks(&listener_callbacks, this); + belle_sip_provider_add_sip_listener(mProvider, mListener); } Sal::~Sal() { - belle_sip_object_unref(this->user_agent); - belle_sip_object_unref(this->prov); - belle_sip_object_unref(this->stack); - belle_sip_object_unref(this->listener); - if (this->supported) belle_sip_object_unref(this->supported); - bctbx_list_free_with_data(this->supported_tags,ms_free); - bctbx_list_free_with_data(this->supported_content_types, ms_free); - if (this->uuid) ms_free(this->uuid); - if (this->root_ca) ms_free(this->root_ca); - if (this->root_ca_data) ms_free(this->root_ca_data); - if (this->linphone_specs) ms_free(this->linphone_specs); + belle_sip_object_unref(mUserAgent); + belle_sip_object_unref(mProvider); + belle_sip_object_unref(mStack); + belle_sip_object_unref(mListener); + if (mSupported) belle_sip_object_unref(mSupported); + bctbx_list_free_with_data(mSupportedTags,ms_free); + bctbx_list_free_with_data(mSupportedContentTypes, ms_free); + if (mUuid) ms_free(mUuid); + if (mRootCa) ms_free(mRootCa); + if (mRootCaData) ms_free(mRootCaData); + if (mLinphoneSpecs) ms_free(mLinphoneSpecs); } -void Sal::set_callbacks(const Callbacks *cbs) { - memcpy(&this->callbacks,cbs,sizeof(*cbs)); - if (this->callbacks.call_received==NULL) - this->callbacks.call_received=(OnCallReceivedCb)unimplemented_stub; - if (this->callbacks.call_ringing==NULL) - this->callbacks.call_ringing=(OnCallRingingCb)unimplemented_stub; - if (this->callbacks.call_accepted==NULL) - this->callbacks.call_accepted=(OnCallAcceptedCb)unimplemented_stub; - if (this->callbacks.call_failure==NULL) - this->callbacks.call_failure=(OnCallFailureCb)unimplemented_stub; - if (this->callbacks.call_terminated==NULL) - this->callbacks.call_terminated=(OnCallTerminatedCb)unimplemented_stub; - if (this->callbacks.call_released==NULL) - this->callbacks.call_released=(OnCallReleasedCb)unimplemented_stub; - if (this->callbacks.call_updating==NULL) - this->callbacks.call_updating=(OnCallUpdatingCb)unimplemented_stub; - if (this->callbacks.auth_failure==NULL) - this->callbacks.auth_failure=(OnAuthFailureCb)unimplemented_stub; - if (this->callbacks.register_success==NULL) - this->callbacks.register_success=(OnRegisterSuccessCb)unimplemented_stub; - if (this->callbacks.register_failure==NULL) - this->callbacks.register_failure=(OnRegisterFailureCb)unimplemented_stub; - if (this->callbacks.dtmf_received==NULL) - this->callbacks.dtmf_received=(OnDtmfReceivedCb)unimplemented_stub; - if (this->callbacks.notify==NULL) - this->callbacks.notify=(OnNotifyCb)unimplemented_stub; - if (this->callbacks.subscribe_received==NULL) - this->callbacks.subscribe_received=(OnSubscribeReceivedCb)unimplemented_stub; - if (this->callbacks.incoming_subscribe_closed==NULL) - this->callbacks.incoming_subscribe_closed=(OnIncomingSubscribeClosedCb)unimplemented_stub; - if (this->callbacks.parse_presence_requested==NULL) - this->callbacks.parse_presence_requested=(OnParsePresenceRequestedCb)unimplemented_stub; - if (this->callbacks.convert_presence_to_xml_requested==NULL) - this->callbacks.convert_presence_to_xml_requested=(OnConvertPresenceToXMLRequestedCb)unimplemented_stub; - if (this->callbacks.notify_presence==NULL) - this->callbacks.notify_presence=(OnNotifyPresenceCb)unimplemented_stub; - if (this->callbacks.subscribe_presence_received==NULL) - this->callbacks.subscribe_presence_received=(OnSubscribePresenceReceivedCb)unimplemented_stub; - if (this->callbacks.message_received==NULL) - this->callbacks.message_received=(OnMessageReceivedCb)unimplemented_stub; - if (this->callbacks.ping_reply==NULL) - this->callbacks.ping_reply=(OnPingReplyCb)unimplemented_stub; - if (this->callbacks.auth_requested==NULL) - this->callbacks.auth_requested=(OnAuthRequestedCb)unimplemented_stub; - if (this->callbacks.info_received==NULL) - this->callbacks.info_received=(OnInfoReceivedCb)unimplemented_stub; - if (this->callbacks.on_publish_response==NULL) - this->callbacks.on_publish_response=(OnPublishResponseCb)unimplemented_stub; - if (this->callbacks.on_expire==NULL) - this->callbacks.on_expire=(OnExpireCb)unimplemented_stub; +void Sal::setCallbacks(const Callbacks *cbs) { + memcpy(&mCallbacks,cbs,sizeof(*cbs)); + if (mCallbacks.call_received==NULL) + mCallbacks.call_received=(OnCallReceivedCb)unimplementedStub; + if (mCallbacks.call_ringing==NULL) + mCallbacks.call_ringing=(OnCallRingingCb)unimplementedStub; + if (mCallbacks.call_accepted==NULL) + mCallbacks.call_accepted=(OnCallAcceptedCb)unimplementedStub; + if (mCallbacks.call_failure==NULL) + mCallbacks.call_failure=(OnCallFailureCb)unimplementedStub; + if (mCallbacks.call_terminated==NULL) + mCallbacks.call_terminated=(OnCallTerminatedCb)unimplementedStub; + if (mCallbacks.call_released==NULL) + mCallbacks.call_released=(OnCallReleasedCb)unimplementedStub; + if (mCallbacks.call_updating==NULL) + mCallbacks.call_updating=(OnCallUpdatingCb)unimplementedStub; + if (mCallbacks.auth_failure==NULL) + mCallbacks.auth_failure=(OnAuthFailureCb)unimplementedStub; + if (mCallbacks.register_success==NULL) + mCallbacks.register_success=(OnRegisterSuccessCb)unimplementedStub; + if (mCallbacks.register_failure==NULL) + mCallbacks.register_failure=(OnRegisterFailureCb)unimplementedStub; + if (mCallbacks.dtmf_received==NULL) + mCallbacks.dtmf_received=(OnDtmfReceivedCb)unimplementedStub; + if (mCallbacks.notify==NULL) + mCallbacks.notify=(OnNotifyCb)unimplementedStub; + if (mCallbacks.subscribe_received==NULL) + mCallbacks.subscribe_received=(OnSubscribeReceivedCb)unimplementedStub; + if (mCallbacks.incoming_subscribe_closed==NULL) + mCallbacks.incoming_subscribe_closed=(OnIncomingSubscribeClosedCb)unimplementedStub; + if (mCallbacks.parse_presence_requested==NULL) + mCallbacks.parse_presence_requested=(OnParsePresenceRequestedCb)unimplementedStub; + if (mCallbacks.convert_presence_to_xml_requested==NULL) + mCallbacks.convert_presence_to_xml_requested=(OnConvertPresenceToXMLRequestedCb)unimplementedStub; + if (mCallbacks.notify_presence==NULL) + mCallbacks.notify_presence=(OnNotifyPresenceCb)unimplementedStub; + if (mCallbacks.subscribe_presence_received==NULL) + mCallbacks.subscribe_presence_received=(OnSubscribePresenceReceivedCb)unimplementedStub; + if (mCallbacks.message_received==NULL) + mCallbacks.message_received=(OnMessageReceivedCb)unimplementedStub; + if (mCallbacks.ping_reply==NULL) + mCallbacks.ping_reply=(OnPingReplyCb)unimplementedStub; + if (mCallbacks.auth_requested==NULL) + mCallbacks.auth_requested=(OnAuthRequestedCb)unimplementedStub; + if (mCallbacks.info_received==NULL) + mCallbacks.info_received=(OnInfoReceivedCb)unimplementedStub; + if (mCallbacks.on_publish_response==NULL) + mCallbacks.on_publish_response=(OnPublishResponseCb)unimplementedStub; + if (mCallbacks.on_expire==NULL) + mCallbacks.on_expire=(OnExpireCb)unimplementedStub; } -void Sal::set_tls_properties(){ - belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(this->prov,"TLS"); +void Sal::setTlsProperties(){ + belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(mProvider,"TLS"); if (lp){ belle_sip_tls_listening_point_t *tlp=BELLE_SIP_TLS_LISTENING_POINT(lp); belle_tls_crypto_config_t *crypto_config = belle_tls_crypto_config_new(); int verify_exceptions = BELLE_TLS_VERIFY_NONE; - if (!this->tls_verify) verify_exceptions = BELLE_TLS_VERIFY_ANY_REASON; - else if (!this->tls_verify_cn) verify_exceptions = BELLE_TLS_VERIFY_CN_MISMATCH; + if (!mTlsVerify) verify_exceptions = BELLE_TLS_VERIFY_ANY_REASON; + else if (!mTlsVerifyCn) verify_exceptions = BELLE_TLS_VERIFY_CN_MISMATCH; belle_tls_crypto_config_set_verify_exceptions(crypto_config, verify_exceptions); - if (this->root_ca != NULL) belle_tls_crypto_config_set_root_ca(crypto_config, this->root_ca); - if (this->root_ca_data != NULL) belle_tls_crypto_config_set_root_ca_data(crypto_config, this->root_ca_data); - if (this->ssl_config != NULL) belle_tls_crypto_config_set_ssl_config(crypto_config, this->ssl_config); + if (mRootCa != NULL) belle_tls_crypto_config_set_root_ca(crypto_config, mRootCa); + if (mRootCaData != NULL) belle_tls_crypto_config_set_root_ca_data(crypto_config, mRootCaData); + if (mSslConfig != NULL) belle_tls_crypto_config_set_ssl_config(crypto_config, mSslConfig); belle_sip_tls_listening_point_set_crypto_config(tlp, crypto_config); belle_sip_object_unref(crypto_config); } } -int Sal::add_listen_port(SalAddress* addr, bool_t is_tunneled) { +int Sal::addListenPort(SalAddress* addr, bool_t is_tunneled) { int result; belle_sip_listening_point_t* lp; if (is_tunneled){ @@ -478,7 +478,7 @@ int Sal::add_listen_port(SalAddress* addr, bool_t is_tunneled) { ms_error("Tunneled mode is only available for UDP kind of transports."); return -1; } - lp = belle_sip_tunnel_listening_point_new(this->stack, this->tunnel_client); + lp = belle_sip_tunnel_listening_point_new(stack, tunnel_client); if (!lp){ ms_error("Could not create tunnel listening point."); return -1; @@ -488,16 +488,16 @@ int Sal::add_listen_port(SalAddress* addr, bool_t is_tunneled) { return -1; #endif }else{ - lp = belle_sip_stack_create_listening_point(this->stack, + lp = belle_sip_stack_create_listening_point(mStack, sal_address_get_domain(addr), sal_address_get_port(addr), sal_transport_to_string(sal_address_get_transport(addr))); } if (lp) { - belle_sip_listening_point_set_keep_alive(lp,(int)this->keep_alive); - result = belle_sip_provider_add_listening_point(this->prov,lp); + belle_sip_listening_point_set_keep_alive(lp,(int)mKeepAlive); + result = belle_sip_provider_add_listening_point(mProvider,lp); if (sal_address_get_transport(addr)==SalTransportTLS) { - set_tls_properties(); + setTlsProperties(); } } else { return -1; @@ -505,75 +505,75 @@ int Sal::add_listen_port(SalAddress* addr, bool_t is_tunneled) { return result; } -int Sal::set_listen_port(const char *addr, int port, SalTransport tr, bool_t is_tunneled) { +int Sal::setListenPort(const char *addr, int port, SalTransport tr, bool_t is_tunneled) { SalAddress* sal_addr = sal_address_new(NULL); int result; sal_address_set_domain(sal_addr,addr); sal_address_set_port(sal_addr,port); sal_address_set_transport(sal_addr,tr); - result = add_listen_port(sal_addr, is_tunneled); + result = addListenPort(sal_addr, is_tunneled); sal_address_destroy(sal_addr); return result; } -int Sal::get_listening_port(SalTransport tr){ +int Sal::getListeningPort(SalTransport tr){ const char *tpn=sal_transport_to_string(tr); - belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(this->prov, tpn); + belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(mProvider, tpn); if (lp){ return belle_sip_listening_point_get_port(lp); } return 0; } -int Sal::unlisten_ports(){ - const belle_sip_list_t * lps = belle_sip_provider_get_listening_points(this->prov); +int Sal::unlistenPorts(){ + const belle_sip_list_t * lps = belle_sip_provider_get_listening_points(mProvider); belle_sip_list_t * tmp_list = belle_sip_list_copy(lps); - belle_sip_list_for_each2 (tmp_list,(void (*)(void*,void*))remove_listening_point,this->prov); + belle_sip_list_for_each2 (tmp_list,(void (*)(void*,void*))removeListeningPoint,mProvider); belle_sip_list_free(tmp_list); ms_message("sal_unlisten_ports done"); return 0; } -int Sal::transport_available(SalTransport t) { +int Sal::isTransportAvailable(SalTransport t) { switch(t){ case SalTransportUDP: case SalTransportTCP: return TRUE; case SalTransportTLS: - return belle_sip_stack_tls_available(this->stack); + return belle_sip_stack_tls_available(mStack); case SalTransportDTLS: return FALSE; } return FALSE; } -void Sal::make_supported_header(){ +void Sal::makeSupportedHeader(){ bctbx_list_t *it; char *alltags=NULL; size_t buflen=64; size_t written=0; - if (this->supported){ - belle_sip_object_unref(this->supported); - this->supported=NULL; + if (mSupported){ + belle_sip_object_unref(mSupported); + mSupported=NULL; } - for(it=this->supported_tags;it!=NULL;it=it->next){ + for(it=mSupportedTags;it!=NULL;it=it->next){ const char *tag=(const char*)it->data; size_t taglen=strlen(tag); if (alltags==NULL || (written+taglen+1>=buflen)) alltags=reinterpret_cast(ms_realloc(alltags,(buflen=buflen*2))); written+=(size_t)snprintf(alltags+written,buflen-written,it->next ? "%s, " : "%s",tag); } if (alltags){ - this->supported=belle_sip_header_create("Supported",alltags); - if (this->supported){ - belle_sip_object_ref(this->supported); + mSupported=belle_sip_header_create("Supported",alltags); + if (mSupported){ + belle_sip_object_ref(mSupported); } ms_free(alltags); } } -void Sal::set_supported_tags(const char* tags){ - this->supported_tags=bctbx_list_free_with_data(this->supported_tags,ms_free); +void Sal::setSupportedTags(const char* tags){ + mSupportedTags=bctbx_list_free_with_data(mSupportedTags,ms_free); if (tags){ char *iter; char *buffer=ms_strdup(tags); @@ -582,170 +582,170 @@ void Sal::set_supported_tags(const char* tags){ iter=buffer; while((tag=strtok_r(iter,", ",&context))!=NULL){ iter=NULL; - this->supported_tags=bctbx_list_append(this->supported_tags,ms_strdup(tag)); + mSupportedTags=bctbx_list_append(mSupportedTags,ms_strdup(tag)); } ms_free(buffer); } - make_supported_header(); + makeSupportedHeader(); } -void Sal::add_supported_tag(const char* tag){ - bctbx_list_t *elem=bctbx_list_find_custom(this->supported_tags,(bctbx_compare_func)strcasecmp,tag); +void Sal::addSupportedTag(const char* tag){ + bctbx_list_t *elem=bctbx_list_find_custom(mSupportedTags,(bctbx_compare_func)strcasecmp,tag); if (!elem){ - this->supported_tags=bctbx_list_append(this->supported_tags,ms_strdup(tag)); - make_supported_header(); + mSupportedTags=bctbx_list_append(mSupportedTags,ms_strdup(tag)); + makeSupportedHeader(); } } -void Sal::remove_supported_tag(const char* tag){ - bctbx_list_t *elem=bctbx_list_find_custom(this->supported_tags,(bctbx_compare_func)strcasecmp,tag); +void Sal::removeSupportedTag(const char* tag){ + bctbx_list_t *elem=bctbx_list_find_custom(mSupportedTags,(bctbx_compare_func)strcasecmp,tag); if (elem){ ms_free(elem->data); - this->supported_tags=bctbx_list_erase_link(this->supported_tags,elem); - make_supported_header(); + mSupportedTags=bctbx_list_erase_link(mSupportedTags,elem); + makeSupportedHeader(); } } -int Sal::reset_transports() { +int Sal::resetTransports() { ms_message("Reseting transports"); - belle_sip_provider_clean_channels(this->prov); + belle_sip_provider_clean_channels(mProvider); return 0; } -ortp_socket_t Sal::get_socket() const { +ortp_socket_t Sal::getSocket() const { ms_warning("sal_get_socket is deprecated"); return -1; } -void Sal::set_user_agent(const char *user_agent) { - belle_sip_header_user_agent_set_products(this->user_agent,NULL); - belle_sip_header_user_agent_add_product(this->user_agent,user_agent); +void Sal::setUserAgent(const char *user_agent) { + belle_sip_header_user_agent_set_products(mUserAgent,NULL); + belle_sip_header_user_agent_add_product(mUserAgent,user_agent); } -const char* Sal::get_user_agent() const { +const char* Sal::getUserAgent() const { static char user_agent[255]; - belle_sip_header_user_agent_get_products_as_string(this->user_agent, user_agent, 254); + belle_sip_header_user_agent_get_products_as_string(mUserAgent, user_agent, 254); return user_agent; } -void Sal::append_stack_string_to_user_agent() { +void Sal::appendStackStringToUserAgent() { char stack_string[64]; snprintf(stack_string, sizeof(stack_string) - 1, "(belle-sip/%s)", belle_sip_version_to_string()); - belle_sip_header_user_agent_add_product(this->user_agent, stack_string); + belle_sip_header_user_agent_add_product(mUserAgent, stack_string); } -void Sal::set_keepalive_period(unsigned int value) { +void Sal::setKeepAlivePeriod(unsigned int value) { const belle_sip_list_t* iterator; belle_sip_listening_point_t* lp; - this->keep_alive=value; - for (iterator=belle_sip_provider_get_listening_points(this->prov);iterator!=NULL;iterator=iterator->next) { + mKeepAlive=value; + for (iterator=belle_sip_provider_get_listening_points(mProvider);iterator!=NULL;iterator=iterator->next) { lp=(belle_sip_listening_point_t*)iterator->data; - if (this->use_tcp_tls_keep_alive || strcasecmp(belle_sip_listening_point_get_transport(lp),"udp")==0) { - belle_sip_listening_point_set_keep_alive(lp,(int)this->keep_alive); + if (mUseTcpTlsKeepAlive || strcasecmp(belle_sip_listening_point_get_transport(lp),"udp")==0) { + belle_sip_listening_point_set_keep_alive(lp,(int)mKeepAlive); } } } -int Sal::set_tunnel(void *tunnelclient) { +int Sal::setTunnel(void *tunnelclient) { #ifdef TUNNEL_ENABLED - this->tunnel_client=tunnelclient; + tunnel_client=tunnelclient; return 0; #else return -1; #endif } -bool_t Sal::is_content_type_supported(const char *content_type) const { +bool_t Sal::isContentTypeSupported(const char *content_type) const { bctbx_list_t *item; - for (item = this->supported_content_types; item != NULL; item = bctbx_list_next(item)) { + for (item = mSupportedContentTypes; item != NULL; item = bctbx_list_next(item)) { const char *item_content_type = (const char *)bctbx_list_get_data(item); if (strcmp(item_content_type, content_type) == 0) return TRUE; } return FALSE; } -void Sal::add_content_type_support(const char *content_type) { - if ((content_type != NULL) && (is_content_type_supported(content_type) == FALSE)) { - this->supported_content_types = bctbx_list_append(this->supported_content_types, ms_strdup(content_type)); +void Sal::addContentTypeSupport(const char *content_type) { + if ((content_type != NULL) && (isContentTypeSupported(content_type) == FALSE)) { + mSupportedContentTypes = bctbx_list_append(mSupportedContentTypes, ms_strdup(content_type)); } } -void Sal::remove_content_type_support(const char *content_type) { +void Sal::removeContentTypeSupport(const char *content_type) { if (content_type != NULL) { - if (bctbx_list_find(this->supported_content_types, content_type)) { - this->supported_content_types = bctbx_list_remove(this->supported_content_types, (char *)content_type); + if (bctbx_list_find(mSupportedContentTypes, content_type)) { + mSupportedContentTypes = bctbx_list_remove(mSupportedContentTypes, (char *)content_type); } } } -void Sal::use_rport(bool_t use_rports) { - belle_sip_provider_enable_rport(this->prov,use_rports); +void Sal::useRport(bool_t use_rports) { + belle_sip_provider_enable_rport(mProvider,use_rports); ms_message("Sal use rport [%s]", use_rports ? "enabled" : "disabled"); } -void Sal::set_contact_linphone_specs(const char *specs) { - if (this->linphone_specs) { - ms_free(this->linphone_specs); - this->linphone_specs = NULL; +void Sal::setContactLinphoneSpecs(const char *specs) { + if (mLinphoneSpecs) { + ms_free(mLinphoneSpecs); + mLinphoneSpecs = NULL; } if (specs) { - this->linphone_specs = ms_strdup(specs); + mLinphoneSpecs = ms_strdup(specs); } } -void Sal::set_root_ca(const char* rootCa) { - if (this->root_ca) { - ms_free(this->root_ca); - this->root_ca = NULL; +void Sal::setRootCa(const char* rootCa) { + if (mRootCa) { + ms_free(mRootCa); + mRootCa = NULL; } if (rootCa) - this->root_ca = ms_strdup(rootCa); - set_tls_properties(); + mRootCa = ms_strdup(rootCa); + setTlsProperties(); } -void Sal::set_root_ca_data(const char* data) { - if (this->root_ca_data) { - ms_free(this->root_ca_data); - this->root_ca_data = NULL; +void Sal::setRootCaData(const char* data) { + if (mRootCaData) { + ms_free(mRootCaData); + mRootCaData = NULL; } if (data) - this->root_ca_data = ms_strdup(data); - set_tls_properties(); + mRootCaData = ms_strdup(data); + setTlsProperties(); } -void Sal::verify_server_certificates(bool_t verify) { - this->tls_verify=verify; - set_tls_properties(); +void Sal::verifyServerCertificates(bool_t verify) { + mTlsVerify=verify; + setTlsProperties(); } -void Sal::verify_server_cn(bool_t verify) { - this->tls_verify_cn = verify; - set_tls_properties(); +void Sal::verifyServerCn(bool_t verify) { + mTlsVerifyCn = verify; + setTlsProperties(); } -void Sal::set_ssl_config(void *ssl_config) { - this->ssl_config = ssl_config; - set_tls_properties(); +void Sal::setSslConfig(void *ssl_config) { + mSslConfig = ssl_config; + setTlsProperties(); } -void Sal::set_uuid(const char *uuid){ - if (this->uuid){ - ms_free(this->uuid); - this->uuid=NULL; +void Sal::setUuid(const char *uuid){ + if (mUuid){ + ms_free(mUuid); + mUuid=NULL; } if (uuid) - this->uuid=ms_strdup(uuid); + mUuid=ms_strdup(uuid); } -int Sal::create_uuid(char *uuid, size_t len) { - if (generate_uuid(uuid, len) == 0) { - set_uuid(uuid); +int Sal::createUuid(char *uuid, size_t len) { + if (generateUuid(uuid, len) == 0) { + setUuid(uuid); return 0; } return -1; } -int Sal::generate_uuid(char *uuid, size_t len) { +int Sal::generateUuid(char *uuid, size_t len) { sal_uuid_t uuid_struct; int i; int written; @@ -771,63 +771,63 @@ int Sal::generate_uuid(char *uuid, size_t len) { return 0; } -void Sal::add_pending_auth(SalOp *op){ - if (bctbx_list_find(this->pending_auths,op)==NULL){ - this->pending_auths=bctbx_list_append(this->pending_auths,op); - op->has_auth_pending=TRUE; +void Sal::addPendingAuth(SalOp *op){ + if (bctbx_list_find(mPendingAuths,op)==NULL){ + mPendingAuths=bctbx_list_append(mPendingAuths,op); + op->mHasAuthPending=TRUE; } } -void Sal::remove_pending_auth(SalOp *op){ - if (op->has_auth_pending){ - op->has_auth_pending=FALSE; - if (bctbx_list_find(this->pending_auths,op)){ - this->pending_auths=bctbx_list_remove(this->pending_auths,op); +void Sal::removePendingAuth(SalOp *op){ + if (op->mHasAuthPending){ + op->mHasAuthPending=FALSE; + if (bctbx_list_find(mPendingAuths,op)){ + mPendingAuths=bctbx_list_remove(mPendingAuths,op); } } } -void Sal::set_default_sdp_handling(SalOpSDPHandling sdp_handling_method) { +void Sal::setDefaultSdpHandling(SalOpSDPHandling sdp_handling_method) { if (sdp_handling_method != SalOpSDPNormal ) ms_message("Enabling special SDP handling for all new SalOp in Sal[%p]!", this); - this->default_sdp_handling = sdp_handling_method; + mDefaultSdpHandling = sdp_handling_method; } -void Sal::enable_nat_helper(bool_t enable) { - this->_nat_helper_enabled=enable; - belle_sip_provider_enable_nat_helper(this->prov,enable); +void Sal::enableNatHelper(bool_t enable) { + mNatHelperEnabled=enable; + belle_sip_provider_enable_nat_helper(mProvider,enable); ms_message("Sal nat helper [%s]",enable?"enabled":"disabled"); } -void Sal::get_default_local_ip(int address_family, char *ip, size_t iplen) { +void Sal::getDefaultLocalIp(int address_family, char *ip, size_t iplen) { strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen); ms_error("sal_get_default_local_ip() is deprecated."); } -void Sal::set_dns_servers(const bctbx_list_t *servers){ +void Sal::setDnsServers(const bctbx_list_t *servers){ belle_sip_list_t *l = NULL; /*we have to convert the bctbx_list_t into a belle_sip_list_t first*/ for (; servers != NULL; servers = servers->next){ l = belle_sip_list_append(l, servers->data); } - belle_sip_stack_set_dns_servers(this->stack, l); + belle_sip_stack_set_dns_servers(mStack, l); belle_sip_list_free(l); } -belle_sip_source_t *Sal::create_timer(belle_sip_source_func_t func, void *data, unsigned int timeout_value_ms, const char* timer_name) { - belle_sip_main_loop_t *ml = belle_sip_stack_get_main_loop(this->stack); +belle_sip_source_t *Sal::createTimer(belle_sip_source_func_t func, void *data, unsigned int timeout_value_ms, const char* timer_name) { + belle_sip_main_loop_t *ml = belle_sip_stack_get_main_loop(mStack); return belle_sip_main_loop_create_timeout(ml, func, data, timeout_value_ms, timer_name); } -void Sal::cancel_timer(belle_sip_source_t *timer) { - belle_sip_main_loop_t *ml = belle_sip_stack_get_main_loop(this->stack); +void Sal::cancelTimer(belle_sip_source_t *timer) { + belle_sip_main_loop_t *ml = belle_sip_stack_get_main_loop(mStack); belle_sip_main_loop_remove_source(ml, timer); } -belle_sip_response_t* Sal::create_response_from_request (belle_sip_request_t* req, int code ) { +belle_sip_response_t* Sal::createResponseFromRequest (belle_sip_request_t* req, int code ) { belle_sip_response_t *resp=belle_sip_response_create_from_request(req,code); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(this->user_agent)); - belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp), this->supported); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(mUserAgent)); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp), mSupported); return resp; } @@ -948,90 +948,90 @@ void sal_uninit(Sal* sal) { } int sal_create_uuid(Sal *ctx, char *uuid, size_t len) { - return ctx->create_uuid(uuid, len); + return ctx->createUuid(uuid, len); } void sal_set_uuid(Sal *ctx, const char *uuid) { - ctx->set_uuid(uuid); + ctx->setUuid(uuid); } void sal_default_set_sdp_handling(Sal* h, SalOpSDPHandling handling_method) { - h->set_default_sdp_handling(handling_method); + h->setDefaultSdpHandling(handling_method); } void sal_set_send_error(Sal *sal,int value) { - sal->set_send_error(value); + sal->setSendError(value); } void sal_set_recv_error(Sal *sal,int value) { - sal->set_recv_error(value); + sal->setRecvError(value); } int sal_enable_pending_trans_checking(Sal *sal, bool_t value) { - return sal->enable_pending_trans_checking(value); + return sal->enablePendingTransactionChecking(value); } void sal_enable_unconditional_answer(Sal *sal,int value) { - sal->enable_unconditional_answer(value); + sal->enableUnconditionalAnswer(value); } void sal_set_dns_timeout(Sal* sal,int timeout) { - sal->set_dns_timeout(timeout); + sal->setDnsTimeout(timeout); } void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file) { - sal->set_dns_user_hosts_file(hosts_file); + sal->setDnsUserHostsFile(hosts_file); } void *sal_get_stack_impl(Sal *sal) { - return sal->get_stack_impl(); + return sal->getStackImpl(); } void sal_set_refresher_retry_after(Sal *sal,int value) { - sal->set_refresher_retry_after(value); + sal->setRefresherRetryAfter(value); } int sal_get_refresher_retry_after(const Sal *sal) { - return sal->get_refresher_retry_after(); + return sal->getRefresherRetryAfter(); } void sal_set_transport_timeout(Sal* sal,int timeout) { - sal->set_transport_timeout(timeout); + sal->setTransportTimeout(timeout); } void sal_enable_test_features(Sal*ctx, bool_t enabled) { - ctx->enable_test_features(enabled); + ctx->enableTestFeatures(enabled); } int sal_transport_available(Sal *ctx, SalTransport t) { - return ctx->transport_available(t); + return ctx->isTransportAvailable(t); } const SalErrorInfo *sal_op_get_error_info(const SalOp *op) { - return op->get_error_info(); + return op->getErrorInfo(); } bool_t sal_call_dialog_request_pending(const SalOp *op) { auto callOp = dynamic_cast(op); - return callOp->dialog_request_pending(); + return callOp->dialogRequestPending(); } void sal_call_set_sdp_handling(SalOp *h, SalOpSDPHandling handling) { auto callOp = dynamic_cast(h); - callOp->set_sdp_handling(handling); + callOp->setSdpHandling(handling); } SalMediaDescription * sal_call_get_final_media_description(SalOp *h) { auto callOp = dynamic_cast(h); - return callOp->get_final_media_description(); + return callOp->getFinalMediaDescription(); } belle_sip_resolver_context_t *sal_resolve_a(Sal *sal, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) { - return sal->resolve_a(name, port, family, cb, data); + return sal->resolveA(name, port, family, cb, data); } Sal *sal_op_get_sal(SalOp *op) { - return op->get_sal(); + return op->getSal(); } SalOp *sal_create_refer_op(Sal *sal) { @@ -1044,31 +1044,31 @@ void sal_release_op(SalOp *op) { void sal_op_set_from(SalOp *sal_refer_op, const char* from) { auto referOp = dynamic_cast(sal_refer_op); - referOp->set_from(from); + referOp->setFrom(from); } void sal_op_set_to(SalOp *sal_refer_op, const char* to) { auto referOp = dynamic_cast(sal_refer_op); - referOp->set_to(to); + referOp->setTo(to); } void sal_op_send_refer(SalOp *sal_refer_op, SalAddress* refer_to) { auto referOp = dynamic_cast(sal_refer_op); - referOp->send_refer(refer_to); + referOp->sendRefer(refer_to); } void sal_set_user_pointer(Sal *sal, void *user_pointer) { - sal->set_user_pointer(user_pointer); + sal->setUserPointer(user_pointer); } void *sal_get_user_pointer(Sal *sal) { - return sal->get_user_pointer(); + return sal->getUserPointer(); } void sal_set_call_refer_callback(Sal *sal, void (*OnReferCb)(SalOp *op, const SalAddress *referto)) { struct Sal::Callbacks cbs = {NULL}; cbs.refer_received = OnReferCb; - sal->set_callbacks(&cbs); + sal->setCallbacks(&cbs); } } diff --git a/src/sal/sal.h b/src/sal/sal.h index 0bfd2afec..51af47e57 100644 --- a/src/sal/sal.h +++ b/src/sal/sal.h @@ -20,9 +20,11 @@ #ifndef _L_SAL_H_ #define _L_SAL_H_ -#include "c-wrapper/internal/c-sal.h" #include "linphone/utils/general.h" +#include "c-wrapper/internal/c-sal.h" +#include "logger/logger.h" + LINPHONE_BEGIN_NAMESPACE class SalOp; @@ -34,42 +36,42 @@ class SalReferOp; class Sal{ public: - typedef void (*OnCallReceivedCb)(SalCallOp *op); - typedef void (*OnCallRingingCb)(SalOp *op); - typedef void (*OnCallAcceptedCb)(SalOp *op); - typedef void (*OnCallAckReceivedCb)(SalOp *op, SalCustomHeader *ack); - typedef void (*OnCallAckBeingSentCb)(SalOp *op, SalCustomHeader *ack); - typedef void (*OnCallUpdatingCb)(SalOp *op, bool_t is_update);/* Called when a reINVITE/UPDATE is received*/ - typedef void (*OnCallTerminatedCb)(SalOp *op, const char *from); - typedef void (*OnCallFailureCb)(SalOp *op); - typedef void (*OnCallReleasedCb)(SalOp *salop); - typedef void (*OnCallCancelDoneCb)(SalOp *salop); - typedef void (*OnAuthRequestedLegacyCb)(SalOp *op, const char *realm, const char *username); - typedef bool_t (*OnAuthRequestedCb)(Sal *sal,SalAuthInfo* info); - typedef void (*OnAuthFailureCb)(SalOp *op, SalAuthInfo* info); - typedef void (*OnRegisterSuccessCb)(SalOp *op, bool_t registered); - typedef void (*OnRegisterFailureCb)(SalOp *op); - typedef void (*OnVfuRequestCb)(SalOp *op); - typedef void (*OnDtmfReceivedCb)(SalOp *op, char dtmf); - typedef void (*OnCallReferCb)(SalOp *op, const SalAddress *referto); - typedef void (*OnReferCb)(SalOp *op, const SalAddress *referto); - typedef void (*OnMessageReceivedCb)(SalOp *op, const SalMessage *msg); - typedef void (*OnMessageDeliveryUpdateCb)(SalOp *op, SalMessageDeliveryStatus); - typedef void (*OnNotifyReferCb)(SalOp *op, SalReferStatus state); - typedef void (*OnSubscribeResponseCb)(SalOp *op, SalSubscribeStatus status, int will_retry); - typedef void (*OnNotifyCb)(SalSubscribeOp *op, SalSubscribeStatus status, const char *event, SalBodyHandler *body); - typedef void (*OnSubscribeReceivedCb)(SalSubscribeOp *salop, const char *event, const SalBodyHandler *body); - typedef void (*OnIncomingSubscribeClosedCb)(SalOp *salop); - typedef void (*OnParsePresenceRequestedCb)(SalOp *salop, const char *content_type, const char *content_subtype, const char *content, SalPresenceModel **result); - typedef void (*OnConvertPresenceToXMLRequestedCb)(SalOp *salop, SalPresenceModel *presence, const char *contact, char **content); - typedef void (*OnNotifyPresenceCb)(SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model, const char *msg); - typedef void (*OnSubscribePresenceReceivedCb)(SalPresenceOp *salop, const char *from); - typedef void (*OnSubscribePresenceClosedCb)(SalPresenceOp *salop, const char *from); - typedef void (*OnPingReplyCb)(SalOp *salop); - typedef void (*OnInfoReceivedCb)(SalOp *salop, SalBodyHandler *body); - typedef void (*OnPublishResponseCb)(SalOp *salop); - typedef void (*OnNotifyResponseCb)(SalOp *salop); - typedef void (*OnExpireCb)(SalOp *salop); + using OnCallReceivedCb = void (*) (SalCallOp *op); + using OnCallRingingCb = void (*) (SalOp *op); + using OnCallAcceptedCb = void (*) (SalOp *op); + using OnCallAckReceivedCb = void (*) (SalOp *op, SalCustomHeader *ack); + using OnCallAckBeingSentCb = void (*) (SalOp *op, SalCustomHeader *ack); + using OnCallUpdatingCb = void (*) (SalOp *op, bool_t isUpdate); // Called when a reINVITE/UPDATE is received + using OnCallTerminatedCb = void (*) (SalOp *op, const char *from); + using OnCallFailureCb = void (*) (SalOp *op); + using OnCallReleasedCb = void (*) (SalOp *op); + using OnCallCancelDoneCb = void (*) (SalOp *op); + using OnAuthRequestedLegacyCb = void (*) (SalOp *op, const char *realm, const char *username); + using OnAuthRequestedCb = bool_t (*) (Sal *sal, SalAuthInfo *info); + using OnAuthFailureCb = void (*) (SalOp *op, SalAuthInfo *info); + using OnRegisterSuccessCb = void (*) (SalOp *op, bool_t registered); + using OnRegisterFailureCb = void (*) (SalOp *op); + using OnVfuRequestCb = void (*) (SalOp *op); + using OnDtmfReceivedCb = void (*) (SalOp *op, char dtmf); + using OnCallReferCb = void (*) (SalOp *op, const SalAddress *referTo); + using OnReferCb = void (*) (SalOp *op, const SalAddress *referTo); + using OnMessageReceivedCb = void (*) (SalOp *op, const SalMessage *msg); + using OnMessageDeliveryUpdateCb = void (*) (SalOp *op, SalMessageDeliveryStatus status); + using OnNotifyReferCb = void (*) (SalOp *op, SalReferStatus status); + using OnSubscribeResponseCb = void (*) (SalOp *op, SalSubscribeStatus status, int willRetry); + using OnNotifyCb = void (*) (SalSubscribeOp *op, SalSubscribeStatus status, const char *event, SalBodyHandler *body); + using OnSubscribeReceivedCb = void (*) (SalSubscribeOp *op, const char *event, const SalBodyHandler *body); + using OnIncomingSubscribeClosedCb = void (*) (SalOp *op); + using OnParsePresenceRequestedCb = void (*) (SalOp *op, const char *contentType, const char *contentSubtype, const char *content, SalPresenceModel **result); + using OnConvertPresenceToXMLRequestedCb = void (*) (SalOp *op, SalPresenceModel *presence, const char *contact, char **content); + using OnNotifyPresenceCb = void (*) (SalOp *op, SalSubscribeStatus ss, SalPresenceModel *model, const char *msg); + using OnSubscribePresenceReceivedCb = void (*) (SalPresenceOp *op, const char *from); + using OnSubscribePresenceClosedCb = void (*) (SalPresenceOp *op, const char *from); + using OnPingReplyCb = void (*) (SalOp *op); + using OnInfoReceivedCb = void (*) (SalOp *op, SalBodyHandler *body); + using OnPublishResponseCb = void (*) (SalOp *op); + using OnNotifyResponseCb = void (*) (SalOp *op); + using OnExpireCb = void (*) (SalOp *op); struct Callbacks { OnCallReceivedCb call_received; @@ -108,148 +110,153 @@ public: OnPublishResponseCb on_publish_response; OnExpireCb on_expire; OnNotifyResponseCb on_notify_response; - OnReferCb refer_received; /*for out of dialog refer*/ + OnReferCb refer_received; // For out of dialog refer }; Sal(MSFactory *factory); ~Sal(); - void set_factory(MSFactory *factory) { - this->factory = factory; + void setFactory (MSFactory *value) { mFactory = value; } + + void setUserPointer (void *value) { mUserPointer = value; } + void *getUserPointer () const { return mUserPointer; } + + void setCallbacks (const Callbacks *cbs); + + void *getStackImpl() const { return mStack; } + + int iterate () { belle_sip_stack_sleep(mStack, 0); return 0; } + + void setSendError (int value) { belle_sip_stack_set_send_error(mStack, value); } + void setRecvError (int value) { belle_sip_provider_set_recv_error(mProvider, value); } + + + // --------------------------------------------------------------------------- + // SIP parameters + // --------------------------------------------------------------------------- + void setSupportedTags (const char *tags); + const char *getSupportedTags () const { + return mSupported ? belle_sip_header_get_unparsed_value(mSupported) : nullptr; + } + void addSupportedTag (const char *tag); + void removeSupportedTag (const char *tag); + + void setUserAgent (const char *userAgent); + const char *getUserAgent() const; + void appendStackStringToUserAgent (); + + bool_t isContentEncodingAvailable (const char *contentEncoding) { + return (bool_t)belle_sip_stack_content_encoding_available(mStack, contentEncoding); + } + bool_t isContentTypeSupported (const char *contentType) const; + void addContentTypeSupport (const char *contentType); + void removeContentTypeSupport (const char *contentType); + + void setDefaultSdpHandling (SalOpSDPHandling sdpHandlingMethod); + + void setUuid (const char *uuid); + int createUuid (char *uuid, size_t len); + static int generateUuid (char *uuid, size_t len); + + void enableNatHelper (bool_t enable); + bool_t natHelperEnabled () const { return mNatHelperEnabled; } + + bool_t pendingTransactionCheckingEnabled () const { return mPendingTransactionChecking; } + int enablePendingTransactionChecking (bool_t value) { mPendingTransactionChecking = value; return 0; } + + void setRefresherRetryAfter (int value) { mRefresherRetryAfter = value; } + int getRefresherRetryAfter () const { return mRefresherRetryAfter; } + + void enableSipUpdateMethod (bool_t value) { mEnableSipUpdate = value; } + void useSessionTimers (int expires) { mSessionExpires = expires; } + void useDates (bool_t value) { mUseDates = value; } + void useOneMatchingCodecPolicy (bool_t value) { mOneMatchingCodec = value; } + void useRport (bool_t value); + void enableAutoContacts (bool_t value) { mAutoContacts = value; } + void enableTestFeatures (bool_t value) { mEnableTestFeatures = value; } + void useNoInitialRoute (bool_t value) { mNoInitialRoute = value; } + void enableUnconditionalAnswer (int value) { belle_sip_provider_enable_unconditional_answer(mProvider, value); } + void enableReconnectToPrimaryAsap (bool_t value) { belle_sip_stack_enable_reconnect_to_primary_asap(mStack, value); } + + bctbx_list_t *getPendingAuths () const { return bctbx_list_copy(mPendingAuths); } + + void setContactLinphoneSpecs (const char *specs); + + + // --------------------------------------------------------------------------- + // Network parameters + // --------------------------------------------------------------------------- + int setListenPort (const char *addr, int port, SalTransport tr, bool_t isTunneled); + int getListeningPort (SalTransport tr); + int isTransportAvailable (SalTransport t); + + void getDefaultLocalIp (int addressFamily, char *ip, size_t ipLen); + + void setTransportTimeout (int value) { belle_sip_stack_set_transport_timeout(mStack, value); } + int getTransportTimeout () const { return belle_sip_stack_get_transport_timeout(mStack); } + + void setKeepAlivePeriod (unsigned int value); + unsigned int getKeepAlivePeriod () const { return mKeepAlive; } + void useTcpTlsKeepAlive (bool_t value) { mUseTcpTlsKeepAlive = value; } + + void setDscp (int dscp) { belle_sip_stack_set_default_dscp(mStack, dscp); } + + int setTunnel (void *tunnelClient); + + void setHttpProxyHost (const char *value) { belle_sip_stack_set_http_proxy_host(mStack, value); } + const char *getHttpProxyHost () const { return belle_sip_stack_get_http_proxy_host(mStack); } + + void setHttpProxyPort (int value) { belle_sip_stack_set_http_proxy_port(mStack, value); } + int getHttpProxyPort () const { return belle_sip_stack_get_http_proxy_port(mStack); } + + ortp_socket_t getSocket () const; + + int unlistenPorts (); + int resetTransports (); + + + // --------------------------------------------------------------------------- + // TLS parameters + // --------------------------------------------------------------------------- + void setSslConfig (void *sslConfig); + void setRootCa (const char *value); + void setRootCaData (const char *data); + const char *getRootCa () const { return mRootCa; } + + void verifyServerCertificates (bool_t value); + void verifyServerCn (bool_t value); + + + // --------------------------------------------------------------------------- + // DNS resolution + // --------------------------------------------------------------------------- + void setDnsTimeout (int value) { belle_sip_stack_set_dns_timeout(mStack, value); } + int getDnsTimeout () const { return belle_sip_stack_get_dns_timeout(mStack); } + + void setDnsServers (const bctbx_list_t *servers); + + void enableDnsSearch (bool_t value) { belle_sip_stack_enable_dns_search(mStack, (unsigned char)value); } + bool_t dnsSearchEnabled () const { return (bool_t)belle_sip_stack_dns_search_enabled(mStack); } + + void enableDnsSrv (bool_t value) { belle_sip_stack_enable_dns_srv(mStack, (unsigned char)value); } + bool_t dnsSrvEnabled () const { return (bool_t)belle_sip_stack_dns_srv_enabled(mStack); } + + void setDnsUserHostsFile (const char *value) { belle_sip_stack_set_dns_user_hosts_file(mStack, value); } + const char *getDnsUserHostsFile () const { return belle_sip_stack_get_dns_user_hosts_file(mStack); } + + belle_sip_resolver_context_t *resolveA (const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) { + return belle_sip_stack_resolve_a(mStack, name, port, family, cb, data); + } + belle_sip_resolver_context_t *resolve (const char *service, const char *transport, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) { + return belle_sip_stack_resolve(mStack, service, transport, name, port, family, cb, data); } - void set_user_pointer(void *user_data) {this->up=user_data;} - void *get_user_pointer() const {return this->up;} - void set_callbacks(const Callbacks *cbs); - - void *get_stack_impl() {return this->stack;} - - int iterate() {belle_sip_stack_sleep(this->stack,0); return 0;} - - void set_send_error(int value) {belle_sip_stack_set_send_error(this->stack,value);} - void set_recv_error(int value) {belle_sip_provider_set_recv_error(this->prov,value);} - - - /******************/ - /* SIP parameters */ - /******************/ - void set_supported_tags(const char* tags); - const char *get_supported_tags() const {return this->supported ? belle_sip_header_get_unparsed_value(this->supported) : NULL;} - void add_supported_tag(const char* tag); - void remove_supported_tag(const char* tag); - - void set_user_agent(const char *user_agent); - const char* get_user_agent() const; - void append_stack_string_to_user_agent(); - - bool_t content_encoding_available(const char *content_encoding) {return (bool_t)belle_sip_stack_content_encoding_available(this->stack, content_encoding);} - bool_t is_content_type_supported(const char *content_type) const; - void add_content_type_support(const char *content_type); - void remove_content_type_support(const char *content_type); - - void set_default_sdp_handling(SalOpSDPHandling sdp_handling_method); - - void set_uuid(const char *uuid); - int create_uuid(char *uuid, size_t len); - static int generate_uuid(char *uuid, size_t len); - - void enable_nat_helper(bool_t enable); - bool_t nat_helper_enabled() const {return this->_nat_helper_enabled;} - - bool_t pending_trans_checking_enabled() const {return this->pending_trans_checking;} - int enable_pending_trans_checking(bool_t value) {this->pending_trans_checking = value; return 0;} - - void set_refresher_retry_after(int value) {this->refresher_retry_after=value;} - int get_refresher_retry_after() const {return this->refresher_retry_after;} - - void enable_sip_update_method(bool_t value) {this->enable_sip_update=value;} - void use_session_timers(int expires) {this->session_expires=expires;} - void use_dates(bool_t enabled) {this->_use_dates=enabled;} - void use_one_matching_codec_policy(bool_t one_matching_codec) {this->one_matching_codec=one_matching_codec;} - void use_rport(bool_t use_rports); - void enable_auto_contacts(bool_t enabled) {this->auto_contacts=enabled;} - void enable_test_features(bool_t enabled) {this->_enable_test_features=enabled;} - void use_no_initial_route(bool_t enabled) {this->no_initial_route=enabled;} - void enable_unconditional_answer(int value) {belle_sip_provider_enable_unconditional_answer(this->prov,value);} - void enable_reconnect_to_primary_asap(bool_t enabled) {belle_sip_stack_enable_reconnect_to_primary_asap(this->stack,enabled);} - - bctbx_list_t *get_pending_auths() const {return bctbx_list_copy(this->pending_auths);} - - void set_contact_linphone_specs(const char *specs); - - /**********************/ - /* Network parameters */ - /**********************/ - int set_listen_port(const char *addr, int port, SalTransport tr, bool_t is_tunneled); - int get_listening_port(SalTransport tr); - int transport_available(SalTransport t); - - void get_default_local_ip(int address_family, char *ip, size_t iplen); - - void set_transport_timeout(int timeout) {belle_sip_stack_set_transport_timeout(this->stack, timeout);} - int get_transport_timeout() const {return belle_sip_stack_get_transport_timeout(this->stack);} - - void set_keepalive_period(unsigned int value); - unsigned int get_keepalive_period() const {return this->keep_alive;} - void use_tcp_tls_keepalive(bool_t enabled) {this->use_tcp_tls_keep_alive=enabled;} - - void set_dscp(int dscp) {belle_sip_stack_set_default_dscp(this->stack,dscp);} - - int set_tunnel(void *tunnelclient); - - void set_http_proxy_host(const char *host) {belle_sip_stack_set_http_proxy_host(this->stack, host);} - const char *get_http_proxy_host() const {return belle_sip_stack_get_http_proxy_host(this->stack);} - - void set_http_proxy_port(int port) {belle_sip_stack_set_http_proxy_port(this->stack, port);} - int get_http_proxy_port() const {return belle_sip_stack_get_http_proxy_port(this->stack);} - - ortp_socket_t get_socket() const; - - int unlisten_ports(); - int reset_transports(); - - - /******************/ - /* TLS parameters */ - /******************/ - void set_ssl_config(void *ssl_config); - void set_root_ca(const char* rootCa); - void set_root_ca_data(const char* data); - const char *get_root_ca() const {return this->root_ca;} - - void verify_server_certificates(bool_t verify); - void verify_server_cn(bool_t verify); - - - /******************/ - /* DNS resolution */ - /******************/ - void set_dns_timeout(int timeout) {belle_sip_stack_set_dns_timeout(this->stack, timeout);} - int get_dns_timeout() const {return belle_sip_stack_get_dns_timeout(this->stack);} - - void set_dns_servers(const bctbx_list_t *servers); - - void enable_dns_search(bool_t enable) {belle_sip_stack_enable_dns_search(this->stack, (unsigned char)enable);} - bool_t dns_search_enabled() const {return (bool_t)belle_sip_stack_dns_search_enabled(this->stack);} - - void enable_dns_srv(bool_t enable) {belle_sip_stack_enable_dns_srv(this->stack, (unsigned char)enable);} - bool_t dns_srv_enabled() const {return (bool_t)belle_sip_stack_dns_srv_enabled(this->stack);} - - void set_dns_user_hosts_file(const char *hosts_file) {belle_sip_stack_set_dns_user_hosts_file(this->stack, hosts_file);} - const char *get_dns_user_hosts_file() const {return belle_sip_stack_get_dns_user_hosts_file(this->stack);} - - belle_sip_resolver_context_t *resolve_a(const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) - {return belle_sip_stack_resolve_a(this->stack,name,port,family,cb,data);} - belle_sip_resolver_context_t *resolve(const char *service, const char *transport, const char *name, int port, int family, belle_sip_resolver_callback_t cb, void *data) - {return belle_sip_stack_resolve(this->stack, service, transport, name, port, family, cb, data);} - - - /**********/ - /* Timers */ - /**********/ - belle_sip_source_t *create_timer(belle_sip_source_func_t func, void *data, unsigned int timeout_value_ms, const char* timer_name); - void cancel_timer(belle_sip_source_t *timer); + // --------------------------------------------------------------------------- + // Timers + // --------------------------------------------------------------------------- + belle_sip_source_t *createTimer (belle_sip_source_func_t func, void *data, unsigned int timeoutValueMs, const char *timerName); + void cancelTimer (belle_sip_source_t *timer); private: @@ -262,57 +269,59 @@ private: unsigned char node[6]; }; - void set_tls_properties(); - int add_listen_port(SalAddress* addr, bool_t is_tunneled); - void make_supported_header(); - void add_pending_auth(SalOp *op); - void remove_pending_auth(SalOp *op); - belle_sip_response_t* create_response_from_request (belle_sip_request_t* req, int code ); + void setTlsProperties (); + int addListenPort (SalAddress *addr, bool_t isTunneled); + void makeSupportedHeader (); + void addPendingAuth (SalOp *op); + void removePendingAuth (SalOp *op); + belle_sip_response_t *createResponseFromRequest (belle_sip_request_t *req, int code); - static void unimplemented_stub() {ms_warning("Unimplemented SAL callback");} - static void remove_listening_point(belle_sip_listening_point_t* lp,belle_sip_provider_t* prov) {belle_sip_provider_remove_listening_point(prov,lp);} + static void unimplementedStub() { lWarning() << "Unimplemented SAL callback"; } + static void removeListeningPoint (belle_sip_listening_point_t *lp,belle_sip_provider_t *prov) { + belle_sip_provider_remove_listening_point(prov, lp); + } - /* Internal callbacks */ - static void process_dialog_terminated_cb(void *sal, const belle_sip_dialog_terminated_event_t *event); - static void process_io_error_cb(void *user_ctx, const belle_sip_io_error_event_t *event); - static void process_request_event_cb(void *ud, const belle_sip_request_event_t *event); - static void process_response_event_cb(void *user_ctx, const belle_sip_response_event_t *event); - static void process_timeout_cb(void *user_ctx, const belle_sip_timeout_event_t *event); - static void process_transaction_terminated_cb(void *user_ctx, const belle_sip_transaction_terminated_event_t *event); - static void process_auth_requested_cb(void *sal, belle_sip_auth_event_t *event); + // Internal callbacks + static void processDialogTerminatedCb (void *userCtx, const belle_sip_dialog_terminated_event_t *event); + static void processIoErrorCb (void *userCtx, const belle_sip_io_error_event_t *event); + static void processRequestEventCb (void *userCtx, const belle_sip_request_event_t *event); + static void processResponseEventCb (void *userCtx, const belle_sip_response_event_t *event); + static void processTimeoutCb (void *userCtx, const belle_sip_timeout_event_t *event); + static void processTransactionTerminatedCb (void *userCtx, const belle_sip_transaction_terminated_event_t *event); + static void processAuthRequestedCb (void *userCtx, belle_sip_auth_event_t *event); - MSFactory *factory = NULL; - Callbacks callbacks = {0}; - MSList *pending_auths = NULL;/*MSList of SalOp */ - belle_sip_stack_t* stack = NULL; - belle_sip_provider_t *prov = NULL; - belle_sip_header_user_agent_t* user_agent = NULL; - belle_sip_listener_t *listener = NULL; - void *tunnel_client = NULL; - void *up = NULL; /*user pointer*/ - int session_expires = 0; - unsigned int keep_alive = 0; - char *root_ca = NULL; - char *root_ca_data = NULL; - char *uuid = NULL; - int refresher_retry_after = 60000; /*retry after value for refresher*/ - MSList *supported_tags = NULL;/*list of char * */ - belle_sip_header_t *supported = NULL; - bool_t one_matching_codec = FALSE; - bool_t use_tcp_tls_keep_alive = FALSE; - bool_t _nat_helper_enabled = FALSE; - bool_t tls_verify = TRUE; - bool_t tls_verify_cn = TRUE; - bool_t _use_dates = FALSE; - bool_t auto_contacts = TRUE; - bool_t _enable_test_features = FALSE; - bool_t no_initial_route = FALSE; - bool_t enable_sip_update = TRUE; /*true by default*/ - SalOpSDPHandling default_sdp_handling = SalOpSDPNormal; - bool_t pending_trans_checking = TRUE; /*testing purpose*/ - void *ssl_config = NULL; - bctbx_list_t *supported_content_types = NULL; /* list of char* */ - char *linphone_specs = NULL; + MSFactory *mFactory = nullptr; + Callbacks mCallbacks = { 0 }; + MSList *mPendingAuths = nullptr; // List of SalOp + belle_sip_stack_t *mStack = nullptr; + belle_sip_provider_t *mProvider = nullptr; + belle_sip_header_user_agent_t *mUserAgent = nullptr; + belle_sip_listener_t *mListener = nullptr; + void *mTunnelClient = nullptr; + void *mUserPointer = nullptr; // User pointer + int mSessionExpires = 0; + unsigned int mKeepAlive = 0; + char *mRootCa = nullptr; + char *mRootCaData = nullptr; + char *mUuid = nullptr; + int mRefresherRetryAfter = 60000; // Retry after value for refresher + MSList *mSupportedTags = nullptr; // List of char * + belle_sip_header_t *mSupported = nullptr; + bool_t mOneMatchingCodec = FALSE; + bool_t mUseTcpTlsKeepAlive = FALSE; + bool_t mNatHelperEnabled = FALSE; + bool_t mTlsVerify = TRUE; + bool_t mTlsVerifyCn = TRUE; + bool_t mUseDates = FALSE; + bool_t mAutoContacts = TRUE; + bool_t mEnableTestFeatures = FALSE; + bool_t mNoInitialRoute = FALSE; + bool_t mEnableSipUpdate = TRUE; // true by default + SalOpSDPHandling mDefaultSdpHandling = SalOpSDPNormal; + bool_t mPendingTransactionChecking = TRUE; // For testing purposes + void *mSslConfig = nullptr; + bctbx_list_t *mSupportedContentTypes = nullptr; // List of char * + char *mLinphoneSpecs = nullptr; friend class SalOp; friend class SalCallOp; @@ -329,3 +338,4 @@ int to_sip_code(SalReason r); LINPHONE_END_NAMESPACE #endif // ifndef _L_SAL_H_ + diff --git a/src/utils/background-task.cpp b/src/utils/background-task.cpp index b91a10f8d..fcea4f2f3 100644 --- a/src/utils/background-task.cpp +++ b/src/utils/background-task.cpp @@ -61,7 +61,7 @@ void BackgroundTask::start (const shared_ptr &core, int maxDurationSeconds mId = newId; if (maxDurationSeconds > 0) { mSal = core->getCCore()->sal; - mTimeout = mSal->create_timer(sHandleSalTimeout, this, (unsigned int)maxDurationSeconds * 1000, mName.c_str()); + mTimeout = mSal->createTimer(sHandleSalTimeout, this, (unsigned int)maxDurationSeconds * 1000, mName.c_str()); } } @@ -72,7 +72,7 @@ void BackgroundTask::stop () { lInfo() << "Ending background task [" << mId << "] with name: [" << mName << "]"; sal_end_background_task(mId); if (mTimeout) { - mSal->cancel_timer(mTimeout); + mSal->cancelTimer(mTimeout); belle_sip_object_unref(mTimeout); mTimeout = nullptr; } From 834cf06a91d79c98fb1d7dd31a27fca5e8d9fc91 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 May 2018 11:10:20 +0200 Subject: [PATCH 138/143] Don't pretty print IMDN and is-composing xml for compatibility with old implementation. --- src/chat/notification/imdn.cpp | 2 +- src/chat/notification/is-composing.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index fd56b7013..7f70d2952 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -160,7 +160,7 @@ string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, map[""].name = "urn:ietf:params:xml:ns:imdn"; if (needLinphoneImdnNamespace) map["imdn"].name = "http://www.linphone.org/xsds/imdn.xsd"; - Xsd::Imdn::serializeImdn(ss, imdn, map); + Xsd::Imdn::serializeImdn(ss, imdn, map, "UTF-8", Xsd::XmlSchema::Flags::dont_pretty_print); return ss.str(); } diff --git a/src/chat/notification/is-composing.cpp b/src/chat/notification/is-composing.cpp index 6cb8d29da..343bf53d9 100644 --- a/src/chat/notification/is-composing.cpp +++ b/src/chat/notification/is-composing.cpp @@ -60,7 +60,7 @@ string IsComposing::createXml (bool isComposing) { stringstream ss; Xsd::XmlSchema::NamespaceInfomap map; map[""].name = "urn:ietf:params:xml:ns:im-iscomposing"; - Xsd::IsComposing::serializeIsComposing(ss, node, map); + Xsd::IsComposing::serializeIsComposing(ss, node, map, "UTF-8", Xsd::XmlSchema::Flags::dont_pretty_print); return ss.str(); } From fa74398e9e600927158ba84db421f18574e36295 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 May 2018 12:22:04 +0200 Subject: [PATCH 139/143] Fixed call to Sal's set_tunnel which now is setTunnel --- coreapi/TunnelManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index c9a14f865..43b1be150 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -159,7 +159,7 @@ void TunnelManager::startClient() { mTunnelClient = TunnelClient::create(TRUE); } - mCore->sal->set_tunnel(mTunnelClient); + mCore->sal->setTunnel(mTunnelClient); if (!mUseDualClient) { static_cast(mTunnelClient)->setCallback(tunnelCallback,this); } else { From d11ba452c28b01d34e214c05d608c52cd2b4e976 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 May 2018 12:24:43 +0200 Subject: [PATCH 140/143] Fixed tunnel related issues in Sal --- src/sal/sal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sal/sal.cpp b/src/sal/sal.cpp index 13e71970e..36d8c0c10 100644 --- a/src/sal/sal.cpp +++ b/src/sal/sal.cpp @@ -478,7 +478,7 @@ int Sal::addListenPort(SalAddress* addr, bool_t is_tunneled) { ms_error("Tunneled mode is only available for UDP kind of transports."); return -1; } - lp = belle_sip_tunnel_listening_point_new(stack, tunnel_client); + lp = belle_sip_tunnel_listening_point_new(mStack, mTunnelClient); if (!lp){ ms_error("Could not create tunnel listening point."); return -1; @@ -648,7 +648,7 @@ void Sal::setKeepAlivePeriod(unsigned int value) { int Sal::setTunnel(void *tunnelclient) { #ifdef TUNNEL_ENABLED - tunnel_client=tunnelclient; + mTunnelClient=tunnelclient; return 0; #else return -1; From 1f5c297c224816abf90e621b909f4cb7ab60ac09 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 May 2018 12:48:22 +0200 Subject: [PATCH 141/143] Fixed rootca not being set if path is a directory + added default root ca path for Android --- coreapi/linphonecore.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 45513f430..c879c99a9 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1269,11 +1269,15 @@ static void certificates_config_read(LinphoneCore *lc) { char *root_ca_path = bctbx_strdup_printf("%s/rootca.pem", data_dir); const char *rootca = lp_config_get_string(lc->config,"sip","root_ca", NULL); // If rootca is not existing anymore, we reset it to the default value - if (rootca == NULL || (bctbx_file_exist(rootca) != 0)) { + if (rootca == NULL || ((bctbx_file_exist(rootca) != 0) && (!bctbx_directory_exists(rootca)))) { #ifdef __linux - struct stat sb; - if (stat("/etc/ssl/certs", &sb) == 0 && S_ISDIR(sb.st_mode)) { - rootca = "/etc/ssl/certs"; + #ifdef __ANDROID__ + const char *possible_rootca = "/system/etc/security/cacerts"; + #else + const char *possible_rootca = "/etc/ssl/certs"; + #endif + if (bctbx_directory_exists(possible_rootca)) { + rootca = possible_rootca; } else #endif { @@ -2287,7 +2291,7 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig lc->http_crypto_config = belle_tls_crypto_config_new(); belle_http_provider_set_tls_crypto_config(lc->http_provider,lc->http_crypto_config); - certificates_config_read(lc); + //certificates_config_read(lc); // This will be done below in _linphone_core_read_config() lc->ringtoneplayer = linphone_ringtoneplayer_new(); From bad6d9e9e18d134d7854f961e7a618c025b9692f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 9 May 2018 14:48:49 +0200 Subject: [PATCH 142/143] Fix IMDN sending in the case where it cannot be aggregated. --- src/chat/chat-message/imdn-message-p.h | 2 +- src/chat/notification/imdn.cpp | 37 +++++++++++++++----------- src/chat/notification/imdn.h | 5 +++- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/chat/chat-message/imdn-message-p.h b/src/chat/chat-message/imdn-message-p.h index 31262e9db..57b0678e9 100644 --- a/src/chat/chat-message/imdn-message-p.h +++ b/src/chat/chat-message/imdn-message-p.h @@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE class ImdnMessagePrivate : public NotificationMessagePrivate { public: - ImdnMessage::Context getContext () {return context;} + const ImdnMessage::Context &getContext () { return context; } private: ImdnMessagePrivate (const ImdnMessage::Context &context) diff --git a/src/chat/notification/imdn.cpp b/src/chat/notification/imdn.cpp index 7f70d2952..8afe38a6b 100644 --- a/src/chat/notification/imdn.cpp +++ b/src/chat/notification/imdn.cpp @@ -86,7 +86,7 @@ void Imdn::notifyDisplay (const shared_ptr &message) { void Imdn::onImdnMessageDelivered (const std::shared_ptr &message) { // If an IMDN has been successfully delivered, remove it from the list so that // it does not get sent again - ImdnMessage::Context context = message->getPrivate()->getContext(); + auto context = message->getPrivate()->getContext(); for (const auto &deliveredMsg : context.deliveredMessages) deliveredMessages.remove(deliveredMsg); @@ -113,15 +113,9 @@ void Imdn::onGlobalStateChanged (LinphoneGlobalState state) { void Imdn::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) { if (sipNetworkReachable) { - // When the SIP network gets up, retry sending every IMDN message that has not - // successfully been delivered - auto messages = sentImdnMessages; + // When the SIP network gets up, retry notification sentImdnMessages.clear(); - for (const auto &message : messages) { - auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(message); - sentImdnMessages.push_back(imdnMessage); - imdnMessage->send(); - } + send(); } } @@ -208,26 +202,37 @@ int Imdn::timerExpired (void *data, unsigned int revents) { // ----------------------------------------------------------------------------- +bool Imdn::aggregationEnabled () const { + auto config = linphone_core_get_config(chatRoom->getCore()->getCCore()); + bool aggregateImdn = linphone_config_get_bool(config, "misc", "aggregate_imdn", TRUE); + return (chatRoom->canHandleCpim() && aggregateImdn); +} + void Imdn::send () { bool networkReachable = linphone_core_is_network_reachable(chatRoom->getCore()->getCCore()); + if (!networkReachable) + return; + if (!deliveredMessages.empty() || !displayedMessages.empty()) { auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages); sentImdnMessages.push_back(imdnMessage); - if (networkReachable) - imdnMessage->getPrivate()->send(); + imdnMessage->getPrivate()->send(); + if (!aggregationEnabled()) { + deliveredMessages.clear(); + displayedMessages.clear(); + } } if (!nonDeliveredMessages.empty()) { auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(nonDeliveredMessages); sentImdnMessages.push_back(imdnMessage); - if (networkReachable) - imdnMessage->getPrivate()->send(); + imdnMessage->getPrivate()->send(); + if (!aggregationEnabled()) + nonDeliveredMessages.clear(); } } void Imdn::startTimer () { - auto config = linphone_core_get_config(chatRoom->getCore()->getCCore()); - bool aggregateImdn = linphone_config_get_bool(config, "misc", "aggregate_imdn", TRUE); - if (!chatRoom->canHandleCpim() || !aggregateImdn) { + if (!aggregationEnabled()) { // Compatibility mode for basic chat rooms, do not aggregate notifications send(); return; diff --git a/src/chat/notification/imdn.h b/src/chat/notification/imdn.h index 789cd4854..58755fdd8 100644 --- a/src/chat/notification/imdn.h +++ b/src/chat/notification/imdn.h @@ -46,7 +46,9 @@ public: MessageReason (const std::shared_ptr &message, LinphoneReason reason) : message(message), reason(reason) {} - bool operator== (const MessageReason &other) const {return message == other.message && reason == other.reason;} + bool operator== (const MessageReason &other) const { + return (message == other.message) && (reason == other.reason); + } const std::shared_ptr message; LinphoneReason reason; @@ -73,6 +75,7 @@ public: private: static int timerExpired (void *data, unsigned int revents); + bool aggregationEnabled () const; void send (); void startTimer (); void stopTimer (); From 1572ef97eee07cd7a49670f8270a5a911fdd47db Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 9 May 2018 15:04:41 +0200 Subject: [PATCH 143/143] fix send of notify multipart --- coreapi/event.c | 2 +- coreapi/private_functions.h | 2 +- src/c-wrapper/api/c-content.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coreapi/event.c b/coreapi/event.c index 149eda87c..ade697ab0 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -324,7 +324,7 @@ LinphoneStatus linphone_event_notify(LinphoneEvent *lev, const LinphoneContent * ms_error("linphone_event_notify(): cannot notify if not an incoming subscription."); return -1; } - body_handler = sal_body_handler_from_content(body); + body_handler = sal_body_handler_from_content(body, false); auto subscribeOp = dynamic_cast(lev->op); return subscribeOp->notify(body_handler); } diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 9d6b29b08..8c09ba1cf 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -386,7 +386,7 @@ void linphone_configure_op(LinphoneCore *lc, LinphonePrivate::SalOp *op, const L void linphone_configure_op_with_proxy(LinphoneCore *lc, LinphonePrivate::SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact, LinphoneProxyConfig *proxy); LinphoneContent * linphone_content_new(void); LinphoneContent * linphone_content_copy(const LinphoneContent *ref); -SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content); +SalBodyHandler *sal_body_handler_from_content(const LinphoneContent *content, bool parseMultipart = true); SalReason linphone_reason_to_sal(LinphoneReason reason); LinphoneReason linphone_reason_from_sal(SalReason reason); void linphone_error_info_to_sal(const LinphoneErrorInfo* ei, SalErrorInfo* sei); diff --git a/src/c-wrapper/api/c-content.cpp b/src/c-wrapper/api/c-content.cpp index 1575248a1..9938b9cb7 100644 --- a/src/c-wrapper/api/c-content.cpp +++ b/src/c-wrapper/api/c-content.cpp @@ -303,13 +303,13 @@ LinphoneContent *linphone_content_from_sal_body_handler (SalBodyHandler *body_ha return NULL; } -SalBodyHandler *sal_body_handler_from_content (const LinphoneContent *content) { +SalBodyHandler *sal_body_handler_from_content (const LinphoneContent *content, bool parseMultipart) { if (content == NULL) return NULL; SalBodyHandler *body_handler; LinphonePrivate::ContentType contentType = L_GET_CPP_PTR_FROM_C_OBJECT(content)->getContentType(); - if (contentType.isMultipart()) { + if (contentType.isMultipart() && parseMultipart) { size_t size = linphone_content_get_size(content); char *buffer = bctbx_strdup(L_GET_CPP_PTR_FROM_C_OBJECT(content)->getBodyAsUtf8String().c_str()); const char *boundary = L_STRING_TO_C(contentType.getParameter("boundary").getValue());