Commit acd22269 authored by Ghislain MARY's avatar Ghislain MARY

Add state of conference participant device.

parent bccf926b
......@@ -20,6 +20,10 @@
#ifndef _L_SERVER_GROUP_CHAT_ROOM_P_H_
#define _L_SERVER_GROUP_CHAT_ROOM_P_H_
#include <chrono>
#include <queue>
#include <unordered_map>
#include "chat-room-p.h"
#include "server-group-chat-room.h"
......@@ -27,15 +31,20 @@
LINPHONE_BEGIN_NAMESPACE
class ParticipantDevice;
class ServerGroupChatRoomPrivate : public ChatRoomPrivate {
public:
std::shared_ptr<Participant> addParticipant (const IdentityAddress &participantAddress);
void removeParticipant (const std::shared_ptr<const Participant> &participant);
std::shared_ptr<Participant> findRemovedParticipant (const std::shared_ptr<const CallSession> &session) const;
std::shared_ptr<Participant> findFilteredParticipant (const std::shared_ptr<const CallSession> &session) const;
std::shared_ptr<Participant> findFilteredParticipant (const IdentityAddress &participantAddress) const;
void confirmCreation ();
void confirmJoining (SalCallOp *op);
void confirmRecreation (SalCallOp *op);
void dispatchQueuedMessages ();
IdentityAddress generateConferenceAddress (const std::shared_ptr<Participant> &me) const;
......@@ -60,13 +69,18 @@ private:
IdentityAddress fromAddr;
Content content;
std::chrono::system_clock::time_point timestamp = std::chrono::system_clock::now();
};
void designateAdmin ();
void dispatchMessage (const Message &message);
void dispatchQueuedMessages ();
void dispatchMessage (const std::shared_ptr<Message> &message, const std::string &uri);
void finalizeCreation ();
void inviteDevice (const std::shared_ptr<ParticipantDevice> &device);
bool isAdminLeft () const;
void queueMessage (const std::shared_ptr<Message> &message);
void queueMessage (const std::shared_ptr<Message> &msg, const IdentityAddress &deviceAddress);
void onParticipantDeviceLeft (const std::shared_ptr<const CallSession> &session);
// ChatRoomListener
void onChatRoomInsertRequested (const std::shared_ptr<AbstractChatRoom> &chatRoom) override;
......@@ -80,11 +94,11 @@ private:
const std::string &message
) override;
std::list<std::shared_ptr<Participant>> removedParticipants;
std::list<std::shared_ptr<Participant>> filteredParticipants;
ChatRoomListener *chatRoomListener = this;
ServerGroupChatRoom::CapabilitiesMask capabilities = ServerGroupChatRoom::Capabilities::Conference;
bool joiningPendingAfterCreation = false;
std::list<Message> queuedMessages;
std::unordered_map<std::string, std::queue<std::shared_ptr<Message>>> queuedMessages;
L_DECLARE_PUBLIC(ServerGroupChatRoom);
};
......
......@@ -34,9 +34,11 @@ shared_ptr<Participant> ServerGroupChatRoomPrivate::addParticipant (const Identi
void ServerGroupChatRoomPrivate::removeParticipant (const shared_ptr<const Participant> &) {}
shared_ptr<Participant> ServerGroupChatRoomPrivate::findRemovedParticipant (
const shared_ptr<const CallSession> &
) const {
shared_ptr<Participant> ServerGroupChatRoomPrivate::findFilteredParticipant (const shared_ptr<const CallSession> &session) const {
return nullptr;
}
shared_ptr<Participant> ServerGroupChatRoomPrivate::findFilteredParticipant (const IdentityAddress &participantAddress) const {
return nullptr;
}
......@@ -48,6 +50,8 @@ void ServerGroupChatRoomPrivate::confirmJoining (SalCallOp *) {}
void ServerGroupChatRoomPrivate::confirmRecreation (SalCallOp *) {}
void ServerGroupChatRoomPrivate::dispatchQueuedMessages () {}
// -----------------------------------------------------------------------------
IdentityAddress ServerGroupChatRoomPrivate::generateConferenceAddress (const shared_ptr<Participant> &me) const {
......@@ -76,16 +80,24 @@ LinphoneReason ServerGroupChatRoomPrivate::onSipMessageReceived (SalOp *, const
void ServerGroupChatRoomPrivate::designateAdmin () {}
void ServerGroupChatRoomPrivate::dispatchMessage (const Message &message) {}
void ServerGroupChatRoomPrivate::dispatchQueuedMessages () {}
void ServerGroupChatRoomPrivate::dispatchMessage (const std::shared_ptr<Message> &message, const std::string &uri) {}
void ServerGroupChatRoomPrivate::finalizeCreation () {}
void ServerGroupChatRoomPrivate::inviteDevice (const std::shared_ptr<ParticipantDevice> &device) {}
bool ServerGroupChatRoomPrivate::isAdminLeft () const {
return false;
}
void ServerGroupChatRoomPrivate::queueMessage (const std::shared_ptr<Message> &message) {}
void ServerGroupChatRoomPrivate::queueMessage (const std::shared_ptr<Message> &msg, const IdentityAddress &deviceAddress) {}
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::onParticipantDeviceLeft (const std::shared_ptr<const CallSession> &session) {}
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::onChatRoomInsertRequested (const shared_ptr<AbstractChatRoom> &chatRoom) {}
......@@ -189,4 +201,6 @@ void ServerGroupChatRoom::join () {}
void ServerGroupChatRoom::leave () {}
void ServerGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {}
LINPHONE_END_NAMESPACE
......@@ -85,6 +85,9 @@ public:
void join () override;
void leave () override;
/* ConferenceListener */
void onFirstNotifyReceived (const IdentityAddress &addr) override;
private:
L_DECLARE_PRIVATE(ServerGroupChatRoom);
L_DISABLE_COPY(ServerGroupChatRoom);
......
......@@ -36,16 +36,16 @@ class IdentityAddress;
class ConferenceListener {
public:
virtual void onConferenceCreated (const IdentityAddress &addr) = 0;
virtual void onConferenceCreated (const IdentityAddress &addr) {}
virtual void onConferenceKeywordsChanged (const std::vector<std::string> &keywords) {}
virtual void onConferenceTerminated (const IdentityAddress &addr) = 0;
virtual void onFirstNotifyReceived (const IdentityAddress &addr) = 0;
virtual void onParticipantAdded (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) = 0;
virtual void onParticipantRemoved (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) = 0;
virtual void onParticipantSetAdmin (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) = 0;
virtual void onSubjectChanged (const std::shared_ptr<ConferenceSubjectEvent> &event, bool isFullState) = 0;
virtual void onParticipantDeviceAdded (const std::shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) = 0;
virtual void onParticipantDeviceRemoved (const std::shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) = 0;
virtual void onConferenceTerminated (const IdentityAddress &addr) {}
virtual void onFirstNotifyReceived (const IdentityAddress &addr) {}
virtual void onParticipantAdded (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {}
virtual void onParticipantRemoved (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {}
virtual void onParticipantSetAdmin (const std::shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {}
virtual void onSubjectChanged (const std::shared_ptr<ConferenceSubjectEvent> &event, bool isFullState) {}
virtual void onParticipantDeviceAdded (const std::shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) {}
virtual void onParticipantDeviceRemoved (const std::shared_ptr<ConferenceParticipantDeviceEvent> &event, bool isFullState) {}
};
LINPHONE_END_NAMESPACE
......
......@@ -83,8 +83,7 @@ shared_ptr<Participant> Conference::getMe () const {
}
int Conference::getParticipantCount () const {
L_D();
return static_cast<int>(d->participants.size());
return static_cast<int>(getParticipants().size());
}
const list<shared_ptr<Participant>> &Conference::getParticipants () const {
......
......@@ -23,6 +23,7 @@
#include "linphone/types.h"
#include "conference/conference-interface.h"
#include "conference/conference-listener.h"
#include "core/core-accessor.h"
// =============================================================================
......@@ -36,6 +37,7 @@ class ConferencePrivate;
class LINPHONE_PUBLIC Conference :
public ConferenceInterface,
public ConferenceListener,
public CoreAccessor {
friend class CallSessionPrivate;
......
......@@ -40,11 +40,11 @@ public:
std::string createNotifyFullState (int notifyId = -1, bool oneToOne = false);
std::string createNotifyMultipart (int notifyId);
std::string createNotifyParticipantAdded (const Address &addr, int notifyId = -1);
std::string createNotifyParticipantAdminStatusChanged (const Address &addr, bool isAdmin, int notifyId = -1);
std::string createNotifyParticipantRemoved (const Address &addr, int notifyId = -1);
std::string createNotifyParticipantAdmined (const Address &addr, bool isAdmin, int notifyId = -1);
std::string createNotifySubjectChanged (int notifyId = -1);
std::string createNotifyParticipantDeviceAdded (const Address &addr, const Address &gruu, int notifyId = -1);
std::string createNotifyParticipantDeviceRemoved (const Address &addr, const Address &gruu, int notifyId = -1);
std::string createNotifySubjectChanged (int notifyId = -1);
inline unsigned int getLastNotify () const { return lastNotify; };
......@@ -54,6 +54,8 @@ private:
LocalConference *conf = nullptr;
unsigned int lastNotify = 1;
static void notifyResponseCb (const LinphoneEvent *ev);
std::string createNotify (Xsd::ConferenceInfo::ConferenceType confInfo, int notifyId = -1, bool isFullState = false);
std::string createNotifySubjectChanged (const std::string &subject, int notifyId = -1);
void notifyParticipant (const std::string &notify, const std::shared_ptr<Participant> &participant);
......
......@@ -34,6 +34,13 @@ class CallSession;
class ParticipantDevice {
public:
enum class State {
Joining,
Present,
Leaving,
Left
};
ParticipantDevice ();
explicit ParticipantDevice (const IdentityAddress &gruu);
virtual ~ParticipantDevice ();
......@@ -43,6 +50,8 @@ public:
inline const IdentityAddress &getAddress () const { return mGruu; }
inline std::shared_ptr<CallSession> getSession () const { return mSession; }
inline void setSession (std::shared_ptr<CallSession> session) { mSession = session; }
inline State getState () const { return mState; }
inline void setState (State newState) { mState = newState; }
inline bool isSubscribedToConferenceEventPackage () const { return mConferenceSubscribeEvent != nullptr; }
LinphoneEvent *getConferenceSubscribeEvent () const { return mConferenceSubscribeEvent; }
......@@ -54,6 +63,7 @@ private:
IdentityAddress mGruu;
std::shared_ptr<CallSession> mSession;
LinphoneEvent *mConferenceSubscribeEvent = nullptr;
State mState = State::Joining;
L_DISABLE_COPY(ParticipantDevice);
};
......
......@@ -20,7 +20,6 @@
#ifndef _L_REMOTE_CONFERENCE_H_
#define _L_REMOTE_CONFERENCE_H_
#include "conference-listener.h"
#include "conference.h"
#include "core/core-accessor.h"
......@@ -30,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
class RemoteConferencePrivate;
class LINPHONE_PUBLIC RemoteConference : public Conference, public ConferenceListener {
class LINPHONE_PUBLIC RemoteConference : public Conference {
friend class ClientGroupChatRoomPrivate;
public:
......
......@@ -1023,7 +1023,7 @@ void send_admined_notify() {
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantAdmined(bobAddr, true);
notify = localHandlerPrivate->createNotifyParticipantAdminStatusChanged(bobAddr, true);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
......@@ -1078,7 +1078,7 @@ void send_unadmined_notify() {
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantAdmined(aliceAddr, false);
notify = localHandlerPrivate->createNotifyParticipantAdminStatusChanged(aliceAddr, false);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment