#pragma once #include #include #include "Swiften/Network/BoostConnection.h" #include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Network/BoostConnectionServer.h" #include "Swiften/Server/UserRegistry.h" #include "Swiften/Base/IDGenerator.h" #include "Swiften/Network/Connection.h" #include "Swiften/LinkLocal/DNSSDService.h" #include "Swiften/LinkLocal/LinkLocalRoster.h" #include "Swiften/Session/SessionTracer.h" #include "Swiften/Server/ServerFromClientSession.h" #include "Swiften/Elements/Element.h" #include "Swiften/LinkLocal/LinkLocalConnector.h" #include "Swiften/JID/JID.h" #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/RosterPayload.h" #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" namespace Swift { class VCardCollection; class Server { public: Server(int clientConnectionPort, int linkLocalConnectionPort, boost::shared_ptr, boost::shared_ptr dnsSDService, VCardCollection* vCardCollection); boost::signal onSelfConnected; private: void handleNewClientConnection(boost::shared_ptr c); void handleNewLinkLocalConnection(boost::shared_ptr connection); void handleServiceRegistered(const DNSSDService::Service& service); void handleSessionStarted(); void handleSessionFinished(boost::shared_ptr); void handleLinkLocalSessionFinished(boost::shared_ptr session); void handleLinkLocalElementReceived(boost::shared_ptr element, boost::shared_ptr session); void unregisterService(); void handleElementReceived(boost::shared_ptr element, boost::shared_ptr session); void handleConnectFinished(boost::shared_ptr connector, bool error); void registerLinkLocalSession(boost::shared_ptr session); boost::shared_ptr getLinkLocalSessionForJID(const JID& jid); boost::shared_ptr getLinkLocalConnectorForJID(const JID& jid); void handleRosterChanged(boost::shared_ptr roster); void handlePresenceChanged(boost::shared_ptr presence); LinkLocalServiceInfo getLinkLocalServiceInfo(boost::shared_ptr presence); private: class DummyUserRegistry : public UserRegistry { public: DummyUserRegistry() {} virtual bool isValidUserPassword(const JID&, const String&) const { return true; } }; private: IDGenerator idGenerator_; BoostIOServiceThread boostIOServiceThread_; DummyUserRegistry userRegistry_; bool dnsSDServiceRegistered_; bool rosterRequested_; int clientConnectionPort_; int linkLocalConnectionPort_; boost::shared_ptr linkLocalRoster_; boost::shared_ptr dnsSDService_; VCardCollection* vCardCollection_; boost::shared_ptr lastPresence_; boost::shared_ptr serverFromClientConnectionServer_; boost::shared_ptr serverFromClientSession_; boost::shared_ptr serverFromNetworkConnectionServer_; std::vector< boost::shared_ptr > tracers_; std::vector< boost::shared_ptr > linkLocalSessions_; std::vector< boost::shared_ptr > connectors_; FullPayloadParserFactoryCollection payloadParserFactories_; FullPayloadSerializerCollection payloadSerializers_; JID selfJID_; }; }