mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
start of implementing list subscription
This commit is contained in:
parent
12660bea3a
commit
1f4df0b4d8
9 changed files with 332 additions and 3 deletions
|
|
@ -183,7 +183,7 @@ ClientGroupChatRoom::ClientGroupChatRoom (
|
|||
RemoteConference(core, me, nullptr) {
|
||||
L_D_T(RemoteConference, dConference);
|
||||
L_D();
|
||||
|
||||
|
||||
IdentityAddress focusAddr(uri);
|
||||
dConference->focus = make_shared<Participant>(focusAddr);
|
||||
dConference->focus->getPrivate()->addDevice(focusAddr);
|
||||
|
|
@ -215,7 +215,7 @@ RemoteConference(core, me->getAddress(), nullptr) {
|
|||
getMe()->getPrivate()->setAdmin(me->isAdmin());
|
||||
|
||||
dConference->eventHandler->setLastNotify(lastNotifyId);
|
||||
dConference->eventHandler->subscribe(getChatRoomId());
|
||||
// dConference->eventHandler->subscribe(getChatRoomId());
|
||||
}
|
||||
|
||||
ClientGroupChatRoom::~ClientGroupChatRoom () {
|
||||
|
|
@ -478,7 +478,7 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
|
|||
void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
|
||||
L_D();
|
||||
d->setState(ChatRoom::State::Created);
|
||||
|
||||
|
||||
if (getParticipantCount() == 1) {
|
||||
ChatRoomId id(getParticipants().front()->getAddress(), getMe()->getAddress());
|
||||
shared_ptr<AbstractChatRoom> chatRoom = getCore()->findChatRoom(id);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* local-conference-list-event-handler.cpp
|
||||
* Copyright (C) 2010-2018 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "local-conference-list-event-handler.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* local-conference-list-event-handler.h
|
||||
* Copyright (C) 2010-2018 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _L_LOCAL_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
#define _L_LOCAL_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class LocalConferenceEventHandler;
|
||||
|
||||
class LocalConferenceListEventHandler : public Object {
|
||||
public:
|
||||
void subscribeReceived ();
|
||||
void notify ();
|
||||
void addHandler (std::shared_ptr<LocalConferenceEventHandler> handler);
|
||||
const std::list<std::shared_ptr<LocalConferenceEventHandler>> &getHandlers () const;
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<LocalConferenceEventHandler>> handlers;
|
||||
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _L_LOCAL_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
138
src/conference/handlers/remote-conference-list-event-handler.cpp
Normal file
138
src/conference/handlers/remote-conference-list-event-handler.cpp
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* remote-conference-list-event-handler.cpp
|
||||
* Copyright (C) 2010-2018 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "address/address.h"
|
||||
#include "content/content.h"
|
||||
#include "content/content-manager.h"
|
||||
#include "content/content-type.h"
|
||||
#include "remote-conference-event-handler.h"
|
||||
#include "remote-conference-list-event-handler.h"
|
||||
#include "xml/resource-lists.h"
|
||||
#include "xml/rlmi.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RemoteConferenceListEventHandler::subscribe () {
|
||||
if (lev)
|
||||
return;
|
||||
|
||||
Content *content;
|
||||
content.setContentType(ContentType::ResourceLists);
|
||||
|
||||
Xsd::ResourceLists::ResourceLists rl = Xsd::ResourceLists::ResourceLists();
|
||||
Xsd::ResourceLists::ListType l = Xsd::ResourceLists::ListType();
|
||||
for (const auto &handler : handlers) {
|
||||
const Address &addr = handler->getChatRoomId()->getPeerAddress();
|
||||
addr.setUriParam("Last-Notify", handler->getLastNotify());
|
||||
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asString());
|
||||
l.getEntry().push_back(entry);
|
||||
}
|
||||
rl.getList().push_back(l);
|
||||
|
||||
Xsd::XmlSchema::NamespaceInfomap map;
|
||||
stringstream xmlBody;
|
||||
serializeResourceLists(xmlBody, rl, map);
|
||||
content.setBody(xmlBody.str());
|
||||
|
||||
LinphoneAddress *rlsAddr = linphone_address_new();
|
||||
LinphoneCore *lc = getCore()->getCCore();
|
||||
LinphoneProxyConfig *cfg = linphone_core_lookup_known_proxy(lc, rlsAddr);
|
||||
if (!cfg || (linphone_proxy_config_get_state(cfg) != LinphoneRegistrationOk)) {
|
||||
linphone_address_unref(rlsAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
lev = linphone_event_ref(linphone_core_create_subscribe(lc, rlsAddr, "conference", 600));
|
||||
lev->op->set_from();
|
||||
linphone_address_unref(rlsAddr);
|
||||
linphone_event_set_content
|
||||
linphone_event_set_internal(lev, TRUE);
|
||||
linphone_event_set_user_data(lev, this);
|
||||
linphone_event_send_subscribe(lev, content.toLinphoneContent());
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::unsubscribe () {
|
||||
if (!lev)
|
||||
return;
|
||||
|
||||
linphone_event_terminate(lev);
|
||||
lev = nullptr;
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::notifyReceived (Content *multipart) {
|
||||
list<Content> contents = ContentManager::multipartToContentList(multipart);
|
||||
char *from = linphone_address_as_string(linphone_event_get_from(lev));
|
||||
const Address local(from);
|
||||
bctbx_free(from);
|
||||
map<Address, Address> addresses;
|
||||
for (const auto &content : contents) {
|
||||
const string &body = content.getBodyAsString();
|
||||
if (content.getContentType == ContentType::Rlmi) {
|
||||
addresses = parseRlmi(body);
|
||||
continue;
|
||||
}
|
||||
|
||||
ChatRoomId id(local, peer);
|
||||
shared_ptr<RemoteConferenceEventHandler> handler = findHandler(id);
|
||||
if (!handler)
|
||||
continue;
|
||||
|
||||
if (content.getContentType == ContentType::Multipart)
|
||||
handler->multipartNotifyReceived(body);
|
||||
else if (content.getContentType == ContentType::Conference)
|
||||
handler->notifyReceived(body);
|
||||
}
|
||||
}
|
||||
|
||||
map<Address, Address> RemoteConferenceListEventHandler::parseRlmi (const string &xmlBody) const {
|
||||
istringstream data(content.getBodyAsString());
|
||||
unique_ptr<Xsd::ResourceLists::ResourceLists> rl(Xsd::ResourceLists::parseResourceLists(
|
||||
data,
|
||||
Xsd::XmlSchema::Flags::dont_validate
|
||||
));
|
||||
map<Address, Address> addresses;
|
||||
for (const auto &l : rl->getList()) {
|
||||
for (const auto &entry : l.getEntry()) {
|
||||
if (entry)
|
||||
Address addr(entry.getUri());
|
||||
addresses.push_back(move(addr));
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::addHandler (std::shared_ptr<RemoteConferenceEventHandler> handler) {
|
||||
|
||||
}
|
||||
|
||||
shared_ptr<RemoteConferenceEventHandler> RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) {
|
||||
|
||||
}
|
||||
|
||||
const list<shared_ptr<RemoteConferenceEventHandler>> &RemoteConferenceListEventHandler::getHandlers () const {
|
||||
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* remote-conference-list-event-handler.h
|
||||
* Copyright (C) 2010-2018 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
#define _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class LinphoneEvent;
|
||||
class RemoteConferenceEventHandler;
|
||||
|
||||
class RemoteConferenceListEventHandler : public Object {
|
||||
public:
|
||||
void subscribe ();
|
||||
void unsubscribe ();
|
||||
void notifyReceived ();
|
||||
void addHandler (std::shared_ptr<RemoteConferenceEventHandler> handler);
|
||||
std::shared_ptr<RemoteConferenceEventHandler> findHandler (const ChatRoomId &chatRoomId) const;
|
||||
const std::list<std::shared_ptr<RemoteConferenceEventHandler>> &getHandlers () const;
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<RemoteConferenceEventHandler>> handlers;
|
||||
LinphoneEvent *lev;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
|
|
@ -48,6 +48,7 @@ const ContentType ContentType::ImIsComposing("application/im-iscomposing+xml");
|
|||
const ContentType ContentType::Multipart("multipart/mixed");
|
||||
const ContentType ContentType::PlainText("text/plain");
|
||||
const ContentType ContentType::ResourceLists("application/resource-lists+xml");
|
||||
const ContentType ContentType::Rlmi("application/rlmi+xml");
|
||||
const ContentType ContentType::Sdp("application/sdp");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -186,6 +187,7 @@ bool ContentType::isFile (const ContentType &contentType) {
|
|||
contentType != Imdn &&
|
||||
contentType != ImIsComposing &&
|
||||
contentType != ResourceLists &&
|
||||
contentType != Rlmi &&
|
||||
contentType != Sdp &&
|
||||
contentType != Cpim &&
|
||||
contentType != ConferenceInfo;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public:
|
|||
static const ContentType Multipart;
|
||||
static const ContentType PlainText;
|
||||
static const ContentType ResourceLists;
|
||||
static const ContentType Rlmi;
|
||||
static const ContentType Sdp;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ def main(argv = None):
|
|||
generate("xml")
|
||||
generate("conference-info")
|
||||
generate("resource-lists")
|
||||
generate("rlmi")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
|
|||
68
src/xml/rlmi.xsd
Normal file
68
src/xml/rlmi.xsd
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xs:schema targetNamespace="urn:ietf:params:xml:ns:rlmi"
|
||||
elementFormDefault="qualified"
|
||||
xmlns="urn:ietf:params:xml:ns:rlmi"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
|
||||
schemaLocation="http://www.w3.org/2001/xml.xsd"/>
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="name" minOccurs="0"
|
||||
maxOccurs="unbounded" />
|
||||
<xs:element ref="resource" minOccurs="0"
|
||||
maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="uri" type="xs:anyURI" use="required" />
|
||||
<xs:attribute name="version" type="xs:unsignedInt"
|
||||
use="required" />
|
||||
<xs:attribute name="fullState" type="xs:boolean"
|
||||
use="required" />
|
||||
<xs:attribute name="cid" type="xs:string" use="optional" />
|
||||
<xs:anyAttribute processContents="lax" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="resource">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="name" minOccurs="0"
|
||||
maxOccurs="unbounded" />
|
||||
<xs:element ref="instance" minOccurs="0"
|
||||
maxOccurs="unbounded" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="uri" type="xs:anyURI" use="required" />
|
||||
<xs:anyAttribute processContents="lax" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="instance">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:any minOccurs="0" maxOccurs="unbounded"
|
||||
processContents="lax" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="id" type="xs:string" use="required" />
|
||||
<xs:attribute name="state" use="required">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="active" />
|
||||
<xs:enumeration value="pending" />
|
||||
<xs:enumeration value="terminated" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="reason" type="xs:string"
|
||||
use="optional" />
|
||||
<xs:attribute name="cid" type="xs:string" use="optional" />
|
||||
<xs:anyAttribute processContents="lax" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="name">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute ref="xml:lang" use="optional"/>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
Loading…
Add table
Reference in a new issue