Commit cc49b6f5 authored by Benjamin REIS's avatar Benjamin REIS

add subscribe to conf event api

parent 8f645956
......@@ -38,6 +38,9 @@ set(LINPHONE_PRIVATE_HEADER_FILES
../src/object/object.h
../src/object/singleton.h
../src/utils/general.h
../src/conference/conference-listener.h
../src/conference/conference-event-package.h
../src/conference/conference-info.hxx
bellesip_sal/sal_impl.h
carddav.h
conference_private.h
......@@ -122,7 +125,12 @@ set(LINPHONE_SOURCE_FILES_C
xmlrpc.c
vtables.c
)
set(LINPHONE_SOURCE_FILES_CXX conference.cc)
set(LINPHONE_SOURCE_FILES_CXX
conference.cc
../src/conference/conference-event-package.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)
if(ANDROID)
list(APPEND LINPHONE_SOURCE_FILES_CXX linphonecore_jni.cc)
set_source_files_properties(linphonecore_jni.cc PROPERTIES COMPILE_DEFINITIONS "USE_JAVAH")
......@@ -158,6 +166,7 @@ set(LIBS
${MEDIASTREAMER2_LIBRARIES}
${ORTP_LIBRARIES}
${XML2_LIBRARIES}
/usr/local/Cellar/xerces-c/3.1.4/lib/libxerces-c.dylib
)
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
list(APPEND LIBS "Ws2_32")
......
......@@ -45,6 +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"
#ifdef INET6
#ifndef _WIN32
......@@ -2115,12 +2116,23 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
linphone_friend_list_notify_presence_received(list, lev, body);
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));
}
}
}
static void linphone_core_internal_subscription_state_changed(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
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) {
}
}
}
......
/*
* conference-event-package.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 "conference-event-package.h"
#include "conference-info.hxx"
#include "private.h"
using namespace std;
using namespace conference_info;
using namespace LinphonePrivate;
class LinphonePrivate::Conference::ConferenceEventPackagePrivate : public ObjectPrivate {
public:
LinphoneCore *lc;
ConferenceListener *listener;
LinphoneAddress *confAddr;
string confId;
LinphoneEvent *lev;
};
Conference::ConferenceEventPackage::ConferenceEventPackage(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr) : Object(new Conference::ConferenceEventPackagePrivate) {
L_D(ConferenceEventPackage);
xercesc::XMLPlatformUtils::Initialize();
d->lc = lc;
d->listener = listener;
d->confAddr = confAddr;
linphone_address_ref(confAddr);
d->lev = NULL;
}
Conference::ConferenceEventPackage::~ConferenceEventPackage() {
L_D(ConferenceEventPackage);
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);
d->confId = confId;
d->lev = linphone_core_create_subscribe(d->lc, d->confAddr, "Conference", 600);
linphone_event_ref(d->lev);
linphone_event_set_internal(d->lev, TRUE);
linphone_event_set_user_data(d->lev, this);
linphone_event_add_custom_header(d->lev, "Conf-id", d->confId.c_str()); // TODO : ???
linphone_event_send_subscribe(d->lev, NULL);
}
void Conference::ConferenceEventPackage::unsubscribe() {
L_D(ConferenceEventPackage);
linphone_event_terminate(d->lev);
}
void Conference::ConferenceEventPackage::notifyReceived(const char *xmlBody) {
L_D(ConferenceEventPackage);
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) {
for (const auto &user : confInfo->getUsers()->getUser()) {
LinphoneAddress *addr = linphone_core_interpret_url(d->lc, user.getEntity()->c_str());
if(user.getState() == "deleted") {
d->listener->participantRemoved(addr);
} else {
bool isAdmin = false;
if(user.getRoles()) {
for (const auto &entry : user.getRoles()->getEntry()) {
if (entry == "admin") {
isAdmin = true;
break;
}
}
}
if(user.getState() == "full") {
d->listener->participantAdded(addr);
}
d->listener->participantSetAdmin(addr, isAdmin);
}
linphone_address_unref(addr);
}
}
}
string Conference::ConferenceEventPackage::getConfId() {
L_D(ConferenceEventPackage);
return d->confId;
}
/*
* conference-event-package.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 _CONFERENCE_EVENT_PACKAGE_H_
#define _CONFERENCE_EVENT_PACKAGE_H_
#include <string>
#include "object/object.h"
#include "conference-listener.h"
#include "linphone/core.h"
namespace LinphonePrivate {
namespace Conference {
class ConferenceEventPackagePrivate;
// -------------------------------------------------------------------------
// ConferenceEventPackage.
// -------------------------------------------------------------------------
class ConferenceEventPackage : public Object {
public:
ConferenceEventPackage(LinphoneCore *lc, ConferenceListener *listener, LinphoneAddress *confAddr);
~ConferenceEventPackage();
void subscribe(std::string confId);
void notifyReceived(const char *xmlBody);
void unsubscribe();
std::string getConfId();
private:
L_DECLARE_PRIVATE(ConferenceEventPackage);
L_DISABLE_COPY(ConferenceEventPackage);
};
}
}
#endif // ifndef _CONFERENCE_EVENT_PACKAGE_H_
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*
* conference-listener.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 _CONFERENCE_LISTENER_H_
#define _CONFERENCE_LISTENER_H_
#include "linphone/core.h"
namespace LinphonePrivate {
namespace Conference {
// -------------------------------------------------------------------------
// ConferenceListener.
// -------------------------------------------------------------------------
class ConferenceListener {
public:
//virtual ~ConferenceListener() = 0;
virtual void conferenceCreated(LinphoneAddress *confAddress) = 0;
virtual void conferenceTerminated(LinphoneAddress *confAddress) = 0;
virtual void participantAdded(LinphoneAddress *addr) = 0;
virtual void participantRemoved(LinphoneAddress *addr) = 0;
virtual void participantSetAdmin(LinphoneAddress *addr, bool isAdmin) = 0;
};
}
}
#endif // ifndef _CONFERENCE_LISTENER_H_
\ No newline at end of file
This diff is collapsed.
......@@ -192,6 +192,10 @@ set(SOURCE_FILES_C
video_tester.c
)
set(SOURCE_FILES_CXX
confeventpackage_tester.cpp
)
set(SOURCE_FILES_OBJC )
if(APPLE)
if (IOS)
......@@ -200,6 +204,7 @@ if(APPLE)
endif()
bc_apply_compile_flags(SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
bc_apply_compile_flags(SOURCE_FILES_C_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
bc_apply_compile_flags(SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC)
if(MSVC)
......@@ -222,7 +227,7 @@ endif()
# on mobile platforms, we compile the tester as a library so that we can link with it directly from native applications
if(ANDROID OR IOS)
add_library(linphonetester SHARED ${SOURCE_FILES_C})
add_library(linphonetester SHARED ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
target_include_directories(linphonetester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(linphonetester ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER})
if(IOS)
......@@ -243,7 +248,7 @@ if(ANDROID OR IOS)
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
add_library(linphone_tester_static STATIC ${SOURCE_FILES_C})
add_library(linphone_tester_static STATIC ${SOURCE_FILES_C} ${SOURCE_FILES_CXX})
target_include_directories(linphone_tester_static PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(linphone_tester_static ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER})
......@@ -277,9 +282,9 @@ endif()
if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(IOS)
set_source_files_properties(${IOS_RESOURCES_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
add_executable(liblinphone_tester MACOSX_BUNDLE ${IOS_RESOURCES_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC})
add_executable(liblinphone_tester MACOSX_BUNDLE ${IOS_RESOURCES_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
else()
add_executable(liblinphone_tester ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC})
add_executable(liblinphone_tester ${SOURCE_FILES_C} ${SOURCE_FILES_CXX} ${SOURCE_FILES_OBJC})
endif()
set_target_properties(liblinphone_tester PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}")
set_target_properties(liblinphone_tester PROPERTIES LINKER_LANGUAGE CXX)
......@@ -312,4 +317,4 @@ if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
install(FILES ${IMAGE_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/liblinphone_tester/images")
install(FILES ${VCARD_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/liblinphone_tester/vcards")
endif()
endif()
endif()
\ No newline at end of file
This diff is collapsed.
......@@ -82,7 +82,11 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
counters->number_of_LinphoneSubscriptionActive++;
if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){
mgr->lev=lev;
linphone_event_notify(lev,content);
if(strcmp(linphone_event_get_name(lev), "Conference") == 0) {
linphone_conf_event_notify(lev);
} else {
linphone_event_notify(lev,content);
}
}
break;
case LinphoneSubscriptionTerminated:
......
......@@ -48,6 +48,7 @@ extern test_suite_t presence_test_suite;
extern test_suite_t presence_server_test_suite;
extern test_suite_t upnp_test_suite;
extern test_suite_t event_test_suite;
extern test_suite_t conf_event_test_suite;
extern test_suite_t flexisip_test_suite;
extern test_suite_t stun_test_suite;
extern test_suite_t remote_provisioning_test_suite;
......@@ -401,7 +402,7 @@ LinphoneAddress * linphone_core_manager_resolve(LinphoneCoreManager *mgr, const
FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres);
void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice );
void linphone_conf_event_notify(LinphoneEvent *lev);
#ifdef __cplusplus
};
......
......@@ -566,7 +566,7 @@ void liblinphone_tester_add_suites() {
#endif
bc_tester_add_suite(&stun_test_suite);
bc_tester_add_suite(&event_test_suite);
bc_tester_add_suite(&flexisip_test_suite);
bc_tester_add_suite(&conf_event_test_suite);
bc_tester_add_suite(&remote_provisioning_test_suite);
bc_tester_add_suite(&quality_reporting_test_suite);
bc_tester_add_suite(&log_collection_test_suite);
......
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