mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
now it compiles
This commit is contained in:
parent
3aa85143f8
commit
8f653ab4bf
8 changed files with 100 additions and 37 deletions
|
|
@ -73,8 +73,10 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
conference/conference.h
|
||||
conference/handlers/local-conference-event-handler-p.h
|
||||
conference/handlers/local-conference-event-handler.h
|
||||
conference/handlers/local-conference-list-event-handler.h
|
||||
conference/handlers/remote-conference-event-handler-p.h
|
||||
conference/handlers/remote-conference-event-handler.h
|
||||
conference/handlers/remote-conference-list-event-handler.h
|
||||
conference/local-conference-p.h
|
||||
conference/local-conference.h
|
||||
conference/params/call-session-params-p.h
|
||||
|
|
@ -156,6 +158,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
|
|||
variant/variant.h
|
||||
xml/conference-info.h
|
||||
xml/resource-lists.h
|
||||
xml/rlmi.h
|
||||
xml/xml.h
|
||||
)
|
||||
|
||||
|
|
@ -206,7 +209,9 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
chat/notification/is-composing.cpp
|
||||
conference/conference.cpp
|
||||
conference/handlers/local-conference-event-handler.cpp
|
||||
conference/handlers/local-conference-list-event-handler.cpp
|
||||
conference/handlers/remote-conference-event-handler.cpp
|
||||
conference/handlers/remote-conference-list-event-handler.cpp
|
||||
conference/local-conference.cpp
|
||||
conference/params/call-session-params.cpp
|
||||
conference/params/media-session-params.cpp
|
||||
|
|
@ -269,6 +274,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
|
|||
variant/variant.cpp
|
||||
xml/conference-info.cpp
|
||||
xml/resource-lists.cpp
|
||||
xml/rlmi.cpp
|
||||
xml/xml.cpp
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* 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"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -28,3 +28,4 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,10 +16,12 @@
|
|||
* 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_
|
||||
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
|
@ -41,3 +43,4 @@ private:
|
|||
LINPHONE_END_NAMESPACE
|
||||
|
||||
#endif // ifndef _L_LOCAL_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,15 +17,25 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "linphone/api/c-api.h"
|
||||
#include "linphone/core.h"
|
||||
#include "linphone/event.h"
|
||||
#include "linphone/proxy_config.h"
|
||||
#include "linphone/utils/utils.h"
|
||||
|
||||
#include "address/address.h"
|
||||
#include "content/content.h"
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "content/content-manager.h"
|
||||
#include "content/content-type.h"
|
||||
#include "core/core-p.h"
|
||||
#include "remote-conference-event-handler.h"
|
||||
#include "remote-conference-list-event-handler.h"
|
||||
#include "xml/resource-lists.h"
|
||||
#include "xml/rlmi.h"
|
||||
|
||||
// TODO: Remove me later.
|
||||
#include "private.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -38,14 +48,14 @@ void RemoteConferenceListEventHandler::subscribe () {
|
|||
if (lev)
|
||||
return;
|
||||
|
||||
Content *content;
|
||||
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());
|
||||
Address addr = handler->getChatRoomId().getPeerAddress();
|
||||
addr.setUriParam("Last-Notify", Utils::toString(handler->getLastNotify()));
|
||||
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asString());
|
||||
l.getEntry().push_back(entry);
|
||||
}
|
||||
|
|
@ -56,18 +66,18 @@ void RemoteConferenceListEventHandler::subscribe () {
|
|||
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);
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(lc);
|
||||
if (!cfg || (linphone_proxy_config_get_state(cfg) != LinphoneRegistrationOk))
|
||||
return;
|
||||
}
|
||||
|
||||
LinphoneAddress *rlsAddr = linphone_address_new(linphone_proxy_config_get_conference_factory_uri(cfg));
|
||||
|
||||
lev = linphone_event_ref(linphone_core_create_subscribe(lc, rlsAddr, "conference", 600));
|
||||
lev->op->set_from();
|
||||
char *from = linphone_address_as_string(linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(getCore()->getCCore())));
|
||||
lev->op->set_from(from);
|
||||
bctbx_free(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());
|
||||
|
|
@ -82,57 +92,75 @@ void RemoteConferenceListEventHandler::unsubscribe () {
|
|||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::notifyReceived (Content *multipart) {
|
||||
list<Content> contents = ContentManager::multipartToContentList(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) {
|
||||
const ContentType &contentType = content.getContentType();
|
||||
if (contentType == ContentType::Rlmi) {
|
||||
addresses = parseRlmi(body);
|
||||
continue;
|
||||
}
|
||||
|
||||
const string &value = content.getHeaderValue("Content-Id");
|
||||
if (value.empty())
|
||||
continue;
|
||||
|
||||
Address cid(value);
|
||||
Address peer = addresses[cid];
|
||||
ChatRoomId id(local, peer);
|
||||
shared_ptr<RemoteConferenceEventHandler> handler = findHandler(id);
|
||||
if (!handler)
|
||||
continue;
|
||||
|
||||
if (content.getContentType == ContentType::Multipart)
|
||||
if (contentType == ContentType::Multipart)
|
||||
handler->multipartNotifyReceived(body);
|
||||
else if (content.getContentType == ContentType::Conference)
|
||||
else if (contentType == ContentType::ConferenceInfo)
|
||||
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(
|
||||
istringstream data(xmlBody);
|
||||
unique_ptr<Xsd::Rlmi::List> rlmi(Xsd::Rlmi::parseList(
|
||||
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));
|
||||
for (const auto &resource : rlmi->getResource()) {
|
||||
if (resource.getInstance().empty())
|
||||
continue;
|
||||
|
||||
Address peer(resource.getUri());
|
||||
for (const auto &instance : resource.getInstance()) {
|
||||
if (!instance.getCid().present())
|
||||
continue;
|
||||
|
||||
Address cid(instance.getCid().get());
|
||||
addresses[cid] = peer;
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
void RemoteConferenceListEventHandler::addHandler (std::shared_ptr<RemoteConferenceEventHandler> handler) {
|
||||
|
||||
handlers.push_back(handler);
|
||||
}
|
||||
|
||||
shared_ptr<RemoteConferenceEventHandler> RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) {
|
||||
shared_ptr<RemoteConferenceEventHandler> RemoteConferenceListEventHandler::findHandler (const ChatRoomId &chatRoomId) const {
|
||||
for (const auto &handler : handlers) {
|
||||
if (handler->getChatRoomId() == chatRoomId)
|
||||
return handler;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const list<shared_ptr<RemoteConferenceEventHandler>> &RemoteConferenceListEventHandler::getHandlers () const {
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -20,25 +20,38 @@
|
|||
#ifndef _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
#define _L_REMOTE_CONFERENCE_LIST_EVENT_HANDLER_H_
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "linphone/types.h"
|
||||
#include "linphone/utils/general.h"
|
||||
|
||||
#include "chat/chat-room/chat-room-id.h"
|
||||
#include "content/content.h"
|
||||
#include "core/core-accessor.h"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
class LinphoneEvent;
|
||||
class Address;
|
||||
class RemoteConferenceEventHandler;
|
||||
|
||||
class RemoteConferenceListEventHandler : public Object {
|
||||
class RemoteConferenceListEventHandler : public Object, public CoreAccessor {
|
||||
public:
|
||||
void subscribe ();
|
||||
void unsubscribe ();
|
||||
void notifyReceived ();
|
||||
void notifyReceived (Content *multipart);
|
||||
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;
|
||||
LinphoneEvent *lev = nullptr;
|
||||
|
||||
std::map<Address, Address> parseRlmi (const std::string &xmlBody) const;
|
||||
};
|
||||
|
||||
LINPHONE_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ private:
|
|||
std::string contentEncoding;
|
||||
std::list<std::pair<std::string, std::string>> headers;
|
||||
|
||||
const std::list<std::pair<std::string, std::string>>::const_iterator findHeader (const std::string &headerName) const;
|
||||
|
||||
L_DECLARE_PUBLIC(Content);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const list<pair<string, string>>::const_iterator ContentPrivate::findHeader (const string &headerName) const {
|
||||
return findIf(headers, [&headerName](const pair<string, string> &pair) {
|
||||
return pair.first == headerName;
|
||||
});
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Content::Content () : ClonableObject(*new ContentPrivate) {}
|
||||
|
||||
Content::Content (const Content &other) : ClonableObject(*new ContentPrivate), AppDataContainer(other) {
|
||||
|
|
@ -208,16 +216,18 @@ const list<pair<string, string>> &Content::getHeaders () const {
|
|||
|
||||
void Content::removeHeader (const string &headerName) {
|
||||
L_D();
|
||||
auto it = findHeader(headerName);
|
||||
auto it = d->findHeader(headerName);
|
||||
if (it != d->headers.cend())
|
||||
d->headers.remove(*it);
|
||||
}
|
||||
|
||||
list<pair<string, string>>::const_iterator Content::findHeader (const string &headerName) const {
|
||||
const string &Content::getHeaderValue (const string &headerName) const {
|
||||
L_D();
|
||||
return findIf(d->headers, [&headerName](const pair<string, string> &pair) {
|
||||
return pair.first == headerName;
|
||||
});
|
||||
auto it = d->findHeader(headerName);
|
||||
if (it != d->headers.cend())
|
||||
return (*it).second;
|
||||
|
||||
return Utils::getEmptyConstRefObject<string>();
|
||||
}
|
||||
|
||||
LinphoneContent *Content::toLinphoneContent () const {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public:
|
|||
const std::list<std::pair<std::string, std::string>> &getHeaders () const;
|
||||
void addHeader (const std::string &headerName, const std::string &headerValue);
|
||||
void removeHeader (const std::string &headerName);
|
||||
std::list<std::pair<std::string, std::string>>::const_iterator findHeader (const std::string &headerName) const;
|
||||
const std::string &getHeaderValue (const std::string &headerName) const;
|
||||
|
||||
// TODO: Remove me later.
|
||||
virtual LinphoneContent *toLinphoneContent () const;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue