From c0d1e3ec7226759428801d4aa37656de7dc6fb83 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 20 Sep 2017 14:00:22 +0200 Subject: [PATCH] Started c wrapper for chat message callbacks --- coreapi/private.h | 9 --- include/CMakeLists.txt | 1 + include/linphone/api/c-chat-message-cbs.h | 71 +++++++++++++++++++++++ include/linphone/api/c-types.h | 10 ++++ src/CMakeLists.txt | 1 + src/c-wrapper/api/c-chat-message-cbs.cpp | 67 +++++++++++++++++++++ 6 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 include/linphone/api/c-chat-message-cbs.h create mode 100644 src/c-wrapper/api/c-chat-message-cbs.cpp diff --git a/coreapi/private.h b/coreapi/private.h index cd4673aef..3bcd62a49 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -174,15 +174,6 @@ typedef struct _CallCallbackObj void * _user_data; }CallCallbackObj; -struct _LinphoneChatMessageCbs { - belle_sip_object_t base; - void *user_data; - LinphoneChatMessageCbsMsgStateChangedCb msg_state_changed; - LinphoneChatMessageCbsFileTransferRecvCb file_transfer_recv; /**< Callback to store file received attached to a #LinphoneChatMessage */ - LinphoneChatMessageCbsFileTransferSendCb file_transfer_send; /**< Callback to collect file chunk to be sent for a #LinphoneChatMessage */ - LinphoneChatMessageCbsFileTransferProgressIndicationCb file_transfer_progress_indication; /**< Callback to indicate file transfer progress */ -}; - BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs); typedef enum _LinphoneChatMessageDir{ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 40d842bf5..87c5aa063 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -78,6 +78,7 @@ set(C_API_HEADER_FILES c-api.h c-callbacks.h c-chat-message.h + c-chat-message-cbs.h c-chat-room.h c-chat-room-cbs.h c-event-log.h diff --git a/include/linphone/api/c-chat-message-cbs.h b/include/linphone/api/c-chat-message-cbs.h new file mode 100644 index 000000000..2bcd9b729 --- /dev/null +++ b/include/linphone/api/c-chat-message-cbs.h @@ -0,0 +1,71 @@ +/* + * c-chat-message-cbs.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _C_CHAT_MESSAGE_CBS_H_ +#define _C_CHAT_MESSAGE_CBS_H_ + +#include "linphone/api/c-callbacks.h" +#include "linphone/api/c-types.h" + +// ============================================================================= + +#ifdef __cplusplus + extern "C" { +#endif // ifdef __cplusplus + +/** + * @addtogroup chatroom + * @{ + */ + +/** + * Acquire a reference to the chat room callbacks object. + * @param[in] cbs The chat room callbacks object + * @return The same chat room callbacks object +**/ +LINPHONE_PUBLIC LinphoneChatMessageCbs * linphone_chat_message_cbs_ref (LinphoneChatMessageCbs *cbs); + +/** + * Release reference to the chat room callbacks object. + * @param[in] cr The chat room callbacks object +**/ +LINPHONE_PUBLIC void linphone_chat_message_cbs_unref (LinphoneChatMessageCbs *cbs); + +/** + * Retrieve the user pointer associated with the chat room callbacks object. + * @param[in] cr The chat room callbacks object + * @return The user pointer associated with the chat room callbacks object +**/ +LINPHONE_PUBLIC void * linphone_chat_message_cbs_get_user_data (const LinphoneChatMessageCbs *cbs); + +/** + * Assign a user pointer to the chat room callbacks object. + * @param[in] cr The chat room callbacks object + * @param[in] ud The user pointer to associate with the chat room callbacks object +**/ +LINPHONE_PUBLIC void linphone_chat_message_cbs_set_user_data (LinphoneChatMessageCbs *cbs, void *ud); + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif // ifdef __cplusplus + +#endif // ifndef _C_CHAT_MESSAGE_H_ diff --git a/include/linphone/api/c-types.h b/include/linphone/api/c-types.h index de41cda49..7e53de356 100644 --- a/include/linphone/api/c-types.h +++ b/include/linphone/api/c-types.h @@ -88,8 +88,18 @@ typedef struct _LinphoneChatRoom LinphoneChatRoom; */ typedef struct _LinphoneChatRoomCbs LinphoneChatRoomCbs; +/** + * An chat message is the object that is sent and received through LinphoneChatRooms. + * @ingroup chatroom + */ typedef struct _LinphoneMessage LinphoneMessage; +/** + * An object to handle the callbacks for the handling a LinphoneChatMessage objects. + * @ingroup chatroom + */ +typedef struct _LinphoneChatMessageCbs LinphoneChatMessageCbs; + /** * The LinphoneParticipant object represents a participant of a conference. * @ingroup misc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae40aa80b..20eaccdc7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -104,6 +104,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES c-wrapper/api/c-address.cpp c-wrapper/api/c-call-params.cpp c-wrapper/api/c-chat-message.cpp + c-wrapper/api/c-chat-message-cbs.cpp c-wrapper/api/c-chat-room.cpp c-wrapper/api/c-chat-room-cbs.cpp c-wrapper/api/c-event-log.cpp diff --git a/src/c-wrapper/api/c-chat-message-cbs.cpp b/src/c-wrapper/api/c-chat-message-cbs.cpp new file mode 100644 index 000000000..d26604dae --- /dev/null +++ b/src/c-wrapper/api/c-chat-message-cbs.cpp @@ -0,0 +1,67 @@ +/* + * c-chat-message-cbs.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "linphone/api/c-chat-message-cbs.h" + +// TODO: Remove me later. +#include "private.h" + +// ============================================================================= + +struct _LinphoneChatMessageCbs { + belle_sip_object_t base; + void *userData; + LinphoneChatMessageCbsMsgStateChangedCb msg_state_changed; + LinphoneChatMessageCbsFileTransferRecvCb file_transfer_recv; + LinphoneChatMessageCbsFileTransferSendCb file_transfer_send; + LinphoneChatMessageCbsFileTransferProgressIndicationCb file_transfer_progress_indication; +}; + +BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs); + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatMessageCbs); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneChatMessageCbs, belle_sip_object_t, + NULL, // destroy + NULL, // clone + NULL, // marshal + FALSE +); + +// ============================================================================= + +LinphoneChatMessageCbs * linphone_chat_message_cbs_new (void) { + return belle_sip_object_new(LinphoneChatMessageCbs); +} + +LinphoneChatMessageCbs * linphone_chat_message_cbs_ref (LinphoneChatMessageCbs *cbs) { + belle_sip_object_ref(cbs); + return cbs; +} + +void linphone_chat_message_cbs_unref (LinphoneChatMessageCbs *cbs) { + belle_sip_object_unref(cbs); +} + +void * linphone_chat_message_cbs_get_user_data (const LinphoneChatMessageCbs *cbs) { + return cbs->userData; +} + +void linphone_chat_message_cbs_set_user_data (LinphoneChatMessageCbs *cbs, void *ud) { + cbs->userData = ud; +}