diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 496be28ac..4a3b6d93f 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -183,7 +183,7 @@ ClientGroupChatRoom::ClientGroupChatRoom ( RemoteConference(core, me, nullptr) { L_D_T(RemoteConference, dConference); L_D(); - + IdentityAddress focusAddr(uri); dConference->focus = make_shared(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 chatRoom = getCore()->findChatRoom(id); diff --git a/src/conference/handlers/local-conference-list-event-handler.cpp b/src/conference/handlers/local-conference-list-event-handler.cpp new file mode 100644 index 000000000..0e4a08a22 --- /dev/null +++ b/src/conference/handlers/local-conference-list-event-handler.cpp @@ -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 diff --git a/src/conference/handlers/local-conference-list-event-handler.h b/src/conference/handlers/local-conference-list-event-handler.h new file mode 100644 index 000000000..3339433c8 --- /dev/null +++ b/src/conference/handlers/local-conference-list-event-handler.h @@ -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 handler); + const std::list> &getHandlers () const; + +private: + std::list> handlers; + +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_LOCAL_CONFERENCE_LIST_EVENT_HANDLER_H_ diff --git a/src/conference/handlers/remote-conference-list-event-handler.cpp b/src/conference/handlers/remote-conference-list-event-handler.cpp new file mode 100644 index 000000000..21e3183d5 --- /dev/null +++ b/src/conference/handlers/remote-conference-list-event-handler.cpp @@ -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 contents = ContentManager::multipartToContentList(multipart); + char *from = linphone_address_as_string(linphone_event_get_from(lev)); + const Address local(from); + bctbx_free(from); + map 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 handler = findHandler(id); + if (!handler) + continue; + + if (content.getContentType == ContentType::Multipart) + handler->multipartNotifyReceived(body); + else if (content.getContentType == ContentType::Conference) + handler->notifyReceived(body); + } +} + +map RemoteConferenceListEventHandler::parseRlmi (const string &xmlBody) const { + istringstream data(content.getBodyAsString()); + unique_ptr rl(Xsd::ResourceLists::parseResourceLists( + data, + Xsd::XmlSchema::Flags::dont_validate + )); + map 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 handler) { + +} + +shared_ptr RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) { + +} + +const list> &RemoteConferenceListEventHandler::getHandlers () const { + +} + +LINPHONE_END_NAMESPACE diff --git a/src/conference/handlers/remote-conference-list-event-handler.h b/src/conference/handlers/remote-conference-list-event-handler.h new file mode 100644 index 000000000..d3a12ee31 --- /dev/null +++ b/src/conference/handlers/remote-conference-list-event-handler.h @@ -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 handler); + std::shared_ptr findHandler (const ChatRoomId &chatRoomId) const; + const std::list> &getHandlers () const; + +private: + std::list> handlers; + LinphoneEvent *lev; +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_ diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index 97a0ad488..51b045166 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -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; diff --git a/src/content/content-type.h b/src/content/content-type.h index b13063115..3cc451046 100644 --- a/src/content/content-type.h +++ b/src/content/content-type.h @@ -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: diff --git a/src/xml/generate.py b/src/xml/generate.py index 0046c4b05..bfd95f825 100755 --- a/src/xml/generate.py +++ b/src/xml/generate.py @@ -101,6 +101,7 @@ def main(argv = None): generate("xml") generate("conference-info") generate("resource-lists") + generate("rlmi") if __name__ == "__main__": sys.exit(main()) diff --git a/src/xml/rlmi.xsd b/src/xml/rlmi.xsd new file mode 100644 index 000000000..a903802fb --- /dev/null +++ b/src/xml/rlmi.xsd @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +