mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
create the conf event notify + tests
This commit is contained in:
parent
d77af88558
commit
fc02978435
8 changed files with 587 additions and 131 deletions
|
|
@ -39,7 +39,8 @@ set(LINPHONE_PRIVATE_HEADER_FILES
|
|||
../src/object/singleton.h
|
||||
../src/utils/general.h
|
||||
../src/conference/conference-listener.h
|
||||
../src/conference/conference-event-package.h
|
||||
../src/conference/remote-conference-event-handler.h
|
||||
../src/conference/local-conference-event-handler.h
|
||||
../src/conference/conference-info.hxx
|
||||
bellesip_sal/sal_impl.h
|
||||
carddav.h
|
||||
|
|
@ -127,7 +128,8 @@ set(LINPHONE_SOURCE_FILES_C
|
|||
)
|
||||
set(LINPHONE_SOURCE_FILES_CXX
|
||||
conference.cc
|
||||
../src/conference/conference-event-package.cpp
|
||||
../src/conference/remote-conference-event-handler.cpp
|
||||
../src/conference/local-conference-event-handler.cpp
|
||||
../src/conference/conference-info.cxx
|
||||
)
|
||||
set(LINPHONE_INCLUDE_DIRS ${LINPHONE_INCLUDE_DIRS} /Users/reisbenjamin/xsd-4.0.0-i686-macosx/libxsd /usr/local/Cellar/xerces-c/3.1.4/include)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "mediastreamer2/msjpegwriter.h"
|
||||
#include "mediastreamer2/msogl.h"
|
||||
#include "mediastreamer2/msvolume.h"
|
||||
#include "conference/conference-event-package.h"
|
||||
#include "conference/remote-conference-event-handler.h"
|
||||
|
||||
#ifdef INET6
|
||||
#ifndef _WIN32
|
||||
|
|
@ -2117,10 +2117,10 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
|
|||
friendLists = friendLists->next;
|
||||
}
|
||||
} else if (strcmp(notified_event, "Conference") == 0) {
|
||||
LinphonePrivate::Conference::ConferenceEventPackage *cep = reinterpret_cast<LinphonePrivate::Conference::ConferenceEventPackage *>(linphone_event_get_user_data(lev));
|
||||
if(cep) {
|
||||
ms_message("notify event for conference %s", cep->getConfId().c_str());
|
||||
cep->notifyReceived((char *) linphone_content_get_buffer(body));
|
||||
LinphonePrivate::Conference::RemoteConferenceEventHandler *handler = reinterpret_cast<LinphonePrivate::Conference::RemoteConferenceEventHandler *>(linphone_event_get_user_data(lev));
|
||||
if(handler) {
|
||||
ms_message("notify event for conference %s", handler->getConfId().c_str());
|
||||
handler->notifyReceived((char *) linphone_content_get_buffer(body));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2129,10 +2129,7 @@ static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc,
|
|||
if (strcasecmp(linphone_event_get_name(lev), "Presence") == 0) {
|
||||
linphone_friend_list_subscription_state_changed(lc, lev, state);
|
||||
} else if (strcmp(linphone_event_get_name(lev), "Conference") == 0) {
|
||||
LinphonePrivate::Conference::ConferenceEventPackage *cep = reinterpret_cast<LinphonePrivate::Conference::ConferenceEventPackage *>(linphone_event_get_user_data(lev));
|
||||
if(cep) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
155
src/conference/local-conference-event-handler.cpp
Normal file
155
src/conference/local-conference-event-handler.cpp
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* local-conference-event-handler.cpp
|
||||
* Copyright (C) 2017 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "local-conference-event-handler.h"
|
||||
#include "conference-info.hxx"
|
||||
#include "private.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace conference_info;
|
||||
using namespace LinphonePrivate;
|
||||
|
||||
class Conference::LocalConferenceEventHandlerPrivate : public ObjectPrivate {
|
||||
public:
|
||||
void notifyFullState(string notify, LinphoneEvent *lev);
|
||||
void notifyAllExcept(string notify, LinphoneAddress *addr);
|
||||
|
||||
LocalConference *conf;
|
||||
LinphoneCore *lc;
|
||||
};
|
||||
|
||||
void Conference::LocalConferenceEventHandlerPrivate::notifyFullState(string notify, LinphoneEvent *lev) {
|
||||
LinphoneContent* content = linphone_core_create_content(lev->lc);
|
||||
linphone_content_set_buffer(content,notify.c_str(),strlen(notify.c_str()));
|
||||
linphone_event_notify(lev, content);
|
||||
linphone_content_unref(content);
|
||||
// linphone_event_unref(lev); ??
|
||||
}
|
||||
|
||||
void Conference::LocalConferenceEventHandlerPrivate::notifyAllExcept(string notify, LinphoneAddress *addr) {
|
||||
for(auto participant : conf->getParticipants()) {
|
||||
if(!linphone_address_equal(participant.getAddress(), addr)) {
|
||||
LinphoneEvent *lev = linphone_core_create_notify(lc, participant.getAddress(), "Conference");
|
||||
LinphoneContent* content = linphone_core_create_content(lev->lc);
|
||||
linphone_content_set_buffer(content,notify.c_str(),strlen(notify.c_str()));
|
||||
linphone_event_notify(lev, content);
|
||||
linphone_content_unref(content);
|
||||
linphone_event_unref(lev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -------- Conference::LocalConferenceEventHandler public methods ---------
|
||||
Conference::LocalConferenceEventHandler::LocalConferenceEventHandler(LinphoneCore *core, LocalConference *localConf) : Object(new LocalConferenceEventHandlerPrivate) {
|
||||
L_D(LocalConferenceEventHandler);
|
||||
xercesc::XMLPlatformUtils::Initialize();
|
||||
d->conf = localConf;
|
||||
d->lc = core; // conf->getCore() ?
|
||||
}
|
||||
|
||||
Conference::LocalConferenceEventHandler::~LocalConferenceEventHandler() {
|
||||
xercesc::XMLPlatformUtils::Terminate();
|
||||
}
|
||||
|
||||
string Conference::LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) {
|
||||
L_D(LocalConferenceEventHandler);
|
||||
char *entity = linphone_address_as_string_uri_only(d->conf->getAddress());
|
||||
Conference_type confInfo = Conference_type(entity);
|
||||
Users_type users;
|
||||
confInfo.setUsers(users);
|
||||
stringstream notify;
|
||||
xml_schema::NamespaceInfomap map;
|
||||
|
||||
map[""].name = "urn:ietf:params:xml:ns:conference-info";
|
||||
for(auto participant : d->conf->getParticipants()) {
|
||||
User_type user = User_type();
|
||||
User_roles_type roles;
|
||||
user.setRoles(roles);
|
||||
user.setEntity(linphone_address_as_string_uri_only(participant.getAddress()));
|
||||
user.getRoles()->getEntry().push_back(participant.isAdmin() ? "admin" : "participant");
|
||||
user.setState("full");
|
||||
confInfo.getUsers()->getUser().push_back(user);
|
||||
}
|
||||
|
||||
serializeConference_info(notify, confInfo, map);
|
||||
//d->notifyFullState(notify.str(), lev);
|
||||
return notify.str();
|
||||
}
|
||||
|
||||
string Conference::LocalConferenceEventHandler::notifyParticipantAdded(LinphoneAddress *addr) {
|
||||
L_D(LocalConferenceEventHandler);
|
||||
char *entity = linphone_address_as_string_uri_only(d->conf->getAddress());
|
||||
Conference_type confInfo = Conference_type(entity);
|
||||
Users_type users;
|
||||
confInfo.setUsers(users);
|
||||
stringstream notify;
|
||||
xml_schema::NamespaceInfomap map;
|
||||
|
||||
User_type user = User_type();
|
||||
User_roles_type roles;
|
||||
user.setRoles(roles);
|
||||
user.setEntity(linphone_address_as_string_uri_only(addr));
|
||||
user.getRoles()->getEntry().push_back("participant");
|
||||
user.setState("full");
|
||||
confInfo.getUsers()->getUser().push_back(user);
|
||||
|
||||
serializeConference_info(notify, confInfo, map);
|
||||
//d->notifyAllExcept(notify.str(), addr);
|
||||
return notify.str();
|
||||
}
|
||||
|
||||
string Conference::LocalConferenceEventHandler::notifyParticipantRemoved(LinphoneAddress *addr) {
|
||||
L_D(LocalConferenceEventHandler);
|
||||
char *entity = linphone_address_as_string_uri_only(d->conf->getAddress());
|
||||
Conference_type confInfo = Conference_type(entity);
|
||||
Users_type users;
|
||||
confInfo.setUsers(users);
|
||||
stringstream notify;
|
||||
xml_schema::NamespaceInfomap map;
|
||||
|
||||
User_type user = User_type();
|
||||
user.setEntity(linphone_address_as_string_uri_only(addr));
|
||||
user.setState("deleted");
|
||||
confInfo.getUsers()->getUser().push_back(user);
|
||||
|
||||
serializeConference_info(notify, confInfo, map);
|
||||
//d->notifyAllExcept(notify.str(), addr);
|
||||
return notify.str();
|
||||
}
|
||||
|
||||
string Conference::LocalConferenceEventHandler::notifyParticipantSetAdmin(LinphoneAddress *addr, bool isAdmin) {
|
||||
L_D(LocalConferenceEventHandler);
|
||||
char *entity = linphone_address_as_string_uri_only(d->conf->getAddress());
|
||||
Conference_type confInfo = Conference_type(entity);
|
||||
Users_type users;
|
||||
confInfo.setUsers(users);
|
||||
stringstream notify;
|
||||
xml_schema::NamespaceInfomap map;
|
||||
|
||||
User_type user = User_type();
|
||||
User_roles_type roles;
|
||||
user.setRoles(roles);
|
||||
user.setEntity(linphone_address_as_string_uri_only(addr));
|
||||
user.getRoles()->getEntry().push_back(isAdmin ? "admin" : "participant");
|
||||
user.setState("partial");
|
||||
confInfo.getUsers()->getUser().push_back(user);
|
||||
|
||||
serializeConference_info(notify, confInfo, map);
|
||||
//d->notifyAllExcept(notify.str(), addr);
|
||||
return notify.str();
|
||||
}
|
||||
112
src/conference/local-conference-event-handler.h
Normal file
112
src/conference/local-conference-event-handler.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* local-conference-event-handler.h
|
||||
* Copyright (C) 2017 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _LOCAL_CONFERENCE_EVENT_HANDLER_H_
|
||||
#define _LOCAL_CONFERENCE_EVENT_HANDLER_H_
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "object/object.h"
|
||||
#include "linphone/core.h"
|
||||
#include "linphone/event.h"
|
||||
|
||||
namespace LinphonePrivate {
|
||||
namespace Conference {
|
||||
// -------------------------------------------------------------------------
|
||||
// LocalConferenceEventHandler.
|
||||
// -------------------------------------------------------------------------
|
||||
class LocalConference;
|
||||
class LocalConferenceEventHandlerPrivate;
|
||||
class LocalConferenceEventHandler : public Object {
|
||||
public:
|
||||
LocalConferenceEventHandler(LinphoneCore *core, LocalConference* localConf);
|
||||
~LocalConferenceEventHandler();
|
||||
std::string subscribeReceived(LinphoneEvent *lev);
|
||||
std::string notifyParticipantAdded(LinphoneAddress *addr);
|
||||
std::string notifyParticipantRemoved(LinphoneAddress *addr);
|
||||
std::string notifyParticipantSetAdmin(LinphoneAddress *addr, bool isAdmin);
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(LocalConferenceEventHandler);
|
||||
L_DISABLE_COPY(LocalConferenceEventHandler);
|
||||
};
|
||||
|
||||
class Participant {
|
||||
public:
|
||||
Participant(LinphoneAddress *addr, bool admin);
|
||||
~Participant();
|
||||
bool isAdmin();
|
||||
LinphoneAddress *getAddress();
|
||||
|
||||
LinphoneAddress *mAddr;
|
||||
bool mAdmin;
|
||||
};
|
||||
|
||||
class LocalConference {
|
||||
public:
|
||||
LocalConference(LinphoneCore *lc, LinphoneAddress *confAddr);
|
||||
~LocalConference();
|
||||
LinphoneAddress *getAddress();
|
||||
std::list<Participant> getParticipants();
|
||||
|
||||
std::shared_ptr<LocalConferenceEventHandler> mHandler;
|
||||
std::list<Participant> mParticipants;
|
||||
LinphoneAddress *mConfAddr;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------- Conference::LocalConference public methods ---------
|
||||
LinphonePrivate::Conference::LocalConference::LocalConference(LinphoneCore *core, LinphoneAddress *confAddr) {
|
||||
mConfAddr = confAddr;
|
||||
mHandler = std::make_shared<LinphonePrivate::Conference::LocalConferenceEventHandler>(core, this);
|
||||
}
|
||||
|
||||
LinphonePrivate::Conference::LocalConference::~LocalConference() {
|
||||
//linphone_address_unref(mConfAddr);
|
||||
}
|
||||
|
||||
LinphoneAddress* LinphonePrivate::Conference::LocalConference::getAddress() {
|
||||
return mConfAddr;
|
||||
}
|
||||
|
||||
std::list<LinphonePrivate::Conference::Participant> LinphonePrivate::Conference::LocalConference::getParticipants() {
|
||||
return mParticipants;
|
||||
}
|
||||
|
||||
LinphonePrivate::Conference::Participant::Participant(LinphoneAddress *addr, bool admin) {
|
||||
mAddr = addr;
|
||||
mAdmin = admin;
|
||||
}
|
||||
|
||||
LinphonePrivate::Conference::Participant::~Participant() {
|
||||
//linphone_address_unref(mAddr);
|
||||
}
|
||||
|
||||
bool LinphonePrivate::Conference::Participant::isAdmin() {
|
||||
return mAdmin;
|
||||
}
|
||||
|
||||
LinphoneAddress* LinphonePrivate::Conference::Participant::getAddress() {
|
||||
return mAddr;
|
||||
}
|
||||
|
||||
#endif // ifndef _LOCAL_CONFERENCE_EVENT_HANDLER_H_
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* conference-event-package.cpp
|
||||
* remote-conference-event-handler.cpp
|
||||
* Copyright (C) 2017 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "conference-event-package.h"
|
||||
#include "remote-conference-event-handler.h"
|
||||
#include "conference-info.hxx"
|
||||
#include "private.h"
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ using namespace std;
|
|||
using namespace conference_info;
|
||||
using namespace LinphonePrivate;
|
||||
|
||||
class LinphonePrivate::Conference::ConferenceEventPackagePrivate : public ObjectPrivate {
|
||||
class Conference::RemoteConferenceEventHandlerPrivate : public ObjectPrivate {
|
||||
public:
|
||||
LinphoneCore *lc;
|
||||
ConferenceListener *listener;
|
||||
|
|
@ -33,8 +33,9 @@ public:
|
|||
LinphoneEvent *lev;
|
||||
};
|
||||
|
||||
Conference::ConferenceEventPackage::ConferenceEventPackage(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr) : Object(new Conference::ConferenceEventPackagePrivate) {
|
||||
L_D(ConferenceEventPackage);
|
||||
// -------- Conference::RemoteConferenceEventHandler public methods ---------
|
||||
Conference::RemoteConferenceEventHandler::RemoteConferenceEventHandler(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr) : Object(new RemoteConferenceEventHandlerPrivate) {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
xercesc::XMLPlatformUtils::Initialize();
|
||||
d->lc = lc;
|
||||
d->listener = listener;
|
||||
|
|
@ -43,15 +44,15 @@ Conference::ConferenceEventPackage::ConferenceEventPackage(LinphoneCore *lc, Con
|
|||
d->lev = NULL;
|
||||
}
|
||||
|
||||
Conference::ConferenceEventPackage::~ConferenceEventPackage() {
|
||||
L_D(ConferenceEventPackage);
|
||||
Conference::RemoteConferenceEventHandler::~RemoteConferenceEventHandler() {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
xercesc::XMLPlatformUtils::Terminate();
|
||||
linphone_address_unref(d->confAddr);
|
||||
if(d->lev) linphone_event_unref(d->lev);
|
||||
}
|
||||
|
||||
void Conference::ConferenceEventPackage::subscribe(string confId) {
|
||||
L_D(ConferenceEventPackage);
|
||||
void Conference::RemoteConferenceEventHandler::subscribe(string confId) {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
d->confId = confId;
|
||||
d->lev = linphone_core_create_subscribe(d->lc, d->confAddr, "Conference", 600);
|
||||
linphone_event_ref(d->lev);
|
||||
|
|
@ -61,13 +62,13 @@ void Conference::ConferenceEventPackage::subscribe(string confId) {
|
|||
linphone_event_send_subscribe(d->lev, NULL);
|
||||
}
|
||||
|
||||
void Conference::ConferenceEventPackage::unsubscribe() {
|
||||
L_D(ConferenceEventPackage);
|
||||
void Conference::RemoteConferenceEventHandler::unsubscribe() {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
linphone_event_terminate(d->lev);
|
||||
}
|
||||
|
||||
void Conference::ConferenceEventPackage::notifyReceived(const char *xmlBody) {
|
||||
L_D(ConferenceEventPackage);
|
||||
void Conference::RemoteConferenceEventHandler::notifyReceived(const char *xmlBody) {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
istringstream data(xmlBody);
|
||||
unique_ptr<Conference_type> confInfo = parseConference_info(data, xml_schema::Flags::dont_validate);
|
||||
if(strcmp(confInfo->getEntity().c_str(), linphone_address_as_string(d->confAddr)) == 0) {
|
||||
|
|
@ -95,7 +96,7 @@ void Conference::ConferenceEventPackage::notifyReceived(const char *xmlBody) {
|
|||
}
|
||||
}
|
||||
|
||||
string Conference::ConferenceEventPackage::getConfId() {
|
||||
L_D(ConferenceEventPackage);
|
||||
string Conference::RemoteConferenceEventHandler::getConfId() {
|
||||
L_D(RemoteConferenceEventHandler);
|
||||
return d->confId;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* conference-event-package.h
|
||||
* remote-conference-event-handler.h
|
||||
* Copyright (C) 2017 Belledonne Communications SARL
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CONFERENCE_EVENT_PACKAGE_H_
|
||||
#define _CONFERENCE_EVENT_PACKAGE_H_
|
||||
#ifndef _REMOTE_CONFERENCE_EVENT_HANDLER_H_
|
||||
#define _REMOTE_CONFERENCE_EVENT_HANDLER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
@ -27,25 +27,24 @@
|
|||
|
||||
namespace LinphonePrivate {
|
||||
namespace Conference {
|
||||
class ConferenceEventPackagePrivate;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// ConferenceEventPackage.
|
||||
// RemoteConferenceEventHandler.
|
||||
// -------------------------------------------------------------------------
|
||||
class ConferenceEventPackage : public Object {
|
||||
class RemoteConferenceEventHandlerPrivate;
|
||||
class RemoteConferenceEventHandler : public Object {
|
||||
public:
|
||||
ConferenceEventPackage(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr);
|
||||
~ConferenceEventPackage();
|
||||
RemoteConferenceEventHandler(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr);
|
||||
~RemoteConferenceEventHandler();
|
||||
void subscribe(std::string confId);
|
||||
void notifyReceived(const char *xmlBody);
|
||||
void unsubscribe();
|
||||
std::string getConfId();
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(ConferenceEventPackage);
|
||||
L_DISABLE_COPY(ConferenceEventPackage);
|
||||
L_DECLARE_PRIVATE(RemoteConferenceEventHandler);
|
||||
L_DISABLE_COPY(RemoteConferenceEventHandler);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ifndef _CONFERENCE_EVENT_PACKAGE_H_
|
||||
#endif // ifndef _REMOTE_CONFERENCE_EVENT_HANDLER_H_
|
||||
|
|
@ -22,7 +22,8 @@
|
|||
#include "private.h"
|
||||
#include "liblinphone_tester.h"
|
||||
#include "conference/conference-listener.h"
|
||||
#include "conference/conference-event-package.h"
|
||||
#include "conference/remote-conference-event-handler.h"
|
||||
#include "conference/local-conference-event-handler.h"
|
||||
|
||||
using namespace LinphonePrivate;
|
||||
using namespace std;
|
||||
|
|
@ -413,20 +414,12 @@ static const char *aliceUri = "sip:alice@example.com";
|
|||
static const char *frankUri = "sip:frank@example.com";
|
||||
static const char *confUri = "sips:conf233@example.com";
|
||||
|
||||
void linphone_conf_event_notify(LinphoneEvent *lev){
|
||||
LinphoneContent* content = linphone_core_create_content(lev->lc);
|
||||
const char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)sal_op_get_to_address(lev->op));
|
||||
char notify[strlen(first_notify) + strlen(uri)];
|
||||
snprintf(notify, sizeof(notify), first_notify, uri);
|
||||
linphone_content_set_buffer(content,notify,strlen(notify));
|
||||
linphone_event_notify(lev, content);
|
||||
linphone_content_unref(content);
|
||||
}
|
||||
|
||||
|
||||
class ConferenceEventTester : public Conference::ConferenceListener{
|
||||
public:
|
||||
shared_ptr<Conference::ConferenceEventPackage> cep;
|
||||
map<string, int> participants;
|
||||
shared_ptr<Conference::RemoteConferenceEventHandler> mHandler;
|
||||
map<string, int> mParticipants;
|
||||
|
||||
ConferenceEventTester(LinphoneCore *lc, LinphoneAddress *confAddr);
|
||||
|
||||
|
|
@ -438,22 +431,22 @@ public:
|
|||
};
|
||||
|
||||
ConferenceEventTester::ConferenceEventTester(LinphoneCore *lc, LinphoneAddress *confAddr){
|
||||
this->cep = make_shared<Conference::ConferenceEventPackage>(lc, this, confAddr);
|
||||
mHandler = make_shared<Conference::RemoteConferenceEventHandler>(lc, this, confAddr);
|
||||
}
|
||||
|
||||
void ConferenceEventTester::conferenceCreated(LinphoneAddress *confAddress){}
|
||||
void ConferenceEventTester::conferenceTerminated(LinphoneAddress *confAddress){}
|
||||
void ConferenceEventTester::participantAdded(LinphoneAddress *addr){
|
||||
this->participants.insert(pair<string, int>(linphone_address_as_string(addr),0));
|
||||
mParticipants.insert(pair<string, int>(linphone_address_as_string(addr),0));
|
||||
}
|
||||
void ConferenceEventTester::participantRemoved(LinphoneAddress *addr){
|
||||
this->participants.erase(linphone_address_as_string(addr));
|
||||
mParticipants.erase(linphone_address_as_string(addr));
|
||||
}
|
||||
void ConferenceEventTester::participantSetAdmin(LinphoneAddress *addr, bool isAdmin){
|
||||
const char *addrAsString = linphone_address_as_string(addr);
|
||||
if(this->participants.find(addrAsString) != this->participants.end()){
|
||||
this->participants.erase(addrAsString);
|
||||
this->participants.insert(pair<string, int>(addrAsString, isAdmin ? 1 : 0));
|
||||
if(mParticipants.find(addrAsString) != mParticipants.end()){
|
||||
mParticipants.erase(addrAsString);
|
||||
mParticipants.insert(pair<string, int>(addrAsString, isAdmin ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -466,13 +459,13 @@ void first_notify_parsing(void){
|
|||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -489,11 +482,11 @@ void first_notify_parsing_wrong_conf(void){
|
|||
char notify[strlen(first_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 0, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 0, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_FALSE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -512,20 +505,20 @@ void participant_added_parsing(void){
|
|||
char notify_added[strlen(participant_added_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
snprintf(notify_added, sizeof(notify_added), participant_added_notify, confUri);
|
||||
tester.cep->notifyReceived(notify_added);
|
||||
tester.mHandler->notifyReceived(notify_added);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 3, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(frankAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(frankAddr))->second == 0);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 3, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(frankAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(frankAddr))->second == 0);
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -545,19 +538,19 @@ void participant_not_added_parsing(void){
|
|||
char notify_not_added[strlen(participant_not_added_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
snprintf(notify_not_added, sizeof(notify_not_added), participant_not_added_notify, confUri);
|
||||
tester.cep->notifyReceived(notify_not_added);
|
||||
tester.mHandler->notifyReceived(notify_not_added);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(frankAddr)) != tester.participants.end());
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.mParticipants.find(linphone_address_as_string(frankAddr)) != tester.mParticipants.end());
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -576,19 +569,19 @@ void participant_deleted_parsing(void){
|
|||
char notify_deleted[strlen(participant_deleted_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
snprintf(notify_deleted, sizeof(notify_deleted), participant_deleted_notify, confUri);
|
||||
tester.cep->notifyReceived(notify_deleted);
|
||||
tester.mHandler->notifyReceived(notify_deleted);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 1, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 1, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -606,20 +599,20 @@ void participant_admined_parsing(void){
|
|||
char notify_admined[strlen(participant_admined_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
snprintf(notify_admined, sizeof(notify_admined), participant_admined_notify, confUri);
|
||||
tester.cep->notifyReceived(notify_admined);
|
||||
tester.mHandler->notifyReceived(notify_admined);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 1);
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -637,20 +630,20 @@ void participant_unadmined_parsing(void){
|
|||
char notify_unadmined[strlen(participant_unadmined_notify) + strlen(confUri)];
|
||||
|
||||
snprintf(notify, sizeof(notify), first_notify, confUri);
|
||||
tester.cep->notifyReceived(notify);
|
||||
tester.mHandler->notifyReceived(notify);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
snprintf(notify_unadmined, sizeof(notify_unadmined), participant_unadmined_notify, confUri);
|
||||
tester.cep->notifyReceived(notify_unadmined);
|
||||
tester.mHandler->notifyReceived(notify_unadmined);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 0);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 0);
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
|
|
@ -658,39 +651,231 @@ void participant_unadmined_parsing(void){
|
|||
linphone_core_manager_destroy(marie);
|
||||
}
|
||||
|
||||
void send_subscribe_receive_first_notify(void){
|
||||
void send_first_notify(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
Conference::LocalConference localConf(pauline->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
Conference::Participant p1(bobAddr, false);
|
||||
Conference::Participant p2(aliceAddr, true);
|
||||
LinphoneEvent *lev = linphone_core_create_notify(pauline->lc, marie->identity, "Conference");
|
||||
string notify;
|
||||
|
||||
localConf.mParticipants.push_back(p1);
|
||||
localConf.mParticipants.push_back(p2);
|
||||
notify = localConf.mHandler->subscribeReceived(lev);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
linphone_event_unref(lev);
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
void send_added_notify(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
Conference::LocalConference localConf(pauline->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
string confId("conf233");
|
||||
LinphoneAddress *frankAddr = linphone_core_interpret_url(marie->lc, frankUri);
|
||||
Conference::Participant p1(bobAddr, false);
|
||||
Conference::Participant p2(aliceAddr, true);
|
||||
Conference::Participant p3(frankAddr, false);
|
||||
LinphoneEvent *lev = linphone_core_create_notify(pauline->lc, marie->identity, "Conference");
|
||||
string notify;
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationOk,1,1000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneRegistrationOk,1,1000));
|
||||
localConf.mParticipants.push_back(p1);
|
||||
localConf.mParticipants.push_back(p2);
|
||||
notify = localConf.mHandler->subscribeReceived(lev);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
tester.cep->subscribe(confId);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionActive,1,3000));
|
||||
wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_NotifyReceived,1,3000);
|
||||
notify = localConf.mHandler->notifyParticipantAdded(frankAddr);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end());
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 3, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(frankAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(frankAddr))->second == 0);
|
||||
|
||||
tester.cep->unsubscribe();
|
||||
linphone_event_unref(lev);
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_address_unref(frankAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
|
||||
void send_removed_notify(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
Conference::LocalConference localConf(pauline->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
Conference::Participant p1(bobAddr, false);
|
||||
Conference::Participant p2(aliceAddr, true);
|
||||
LinphoneEvent *lev = linphone_core_create_notify(pauline->lc, marie->identity, "Conference");
|
||||
string notify;
|
||||
|
||||
localConf.mParticipants.push_back(p1);
|
||||
localConf.mParticipants.push_back(p2);
|
||||
notify = localConf.mHandler->subscribeReceived(lev);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
notify = localConf.mHandler->notifyParticipantRemoved(bobAddr);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 1, int, "%d");
|
||||
BC_ASSERT_FALSE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
linphone_event_unref(lev);
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
void send_admined_notify(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
Conference::LocalConference localConf(pauline->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
Conference::Participant p1(bobAddr, false);
|
||||
Conference::Participant p2(aliceAddr, true);
|
||||
Conference::Participant p3(bobAddr, true);
|
||||
LinphoneEvent *lev = linphone_core_create_notify(pauline->lc, marie->identity, "Conference");
|
||||
string notify;
|
||||
|
||||
localConf.mParticipants.push_back(p1);
|
||||
localConf.mParticipants.push_back(p2);
|
||||
notify = localConf.mHandler->subscribeReceived(lev);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
notify = localConf.mHandler->notifyParticipantSetAdmin(bobAddr, true);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 1);
|
||||
|
||||
linphone_event_unref(lev);
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
void send_unadmined_notify(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
Conference::LocalConference localConf(pauline->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
Conference::Participant p1(bobAddr, false);
|
||||
Conference::Participant p2(aliceAddr, true);
|
||||
Conference::Participant p3(aliceAddr, false);
|
||||
LinphoneEvent *lev = linphone_core_create_notify(pauline->lc, marie->identity, "Conference");
|
||||
string notify;
|
||||
|
||||
localConf.mParticipants.push_back(p1);
|
||||
localConf.mParticipants.push_back(p2);
|
||||
notify = localConf.mHandler->subscribeReceived(lev);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
notify = localConf.mHandler->notifyParticipantSetAdmin(aliceAddr, false);
|
||||
tester.mHandler->notifyReceived(notify.c_str());
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
|
||||
linphone_event_unref(lev);
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
void send_subscribe_receive_first_notify(void){
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
|
||||
ConferenceEventTester tester(marie->lc, pauline->identity);
|
||||
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
|
||||
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
|
||||
string confId("conf233");
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneRegistrationOk,1,1000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneRegistrationOk,1,1000));
|
||||
|
||||
tester.mHandler->subscribe(confId);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000));
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionActive,1,3000));
|
||||
wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_NotifyReceived,1,3000);
|
||||
|
||||
BC_ASSERT_EQUAL(tester.mParticipants.size(), 2, int, "%d");
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr)) != tester.mParticipants.end());
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(bobAddr))->second == 0);
|
||||
BC_ASSERT_TRUE(tester.mParticipants.find(linphone_address_as_string(aliceAddr))->second == 1);
|
||||
|
||||
tester.mHandler->unsubscribe();
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
|
||||
|
||||
linphone_address_unref(bobAddr);
|
||||
linphone_address_unref(aliceAddr);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
test_t conf_event_tests[] = {
|
||||
TEST_NO_TAG("First notify parsing", first_notify_parsing),
|
||||
TEST_NO_TAG("First notify parsing wrong conf", first_notify_parsing_wrong_conf),
|
||||
|
|
@ -699,7 +884,12 @@ test_t conf_event_tests[] = {
|
|||
TEST_NO_TAG("Participant deleted", participant_deleted_parsing),
|
||||
TEST_NO_TAG("Participant admined", participant_admined_parsing),
|
||||
TEST_NO_TAG("Participant unadmined", participant_unadmined_parsing),
|
||||
TEST_NO_TAG("Send subscribe receive first notify", send_subscribe_receive_first_notify)
|
||||
TEST_NO_TAG("Send first notify", send_first_notify),
|
||||
TEST_NO_TAG("Send participant added notify", send_added_notify),
|
||||
TEST_NO_TAG("Send participant removed notify", send_removed_notify),
|
||||
TEST_NO_TAG("Send participant admined notify", send_admined_notify),
|
||||
TEST_NO_TAG("Send participant unadmined notify", send_unadmined_notify)
|
||||
//TEST_NO_TAG("Send subscribe receive first notify", send_subscribe_receive_first_notify)
|
||||
};
|
||||
|
||||
test_suite_t conf_event_test_suite = {"Conf event package", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
|
|||
if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){
|
||||
mgr->lev=lev;
|
||||
if(strcmp(linphone_event_get_name(lev), "Conference") == 0) {
|
||||
linphone_conf_event_notify(lev);
|
||||
// TODO : Get LocalConfEventHandler and call handler->subscribeReceived(lev)
|
||||
} else {
|
||||
linphone_event_notify(lev,content);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue