Commit 19f780f5 authored by Benjamin REIS's avatar Benjamin REIS

Feature/notify device name in conference

parent bebd0911
......@@ -234,6 +234,14 @@ LinphoneAddress *linphone_factory_create_address(const LinphoneFactory *factory,
return linphone_address_new(addr);
}
LinphoneParticipantDeviceIdentity *linphone_factory_create_participant_device_identity(
const LinphoneFactory *factory,
const LinphoneAddress *address,
const char *name
) {
return linphone_participant_device_identity_new(address, name);
}
LinphoneAuthInfo *linphone_factory_create_auth_info(const LinphoneFactory *factory, const char *username, const char *userid, const char *passwd, const char *ha1, const char *realm, const char *domain) {
return linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
}
......
......@@ -90,6 +90,7 @@ set(C_API_HEADER_FILES
c-magic-search.h
c-participant.h
c-participant-device.h
c-participant-device-identity.h
c-participant-imdn-state.h
c-search-result.h
c-types.h
......@@ -138,7 +139,7 @@ set(LINPHONE_HEADER_FILES ${ROOT_HEADER_FILES} ${C_API_HEADER_FILES} ${ENUMS_HEA
set(LINPHONE_HEADER_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}" PARENT_SCOPE)
# ------------------------------------------------------------------------------
if (IOS AND ENABLE_SHARED)
if (IOS AND ENABLE_SHARED)
#cmake 3.10 seems not able to handle subdirectories for PUBLIC_HEADER. My be rework in the futur
set(DEST_ROOT_DIRECTORY "${CMAKE_INSTALL_PREFIX}/Frameworks/linphone.framework/Headers")
else()
......
......@@ -38,6 +38,7 @@
#include "linphone/api/c-participant-imdn-state.h"
#include "linphone/api/c-participant.h"
#include "linphone/api/c-participant-device.h"
#include "linphone/api/c-participant-device-identity.h"
#include "linphone/api/c-search-result.h"
#include "linphone/api/c-types.h"
......
......@@ -477,9 +477,9 @@ LINPHONE_PUBLIC void linphone_chat_room_set_conference_address (LinphoneChatRoom
* #LinphoneChatRoomCbsParticipantDeviceFetchRequestedCb callback and only there.
* @param[in] cr A #LinphoneChatRoom object
* @param[in] partAddr The participant address
* @param[in] partDevices \bctbx_list{LinphoneAddress} list of the participant devices to be used by the group chat room
* @param[in] deviceIdentities \bctbx_list{LinphoneParticipantDeviceIdentity} list of the participant devices to be used by the group chat room
*/
LINPHONE_PUBLIC void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *partDevices);
LINPHONE_PUBLIC void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *deviceIdentities);
/**
* Set the participant device. This function needs to be called from the
......
/*
* c-participant-device-identity.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_C_PARTICIPANT_DEVICE_IDENTiTY_H_
#define _L_C_PARTICIPANT_DEVICE_IDENTiTY_H_
#include "linphone/api/c-types.h"
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/**
* @addtogroup misc
* @{
*/
/**
* Constructs a #LinphoneParticipantDeviceIdentity object.
**/
LINPHONE_PUBLIC LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_new (const LinphoneAddress *address, const char *name);
/**
* Clones a #LinphoneParticipantDeviceIdentity object.
**/
LINPHONE_PUBLIC LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_clone (const LinphoneParticipantDeviceIdentity *deviceIdentity);
/**
* Increment reference count of #LinphoneParticipantDeviceIdentity object.
**/
LINPHONE_PUBLIC LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_ref (LinphoneParticipantDeviceIdentity *deviceIdentity);
/**
* Decrement reference count of #LinphoneParticipantDeviceIdentity object. When dropped to zero, memory is freed.
**/
LINPHONE_PUBLIC void linphone_participant_device_identity_unref (LinphoneParticipantDeviceIdentity *deviceIdentity);
/**
* @}
*/
#ifdef __cplusplus
}
#endif // ifdef __cplusplus
#endif // ifndef _L_C_PARTICIPANT_DEVICE_IDENTiTY_H_
......@@ -63,7 +63,7 @@ LINPHONE_PUBLIC void linphone_participant_device_set_user_data(LinphoneParticipa
* @return The address of the participant's device
*/
LINPHONE_PUBLIC const LinphoneAddress * linphone_participant_device_get_address (const LinphoneParticipantDevice *participant_device);
/**
* Get the security level of a participant's device.
* @param[in] participant_device A #LinphoneParticipantDevice object
......@@ -71,6 +71,13 @@ LINPHONE_PUBLIC const LinphoneAddress * linphone_participant_device_get_address
*/
LINPHONE_PUBLIC LinphoneChatRoomSecurityLevel linphone_participant_device_get_security_level (const LinphoneParticipantDevice *participant_device);
/**
* Return the name of the device or NULL.
* @param[in] participant_device A #LinphoneParticipantDevice object
* @return the name of the device or NULL
*/
LINPHONE_PUBLIC const char *linphone_participant_device_get_name (const LinphoneParticipantDevice *LinphoneParticipantDevice);
/**
* @}
*/
......
......@@ -86,11 +86,12 @@ LINPHONE_PUBLIC LinphoneChatRoomSecurityLevel linphone_participant_get_security_
LINPHONE_PUBLIC bctbx_list_t *linphone_participant_get_devices (const LinphoneParticipant *participant);
/**
* Gets the list of devices from a chat room's participant.
* Find a device in the list of devices from a chat room's participant.
* @param[in] participant A #LinphoneParticipant object
* @return \bctbx_list{LinphoneParticipantDevice}
* @param[in] address A #LinphoneAddress object
* @return a #LinphoneParticipantDevice or NULL if not found
*/
LINPHONE_PUBLIC bctbx_list_t *linphone_participant_get_devices (const LinphoneParticipant *participant);
LINPHONE_PUBLIC LinphoneParticipantDevice *linphone_participant_find_device (const LinphoneParticipant *participant, const LinphoneAddress *address);
/**
* @}
......
......@@ -180,6 +180,11 @@ typedef struct _LinphoneParticipantImdnState LinphoneParticipantImdnState;
*/
typedef struct _LinphoneParticipantDevice LinphoneParticipantDevice;
/**
* @ingroup misc
*/
typedef struct _LinphoneParticipantDeviceIdentity LinphoneParticipantDeviceIdentity;
/**
* The LinphoneSearchResult object represents a result of a search
* @ingroup misc
......
......@@ -200,6 +200,19 @@ LINPHONE_PUBLIC LinphoneCoreCbs *linphone_factory_create_core_cbs(const Linphone
*/
LINPHONE_PUBLIC LinphoneAddress *linphone_factory_create_address(const LinphoneFactory *factory, const char *addr);
/**
* Create a #LinphoneParticipantDeviceIdentity object.
* @param factory The #LinphoneFactory singleton.
* @param address #LinphoneAddress object.
* @param name the name given to the device.
* @return A new #LinphoneParticipantDeviceIdentity.
*/
LINPHONE_PUBLIC LinphoneParticipantDeviceIdentity *linphone_factory_create_participant_device_identity(
const LinphoneFactory *factory,
const LinphoneAddress *address,
const char *name
);
/**
* Creates a #LinphoneAuthInfo object.
* The object can be created empty, that is with all arguments set to NULL.
......
......@@ -250,6 +250,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-magic-search.cpp
c-wrapper/api/c-participant.cpp
c-wrapper/api/c-participant-device.cpp
c-wrapper/api/c-participant-device-identity.cpp
c-wrapper/api/c-participant-imdn-state.cpp
c-wrapper/api/c-participant.cpp
c-wrapper/api/c-search-result.cpp
......
......@@ -382,15 +382,12 @@ void linphone_chat_room_set_conference_address (LinphoneChatRoom *cr, const Linp
bctbx_free(addrStr);
}
void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *partDevices) {
void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *deviceIdentities) {
char *addrStr = linphone_address_as_string(partAddr);
list<LinphonePrivate::Address> lDevices = L_GET_RESOLVED_CPP_LIST_FROM_C_LIST(partDevices, Address);
list<LinphonePrivate::IdentityAddress> lIdentAddr;
for (const auto &addr : lDevices)
lIdentAddr.push_back(LinphonePrivate::IdentityAddress(addr));
list<LinphonePrivate::ParticipantDeviceIdentity> lDevicesIdentities = L_GET_RESOLVED_CPP_LIST_FROM_C_LIST(deviceIdentities, ParticipantDeviceIdentity);
LinphonePrivate::ServerGroupChatRoomPrivate *sgcr = dynamic_cast<LinphonePrivate::ServerGroupChatRoomPrivate *>(L_GET_PRIVATE_FROM_C_OBJECT(cr));
if (sgcr)
sgcr->setParticipantDevices(LinphonePrivate::IdentityAddress(addrStr), lIdentAddr);
sgcr->setParticipantDevices(LinphonePrivate::IdentityAddress(addrStr), lDevicesIdentities);
bctbx_free(addrStr);
}
......
/*
* c-address.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-room/server-group-chat-room-p.h"
#include "c-wrapper/c-wrapper.h"
// =============================================================================
L_DECLARE_C_CLONABLE_OBJECT_IMPL(ParticipantDeviceIdentity);
using namespace std;
// =============================================================================
LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_new (const LinphoneAddress *address, const char *name) {
LinphonePrivate::ParticipantDeviceIdentity *cppPtr = new LinphonePrivate::ParticipantDeviceIdentity(
*L_GET_CPP_PTR_FROM_C_OBJECT(address),
L_C_TO_STRING(name)
);
LinphoneParticipantDeviceIdentity *object = L_INIT(ParticipantDeviceIdentity);
L_SET_CPP_PTR_FROM_C_OBJECT(object, cppPtr);
return object;
}
LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_clone (const LinphoneParticipantDeviceIdentity *deviceIdentity) {
return reinterpret_cast<LinphoneParticipantDeviceIdentity *>(belle_sip_object_clone(BELLE_SIP_OBJECT(deviceIdentity)));
}
LinphoneParticipantDeviceIdentity *linphone_participant_device_identity_ref (LinphoneParticipantDeviceIdentity *deviceIdentity) {
belle_sip_object_ref(deviceIdentity);
return deviceIdentity;
}
void linphone_participant_device_identity_unref (LinphoneParticipantDeviceIdentity *deviceIdentity) {
belle_sip_object_unref(deviceIdentity);
}
......@@ -55,6 +55,11 @@ const LinphoneAddress *linphone_participant_device_get_address(const LinphonePar
participant_device->addressCache = linphone_address_new(addr.asString().c_str());
return participant_device->addressCache;
}
LinphoneChatRoomSecurityLevel linphone_participant_device_get_security_level (const LinphoneParticipantDevice *participant_device) {
return (LinphoneChatRoomSecurityLevel)L_GET_CPP_PTR_FROM_C_OBJECT(participant_device)->getSecurityLevel();
return (LinphoneChatRoomSecurityLevel)L_GET_CPP_PTR_FROM_C_OBJECT(participant_device)->getSecurityLevel();
}
const char *linphone_participant_device_get_name (const LinphoneParticipantDevice *participant_device) {
return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(participant_device)->getName());
}
......@@ -64,6 +64,14 @@ bool_t linphone_participant_is_admin (const LinphoneParticipant *participant) {
LinphoneChatRoomSecurityLevel linphone_participant_get_security_level (const LinphoneParticipant *participant) {
return (LinphoneChatRoomSecurityLevel)L_GET_CPP_PTR_FROM_C_OBJECT(participant)->getSecurityLevel();
}
bctbx_list_t *linphone_participant_get_devices (const LinphoneParticipant *participant) {
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_PRIVATE_FROM_C_OBJECT(participant)->getDevices());
}
LinphoneParticipantDevice *linphone_participant_find_device (const LinphoneParticipant *participant, const LinphoneAddress *address) {
char *addrStr = linphone_address_as_string(address);
LinphonePrivate::Address deviceAddress(addrStr);
bctbx_free(addrStr);
return L_GET_C_BACK_PTR(L_GET_PRIVATE_FROM_C_OBJECT(participant)->findDevice(deviceAddress));
}
......@@ -44,6 +44,7 @@
F(MediaSessionParams, CallParams) \
F(Participant, Participant) \
F(ParticipantDevice, ParticipantDevice) \
F(ParticipantDeviceIdentity, ParticipantDeviceIdentity) \
F(ParticipantImdnState, ParticipantImdnState) \
F(SearchResult, SearchResult)
......
......@@ -854,7 +854,10 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceP
}
ChatRoom::SecurityLevel currentSecurityLevel = getSecurityLevel();
participant->getPrivate()->addDevice(event->getDeviceAddress());
shared_ptr<ParticipantDevice> device = participant->getPrivate()->addDevice(event->getDeviceAddress());
const string &deviceName = event->getDeviceName();
if (!deviceName.empty())
device->setName(deviceName);
// Check if new device degrades the chatroom security level and return corresponding security event
shared_ptr<ConferenceSecurityEvent> securityEvent = nullptr;
......
......@@ -26,7 +26,10 @@
#include "chat-room-p.h"
#include "server-group-chat-room.h"
#include "conference/participant-device.h"
#include "object/clonable-object.h"
#include "object/clonable-object-p.h"
// =============================================================================
......@@ -34,6 +37,27 @@ LINPHONE_BEGIN_NAMESPACE
class ParticipantDevice;
class ParticipantDeviceIdentityPrivate : public ClonableObjectPrivate {
public:
Address deviceAddress;
std::string deviceName;
};
class ParticipantDeviceIdentity : public ClonableObject {
public:
ParticipantDeviceIdentity (const Address &address, const std::string &name);
ParticipantDeviceIdentity (const ParticipantDeviceIdentity &other);
ParticipantDeviceIdentity* clone () const override {
return new ParticipantDeviceIdentity(*this);
}
const Address &getDeviceAddress () const;
const std::string &getDeviceName () const;
private:
L_DECLARE_PRIVATE(ParticipantDeviceIdentity);
};
class ServerGroupChatRoomPrivate : public ChatRoomPrivate {
public:
void setState (ChatRoom::State state) override;
......@@ -60,7 +84,7 @@ public:
bool update (SalCallOp *op);
void setConferenceAddress (const IdentityAddress &conferenceAddress);
void setParticipantDevices (const IdentityAddress &addr, const std::list<IdentityAddress> &devices);
void setParticipantDevices (const IdentityAddress &addr, const std::list<ParticipantDeviceIdentity> &devices);
void addCompatibleParticipants (const IdentityAddress &deviceAddr, const std::list<IdentityAddress> &compatibleParticipants);
void checkCompatibleParticipants (const IdentityAddress &deviceAddr, const std::list<IdentityAddress> &addressesToCheck);
......@@ -91,7 +115,7 @@ private:
static void copyMessageHeaders (const std::shared_ptr<Message> &fromMessage, const std::shared_ptr<ChatMessage> &toMessage);
void addParticipantDevice (const std::shared_ptr<Participant> &participant, const IdentityAddress &deviceAddress);
void addParticipantDevice (const std::shared_ptr<Participant> &participant, const IdentityAddress &deviceAddress, const std::string &name = "");
void byeDevice (const std::shared_ptr<ParticipantDevice> &device);
void designateAdmin ();
void dispatchMessage (const std::shared_ptr<Message> &message, const std::string &uri);
......
......@@ -47,6 +47,32 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
ParticipantDeviceIdentity::ParticipantDeviceIdentity (const Address &address, const string &name) : ClonableObject(*new ParticipantDeviceIdentityPrivate) {
L_D();
d->deviceAddress = address;
d->deviceName = name;
}
ParticipantDeviceIdentity::ParticipantDeviceIdentity (const ParticipantDeviceIdentity &other) : ClonableObject(*new ParticipantDeviceIdentityPrivate) {
L_D();
d->deviceAddress = other.getDeviceAddress();
d->deviceName = other.getDeviceName();
}
const Address &ParticipantDeviceIdentity::getDeviceAddress () const {
L_D();
return d->deviceAddress;
}
const string &ParticipantDeviceIdentity::getDeviceName () const {
L_D();
return d->deviceName;
}
// -----------------------------------------------------------------------------
#define CALL_CHAT_ROOM_CBS(cr, cbName, functionName, ...) \
bctbx_list_t *callbacksCopy = bctbx_list_copy(linphone_chat_room_get_callbacks_list(cr)); \
for (bctbx_list_t *it = callbacksCopy; it; it = bctbx_list_next(it)) { \
......@@ -417,27 +443,30 @@ void ServerGroupChatRoomPrivate::setConferenceAddress (const IdentityAddress &co
finalizeCreation();
}
void ServerGroupChatRoomPrivate::setParticipantDevices(const IdentityAddress &participantAddress, const list<IdentityAddress> &devices) {
void ServerGroupChatRoomPrivate::setParticipantDevices (const IdentityAddress &participantAddress, const list<ParticipantDeviceIdentity> &deviceIdentities) {
L_Q();
shared_ptr<Participant> participant = q->findParticipant(participantAddress);
if (!participant)
return;
lInfo() << q << ": Setting " << devices.size() << " participant device(s) for " << participantAddress.asString();
lInfo() << q << ": Setting " << deviceIdentities.size() << " participant device(s) for " << participantAddress.asString();
// Remove devices that are in the chatroom but no longer in the given list
list<shared_ptr<ParticipantDevice>> devicesToRemove;
for (const auto &device : participant->getPrivate()->getDevices()) {
auto it = find(devices.cbegin(), devices.cend(), device->getAddress());
if (it == devices.cend())
auto predicate = [device] (ParticipantDeviceIdentity deviceIdentity) {
return device->getAddress() == deviceIdentity.getDeviceAddress();
};
const auto it = find_if(deviceIdentities.cbegin(), deviceIdentities.cend(), predicate);
if (it == deviceIdentities.cend())
devicesToRemove.push_back(device);
}
for (auto &device : devicesToRemove)
for (const auto &device : devicesToRemove)
removeParticipantDevice(participant, device->getAddress());
// Add all the devices in the given list
for (const auto &deviceAddress : devices)
addParticipantDevice(participant, deviceAddress);
for (const auto &deviceIdentity : deviceIdentities)
addParticipantDevice(participant, deviceIdentity.getDeviceAddress(), deviceIdentity.getDeviceName());
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(q);
LinphoneAddress *laddr = linphone_address_new(participantAddress.asString().c_str());
......@@ -527,12 +556,14 @@ void ServerGroupChatRoomPrivate::copyMessageHeaders (const shared_ptr<Message> &
}
}
void ServerGroupChatRoomPrivate::addParticipantDevice (const shared_ptr<Participant> &participant, const IdentityAddress &deviceAddress) {
void ServerGroupChatRoomPrivate::addParticipantDevice (const shared_ptr<Participant> &participant, const IdentityAddress &deviceAddress, const string &name) {
L_Q();
L_Q_T(LocalConference, qConference);
shared_ptr<ParticipantDevice> device = participant->getPrivate()->findDevice(deviceAddress);
if (device) {
lInfo() << q << ": Adding participant device that is currently in state [" << device->getState() << "]";
if (!name.empty())
device->setName(name);
switch (device->getState()) {
case ParticipantDevice::State::Joining:
inviteDevice(device);
......@@ -549,7 +580,7 @@ void ServerGroupChatRoomPrivate::addParticipantDevice (const shared_ptr<Particip
}
} else if (findFilteredParticipant(participant->getAddress())) {
// Add device only if participant is not currently being removed
device = participant->getPrivate()->addDevice(deviceAddress);
device = participant->getPrivate()->addDevice(deviceAddress, name);
setParticipantDeviceState(device, ParticipantDevice::State::Joining);
shared_ptr<ConferenceParticipantDeviceEvent> event = qConference->getPrivate()->eventHandler->notifyParticipantDeviceAdded(participant->getAddress(), deviceAddress);
q->getCore()->getPrivate()->mainDb->addEvent(event);
......
......@@ -93,6 +93,10 @@ string LocalConferenceEventHandlerPrivate::createNotifyFullState (int notifyId,
const string &gruu = device->getAddress().asString();
EndpointType endpoint = EndpointType();
endpoint.setEntity(gruu);
const string &displayName = device->getName();
if (!displayName.empty())
endpoint.setDisplayText(displayName);
endpoint.setState(StateType::full);
user.getEndpoint().push_back(endpoint);
}
......@@ -212,6 +216,10 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const A
const string &gruu = device->getAddress().asString();
EndpointType endpoint = EndpointType();
endpoint.setEntity(gruu);
const string &displayName = device->getName();
if (!displayName.empty())
endpoint.setDisplayText(displayName);
endpoint.setState(StateType::full);
user.getEndpoint().push_back(endpoint);
}
......@@ -271,6 +279,18 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantDeviceAdded (c
EndpointType endpoint = EndpointType();
endpoint.setEntity(gruu.asStringUriOnly());
shared_ptr<Participant> p = conf->findParticipant(addr);
if (p) {
shared_ptr<ParticipantDevice> device = p->getPrivate()->findDevice(gruu);
if (device) {
const string &displayName = device->getName();
if (!displayName.empty())
endpoint.setDisplayText(displayName);
endpoint.setState(StateType::full);
user.getEndpoint().push_back(endpoint);
}
}
endpoint.setState(StateType::full);
user.getEndpoint().push_back(endpoint);
......
......@@ -170,6 +170,7 @@ void RemoteConferenceEventHandlerPrivate::simpleNotifyReceived (const string &xm
isFullState
);
} else if (state == StateType::full) {
const string &name = endpoint.getDisplayText().present() ? endpoint.getDisplayText().get() : "";
confListener->onParticipantDeviceAdded(
make_shared<ConferenceParticipantDeviceEvent>(
EventLog::Type::ConferenceParticipantDeviceAdded,
......@@ -177,7 +178,8 @@ void RemoteConferenceEventHandlerPrivate::simpleNotifyReceived (const string &xm
conferenceId,
lastNotify,
address,
gruu
gruu,
name
),
isFullState
);
......
......@@ -42,8 +42,8 @@ private:
ParticipantDevice::ParticipantDevice () : Object(*new ParticipantDevicePrivate) {}
ParticipantDevice::ParticipantDevice (Participant *participant, const IdentityAddress &gruu)
: Object(*new ParticipantDevicePrivate), mParticipant(participant), mGruu(gruu) {}
ParticipantDevice::ParticipantDevice (Participant *participant, const IdentityAddress &gruu, const string &name)
: Object(*new ParticipantDevicePrivate), mParticipant(participant), mGruu(gruu), mName(name) {}
ParticipantDevice::~ParticipantDevice () {
if (mConferenceSubscribeEvent)
......
......@@ -49,7 +49,7 @@ public:
};
ParticipantDevice ();
explicit ParticipantDevice (Participant *participant, const IdentityAddress &gruu);
explicit ParticipantDevice (Participant *participant, const IdentityAddress &gruu, const std::string &name = "");
virtual ~ParticipantDevice ();
bool operator== (const ParticipantDevice &device) const;
......@@ -57,6 +57,8 @@ public:
std::shared_ptr<Core> getCore () const;
inline const IdentityAddress &getAddress () const { return mGruu; }
inline const std::string &getName () const { return mName; }
inline void setName (const std::string &name) { mName = name; }
Participant *getParticipant () const { return mParticipant; }
inline std::shared_ptr<CallSession> getSession () const { return mSession; }
inline void setSession (std::shared_ptr<CallSession> session) { mSession = session; }
......@@ -75,6 +77,7 @@ private:
Participant *mParticipant = nullptr;
IdentityAddress mGruu;
std::string mName;
std::shared_ptr<CallSession> mSession;
LinphoneEvent *mConferenceSubscribeEvent = nullptr;
State mState = State::Joining;
......
......@@ -44,7 +44,7 @@ public:
inline void setAddress (const IdentityAddress &newAddr) { addr = newAddr; }
inline void setAdmin (bool isAdmin) { this->isAdmin = isAdmin; }
std::shared_ptr<ParticipantDevice> addDevice (const IdentityAddress &gruu);
std::shared_ptr<ParticipantDevice> addDevice (const IdentityAddress &gruu, const std::string &name = "");
void clearDevices ();
std::shared_ptr<ParticipantDevice> findDevice (const IdentityAddress &gruu) const;
std::shared_ptr<ParticipantDevice> findDevice (const std::shared_ptr<const CallSession> &session);
......
......@@ -46,12 +46,12 @@ shared_ptr<CallSession> ParticipantPrivate::createSession (
// -----------------------------------------------------------------------------
shared_ptr<ParticipantDevice> ParticipantPrivate::addDevice (const IdentityAddress &gruu) {
shared_ptr<ParticipantDevice> ParticipantPrivate::addDevice (const IdentityAddress &gruu, const string &name) {
L_Q();
shared_ptr<ParticipantDevice> device = findDevice(gruu);
if (device)
return device;
device = make_shared<ParticipantDevice>(q, gruu);
device = make_shared<ParticipantDevice>(q, gruu, name);
devices.push_back(device);
return device;
}
......
......@@ -61,7 +61,7 @@ private:
);
long long insertChatRoom (const std::shared_ptr<AbstractChatRoom> &chatRoom, unsigned int notifyId = 0);
long long insertChatRoomParticipant (long long chatRoomId, long long participantSipAddressId, bool isAdmin);
void insertChatRoomParticipantDevice (long long participantId, long long participantDeviceSipAddressId);
void insertChatRoomParticipantDevice (long long participantId, long long participantDeviceSipAddressId, const std::string &deviceName);
void insertChatMessageParticipant (long long chatMessageId, long long sipAddressId, int state, time_t stateChangeTime);
long long selectSipAddressId (const std::string &sipAddress) const;
......
......@@ -48,7 +48,7 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
namespace {
constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 5);
constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 7);
constexpr unsigned int ModuleVersionFriends = makeVersion(1, 0, 0);
constexpr unsigned int ModuleVersionLegacyFriendsImport = makeVersion(1, 0, 0);
constexpr unsigned int ModuleVersionLegacyHistoryImport = makeVersion(1, 0, 0);
......@@ -373,7 +373,7 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
me->isAdmin()
);
for (const auto &device : me->getPrivate()->getDevices())
insertChatRoomParticipantDevice(meId, insertSipAddress(device->getAddress().asString()));
insertChatRoomParticipantDevice(meId, insertSipAddress(device->getAddress().asString()), device->getName());
}
for (const auto &participant : chatRoom->getParticipants()) {
......@@ -383,7 +383,7 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &cha
participant->isAdmin()
);
for (const auto &device : participant->getPrivate()->getDevices())
insertChatRoomParticipantDevice(participantId, insertSipAddress(device->getAddress().asString()));
insertChatRoomParticipantDevice(participantId, insertSipAddress(device->getAddress().asString()), device->getName());
}
return chatRoomId;
......@@ -412,7 +412,8 @@ long long MainDbPrivate::insertChatRoomParticipant (
void MainDbPrivate::insertChatRoomParticipantDevice (
long long participantId,
long long participantDeviceSipAddressId
long long participantDeviceSipAddressId,
const string &deviceName
) {
soci::session *session = dbSession.getBackendSession();
long long count;
......@@ -423,9 +424,9 @@ void MainDbPrivate::insertChatRoomParticipantDevice (
if (count)
return;
*session << "INSERT INTO chat_room_participant_device (chat_room_participant_id, participant_device_sip_address_id)"
" VALUES (:participantId, :participantDeviceSipAddressId)",
soci::use(participantId), soci::use(participantDeviceSipAddressId);
*session << "INSERT INTO chat_room_participant_device (chat_room_participant_id, participant_device_sip_address_id, name)"
" VALUES (:participantId, :participantDeviceSipAddressId, :participantDeviceName)",
soci::use(participantId), soci::use(participantDeviceSipAddressId), soci::use(deviceName);
}
void MainDbPrivate::insertChatMessageParticipant (long long chatMessageId, long long sipAddressId, int state, time_t stateChangeTime) {
......@@ -954,7 +955,7 @@ long long MainDbPrivate::insertConferenceParticipantDeviceEvent (const shared_pt
switch (eventLog->getType()) {
case EventLog::Type::ConferenceParticipantDeviceAdded:
insertChatRoomParticipantDevice(participantId, deviceAddressId);
insertChatRoomParticipantDevice(participantId, deviceAddressId, participantDeviceEvent->getDeviceName());
break;
case EventLog::Type::ConferenceParticipantDeviceRemoved:
......@@ -1161,6 +1162,9 @@ void MainDbPrivate::updateSchema () {
" LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id"
" LEFT JOIN conference_security_event ON conference_security_event.event_id = event.id";
}
if (version < makeVersion(1, 0, 7)) {
*session << "ALTER TABLE chat_room_participant_device ADD COLUMN name VARCHAR(255)";
}
}
// -----------------------------------------------------------------------------
......@@ -2557,13 +2561,13 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
// Fetch devices.
{
const long long &participantId = d->dbSession.resolveId(row, 0);
static const string query = "SELECT sip_address.value, state FROM chat_room_participant_device, sip_address"
static const string query = "SELECT sip_address.value, state, name FROM chat_room_participant_device, sip_address"
" WHERE chat_room_participant_id = :participantId"
" AND participant_device_sip_address_id = sip_address.id";
soci::rowset<soci::row> rows = (session->prepare << query, soci::use(participantId));
for (const auto &row : rows) {
shared_ptr<ParticipantDevice> device = dParticipant->addDevice(IdentityAddress(row.get<string>(0)));
shared_ptr<ParticipantDevice> device = dParticipant->addDevice(IdentityAddress(row.get<string>(0)), row.get<string>(2));
device->setState(ParticipantDevice::State(static_cast<unsigned int>(row.get<int>(1, 0))));
}
}
......@@ -2697,7 +2701,7 @@ void MainDb::migrateBasicToClientGroupChatRoom (
true
);
for (const auto &device : me->getPrivate()->getDevices())
d->insertChatRoomParticipantDevice(meId, d->insertSipAddress(device->getAddress().asString()));
d->insertChatRoomParticipantDevice(meId, d->insertSipAddress(device->getAddress().asString()), device->getName());
for (const auto &participant : clientGroupChatRoom->getParticipants()) {
long long participantId =</