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 diff is collapsed.
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema
targetNamespace="urn:ietf:params:xml:ns:conference-info"
xmlns:tns="urn:ietf:params:xml:ns:conference-info"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:ietf:params:xml:ns:conference-info"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!--
This imports the xml:language definition
-->
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<!--
CONFERENCE ELEMENT
-->
<xs:element name="conference-info" type="conference-type"/>
<!--
CONFERENCE TYPE
-->
<xs:complexType name="conference-type">
<xs:sequence>
<xs:element name="conference-description"
type="conference-description-type" minOccurs="0"/>
<xs:element name="host-info"
type="host-type" minOccurs="0"/>
<xs:element name="conference-state"
type="conference-state-type" minOccurs="0"/>
<xs:element name="users"
type="users-type" minOccurs="0"/>
<xs:element name="sidebars-by-ref"
type="uris-type" minOccurs="0"/>
<xs:element name="sidebars-by-val"
type="sidebars-by-val-type" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="entity"
type="xs:anyURI" use="required"/>
<xs:attribute name="state"
type="state-type" use="optional" default="full"/>
<xs:attribute name="version"
type="xs:unsignedInt" use="optional"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
STATE TYPE
-->
<xs:simpleType name="state-type">
<xs:restriction base="xs:string">
<xs:enumeration value="full"/>
<xs:enumeration value="partial"/>
<xs:enumeration value="deleted"/>
</xs:restriction>
</xs:simpleType>
<!--
CONFERENCE DESCRIPTION TYPE
-->
<xs:complexType name="conference-description-type">
<xs:sequence>
<xs:element name="display-text"
type="xs:string" minOccurs="0"/>
<xs:element name="subject"
type="xs:string" minOccurs="0"/>
<xs:element name="free-text"
type="xs:string" minOccurs="0"/>
<xs:element name="keywords"
type="keywords-type" minOccurs="0"/>
<xs:element name="conf-uris"
type="uris-type" minOccurs="0"/>
<xs:element name="service-uris"
type="uris-type" minOccurs="0"/>
<xs:element name="maximum-user-count"
type="xs:unsignedInt" minOccurs="0"/>
<xs:element name="available-media"
type="conference-media-type" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
HOST TYPE
-->
<xs:complexType name="host-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="web-page" type="xs:anyURI"
minOccurs="0"/>
<xs:element name="uris" type="uris-type"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
CONFERENCE STATE TYPE
-->
<xs:complexType name="conference-state-type">
<xs:sequence>
<xs:element name="user-count" type="xs:unsignedInt"
minOccurs="0"/>
<xs:element name="active" type="xs:boolean"
minOccurs="0"/>
<xs:element name="locked" type="xs:boolean"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
CONFERENCE MEDIA TYPE
-->
<xs:complexType name="conference-media-type">
<xs:sequence>
<xs:element name="entry" type="conference-medium-type"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
CONFERENCE MEDIUM TYPE
-->
<xs:complexType name="conference-medium-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="type" type="xs:string"/>
<xs:element name="status" type="media-status-type"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="label" type="xs:string"
use="required"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
URIs TYPE
-->
<xs:complexType name="uris-type">
<xs:sequence>
<xs:element name="entry" type="uri-type"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="state" type="state-type"
use="optional" default="full"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
URI TYPE
-->
<xs:complexType name="uri-type">
<xs:sequence>
<xs:element name="uri" type="xs:anyURI"/>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="purpose" type="xs:string"
minOccurs="0"/>
<xs:element name="modified" type="execution-type"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
KEYWORDS TYPE
-->
<xs:simpleType name="keywords-type">
<xs:list itemType="xs:string"/>
</xs:simpleType>
<!--
USERS TYPE
-->
<xs:complexType name="users-type">
<xs:sequence>
<xs:element name="user" type="user-type"
minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="state" type="state-type"
use="optional" default="full"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
USER TYPE
-->
<xs:complexType name="user-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="associated-aors" type="uris-type"
minOccurs="0"/>
<xs:element name="roles" type="user-roles-type"
minOccurs="0"/>
<xs:element name="languages" type="user-languages-type"
minOccurs="0"/>
<xs:element name="cascaded-focus" type="xs:anyURI"
minOccurs="0"/>
<xs:element name="endpoint" type="endpoint-type"
minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="entity" type="xs:anyURI"/>
<xs:attribute name="state" type="state-type"
use="optional" default="full"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
USER ROLES TYPE
-->
<xs:complexType name="user-roles-type">
<xs:sequence>
<xs:element name="entry" type="xs:string"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
USER LANGUAGES TYPE
-->
<xs:simpleType name="user-languages-type">
<xs:list itemType="xs:language"/>
</xs:simpleType>
<!--
ENDPOINT TYPE
-->
<xs:complexType name="endpoint-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="referred" type="execution-type"
minOccurs="0"/>
<xs:element name="status" type="endpoint-status-type"
minOccurs="0"/>
<xs:element name="joining-method" type="joining-type"
minOccurs="0"/>
<xs:element name="joining-info"
type="execution-type"
minOccurs="0"/>
<xs:element name="disconnection-method"
type="disconnection-type"
minOccurs="0"/>
<xs:element name="disconnection-info"
type="execution-type"
minOccurs="0"/>
<xs:element name="media" type="media-type"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="call-info" type="call-type"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="entity" type="xs:string"/>
<xs:attribute name="state" type="state-type"
use="optional" default="full"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
ENDPOINT STATUS TYPE
-->
<xs:simpleType name="endpoint-status-type">
<xs:restriction base="xs:string">
<xs:enumeration value="pending"/>
<xs:enumeration value="dialing-out"/>
<xs:enumeration value="dialing-in"/>
<xs:enumeration value="alerting"/>
<xs:enumeration value="on-hold"/>
<xs:enumeration value="connected"/>
<xs:enumeration value="muted-via-focus"/>
<xs:enumeration value="disconnecting"/>
<xs:enumeration value="disconnected"/>
</xs:restriction>
</xs:simpleType>
<!--
JOINING TYPE
-->
<xs:simpleType name="joining-type">
<xs:restriction base="xs:string">
<xs:enumeration value="dialed-in"/>
<xs:enumeration value="dialed-out"/>
<xs:enumeration value="focus-owner"/>
</xs:restriction>
</xs:simpleType>
<!--
DISCONNECTION TYPE
-->
<xs:simpleType name="disconnection-type">
<xs:restriction base="xs:string">
<xs:enumeration value="departed"/>
<xs:enumeration value="booted"/>
<xs:enumeration value="failed"/>
<xs:enumeration value="busy"/>
</xs:restriction>
</xs:simpleType>
<!--
EXECUTION TYPE
-->
<xs:complexType name="execution-type">
<xs:sequence>
<xs:element name="when" type="xs:dateTime"
minOccurs="0"/>
<xs:element name="reason" type="xs:string"
minOccurs="0"/>
<xs:element name="by" type="xs:anyURI"
minOccurs="0"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
CALL TYPE
-->
<xs:complexType name="call-type">
<xs:choice>
<xs:element name="sip" type="sip-dialog-id-type"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
SIP DIALOG ID TYPE
-->
<xs:complexType name="sip-dialog-id-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="call-id" type="xs:string"/>
<xs:element name="from-tag" type="xs:string"/>
<xs:element name="to-tag" type="xs:string"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
MEDIA TYPE
-->
<xs:complexType name="media-type">
<xs:sequence>
<xs:element name="display-text" type="xs:string"
minOccurs="0"/>
<xs:element name="type" type="xs:string"
minOccurs="0"/>
<xs:element name="label" type="xs:string"
minOccurs="0"/>
<xs:element name="src-id" type="xs:string"
minOccurs="0"/>
<xs:element name="status" type="media-status-type"
minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"
use="required"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!--
MEDIA STATUS TYPE
-->
<xs:simpleType name="media-status-type">
<xs:restriction base="xs:string">
<xs:enumeration value="recvonly"/>
<xs:enumeration value="sendonly"/>
<xs:enumeration value="sendrecv"/>
<xs:enumeration value="inactive"/>
</xs:restriction>
</xs:simpleType>
<!--
SIDEBARS BY VAL TYPE
-->
<xs:complexType name="sidebars-by-val-type">
<xs:sequence>
<xs:element name="entry" type="conference-type"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="state" type="state-type"
use="optional" default="full"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:schema>
\ No newline at end of file