From f4f3b90c9ed86cbc367ce0aac7757d0bb599f7e9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 15 Sep 2017 10:59:47 +0200 Subject: [PATCH] Add C wrapper for Participant class. --- coreapi/private.h | 3 +- include/CMakeLists.txt | 1 + include/linphone/api/c-api.h | 1 + include/linphone/api/c-participant.h | 88 ++++++++++++++++++++++++++++ include/linphone/api/c-types.h | 1 + src/CMakeLists.txt | 1 + src/c-wrapper/api/c-participant.cpp | 64 ++++++++++++++++++++ 7 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 include/linphone/api/c-participant.h create mode 100644 src/c-wrapper/api/c-participant.cpp diff --git a/coreapi/private.h b/coreapi/private.h index 95f98514e..d8f94da45 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1723,7 +1723,8 @@ BELLE_SIP_TYPE_ID(LinphonePlayer), BELLE_SIP_TYPE_ID(LinphonePlayerCbs), BELLE_SIP_TYPE_ID(LinphoneEventLog), BELLE_SIP_TYPE_ID(LinphoneMessage), -BELLE_SIP_TYPE_ID(LinphoneMessageEvent) +BELLE_SIP_TYPE_ID(LinphoneMessageEvent), +BELLE_SIP_TYPE_ID(LinphoneParticipant) BELLE_SIP_DECLARE_TYPES_END diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index d54cb0ddf..cd1e77d89 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -77,6 +77,7 @@ set(C_API_HEADER_FILES c-address.h c-api.h c-event-log.h + c-participant.h c-types.h ) diff --git a/include/linphone/api/c-api.h b/include/linphone/api/c-api.h index 746ac7c3a..fab3520bd 100644 --- a/include/linphone/api/c-api.h +++ b/include/linphone/api/c-api.h @@ -21,5 +21,6 @@ #include "linphone/api/c-address.h" #include "linphone/api/c-event-log.h" +#include "linphone/api/c-participant.h" #endif // ifndef _C_API_H_ diff --git a/include/linphone/api/c-participant.h b/include/linphone/api/c-participant.h new file mode 100644 index 000000000..f09789ce5 --- /dev/null +++ b/include/linphone/api/c-participant.h @@ -0,0 +1,88 @@ +/* + * c-participant.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_PARTICIPANT_H_ +#define _C_PARTICIPANT_H_ + +#include "linphone/api/c-types.h" + +// ============================================================================= + +#ifdef __cplusplus + extern "C" { +#endif // ifdef __cplusplus + +/** + * @addtogroup misc + * @{ + */ + +/** + * Increment reference count of LinphoneParticipant object. + **/ +LINPHONE_PUBLIC LinphoneParticipant *linphone_participant_ref (LinphoneParticipant *participant); + +/** + * Decrement reference count of LinphoneParticipant object. + **/ +LINPHONE_PUBLIC void linphone_participant_unref (LinphoneParticipant *participant); + +/** + * Retrieve the user pointer associated with the conference participant. + * @param[in] participant A LinphoneParticipant object + * @return The user pointer associated with the participant. +**/ +LINPHONE_PUBLIC void * linphone_participant_get_user_data(const LinphoneParticipant *participant); + +/** + * Assign a user pointer to the conference participant. + * @param[in] participant A LinphoneParticipant object + * @param[in] ud The user pointer to associate with the participant +**/ +LINPHONE_PUBLIC void linphone_participant_set_user_data(LinphoneParticipant *participant, void *ud); + +/** + * Get the address of a conference participant. + * @param[in] participant A LinphoneParticipant object + * @return The address of the participant + */ +LINPHONE_PUBLIC const LinphoneAddress * linphone_participant_get_address (const LinphoneParticipant *participant); + +/** + * Tells whether a conference participant is an administrator of the conference. + * @param[in] participant A LinphoneParticipant object + * @return A boolean value telling whether the participant is an administrator + */ +LINPHONE_PUBLIC bool_t linphone_participant_is_admin (const LinphoneParticipant *participant); + +/** + * Give the administrator rights or remove them to a conference participant. + * @param[in] participant A LinphoneParticipant object + * @param value A boolean value telling whether the participant should be an administrator or not + */ +LINPHONE_PUBLIC void linphone_participant_set_admin (LinphoneParticipant *participant, bool_t value); + +/** + * @} + */ + +#ifdef __cplusplus + } +#endif // ifdef __cplusplus + +#endif // ifndef _C_PARTICIPANT_H_ diff --git a/include/linphone/api/c-types.h b/include/linphone/api/c-types.h index d71ba795d..288564328 100644 --- a/include/linphone/api/c-types.h +++ b/include/linphone/api/c-types.h @@ -80,6 +80,7 @@ typedef struct _LinphoneConferenceParticipantEvent LinphoneConferenceParticipant typedef struct _LinphoneEventLog LinphoneEventLog; typedef struct _LinphoneMessage LinphoneMessage; typedef struct _LinphoneMessageEvent LinphoneMessageEvent; +typedef struct _LinphoneParticipant LinphoneParticipant; // ============================================================================= // C Enums. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ed8e1602..55e15fe9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES c-wrapper/api/c-call-params.cpp c-wrapper/api/c-chat-room.cpp c-wrapper/api/c-event-log.cpp + c-wrapper/api/c-participant.cpp call/call.cpp chat/basic-chat-room.cpp chat/chat-message.cpp diff --git a/src/c-wrapper/api/c-participant.cpp b/src/c-wrapper/api/c-participant.cpp new file mode 100644 index 000000000..d4d787183 --- /dev/null +++ b/src/c-wrapper/api/c-participant.cpp @@ -0,0 +1,64 @@ +/* + * c-participant.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-participant.h" + +#include "c-wrapper/c-tools.h" + +#include "conference/participant.h" + +// ============================================================================= + +using namespace std; + +L_DECLARE_C_STRUCT_IMPL(Participant, Participant, participant, + mutable LinphoneAddress *addressCache; +); + +LinphoneParticipant *linphone_participant_ref (LinphoneParticipant *participant) { + belle_sip_object_ref(participant); + return participant; +} + +void linphone_participant_unref (LinphoneParticipant *participant) { + belle_sip_object_unref(participant); +} + +void * linphone_participant_get_user_data(const LinphoneParticipant *participant) { + return L_GET_USER_DATA_FROM_C_STRUCT(participant, Participant, Participant); +} + +void linphone_participant_set_user_data(LinphoneParticipant *participant, void *ud) { + L_SET_USER_DATA_FROM_C_STRUCT(participant, ud, Participant, Participant); +} + +const LinphoneAddress * linphone_participant_get_address (const LinphoneParticipant *participant) { + LinphonePrivate::Address addr = L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant, Participant)->getAddress(); + if (participant->addressCache) + linphone_address_unref(participant->addressCache); + participant->addressCache = linphone_address_new(addr.asString().c_str()); + return participant->addressCache; +} + +bool_t linphone_participant_is_admin (const LinphoneParticipant *participant) { + return L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant, Participant)->isAdmin(); +} + +void linphone_participant_set_admin (LinphoneParticipant *participant, bool_t value) { + L_GET_CPP_PTR_FROM_C_STRUCT(participant, Participant, Participant)->setAdmin(value); +}