diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-04-28 08:36:39 (GMT) |
|---|---|---|
| committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-04-28 15:23:59 (GMT) |
| commit | be642f17bfa2df7cb88ddb5fb4aa37438d9e2110 (patch) | |
| tree | c11e239dfcfcab2b38b64e6a19ffb48e8c30c44d /Slimber | |
| parent | 64511948b075e650cacfcc78e40371abee1d2716 (diff) | |
| download | swift-contrib-be642f17bfa2df7cb88ddb5fb4aa37438d9e2110.zip swift-contrib-be642f17bfa2df7cb88ddb5fb4aa37438d9e2110.tar.bz2 | |
Create ToplevelElement to replace Element.
Change-Id: I3460f6f4a2ffa9b795080664f49d9138440de72d
Diffstat (limited to 'Slimber')
| -rw-r--r-- | Slimber/Server.cpp | 10 | ||||
| -rw-r--r-- | Slimber/Server.h | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index b63ca67..41b90c4 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -1,26 +1,26 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include "Slimber/Server.h" #include <string> #include <boost/bind.hpp> #include <iostream> #include "Swiften/Base/String.h" #include "Swiften/LinkLocal/LinkLocalConnector.h" #include "Swiften/Network/Connection.h" #include "Swiften/Session/SessionTracer.h" -#include "Swiften/Elements/Element.h" +#include "Swiften/Elements/ToplevelElement.h" #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/RosterPayload.h" #include "Swiften/Network/BoostConnection.h" #include "Swiften/Network/BoostConnectionServer.h" #include "Swiften/Session/SessionTracer.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/VCard.h" #include "Limber/Server/UserRegistry.h" #include "Swiften/Session/Session.h" @@ -176,19 +176,19 @@ void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession>) { } void Server::unregisterService() { if (linkLocalServiceRegistered) { linkLocalServiceRegistered = false; linkLocalServiceBrowser->unregisterService(); } } -void Server::handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session) { +void Server::handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session) { boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element); if (!stanza) { return; } stanza->setFrom(session->getRemoteJID()); if (!stanza->getTo().isValid()) { stanza->setTo(session->getLocalJID()); } @@ -286,19 +286,19 @@ void Server::handleNewLinkLocalConnection(boost::shared_ptr<Connection> connecti } void Server::handleLinkLocalSessionFinished(boost::shared_ptr<Session> session) { //std::cout << "Link local session from " << session->getRemoteJID() << " ended" << std::endl; linkLocalSessions.erase( std::remove(linkLocalSessions.begin(), linkLocalSessions.end(), session), linkLocalSessions.end()); } -void Server::handleLinkLocalElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<Session> session) { +void Server::handleLinkLocalElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<Session> session) { if (boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element)) { JID fromJID = session->getRemoteJID(); if (!presenceManager->getServiceForJID(fromJID.toBare())) { return; // TODO: Send error back } stanza->setFrom(fromJID); serverFromClientSession->sendElement(stanza); } } @@ -307,19 +307,19 @@ void Server::handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connect if (error) { std::cerr << "Error connecting" << std::endl; // TODO: Send back queued stanzas } else { boost::shared_ptr<OutgoingLinkLocalSession> outgoingSession( new OutgoingLinkLocalSession( selfJID, connector->getService().getJID(), connector->getConnection(), &payloadParserFactories, &payloadSerializers, &xmlParserFactory)); - foreach(const boost::shared_ptr<Element> element, connector->getQueuedElements()) { + foreach(const boost::shared_ptr<ToplevelElement> element, connector->getQueuedElements()) { outgoingSession->queueElement(element); } registerLinkLocalSession(outgoingSession); } connectors.erase(std::remove(connectors.begin(), connectors.end(), connector), connectors.end()); } void Server::registerLinkLocalSession(boost::shared_ptr<Session> session) { session->onSessionFinished.connect( diff --git a/Slimber/Server.h b/Slimber/Server.h index 96401d9..2d520d6 100644 --- a/Slimber/Server.h +++ b/Slimber/Server.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2014 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <boost/shared_ptr.hpp> #include <boost/optional.hpp> #include <vector> @@ -59,25 +59,25 @@ namespace Swift { boost::signal<void (bool)> onSelfConnected; boost::signal<void (boost::optional<ServerError>)> onStopped; private: void stop(boost::optional<ServerError>); void handleNewClientConnection(boost::shared_ptr<Connection> c); void handleSessionStarted(); void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>); - void handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session); + void handleElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<ServerFromClientSession> session); void handleRosterChanged(boost::shared_ptr<RosterPayload> roster); void handlePresenceChanged(boost::shared_ptr<Presence> presence); void handleServiceRegistered(const DNSSDServiceID& service); void handleNewLinkLocalConnection(boost::shared_ptr<Connection> connection); void handleLinkLocalSessionFinished(boost::shared_ptr<Session> session); - void handleLinkLocalElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<Session> session); + void handleLinkLocalElementReceived(boost::shared_ptr<ToplevelElement> element, boost::shared_ptr<Session> session); void handleConnectFinished(boost::shared_ptr<LinkLocalConnector> connector, bool error); void handleClientConnectionServerStopped( boost::optional<BoostConnectionServer::Error>); void handleLinkLocalConnectionServerStopped( boost::optional<BoostConnectionServer::Error>); boost::shared_ptr<Session> getLinkLocalSessionForJID(const JID& jid); boost::shared_ptr<LinkLocalConnector> getLinkLocalConnectorForJID(const JID& jid); void registerLinkLocalSession(boost::shared_ptr<Session> session); void unregisterService(); |
Swift