mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
integration of chatroom list subscription on client side
This commit is contained in:
parent
8f653ab4bf
commit
3728262f9a
10 changed files with 73 additions and 18 deletions
|
|
@ -23,7 +23,8 @@
|
|||
#include "basic-to-client-group-chat-room.h"
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "client-group-chat-room-p.h"
|
||||
#include "conference/handlers/remote-conference-event-handler.h"
|
||||
#include "conference/handlers/remote-conference-event-handler-p.h"
|
||||
#include "conference/handlers/remote-conference-list-event-handler.h"
|
||||
#include "conference/participant-p.h"
|
||||
#include "conference/remote-conference-p.h"
|
||||
#include "conference/session/call-session-p.h"
|
||||
|
|
@ -214,8 +215,9 @@ RemoteConference(core, me->getAddress(), nullptr) {
|
|||
|
||||
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||
|
||||
dConference->eventHandler->setChatRoomId(chatRoomId);
|
||||
dConference->eventHandler->setLastNotify(lastNotifyId);
|
||||
// dConference->eventHandler->subscribe(getChatRoomId());
|
||||
getCore()->getPrivate()->remoteListEventHandler->addHandler(dConference->eventHandler);
|
||||
}
|
||||
|
||||
ClientGroupChatRoom::~ClientGroupChatRoom () {
|
||||
|
|
|
|||
|
|
@ -299,6 +299,11 @@ void RemoteConferenceEventHandler::multipartNotifyReceived (const string &xmlBod
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RemoteConferenceEventHandler::setChatRoomId (ChatRoomId chatRoomId) {
|
||||
L_D();
|
||||
d->chatRoomId = chatRoomId;
|
||||
}
|
||||
|
||||
const ChatRoomId &RemoteConferenceEventHandler::getChatRoomId () const {
|
||||
L_D();
|
||||
return d->chatRoomId;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
void multipartNotifyReceived (const std::string &xmlBody);
|
||||
void unsubscribe ();
|
||||
|
||||
void setChatRoomId (ChatRoomId chatRoomId);
|
||||
const ChatRoomId &getChatRoomId () const;
|
||||
|
||||
unsigned int getLastNotify () const;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,23 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
RemoteConferenceListEventHandler::RemoteConferenceListEventHandler (const std::shared_ptr<Core> &core) : CoreAccessor(core) {
|
||||
getCore()->getPrivate()->registerListener(this);
|
||||
}
|
||||
|
||||
RemoteConferenceListEventHandler::~RemoteConferenceListEventHandler () {
|
||||
try {
|
||||
getCore()->getPrivate()->unregisterListener(this);
|
||||
} catch (const bad_weak_ptr &) {
|
||||
// Unable to unregister listener here. Core is destroyed and the listener doesn't exist.
|
||||
}
|
||||
|
||||
if (lev)
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RemoteConferenceListEventHandler::subscribe () {
|
||||
if (lev)
|
||||
return;
|
||||
|
|
@ -56,7 +73,7 @@ void RemoteConferenceListEventHandler::subscribe () {
|
|||
for (const auto &handler : handlers) {
|
||||
Address addr = handler->getChatRoomId().getPeerAddress();
|
||||
addr.setUriParam("Last-Notify", Utils::toString(handler->getLastNotify()));
|
||||
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asString());
|
||||
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asStringUriOnly());
|
||||
l.getEntry().push_back(entry);
|
||||
}
|
||||
rl.getList().push_back(l);
|
||||
|
|
@ -123,6 +140,25 @@ void RemoteConferenceListEventHandler::notifyReceived (Content *multipart) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
shared_ptr<RemoteConferenceEventHandler> RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) const {
|
||||
for (const auto &handler : handlers) {
|
||||
if (handler->getChatRoomId() == chatRoomId)
|
||||
return handler;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const list<shared_ptr<RemoteConferenceEventHandler>> &RemoteConferenceListEventHandler::getHandlers () const {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::addHandler (std::shared_ptr<RemoteConferenceEventHandler> handler) {
|
||||
handlers.push_back(handler);
|
||||
}
|
||||
|
||||
map<Address, Address> RemoteConferenceListEventHandler::parseRlmi (const string &xmlBody) const {
|
||||
istringstream data(xmlBody);
|
||||
unique_ptr<Xsd::Rlmi::List> rlmi(Xsd::Rlmi::parseList(
|
||||
|
|
@ -146,21 +182,16 @@ map<Address, Address> RemoteConferenceListEventHandler::parseRlmi (const string
|
|||
return addresses;
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::addHandler (std::shared_ptr<RemoteConferenceEventHandler> handler) {
|
||||
handlers.push_back(handler);
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RemoteConferenceListEventHandler::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {
|
||||
if (!sipNetworkReachable)
|
||||
unsubscribe();
|
||||
}
|
||||
|
||||
shared_ptr<RemoteConferenceEventHandler> RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) const {
|
||||
for (const auto &handler : handlers) {
|
||||
if (handler->getChatRoomId() == chatRoomId)
|
||||
return handler;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const list<shared_ptr<RemoteConferenceEventHandler>> &RemoteConferenceListEventHandler::getHandlers () const {
|
||||
return handlers;
|
||||
void RemoteConferenceListEventHandler::onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) {
|
||||
if (state == LinphoneRegistrationOk)
|
||||
subscribe();
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "chat/chat-room/chat-room-id.h"
|
||||
#include "content/content.h"
|
||||
#include "core/core-accessor.h"
|
||||
#include "core/core-listener.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
|
|
@ -38,8 +39,11 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
class Address;
|
||||
class RemoteConferenceEventHandler;
|
||||
|
||||
class RemoteConferenceListEventHandler : public Object, public CoreAccessor {
|
||||
class RemoteConferenceListEventHandler : public CoreAccessor , public CoreListener {
|
||||
public:
|
||||
RemoteConferenceListEventHandler (const std::shared_ptr<Core> &core);
|
||||
~RemoteConferenceListEventHandler ();
|
||||
|
||||
void subscribe ();
|
||||
void unsubscribe ();
|
||||
void notifyReceived (Content *multipart);
|
||||
|
|
@ -52,6 +56,10 @@ private:
|
|||
LinphoneEvent *lev = nullptr;
|
||||
|
||||
std::map<Address, Address> parseRlmi (const std::string &xmlBody) const;
|
||||
|
||||
// CoreListener
|
||||
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
|
||||
void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) override;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class RemoteConferenceEventHandler;
|
|||
class RemoteConferencePrivate : public ConferencePrivate {
|
||||
public:
|
||||
std::shared_ptr<Participant> focus;
|
||||
std::unique_ptr<RemoteConferenceEventHandler> eventHandler;
|
||||
std::shared_ptr<RemoteConferenceEventHandler> eventHandler;
|
||||
|
||||
private:
|
||||
L_DECLARE_PUBLIC(RemoteConference);
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ LinphoneContent *Content::toLinphoneContent () const {
|
|||
LinphoneContent *content = linphone_core_create_content(nullptr);
|
||||
linphone_content_set_type(content, getContentType().getType().c_str());
|
||||
linphone_content_set_subtype(content, getContentType().getSubType().c_str());
|
||||
linphone_content_set_buffer(content, (const uint8_t *)getBodyAsUtf8String().c_str(), getBodyAsUtf8String().size());
|
||||
return content;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class CoreListener;
|
||||
class RemoteConferenceListEventHandler;
|
||||
|
||||
class CorePrivate : public ObjectPrivate {
|
||||
public:
|
||||
|
|
@ -65,6 +66,7 @@ public:
|
|||
void replaceChatRoom (const std::shared_ptr<AbstractChatRoom> &replacedChatRoom, const std::shared_ptr<AbstractChatRoom> &newChatRoom);
|
||||
|
||||
std::unique_ptr<MainDb> mainDb;
|
||||
std::unique_ptr<RemoteConferenceListEventHandler> remoteListEventHandler;
|
||||
|
||||
private:
|
||||
std::list<CoreListener *> listeners;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@
|
|||
#include <mediastreamer2/mscommon.h>
|
||||
#include <xercesc/util/PlatformUtils.hpp>
|
||||
|
||||
//#include "linphone/utils/general.h"
|
||||
|
||||
#include "address/address-p.h"
|
||||
#include "call/call.h"
|
||||
#include "conference/handlers/remote-conference-list-event-handler.h"
|
||||
#include "core/core-listener.h"
|
||||
#include "core/core-p.h"
|
||||
#include "logger/logger.h"
|
||||
|
|
@ -42,6 +45,7 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
void CorePrivate::init () {
|
||||
L_Q();
|
||||
mainDb.reset(new MainDb(q->getSharedFromThis()));
|
||||
remoteListEventHandler = makeUnique<RemoteConferenceListEventHandler>(q->getSharedFromThis());
|
||||
|
||||
AbstractDb::Backend backend;
|
||||
string uri = L_C_TO_STRING(lp_config_get_string(linphone_core_get_config(L_GET_C_BACK_PTR(q)), "storage", "uri", nullptr));
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class LINPHONE_PUBLIC Core : public Object {
|
|||
friend class MainDbEventKey;
|
||||
friend class MediaSessionPrivate;
|
||||
friend class RemoteConferenceEventHandler;
|
||||
friend class RemoteConferenceListEventHandler;
|
||||
friend class ServerGroupChatRoom;
|
||||
friend class ServerGroupChatRoomPrivate;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue