Commit a4ffc297 authored by Nicolas Michon's avatar Nicolas Michon

Add chat room parameters and add new chat room creation API

Add utility C to C++ list conversion fonction

WIP ChatRoomParams

Fix tests using chatroom params

Additional check for tester account manager

Use new convenience method of HybridObject

Use const ChatRoomParams + Add isValid public API

Group chat tests ok with new API

Remove enable_basic_to_client_group_chat_room_migration param from rcfiles

Fix chat room migration tests

Add test case for group chat

Use default copy constructor for ChatRoomParams

Update documentation

Fix compilation error on gcc 4.8

Fix compilation error

Rename ChatRoomParams enums to avoid name conflit with Java wrapper

Do not export ChatRoomParams (Fix windows build)
parent 9f27a9b8
......@@ -37,6 +37,7 @@
#include "c-wrapper/c-wrapper.h"
#include "call/call.h"
#include "chat/chat-room/chat-room-params.h"
#include "chat/chat-room/basic-chat-room.h"
#include "chat/chat-room/client-group-chat-room.h"
#include "chat/chat-room/client-group-to-basic-chat-room.h"
......@@ -44,6 +45,7 @@
#include "chat/chat-room/real-time-text-chat-room.h"
#include "content/content-type.h"
#include "core/core-p.h"
#include "linphone/api/c-chat-room-params.h"
using namespace std;
......@@ -80,8 +82,8 @@ LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call){
return cr;
}
LinphoneChatRoom *linphone_core_get_chat_room (LinphoneCore *lc, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)));
LinphoneChatRoom *linphone_core_get_chat_room (LinphoneCore *lc, const LinphoneAddress *peerAddr) {
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(peerAddr)));
}
LinphoneChatRoom *linphone_core_get_chat_room_2 (
......@@ -95,14 +97,46 @@ LinphoneChatRoom *linphone_core_get_chat_room_2 (
)));
}
LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, const char *subject, bool_t fallback) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom(L_C_TO_STRING(subject), !!fallback, false));
//Deprecated
LinphoneChatRoom *linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject, bool_t fallback) {
return linphone_core_create_client_group_chat_room_2(lc, subject, fallback, FALSE);
}
LinphoneChatRoom *linphone_core_create_client_group_chat_room_2 (LinphoneCore *lc, const char *subject, bool_t fallback, bool_t encrypted) {
//Deprecated
LinphoneChatRoom *linphone_core_create_client_group_chat_room_2(LinphoneCore *lc, const char *subject, bool_t fallback, bool_t encrypted) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createClientGroupChatRoom(L_C_TO_STRING(subject), !!fallback, !!encrypted));
}
LinphoneChatRoom *linphone_core_create_chat_room(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const char *subject, const bctbx_list_t *participants) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr));
})));
}
LinphoneChatRoom *linphone_core_create_chat_room_2(LinphoneCore *lc, const LinphoneChatRoomParams *params, const char *subject, const bctbx_list_t *participants) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr));
})));
}
LinphoneChatRoom *linphone_core_create_chat_room_3(LinphoneCore *lc, const char *subject, const bctbx_list_t *participants) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(L_C_TO_STRING(subject), L_GET_CPP_LIST_FROM_C_LIST_2(participants, LinphoneAddress *, LinphonePrivate::IdentityAddress, [] (LinphoneAddress *addr) {
return LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(addr));
})));
}
LinphoneChatRoom *linphone_core_create_chat_room_4(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const LinphoneAddress *participant) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::ChatRoomParams::toSharedPtr(params), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(localAddr)), LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant))));
}
LinphoneChatRoom *linphone_core_create_chat_room_5(LinphoneCore *lc, const LinphoneAddress *participant) {
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(lc)->createChatRoom(LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant))));
}
LinphoneChatRoomParams *linphone_core_create_default_chat_room_params(LinphoneCore *lc) {
return LinphonePrivate::ChatRoomParams::createCObject();
}
LinphoneChatRoom *_linphone_core_create_server_group_chat_room (LinphoneCore *lc, LinphonePrivate::SalCallOp *op) {
return _linphone_server_group_chat_room_new(lc, op);
}
......@@ -134,7 +168,7 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room (
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findOneToOneChatRoom(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(local_addr)),
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant_addr)),
false)
false, false)
);
}
......@@ -147,7 +181,7 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room_2 (
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findOneToOneChatRoom(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(local_addr)),
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant_addr)),
!!encrypted)
false, !!encrypted)
);
}
......@@ -155,9 +189,9 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, LinphonePrivate:
LinphoneReason reason = LinphoneReasonNotAcceptable;
std::string peerAddress;
std::string localAddress;
const char *session_mode = sal_custom_header_find(op->getRecvCustomHeaders(), "Session-mode");
if (linphone_core_conference_server_enabled(lc)) {
localAddress = peerAddress = op->getTo();
} else {
......@@ -174,15 +208,15 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, LinphonePrivate:
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
else if (!linphone_core_conference_server_enabled(lc)) {
/* Client mode but check that it is really for basic chatroom before creating it.*/
if (session_mode && strcasecmp(session_mode, "true") == 0){
if (session_mode && strcasecmp(session_mode, "true") == 0) {
lError() << "Message is received in the context of a client chatroom for which we have no context.";
reason = LinphoneReasonNotAcceptable;
}else{
} else {
chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(conferenceId);
if (chatRoom)
reason = L_GET_PRIVATE(chatRoom)->onSipMessageReceived(op, sal_msg);
}
}else{
} else {
/* Server mode but chatroom not found. */
reason = LinphoneReasonNotFound;
}
......
Android portability
===============
===================
Video
-----
......@@ -15,4 +15,4 @@ Here's the complete code:
TextureView mCaptureView = view.findViewById(R.id.videoCaptureSurface);
mCore.setNativeVideoWindowId(mVideoView);
mCore.setNativePreviewWindowId(mCaptureView);
\ No newline at end of file
mCore.setNativePreviewWindowId(mCaptureView);
Chat room and messaging
=======================
There are different types of chat rooms. Basic chat rooms are simple chat rooms between two participants, they do not require a conference server and are considered as one-to-one chat rooms. Group chat rooms allow more than one peer user and require a conference server. Group chat rooms can also be considered as one-to-one if they have only one peer participant at the time of their creation and if the parameter "enable_one_to_one_chat_room" is set to true, otherwise a basic chat room will be created instead. Secured chat rooms are group chat rooms where LIME X3DH end-to-end encryption is enabled, they can be either group chat rooms or one-to-one chat rooms but not basic chat rooms.
There are different types of chat rooms. Basic chat rooms are simple chat rooms between two participants, they do not require a conference server and are considered as one-to-one chat rooms.
Group chat rooms allow more than one peer user and require a conference server.
Group chat rooms can also be considered as one-to-one if they have only one peer participant at the time of their creation and if the parameter "enable_one_to_one_chat_room" is set to true, otherwise a basic chat room will be created instead.
Secured chat rooms are group chat rooms where LIME X3DH end-to-end encryption is enabled, they can be either group chat rooms or one-to-one chat rooms but not basic chat rooms.
Chat rooms parameters
---------------------
Chat rooms creation and behavior can be controlled with the use of :cpp:type:`LinphoneChatRoomParams`.
.. code-block:: c
LinphoneChatRoomParams *params = linphone_core_create_default_chat_room_params(linphoneCore);
Default parameters will create an un-encrypted basic chat room (See next section).
You can change parameters prior to chat room creation. Possible types are :cpp:enumerator:`LinphoneChatRoomBackendBasic` and :cpp:enumerator:`LinphoneChatRoomBackendFlexisipChat`
.. code-block:: c
//Change chat room type
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendBasic);
linphone_chat_room_params_set_backend(params, LinphoneChatRoomBackendFlexisipChat);
//Enable encryption
linphone_chat_room_params_enable_encryption(params, TRUE);
//Enable group chat (valid only with LinphoneChatRoomFlexisipChat)
linphone_chat_room_params_enable_group(params, TRUE);
//Enable real time text (valid only with LinphoneChatRoomBasic)
linphone_chat_room_params_enable_rtt(params, TRUE);
//Check that parameters are valid
assert(linphone_chat_room_params_is_valid(params));
.. _chat-room-creation:
Chat room creation
------------------
Chat rooms can be created with :cpp:func:`linphone_core_create_chat_room <linphone_core_create_chat_room>`.
The full list of parameters includes a :cpp:type:`LinphoneChatRoomParams` object, a subject, a local sip address to use and a list of participants.
Convenience methods are provided to ease chat room creation by passing only minimum required parameters.
Non-provided parameters will be created and default values will be used.
Functions accepting a list of participants with a size greater than 1 will create a group chat room (unless LinphoneChatRoomBackendBasic is used in parameters, in which case the chat room creation will fail).
* :cpp:func:`linphone_core_create_chat_room_2 <linphone_core_create_chat_room_2>`
* :cpp:func:`linphone_core_create_chat_room_3 <linphone_core_create_chat_room_3>`
* :cpp:func:`linphone_core_create_chat_room_4 <linphone_core_create_chat_room_4>`
* :cpp:func:`linphone_core_create_chat_room_5 <linphone_core_create_chat_room_5>`
NULL will be returned if the chat room creation failed.
Basic chat rooms
----------------
Basic chat rooms can be created with :cpp:func:`linphone_core_get_chat_room <linphone_core_get_chat_room>` using a peer sip uri.
See :ref:`chat-room-creation` for creating basic chat rooms.
.. code-block:: c
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(linphoneCore, "sip:joe@sip.linphone.org");
LinphoneChatRoomParams *params = linphone_core_create_default_chat_room_params(linphoneCore);
LinphoneChatRoom* chat_room = linphone_core_create_chat_room_2(linphoneCore, params, "Subject", "sip:joe@sip.linphone.org");
//Or more simply:
LinphoneChatRoom* chat_room = linphone_core_create_chat_room_5(linphoneCore, "sip:joe@sip.linphone.org");
Once created, messages are sent using :cpp:func:`linphone_chat_room_send_message`.
......@@ -29,19 +86,16 @@ Incoming message are received through callbacks which can be set after the chat
Group chat rooms
----------------
Group chat rooms can be created with :cpp:func:`linphone_core_create_client_group_chat_room <linphone_core_create_client_group_chat_room>`. The third argument is a "fallback" boolean which is taken into account when creating a group chat room with only one peer which does not support group chat. In this case and if this argument is true, a basic chat room will be created instead of not being able to create a group chat room.
.. code-block:: c
LinphoneChatRoom *chatRoom = linphone_core_create_client_group_chat_room(linphoneCore, "Colleagues", FALSE);
See :ref:`chat-room-creation` for creating group chat rooms.
A "fallback" mecanism exists when creating a group chat room with only one peer which does not support group chat. A basic chat room will be created instead. This mecanism is disabled by default and not accessible through normal creation functions. If you want to enable it, use :cpp:func:`linphone_core_create_client_group_chat_room` with `TRUE` as third argument to create the chat room.
Participants can be invited to the chat room using :cpp:func:`linphone_chat_room_add_participant <linphone_chat_room_add_participant>` or :cpp:func:`linphone_chat_room_add_participants <linphone_chat_room_add_participants>`. Participants can be removed using :cpp:func:`linphone_chat_room_remove_participant <linphone_chat_room_remove_participant>`.
.. code-block:: c
linphone_chat_room_add_participants(chatRoom, participantsAddressList);
linphone_chat_room_remove_participant(marieChatRoom, laureParticipant); // remove Laure from Marie's chat room
LinphoneChatRoomParams *params; //Create parameters
LinphoneChatRoom *chatRoom = linphone_core_create_chat_room(linphoneCore, params, "Subject", participantsAddressList);
linphone_chat_room_remove_participant(chatRoom, laureParticipant); // remove Laure from chat room
The list of participants of a chat room can be obtained with :cpp:func:`linphone_chat_room_get_participants <linphone_chat_room_get_participants>`. Note that Marie is not considered as a participant in Marie's chat rooms, one's own participant can be obtained with :cpp:func:`linphone_chat_room_get_me <linphone_chat_room_get_me>`.
......@@ -70,11 +124,14 @@ Concerning admins, events, history and instant message disposition notifications
Secured chat rooms
------------------
LIME X3DH end-to-end encryption for instant messages are enabled in secured chat rooms, also known as encrypted chat rooms, which can be created with :cpp:func:`linphone_core_create_client_group_chat_room_2 <linphone_core_create_client_group_chat_room_2>`. Secured chat rooms and regular chat rooms can coexist, even if they have exactly the same participants.
LIME X3DH end-to-end encryption for instant messages are enabled in secured chat rooms, also known as encrypted chat rooms.
Secured chat rooms and regular chat rooms can coexist, even if they have exactly the same participants.
.. code-block:: c
LinphoneChatRoom *securedChatRoom = linphone_core_create_client_group_chat_room_2(linphoneCore, "Secured Conversation", FALSE, TRUE);
LinphoneChatRoomParams *params; //Create parameters
linphone_chat_room_params_enable_encryption(params, TRUE); //Enable encryption
LinphoneChatRoom *securedChatRoom = linphone_core_create_chat_room_2(linphoneCore, params, "Secured Conversation", participants);
Encrypted chat rooms only allow encrypted messages and files to transit (except for error IMDNs in case a message was incorrectly decrypted). Encrypted chat rooms have a concept of security level based on LIME X3DH trust level of each participant device in the conference. The current security level of a chat room can be obtained with :cpp:func:`linphone_chat_room_get_security_level <linphone_chat_room_get_security_level>`.
......
......@@ -38,7 +38,7 @@ This pseudo code demonstrates basic registration operations:
linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/
linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/
Registration sate call back:
Registration state call back:
.. code-block:: c
......
......@@ -77,7 +77,7 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat root*/
chat_room = linphone_core_get_chat_room_from_uri(lc,dest_friend);
chat_room = linphone_core_create_chat_room(lc, dest_friend);
linphone_chat_room_send_message(chat_room,"Hello world"); /*sending message*/
......
......@@ -741,7 +741,7 @@ bool_t linphone_config_get_skip_flag_for_section(const LpConfig *lpconfig, const
}
void linphone_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value){
LpItem *item;
LpItem *item;
LpSection *sec=linphone_config_find_section(lpconfig,section);
if (sec!=NULL){
item=lp_section_find_item(sec,key);
......
......@@ -84,6 +84,7 @@ set(C_API_HEADER_FILES
c-chat-message.h
c-chat-room-cbs.h
c-chat-room.h
c-chat-room-params.h
c-content.h
c-dial-plan.h
c-event-log.h
......
/*
* c-chat-room-params.h
* Copyright (C) 2010-2019 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_C_CHAT_ROOM_PARAMS_H_
#define _L_C_CHAT_ROOM_PARAMS_H_
#include "linphone/api/c-types.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup chatroom
* @{
*/
/**
* Returns new chat room parameters.
* @return LinphoneChatRoomParams
**/
LINPHONE_PUBLIC LinphoneChatRoomParams *linphone_chat_room_params_new(void);
/**
* Acquire a reference to the chat room parameters.
* @param[in] params The chat room parameters.
* @return The same chat room parameters.
**/
LINPHONE_PUBLIC LinphoneChatRoomParams *linphone_chat_room_params_ref(LinphoneChatRoomParams *params);
/**
* Release reference to the chat room params.
* @param[in] params The chat room params.
**/
LINPHONE_PUBLIC void linphone_chat_room_params_unref(LinphoneChatRoomParams *params);
/**
* @param[in] params The chat room params.
* @return TRUE if the given parameters are valid, FALSE otherwise
**/
LINPHONE_PUBLIC bool_t linphone_chat_room_params_is_valid(const LinphoneChatRoomParams *params);
/**
* Get the backend implementation of the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @return LinphoneChatRoomBackend
**/
LINPHONE_PUBLIC LinphoneChatRoomBackend linphone_chat_room_params_get_backend(const LinphoneChatRoomParams *params);
/**
* Get the encryption implementation of the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @return LinphoneChatRoomEncryptionBackend
**/
LINPHONE_PUBLIC LinphoneChatRoomEncryptionBackend linphone_chat_room_params_get_encryption_backend(const LinphoneChatRoomParams *params);
/**
* Get the group chat status of the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @return TRUE if group chat is enabled, FALSE if one-to-one
**/
LINPHONE_PUBLIC bool_t linphone_chat_room_params_group_enabled(const LinphoneChatRoomParams *params);
/**
* Get the encryption status of the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @return TRUE if encryption is enabled, FALSE otherwise
**/
LINPHONE_PUBLIC bool_t linphone_chat_room_params_encryption_enabled(const LinphoneChatRoomParams *params);
/**
* Get the real time text status of the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @return TRUE if real time text is enabled, FALSE otherwise
**/
LINPHONE_PUBLIC bool_t linphone_chat_room_params_rtt_enabled(const LinphoneChatRoomParams *params);
/**
* Set the backend implementation of these chat room parameters.
* @param[in] params The chat room params.
* @param[in] backend The #LinphoneChatRoomBackend enum value
**/
LINPHONE_PUBLIC void linphone_chat_room_params_set_backend(LinphoneChatRoomParams *params, LinphoneChatRoomBackend backend);
/**
* Set the encryption backend implementation of these chat room parameters.
* @param[in] params The chat room params.
* @param[in] backend The #LinphoneChatRoomEncryptionBackend enum value
**/
LINPHONE_PUBLIC void linphone_chat_room_params_set_encryption_backend(LinphoneChatRoomParams *params, LinphoneChatRoomEncryptionBackend backend);
/**
* Enables or disables group chat for the chat room associated with the given parameters.
* @param[in] cr The chat room params.
* @param[in] group. TRUE to enable group chat, FALSE to disable (resulting in one-to-one chat room)
**/
LINPHONE_PUBLIC void linphone_chat_room_params_enable_group(LinphoneChatRoomParams *params, bool_t group);
/**
* Enables or disables encryption for the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @param[in] encrypted. TRUE to enable encryption, FALSE to disable.
**/
LINPHONE_PUBLIC void linphone_chat_room_params_enable_encryption(LinphoneChatRoomParams *params, bool_t encrypted);
/**
* Enables or disables real time text for the chat room associated with the given parameters.
* @param[in] params The chat room params.
* @param[in] rtt. TRUE to enable real time text, FALSE to disable.
**/
LINPHONE_PUBLIC void linphone_chat_room_params_enable_rtt(LinphoneChatRoomParams *params, bool_t rtt);
/**
* @}
*/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _L_C_CHAT_ROOM_PARAMS_H_
......@@ -498,6 +498,15 @@ LINPHONE_PUBLIC void linphone_chat_room_notify_participant_device_registration(L
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneCore* linphone_chat_room_get_lc(const LinphoneChatRoom *cr);
/**
* Returns current parameters associated with the chat room.
* This is typically the parameters passed at chat room creation to linphone_core_create_chat_room() or some default
* parameters if no #LinphoneChatRoomParams was explicitely passed during chat room creation.
* @param cr the #LinphoneChatRoom object
* @return the chat room current parameters.
**/
LINPHONE_PUBLIC const LinphoneChatRoomParams *linphone_chat_room_get_current_params(const LinphoneChatRoom *cr);
/**
* @}
*/
......
......@@ -120,6 +120,13 @@ typedef struct _LinphoneChatMessageCbs LinphoneChatMessageCbs;
*/
typedef struct _LinphoneChatRoom LinphoneChatRoom;
/**
* An object to handle a chat room parameters.
* Can be created with linphone_core_get_default_chat_room_params() or linphone_chat_room_params_new().
* @ingroup chatroom
*/
typedef struct _LinphoneChatRoomParams LinphoneChatRoomParams;
/**
* A mask of #LinphoneChatRoomCapabilities
* @ingroup chatroom
......@@ -250,6 +257,18 @@ L_DECLARE_C_ENUM(ChatMessageState, L_ENUM_VALUES_CHAT_MESSAGE_STATE);
*/
L_DECLARE_C_ENUM_FIXED_VALUES(ChatRoomCapabilities, L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES);
/**
* #LinphoneChatRoomBackend is used to indicate the backend implementation of a chat room.
* @ingroup chatroom
*/
L_DECLARE_C_ENUM_FIXED_VALUES(ChatRoomBackend, L_ENUM_VALUES_CHAT_ROOM_BACKEND);
/**
* #LinphoneChatRoomEncryptionBackend is used to indicate the encryption engine used by a chat room.
* @ingroup chatroom
*/
L_DECLARE_C_ENUM_FIXED_VALUES(ChatRoomEncryptionBackend, L_ENUM_VALUES_CHAT_ROOM_ENCRYPTION_BACKEND);
/**
* TODO move to encryption engine object when available
* #LinphoneChatRoomSecurityLevel is used to indicate the encryption security level of a chat room.
......
......@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-message.h"
#include "linphone/api/c-chat-message-cbs.h"
#include "linphone/api/c-chat-room-params.h"
#include "linphone/api/c-chat-room.h"
#include "linphone/api/c-chat-room-cbs.h"
......@@ -46,7 +47,12 @@ extern "C" {
**/
LINPHONE_PUBLIC const bctbx_list_t* linphone_core_get_chat_rooms(LinphoneCore *lc);
/**
* Creates and returns the default chat room parameters.
* @param[in] lc #LinphoneCore object
* @return LinphoneChatRoomParams
**/
LINPHONE_PUBLIC LinphoneChatRoomParams *linphone_core_create_default_chat_room_params(LinphoneCore *lc);
/**
* @}
......
......@@ -5280,7 +5280,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC const char *linphone_core_get_chat_database_
* @param[in] fallback Boolean value telling whether we should plan on being able to fallback to a basic chat room if the client-side group chat room creation fails
* @return The newly created client-side group chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject, bool_t fallback);
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const char *subject, bool_t fallback);
/**
* Create a client-side group chat room. When calling this function the chat room is only created
......@@ -5292,7 +5292,57 @@ LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(L
* @param[in] encrypted Boolean value telling whether we should apply encryption or not on chat messages sent and received on this room.
* @return The newly created client-side group chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_client_group_chat_room_2 (LinphoneCore *lc, const char *subject, bool_t fallback, bool_t encrypted);
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneChatRoom *linphone_core_create_client_group_chat_room_2(LinphoneCore *lc, const char *subject, bool_t fallback, bool_t encrypted);
/**
* Create a chat room.
*
* @param[in] lc A #LinphoneCore object
* @param[in] params The chat room creation parameters #LinphoneChatRoomParams
* @param[in] localAddr #LinphoneAddress representing the local proxy configuration to use for the chat room creation
* @param[in] subject The subject of the group chat room
* @param[in] participants \bctbx_list{LinphoneAddress} The initial list of participants of the chat room
* @return The newly created chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const char *subject, const bctbx_list_t *participants);
/**
* Create a chat room.
*
* @param[in] lc A #LinphoneCore object
* @param[in] params The chat room creation parameters #LinphoneChatRoomParams
* @param[in] subject The subject of the group chat room
* @param[in] participants \bctbx_list{LinphoneAddress} The initial list of participants of the chat room
* @return The newly created chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room_2(LinphoneCore *lc, const LinphoneChatRoomParams *params, const char *subject, const bctbx_list_t *participants);
/**
*
* @param[in] lc A #LinphoneCore object
* @param[in] subject The subject of the group chat room
* @param[in] participants \bctbx_list{LinphoneAddress} The initial list of participants of the chat room
* @return The newly created chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room_3(LinphoneCore *lc, const char *subject, const bctbx_list_t *participants);
/**
*
* @param[in] lc A #LinphoneCore object
* @param[in] params The chat room creation parameters #LinphoneChatRoomParams
* @param[in] localAddr #LinphoneAddress representing the local proxy configuration to use for the chat room creation
* @param[in] participant #LinphoneAddress representing the initial participant to add to the chat room
* @return The newly created chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room_4(LinphoneCore *lc, const LinphoneChatRoomParams *params, const LinphoneAddress *localAddr, const LinphoneAddress *participant);
/**
*
* @param[in] lc A #LinphoneCore object
* @param[in] participant #LinphoneAddress representing the initial participant to add to the chat room
* @return The newly created chat room.
*/
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_create_chat_room_5(LinphoneCore *lc, const LinphoneAddress *participant);
/**
* Get a basic chat room whose peer is the supplied address. If it does not exist yet, it will be created.
......
......@@ -33,7 +33,9 @@
F(TerminationFailed /**< The chat room termination failed */) \
F(Deleted /**< Chat room was deleted on the server */)
//To be deprecated
#define L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES(F) \
F(None /**< No capabilities. */, 0) \
F(Basic /**< No server. It&apos;s a direct communication */, 1 << 0) \
F(RealTimeText /**< Supports RTT */, 1 << 1) \
F(Conference /**< Use server (supports group chat) */, 1 << 2) \
......@@ -42,4 +44,12 @@
F(OneToOne /**< A communication between two participants (can be Basic or Conference) */, 1 << 5) \
F(Encrypted /**< Chat room is encrypted */, 1 << 6)
#define L_ENUM_VALUES_CHAT_ROOM_BACKEND(F) \
F(Basic /**< Basic (client-to-client) chat room. */, 1 << 0) \
F(FlexisipChat /**< Server-based chat room. */, 1 << 1)
#define L_ENUM_VALUES_CHAT_ROOM_ENCRYPTION_BACKEND(F) \
F(None /**< No encryption. */, 0) \
F(Lime /**< Lime x3dh encryption. */, 1 << 0)
#endif // ifndef _L_CHAT_ROOM_ENUMS_H_
......@@ -85,6 +85,15 @@ struct IsDefinedEnum {
enum { value = sizeof(getEnumValueAsString(std::declval<T>())) == sizeof(const char *) };
};
//Explicit conversion from enum type to underlying type
template<typename T>
constexpr auto to_integral(T e) -> typename std::underlying_type<T>::type
{
return static_cast<typename std::underlying_type<T>::type>(e);
}
#define L_GET_ENUM_VALUE(VALUE) to_integral(VALUE)
#endif
#define L_C_ENUM_PREFIX Linphone
......
......@@ -92,6 +92,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
chat/chat-message/is-composing-message.h
chat/chat-message/notification-message-p.h
chat/chat-message/notification-message.h
chat/chat-room/chat-room-params.h
chat/chat-room/abstract-chat-room-p.h
chat/chat-room/abstract-chat-room.h
chat/chat-room/basic-chat-room-p.h
......@@ -241,6 +242,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-call.cpp
c-wrapper/api/c-chat-message-cbs.cpp
c-wrapper/api/c-chat-message.cpp
c-wrapper/api/c-chat-room-params.cpp
c-wrapper/api/c-chat-room-cbs.cpp
c-wrapper/api/c-chat-room.cpp
c-wrapper/api/c-content.cpp
......@@ -272,6 +274,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
chat/chat-room/proxy-chat-room.cpp
chat/chat-room/real-time-text-chat-room.cpp
chat/chat-room/server-group-chat-room.cpp
chat/chat-room/chat-room-params.cpp
chat/cpim/header/cpim-core-headers.cpp
chat/cpim/header/cpim-generic-header.cpp
chat/cpim/header/cpim-header.cpp
......
/*
* c-chat-room-params.cpp
* Copyright (C) 2010-2019 Belledonne Communications SARL
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/api/c-chat-room-params.h"
#include "chat/chat-room/chat-room-params.h"
// =============================================================================
using namespace LinphonePrivate;
// =============================================================================
LinphoneChatRoomParams *linphone_chat_room_params_new(void) {
return ChatRoomParams::createCObject();
}
LinphoneChatRoomParams *linphone_chat_room_params_ref(LinphoneChatRoomParams *params) {
ChatRoomParams::toCpp(params)->ref();
return params;
}
void linphone_chat_room_params_unref(LinphoneChatRoomParams *params) {
ChatRoomParams::toCpp(params)->unref();
}
bool_t linphone_chat_room_params_is_valid(const LinphoneChatRoomParams *params) {
return ChatRoomParams::toCpp(params)->isValid();
}
LinphoneChatRoomBackend linphone_chat_room_params_get_backend(const LinphoneChatRoomParams *params) {
return static_cast<LinphoneChatRoomBackend>(ChatRoomParams::toCpp(params)->getChatRoomBackend());
}
LinphoneChatRoomEncryptionBackend linphone_chat_room_params_get_encryption_backend(const LinphoneChatRoomParams *params) {
return static_cast<LinphoneChatRoomEncryptionBackend>(ChatRoomParams::toCpp(params)->getChatRoomEncryptionBackend());
}
bool_t linphone_chat_room_params_group_enabled(const LinphoneChatRoomParams *params) {
return ChatRoomParams::toCpp(params)->isGroup();
}
bool_t linphone_chat_room_params_encryption_enabled(const LinphoneChatRoomParams *params) {
return ChatRoomParams::toCpp(params)->isEncrypted();
}
bool_t linphone_chat_room_params_rtt_enabled(const LinphoneChatRoomParams *params) {
return ChatRoomParams::toCpp(params)->isRealTimeText();
}
void linphone_chat_room_params_set_backend(LinphoneChatRoomParams *params, LinphoneChatRoomBackend backend) {
ChatRoomParams::toCpp(params)->setChatRoomBackend(static_cast<ChatRoomParams::ChatRoomBackend>(backend));
}
void linphone_chat_room_params_set_encryption_backend(LinphoneChatRoomParams *params, LinphoneChatRoomEncryptionBackend backend) {
ChatRoomParams::toCpp(params)->setChatRoomEncryptionBackend(static_cast<ChatRoomParams::ChatRoomEncryptionBackend>(backend));
}
void linphone_chat_room_params_enable_group(LinphoneChatRoomParams *params, bool_t group) {
ChatRoomParams::toCpp(params)->setGroup(!!group);
}
void linphone_chat_room_params_enable_encryption(LinphoneChatRoomParams *params, bool_t encrypted) {
ChatRoomParams::toCpp(params)->setEncrypted(!!encrypted);
}