/** * libtransport -- C++ library for easy XMPP Transports development * * Copyright (C) 2011, Jan Kaluza * * 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 02111-1301 USA */ #pragma once #include #include "Swiften/Swiften.h" #include "Swiften/Presence/PresenceOracle.h" #include "Swiften/Disco/EntityCapsManager.h" #include "Swiften/Network/ConnectionServer.h" #include "Swiften/Network/Connection.h" #include "Swiften/Network/BoostTimerFactory.h" #include "Swiften/Network/BoostNetworkFactories.h" #include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/Network/Connection.h" #include "storagebackend.h" namespace Transport { class NetworkPlugin { public: NetworkPlugin(Swift::EventLoop *loop, const std::string &host, int port); virtual ~NetworkPlugin(); void handleBuddyChanged(const std::string &user, const std::string &buddyName, const std::string &alias, const std::string &groups, int status, const std::string &statusMessage = "", const std::string &iconHash = "" ); void handleDisconnected(const std::string &user, const std::string &legacyName, int error, const std::string &message); virtual void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) = 0; virtual void handleLogoutRequest(const std::string &user, const std::string &legacyName) = 0; private: void connect(); void handleLoginPayload(const std::string &payload); void handleLogoutPayload(const std::string &payload); void handleDataRead(const Swift::ByteArray&); void handleConnected(bool error); void handleDisconnected(); void send(const std::string &data); void sendPong(); std::string m_data; std::string m_host; int m_port; Swift::BoostNetworkFactories *m_factories; Swift::BoostIOServiceThread m_boostIOServiceThread; boost::shared_ptr m_conn; Swift::Timer::ref m_reconnectTimer; }; }