Commit ae4b36ee authored by Simon Morlat's avatar Simon Morlat

Merge branch 'fix/conference_refactoring'

parents a1be0b5f 67b9c981
Pipeline #2549 passed with stages
in 145 minutes and 44 seconds
......@@ -52,10 +52,10 @@ class OnRequestBindListener : public ContactUpdateListener {
sip_contact_t *contact = NULL, sip_path_t *path = NULL);
~OnRequestBindListener();
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec);
void onRecordFound(Record *r);
void onError();
void onInvalid();
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec) override;
void onRecordFound(const std::shared_ptr<Record> &r)override;
void onError()override;
void onInvalid()override;
};
class OnResponseBindListener : public ContactUpdateListener {
......@@ -67,10 +67,10 @@ class OnResponseBindListener : public ContactUpdateListener {
public:
OnResponseBindListener(ModuleRegistrar *module, std::shared_ptr<ResponseSipEvent> ev, std::shared_ptr<OutgoingTransaction> tr,
std::shared_ptr<ResponseContext> ctx);
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec);
void onRecordFound(Record *r);
void onError();
void onInvalid();
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec)override;
void onRecordFound(const std::shared_ptr<Record> &r)override;
void onError()override;
void onInvalid()override;
};
// Listener class NEED to copy the shared pointer
......@@ -82,10 +82,10 @@ class OnStaticBindListener : public ContactUpdateListener {
public:
OnStaticBindListener(const url_t *from, const sip_contact_t *ct);
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec);
void onRecordFound(Record *r);
void onError();
void onInvalid();
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec)override;
void onRecordFound(const std::shared_ptr<Record> &r)override;
void onError()override;
void onInvalid()override;
};
class FakeFetchListener : public ContactUpdateListener {
......@@ -93,11 +93,10 @@ class FakeFetchListener : public ContactUpdateListener {
public:
FakeFetchListener();
void onRecordFound(Record *r);
void onError();
void onInvalid();
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec);
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec)override;
void onRecordFound(const std::shared_ptr<Record> &r)override;
void onError()override;
void onInvalid()override;
};
class ResponseContext {
......
......@@ -58,8 +58,8 @@ class ModuleRouter : public Module, public ModuleToolbox, public ForkContextList
virtual void onForkContextFinished(std::shared_ptr<ForkContext> ctx) override;
void sendReply(std::shared_ptr<RequestSipEvent> &ev, int code, const char *reason, int warn_code = 0, const char *warning = nullptr);
void routeRequest(std::shared_ptr<RequestSipEvent> &ev, Record *aor, const url_t *sipUri);
void onContactRegistered(const std::string &uid, Record *aor, const url_t *sipUri);
void routeRequest(std::shared_ptr<RequestSipEvent> &ev, const std::shared_ptr<Record> &aor, const url_t *sipUri);
void onContactRegistered(const std::string &uid, const std::shared_ptr<Record> &aor, const url_t *sipUri);
const std::string &getFallbackRoute() const {
return mFallbackRoute;
......@@ -81,7 +81,7 @@ class ModuleRouter : public Module, public ModuleToolbox, public ForkContextList
}
protected:
bool makeGeneratedContactRoute(std::shared_ptr<RequestSipEvent> &ev, Record *aor,
bool makeGeneratedContactRoute(std::shared_ptr<RequestSipEvent> &ev, const std::shared_ptr<Record> &aor,
std::list<std::shared_ptr<ExtendedContact>> &ec_list);
virtual bool dispatch(const std::shared_ptr<RequestSipEvent> &ev, const std::shared_ptr<ExtendedContact> &contact,
std::shared_ptr<ForkContext> context, const std::string &targetUris);
......@@ -138,13 +138,13 @@ class OnContactRegisteredListener : public ContactRegisteredListener, public Con
su_home_deinit(&mHome);
}
void onContactRegistered(Record *r, const std::string &uid) {
void onContactRegistered(const std::shared_ptr<Record> &r, const std::string &uid) override{
LOGD("Listener found for topic = %s, uid = %s, sipUri = %s", r->getKey().c_str(), uid.c_str(), url_as_string(&mHome, mSipUri));
mUid = uid;
onRecordFound(r);
}
void onRecordFound(Record *r) {
void onRecordFound(const std::shared_ptr<Record> &r)override{
if (r) {
LOGD("Record found for uid = %s", mUid.c_str());
mModule->onContactRegistered(mUid, r, mSipUri);
......@@ -152,12 +152,12 @@ class OnContactRegisteredListener : public ContactRegisteredListener, public Con
LOGW("No record found for uid = %s", mUid.c_str());
}
}
void onError() {
void onError() override{
}
void onInvalid() {
void onInvalid() override{
}
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec) {
void onContactUpdated(const std::shared_ptr<ExtendedContact> &ec) override{
}
};
......
......@@ -195,10 +195,14 @@ class Record {
friend class RegistrarDb;
private:
Record(const Record &other) = delete; //disable copy constructor, this is unsafe due to su_home_t here.
void operator=(const Record &other) = delete; //disable assignement operator too
SofiaAutoHome mHome;
static void init();
std::list<std::shared_ptr<ExtendedContact>> mContacts;
std::list<std::shared_ptr<ExtendedContact>> mContactsToRemove;
std::string mKey;
url_t *mAor;
bool mIsDomain; /*is a domain registration*/
bool mOnlyStaticContacts;
......@@ -207,7 +211,9 @@ class Record {
static int sMaxContacts;
static bool sAssumeUniqueDomains;
Record(const url_t *aor);
static std::string extractUniqueId(const sip_contact_t *contact);
//Get address of record
const url_t *getAor()const;
void insertOrUpdateBinding(const std::shared_ptr<ExtendedContact> &ec, const std::shared_ptr<ContactUpdateListener> &listener);
const std::shared_ptr<ExtendedContact> extractContactByUniqueId(std::string uid);
sip_contact_t *getContacts(su_home_t *home, time_t now);
......@@ -245,6 +251,12 @@ class Record {
void cleanContactsToRemoveList() {
mContactsToRemove.clear();
}
/*
* Synthetise the pub-gruu address from an extended contact belonging to this Record.
* FIXME: Unfortunately this function is not widely used in Flexisip, instead there are several
* places where pub-gruu address is synthesized.
*/
url_t *getPubGruu(const std::shared_ptr<ExtendedContact> &ec, su_home_t *home);
/**
* Check if the contacts list size is < to max aor config option and remove older contacts to match restriction if needed
*/
......@@ -257,8 +269,10 @@ class Record {
time_t latestExpire() const;
time_t latestExpire(Agent *ag) const;
static std::list<std::string> route_to_stl(const sip_route_s *route);
void appendContactsFrom(Record *src);
void appendContactsFrom(const std::shared_ptr<Record> &src);
static std::string defineKeyFromUrl(const url_t *aor);
static url_t *makeUrlFromKey(su_home_t *home, const std::string &key);
static std::string extractUniqueId(const sip_contact_t *contact);
~Record();
bool haveOnlyStaticContacts() const {
......@@ -287,7 +301,7 @@ class RegistrarDbListener : public StatFinishListener {
* is held by the implementation and the object might be
* destroyed immediately after onRecordFound() has returned.
*/
virtual void onRecordFound(Record *r) = 0;
virtual void onRecordFound(const std::shared_ptr<Record> &r) = 0;
virtual void onError() = 0;
virtual void onInvalid() = 0;
};
......@@ -308,13 +322,13 @@ class ListContactUpdateListener {
virtual ~ListContactUpdateListener() = default;
virtual void onContactsUpdated() = 0;
std::vector<Record> records;
std::vector<std::shared_ptr<Record>> records;
};
class ContactRegisteredListener {
public:
virtual ~ContactRegisteredListener();
virtual void onContactRegistered(Record *r, const std::string &uid) = 0;
virtual void onContactRegistered(const std::shared_ptr<Record> &r, const std::string &uid) = 0;
};
class LocalRegExpireListener {
......@@ -359,7 +373,7 @@ class RegistrarDb {
void fetch(const url_t *url, const std::shared_ptr<ContactUpdateListener> &listener, bool includingDomains, bool recursive);
void fetchForGruu(const url_t *url, const std::string &gruu, const std::shared_ptr<ContactUpdateListener> &listener);
void fetchList(const std::vector<url_t *> urls, const std::shared_ptr<ListContactUpdateListener> &listener);
void notifyContactListener (Record *r, const std::string &uid);
void notifyContactListener (const std::shared_ptr<Record> &r, const std::string &uid);
void updateRemoteExpireTime(const std::string &key, time_t expireat);
unsigned long countLocalActiveRecords() {
return mLocalRegExpire->countActives();
......@@ -397,7 +411,7 @@ class RegistrarDb {
std::lock_guard<std::mutex> lock(mMutex);
mRegMap.erase(key);
}
void update(const Record &record);
void update(const std::shared_ptr<Record> &record);
size_t countActives();
void removeExpiredBefore(time_t before);
LocalRegExpire(Agent *ag);
......@@ -425,7 +439,6 @@ class RegistrarDb {
RegistrarDb(Agent *ag);
virtual ~RegistrarDb();
std::map<std::string, Record *> mRecords;
std::multimap<std::string, std::shared_ptr<ContactRegisteredListener>> mContactListenersMap;
std::list<std::shared_ptr<RegistrarDbStateListener>> mStateListeners;
LocalRegExpire *mLocalRegExpire;
......
Subproject commit 9f908b1061828cf361b91e21c8a5b64f41e73ea2
Subproject commit 7be5e0451622687204e591cd8bb906e31cd9b94a
......@@ -236,14 +236,18 @@ if(ENABLE_CONFERENCE)
conference/conference-address-generator.hh
conference/conference-server.cc
conference/conference-server.hh
conference/participant-capabilities-check.cc
conference/participant-capabilities-check.hh
conference/participant-devices-search.cc
conference/participant-devices-search.hh
conference/participant-registration-subscription.cc
conference/participant-registration-subscription.hh
conference/registration-subscription.cc
conference/registration-subscription.hh
conference/participant-registration-subscription-handler.cc
conference/participant-registration-subscription-handler.hh
# conference/participant-capabilities-check.cc
# conference/participant-capabilities-check.hh
# conference/participant-devices-search.cc
# conference/participant-devices-search.hh
# conference/participant-registration-subscription.cc
# conference/participant-registration-subscription.hh
)
endif()
......
......@@ -23,6 +23,8 @@
/* cJSON */
/* JSON parser in C. */
#include "bctoolbox/defs.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
......@@ -38,7 +40,8 @@ const char *cJSON_GetErrorPtr() {return ep;}
static int cJSON_strcasecmp(const char *s1,const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
if (!s1) return (s1==s2)?0:1;
if (!s2) return 1;
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
......@@ -180,8 +183,11 @@ static const char *parse_string(cJSON *item,const char *str)
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
BCTBX_NO_BREAK;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
BCTBX_NO_BREAK;
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
BCTBX_NO_BREAK;
case 1: *--ptr2 =(uc | firstByteMark[len]);
}
ptr2+=len;
......@@ -458,7 +464,8 @@ static char *print_object(cJSON *item,int depth,int fmt)
*ptr++=':';if (fmt) *ptr++='\t';
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0;
if (fmt) *ptr++='\n';
*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]);
}
......@@ -484,8 +491,14 @@ void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;
if (!c) return 0;
if (c->prev) c->prev->next=c->next;
if (c->next) c->next->prev=c->prev;
if (c==array->child) array->child=c->next;
c->prev=c->next=0;
return c;
}
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
......
......@@ -32,6 +32,7 @@
#include <flexisip/registrardb.hh>
using namespace flexisip;
using namespace std;
CommandLineInterface::CommandLineInterface(const std::string &name) : mName(name) {
if (pipe(mControlFds) == -1)
......@@ -321,7 +322,7 @@ void ProxyCommandLineInterface::handle_registrar_clear_command(unsigned int sock
ClearListener(ProxyCommandLineInterface *cli, unsigned int socket, const std::string &uri)
: mCli(cli), mSocket(socket), mUri(uri) {}
void onRecordFound(Record *r) override {
void onRecordFound(const shared_ptr<Record> &r) override {
RegistrarDb::get()->publish(mUri, "");
mCli->answer(mSocket, "Done: cleared record " + mUri);
}
......
......@@ -49,7 +49,7 @@ void ConferenceAddressGenerator::run () {
RegistrarDb::get()->fetch(url, shared_from_this(), false, false);
}
void ConferenceAddressGenerator::onRecordFound (Record *r) {
void ConferenceAddressGenerator::onRecordFound(const std::shared_ptr<Record> &r) {
if (mState == State::Fetching) {
if (r) {
run();
......
......@@ -48,7 +48,7 @@ namespace flexisip {
void run ();
private:
void onRecordFound (Record *r) override;
void onRecordFound (const std::shared_ptr<Record> &r) override;
void onError () override;
void onInvalid () override {}
void onContactUpdated (const std::shared_ptr<ExtendedContact> &ec) override {}
......
......@@ -22,8 +22,7 @@
#include "conference-address-generator.hh"
#include "conference-server.hh"
#include "participant-capabilities-check.hh"
#include "participant-devices-search.hh"
#include <flexisip/configmanager.hh>
......@@ -141,27 +140,6 @@ void ConferenceServer::onConferenceAddressGeneration (const shared_ptr<linphone:
generator->run();
}
void ConferenceServer::onParticipantDeviceFetchRequested (
const shared_ptr<linphone::ChatRoom> & cr,
const shared_ptr<const linphone::Address> & participantAddr
) {
shared_ptr<ParticipantDevicesSearch> search = make_shared<ParticipantDevicesSearch>(cr, participantAddr);
search->run();
}
void ConferenceServer::onParticipantsCapabilitiesChecked (
const shared_ptr<linphone::ChatRoom> & cr,
const shared_ptr<const linphone::Address> &deviceAddr,
const list<shared_ptr<linphone::Address> > & participantsAddr
) {
shared_ptr<ParticipantCapabilitiesCheck> check = make_shared<ParticipantCapabilitiesCheck>(
cr,
deviceAddr,
participantsAddr
);
check->run();
}
void flexisip::ConferenceServer::onParticipantRegistrationSubscriptionRequested (
const shared_ptr<linphone::ChatRoom> &cr,
const shared_ptr<const linphone::Address> &participantAddr
......@@ -193,10 +171,10 @@ void flexisip::ConferenceServer::bindAddresses () {
void flexisip::ConferenceServer::bindConference() {
class FakeListener : public ContactUpdateListener {
void onRecordFound(Record *r) {}
void onError() {}
void onInvalid() {}
void onContactUpdated(const shared_ptr<ExtendedContact> &ec) {
void onRecordFound(const std::shared_ptr<Record> &r) override{}
void onError()override {}
void onInvalid()override {}
void onContactUpdated(const shared_ptr<ExtendedContact> &ec)override {
SLOGD << "ConferenceServer: ExtendedContact contactId=" << ec->contactId() << " callId=" << ec->callId();
}
};
......
......@@ -25,6 +25,7 @@
#include <flexisip/registrardb.hh>
#include "service-server.hh"
#include "registration-subscription.hh"
#include "participant-registration-subscription-handler.hh"
......@@ -73,15 +74,7 @@ namespace flexisip {
// ChatRoomListener implementation
void onConferenceAddressGeneration (const std::shared_ptr<linphone::ChatRoom> &cr) override;
void onParticipantDeviceFetchRequested (
const std::shared_ptr<linphone::ChatRoom> &cr,
const std::shared_ptr<const linphone::Address> & participantAddr
) override;
void onParticipantsCapabilitiesChecked (
const std::shared_ptr<linphone::ChatRoom> &cr,
const std::shared_ptr<const linphone::Address> &deviceAddr,
const std::list<std::shared_ptr<linphone::Address> > & participantsAddr
) override;
void onParticipantRegistrationSubscriptionRequested (
const std::shared_ptr<linphone::ChatRoom> &cr,
const std::shared_ptr<const linphone::Address> & participantAddr
......@@ -106,4 +99,4 @@ namespace flexisip {
static Init sStaticInit;
static SofiaAutoHome mHome;
};
} // namespace flexisip
\ No newline at end of file
} // namespace flexisip
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2018 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "participant-capabilities-check.hh"
using namespace flexisip;
using namespace std;
ParticipantCapabilitiesCheck::ParticipantCapabilitiesCheck (
const shared_ptr<linphone::ChatRoom> &cr,
const shared_ptr<const linphone::Address> &deviceAddr,
const list<shared_ptr<linphone::Address>> &list
) : mChatRoom(cr), mDeviceAddr(deviceAddr), mParticipantsList(list) {
mIterator = mParticipantsList.begin();
}
void ParticipantCapabilitiesCheck::run () {
url_t *url = url_make(mHome.home(), mIterator->get()->asStringUriOnly().c_str());
RegistrarDb::get()->fetch(url, shared_from_this(), false, false);
}
void ParticipantCapabilitiesCheck::onRecordFound (Record *r) {
if (r) {
for (const shared_ptr<ExtendedContact> &ec : r->getExtendedContacts()) {
string uri = ExtendedContact::urlToString(ec->mSipContact->m_url);
shared_ptr<linphone::Address> addr = linphone::Factory::get()->createAddress(uri);
if (!addr->getUriParam("gr").empty()
&& (ec->getOrgLinphoneSpecs().find("groupchat") != string::npos)
) {
mParticipantsCompatibleList.push_back(*mIterator);
break;
}
}
}
mIterator++;
if (mIterator != mParticipantsList.end())
run();
else
mChatRoom->addCompatibleParticipants(mDeviceAddr, mParticipantsCompatibleList);
}
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2018 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <list>
#include <linphone++/linphone.hh>
#include <flexisip/registrardb.hh>
namespace flexisip {
class ParticipantCapabilitiesCheck
: public ContactUpdateListener
, public std::enable_shared_from_this<ParticipantCapabilitiesCheck>
{
public:
ParticipantCapabilitiesCheck (
const std::shared_ptr<linphone::ChatRoom> &cr,
const std::shared_ptr<const linphone::Address> &deviceAddr,
const std::list<std::shared_ptr<linphone::Address>> &list
);
void run ();
private:
void onRecordFound (Record *r) override;
void onError () override {}
void onInvalid () override {}
void onContactUpdated (const std::shared_ptr<ExtendedContact> &ec) override {}
SofiaAutoHome mHome;
const std::shared_ptr<linphone::ChatRoom> mChatRoom;
std::shared_ptr<const linphone::Address> mDeviceAddr;
std::list<std::shared_ptr<linphone::Address>> mParticipantsList;
std::list<std::shared_ptr<linphone::Address>> mParticipantsCompatibleList;
std::list<std::shared_ptr<linphone::Address>>::iterator mIterator;
};
} // namespace flexisip
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2018 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "participant-devices-search.hh"
using namespace flexisip;
using namespace std;
ParticipantDevicesSearch::ParticipantDevicesSearch (
const shared_ptr<linphone::ChatRoom> &cr,
const shared_ptr<const linphone::Address> &uri
) : mChatRoom(cr), mSipUri(uri) {}
void ParticipantDevicesSearch::run () {
url_t *url = url_make(mHome.home(), mSipUri->asStringUriOnly().c_str());
RegistrarDb::get()->fetch(url, shared_from_this(), false, false);
}
void ParticipantDevicesSearch::onRecordFound (Record *r) {
if (!r) return;
list<shared_ptr<linphone::ParticipantDeviceIdentity>> listDeviceIdentities;
for (const shared_ptr<ExtendedContact> &ec : r->getExtendedContacts()) {
string uri = ExtendedContact::urlToString(ec->mSipContact->m_url);
shared_ptr<linphone::Address> addr = linphone::Factory::get()->createAddress(uri);
if (!addr->getUriParam("gr").empty()
&& (ec->getOrgLinphoneSpecs().find("groupchat") != string::npos)
) {
shared_ptr<linphone::Address> deviceAddr = linphone::Factory::get()->createAddress(
mSipUri->asStringUriOnly()
);
deviceAddr->setUriParam("gr", addr->getUriParam("gr"));
const string &userAgent = ec->getUserAgent();
size_t begin = userAgent.find("(");
string deviceName = "";
if (begin != string::npos) {
size_t end = userAgent.find(")", begin);
deviceName = userAgent.substr(begin + 1, end - (begin + 1));
}
shared_ptr<linphone::ParticipantDeviceIdentity> identity = linphone::Factory::get()->createParticipantDeviceIdentity(deviceAddr, deviceName);
listDeviceIdentities.push_back(identity);
}
}
mChatRoom->setParticipantDevices(mSipUri, listDeviceIdentities);
}
/*
Flexisip, a flexible SIP proxy server with media capabilities.
Copyright (C) 2018 Belledonne Communications SARL.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <linphone++/linphone.hh>
#include <flexisip/registrardb.hh>
namespace flexisip {
class ParticipantDevicesSearch
: public ContactUpdateListener
, public std::enable_shared_from_this<ParticipantDevicesSearch>
{
public:
ParticipantDevicesSearch (
const std::shared_ptr<linphone::ChatRoom> &cr,
const std::shared_ptr<const linphone::Address> &uri
);
void run ();
private:
void onRecordFound (Record *r) override;
void onError () override {}
void onInvalid () override {}
void onContactUpdated (const std::shared_ptr<ExtendedContact> &ec) override {}
SofiaAutoHome mHome;
const std::shared_ptr<linphone::ChatRoom> mChatRoom;
const std::shared_ptr<const linphone::Address> mSipUri;
};
} // namespace flexisip
......@@ -18,13 +18,14 @@
#include "participant-registration-subscription-handler.hh"
using namespace flexisip;
using namespace std;
string ParticipantRegistrationSubscriptionHandler::getKey (const shared_ptr<const linphone::Address> &address) {
return address->getUsername() + "@" + address->getDomain();
ostringstream ostr;
ostr << address->getUsername() << "@" << address->getDomain();
return ostr.str();
}
void ParticipantRegistrationSubscriptionHandler::subscribe (
......@@ -41,11 +42,9 @@ void ParticipantRegistrationSubscriptionHandler::subscribe (
}
}
if (toSubscribe) {
SLOGI << "Subscribe to RegistrarDB for key '" << key << "' and ChatRoom '"
<< chatRoom->getLocalAddress()->asString() << "'";
auto subscription = make_shared<ParticipantRegistrationSubscription>(address, chatRoom);
shared_ptr<OwnRegistrationSubscription> subscription(new OwnRegistrationSubscription(chatRoom, address));
mSubscriptions.insert(make_pair(key, subscription));
RegistrarDb::get()->subscribe(key, subscription);
subscription->start();
}
}
......@@ -57,9 +56,7 @@ void ParticipantRegistrationSubscriptionHandler::unsubscribe (
auto range = mSubscriptions.equal_range(key);
for (auto it = range.first; it != range.second;) {
if (it->second->getChatRoom() == chatRoom) {
SLOGI << "Unsubscribe from RegistrarDB for key '" << key << "' and ChatRoom '"
<< chatRoom->getLocalAddress()->asString() << "'";
RegistrarDb::get()->unsubscribe(key, it->second);
it->second->stop();