From d111d78f71114d0ec0ba01af93a344c1d318cf59 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 30 Nov 2017 11:20:38 +0100 Subject: [PATCH] feat(core-c): provide a way to find chat room --- coreapi/chat.c | 11 +++++++++++ coreapi/tester_utils.cpp | 11 ----------- coreapi/tester_utils.h | 2 -- include/linphone/core.h | 24 +++++++++++++++++++----- src/db/abstract/abstract-db.cpp | 4 ++-- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index c5b5d1200..2a2fac935 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -104,6 +104,17 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c return L_GET_C_BACK_PTR(lc->cppCore->getOrCreateBasicChatRoomFromUri(L_C_TO_STRING(to))); } +LinphoneChatRoom *linphone_core_find_chat_room( + const LinphoneCore *lc, + const LinphoneAddress *peerAddr, + const LinphoneAddress *localAddr +) { + return L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId( + LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(peerAddr)), + LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)) + ))); +} + int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op, const SalMessage *sal_msg) { LinphoneReason reason = LinphoneReasonNotAcceptable; const char *peerAddress; diff --git a/coreapi/tester_utils.cpp b/coreapi/tester_utils.cpp index f5d50e8e3..600c21bdb 100644 --- a/coreapi/tester_utils.cpp +++ b/coreapi/tester_utils.cpp @@ -56,17 +56,6 @@ bctbx_list_t **linphone_core_get_call_logs_attribute(LinphoneCore *lc) { return &lc->call_logs; } -LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *peerAddr, const LinphoneAddress *localAddr) { - shared_ptr chatRoom = lc->cppCore->findChatRoom(ChatRoomId( - IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(peerAddr)), - IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)) - )); - - if (chatRoom) - return L_GET_C_BACK_PTR(chatRoom); - return nullptr; -} - void linphone_core_cbs_set_auth_info_requested(LinphoneCoreCbs *cbs, LinphoneCoreAuthInfoRequestedCb cb) { cbs->vtable->auth_info_requested = cb; } diff --git a/coreapi/tester_utils.h b/coreapi/tester_utils.h index 862d1043a..32a058161 100644 --- a/coreapi/tester_utils.h +++ b/coreapi/tester_utils.h @@ -93,8 +93,6 @@ LINPHONE_PUBLIC mblk_t *_linphone_call_stats_get_received_rtcp (const LinphoneCa LINPHONE_PUBLIC LinphoneQualityReporting *linphone_call_log_get_quality_reporting(LinphoneCallLog *call_log); LINPHONE_PUBLIC reporting_session_report_t **linphone_quality_reporting_get_reports(LinphoneQualityReporting *qreporting); -LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_find_chat_room (const LinphoneCore *lc, const LinphoneAddress *peerAddr, const LinphoneAddress *localAddr); - LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list); LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_friend_invalidate_subscription(LinphoneFriend *lf); diff --git a/include/linphone/core.h b/include/linphone/core.h index 55e8cbe5f..9e627b785 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -3448,7 +3448,7 @@ LINPHONE_PUBLIC void linphone_core_set_preview_video_definition(LinphoneCore *lc /** * @biref 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. * Using this feature increases the CPU consumption, since a rescaling will be done internally. @@ -3501,7 +3501,7 @@ LINPHONE_PUBLIC LinphoneVideoDefinition * linphone_core_get_current_preview_vide /** * @brief Returns the effective video size for the captured video as provided by the camera. - * + * * When preview is disabled or not yet started, this function returns a zeroed video size. * @see #linphone_core_set_preview_video_size() * @ingroup media_parameters @@ -4725,7 +4725,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_multicast_enabled(const LinphoneCore /** * @brief Set the network simulator parameters. - * + * * Liblinphone has the capabability of simulating the effects of a network (latency, lost packets, jitter, max bandwidth). * Please refer to the oRTP documentation for the meaning of the parameters of the OrtpNetworkSimulatorParams structure. * This function has effect for future calls, but not for currently running calls, though this behavior may be changed in future versions. @@ -4941,7 +4941,7 @@ LINPHONE_PUBLIC const char *linphone_core_get_chat_database_path(const LinphoneC LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject); /** - * Get a chat room whose peer is the supplied address. If it does not exist yet, it will be created. + * Get a basic chat room whose peer is the supplied address. If it does not exist yet, it will be created. * No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room. * @param lc the linphone core * @param addr a linphone address. @@ -4950,7 +4950,7 @@ LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(L LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr); /** - * Get a chat room for messaging from a sip uri like sip:joe@sip.linphone.org. If it does not exist yet, it will be created. + * Get a basic chat room for messaging from a sip uri like sip:joe@sip.linphone.org. If it does not exist yet, it will be created. * No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room. * @param lc A #LinphoneCore object * @param to The destination address for messages. @@ -4958,6 +4958,20 @@ LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, **/ LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const char *to); +/** + * Find a chat room. + * No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room. + * @param lc the linphone core + * @param peerAddr a linphone address. + * @param localAddr a linphone address. + * @return #LinphoneChatRoom where messaging can take place. +**/ +LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_find_chat_room ( + const LinphoneCore *lc, + const LinphoneAddress *peerAddr, + const LinphoneAddress *localAddr +); + /** * Removes a chatroom including all message history from the LinphoneCore. * @param lc A #LinphoneCore object diff --git a/src/db/abstract/abstract-db.cpp b/src/db/abstract/abstract-db.cpp index eea755fa7..3f58b5251 100644 --- a/src/db/abstract/abstract-db.cpp +++ b/src/db/abstract/abstract-db.cpp @@ -52,8 +52,8 @@ bool AbstractDb::connect (Backend backend, const string ¶meters) { d->backend = backend; d->dbSession = DbSessionProvider::getInstance()->getSession( - (backend == Mysql ? "mysql://" : "sqlite3://") + parameters - ); + (backend == Mysql ? "mysql://" : "sqlite3://") + parameters + ); if (d->dbSession) { try {