diff --git a/3rdparty/cpprestsdk/CMakeLists.txt b/3rdparty/cpprestsdk/CMakeLists.txt index d6637104..8edeec94 100644 --- a/3rdparty/cpprestsdk/CMakeLists.txt +++ b/3rdparty/cpprestsdk/CMakeLists.txt @@ -158,9 +158,9 @@ else() endif() # Reconfigure final output directory -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries) # These settings can be used by the test targets set(Casablanca_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/spectrum/src/frontends/slack/SlackFrontend.cpp b/spectrum/src/frontends/slack/SlackFrontend.cpp new file mode 100644 index 00000000..e8dd5f0f --- /dev/null +++ b/spectrum/src/frontends/slack/SlackFrontend.cpp @@ -0,0 +1,111 @@ +/** + * Spectrum 2 Slack Frontend + * + * Copyright (C) 2015, 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 + */ + +#include "SlackFrontend.h" +#include "SlackRosterManager.h" +#include "SlackUser.h" +#include "SlackUserManager.h" + +#include "transport/StorageBackend.h" +#include "transport/Factory.h" +#include "transport/UserRegistry.h" +#include "transport/Logging.h" +#include "transport/Config.h" +#include "transport/Transport.h" + +#include +#include +#include + +using namespace boost; + +namespace Transport { + +DEFINE_LOGGER(logger, "SlackFrontend"); + +SlackFrontend::SlackFrontend() { +} + +void SlackFrontend::init(Component *transport, Swift::EventLoop *loop, Swift::NetworkFactories *factories, Config *config, Transport::UserRegistry *userRegistry) { + m_transport = transport; + m_config = transport->getConfig(); + m_jid = Swift::JID(CONFIG_STRING(m_config, "service.jid")); + + +} + +SlackFrontend::~SlackFrontend() { + +} + +void SlackFrontend::clearRoomList() { + +} + +void SlackFrontend::addRoomToRoomList(const std::string &handle, const std::string &name) { + +} + +void SlackFrontend::sendPresence(Swift::Presence::ref presence) { + +} + +void SlackFrontend::sendVCard(Swift::VCard::ref vcard, Swift::JID to) { +} + +void SlackFrontend::sendRosterRequest(Swift::RosterPayload::ref payload, Swift::JID to) { +} + +void SlackFrontend::sendMessage(boost::shared_ptr message) { +} + +void SlackFrontend::sendIQ(boost::shared_ptr iq) { +} + +boost::shared_ptr SlackFrontend::sendCapabilitiesRequest(Swift::JID to) { + + return Swift::DiscoInfo::ref(); +} + +void SlackFrontend::reconnectUser(const std::string &user) { + +} + +RosterManager *SlackFrontend::createRosterManager(User *user, Component *component) { + return new SlackRosterManager(user, component); +} + +User *SlackFrontend::createUser(const Swift::JID &jid, UserInfo &userInfo, Component *component, UserManager *userManager) { + return new SlackUser(jid, userInfo, component, userManager); +} + +UserManager *SlackFrontend::createUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend) { + return new SlackUserManager(component, userRegistry, storageBackend); +} + + +void SlackFrontend::connectToServer() { +} + +void SlackFrontend::disconnectFromServer() { + +} + +} diff --git a/spectrum/src/frontends/slack/SlackFrontend.h b/spectrum/src/frontends/slack/SlackFrontend.h new file mode 100644 index 00000000..35a8b326 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackFrontend.h @@ -0,0 +1,73 @@ +/** + * Spectrum 2 Slack Frontend + * + * Copyright (C) 2015, 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 "transport/Frontend.h" + +#include +#include + +namespace Transport { + class UserRegistry; + class Frontend; + class Config; + class DiscoItemsResponder; + class VCardResponder; + + class SlackFrontend : public Frontend { + public: + SlackFrontend(); + + virtual ~SlackFrontend(); + + virtual void init(Component *component, Swift::EventLoop *loop, Swift::NetworkFactories *factories, Config *config, UserRegistry *userRegistry); + + virtual void connectToServer(); + + virtual void disconnectFromServer(); + + virtual void sendPresence(Swift::Presence::ref presence); + + virtual void sendVCard(Swift::VCard::ref vcard, Swift::JID to); + + virtual void sendRosterRequest(Swift::RosterPayload::ref, Swift::JID to); + + virtual void sendMessage(boost::shared_ptr message); + + virtual void sendIQ(boost::shared_ptr); + + virtual void reconnectUser(const std::string &user); + + virtual RosterManager *createRosterManager(User *user, Component *component); + virtual User *createUser(const Swift::JID &jid, UserInfo &userInfo, Component *component, UserManager *userManager); + virtual UserManager *createUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend = NULL); + virtual boost::shared_ptr sendCapabilitiesRequest(Swift::JID to); + virtual void clearRoomList(); + virtual void addRoomToRoomList(const std::string &handle, const std::string &name); + + void handleMessage(boost::shared_ptr message); + + private: + Config* m_config; + Swift::JID m_jid; + Component *m_transport; + }; +} diff --git a/spectrum/src/frontends/slack/SlackRosterManager.cpp b/spectrum/src/frontends/slack/SlackRosterManager.cpp new file mode 100644 index 00000000..0540697d --- /dev/null +++ b/spectrum/src/frontends/slack/SlackRosterManager.cpp @@ -0,0 +1,63 @@ +/** + * XMPP - libpurple transport + * + * Copyright (C) 2009, 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 + */ + +#include "SlackRosterManager.h" +#include "SlackFrontend.h" +#include "SlackUser.h" + +#include "transport/Buddy.h" +#include "transport/User.h" +#include "transport/Logging.h" +#include "transport/Factory.h" +#include "transport/PresenceOracle.h" +#include "transport/Transport.h" + +#include +#include +#include +#include + +namespace Transport { + +DEFINE_LOGGER(logger, "SlackRosterManager"); + +SlackRosterManager::SlackRosterManager(User *user, Component *component) : RosterManager(user, component){ + m_user = user; + m_transport = component; +} + +SlackRosterManager::~SlackRosterManager() { + +} + +void SlackRosterManager::doRemoveBuddy(Buddy *buddy) { + +} + +void SlackRosterManager::doAddBuddy(Buddy *buddy) { + +} + +void SlackRosterManager::doUpdateBuddy(Buddy *buddy) { + +} + + +} diff --git a/spectrum/src/frontends/slack/SlackRosterManager.h b/spectrum/src/frontends/slack/SlackRosterManager.h new file mode 100644 index 00000000..fb79e797 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackRosterManager.h @@ -0,0 +1,54 @@ +/** + * Spectrum 2 Slack Frontend + * + * Copyright (C) 2015, 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 "transport/RosterManager.h" + +#include +#include +#include + +namespace Transport { + +class Buddy; +class User; +class Component; +class StorageBackend; +class RosterStorage; + +class SlackRosterManager : public RosterManager { + public: + SlackRosterManager(User *user, Component *component); + + virtual ~SlackRosterManager(); + + virtual void doRemoveBuddy(Buddy *buddy); + virtual void doAddBuddy(Buddy *buddy); + virtual void doUpdateBuddy(Buddy *buddy); + + + private: + RosterStorage *m_rosterStorage; + User *m_user; + Component *m_transport; +}; + +} diff --git a/spectrum/src/frontends/slack/SlackUser.cpp b/spectrum/src/frontends/slack/SlackUser.cpp new file mode 100644 index 00000000..c1b35524 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUser.cpp @@ -0,0 +1,54 @@ +/** + * 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 + */ + +#include "SlackUser.h" +#include "SlackFrontend.h" + +#include "transport/Transport.h" +#include "transport/UserManager.h" +#include "transport/Logging.h" + +#include +#include +#include + +using namespace boost; + +namespace Transport { + +DEFINE_LOGGER(logger, "SlackUser"); + +SlackUser::SlackUser(const Swift::JID &jid, UserInfo &userInfo, Component *component, UserManager *userManager) : User(jid, userInfo, component, userManager) { + m_jid = jid.toBare(); + + m_component = component; + m_userManager = userManager; + m_userInfo = userInfo; +} + +SlackUser::~SlackUser(){ +} + +void SlackUser::disconnectUser(const std::string &error, Swift::SpectrumErrorPayload::Error e) { + +} + + +} diff --git a/spectrum/src/frontends/slack/SlackUser.h b/spectrum/src/frontends/slack/SlackUser.h new file mode 100644 index 00000000..038fcb85 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUser.h @@ -0,0 +1,51 @@ +/** + * 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 "transport/User.h" + +#include + +namespace Transport { + +class Component; +class RosterManager; +class ConversationManager; +class UserManager; +class PresenceOracle; +struct UserInfo; + +class SlackUser : public User { + public: + SlackUser(const Swift::JID &jid, UserInfo &userInfo, Component * component, UserManager *userManager); + + virtual ~SlackUser(); + + void disconnectUser(const std::string &error, Swift::SpectrumErrorPayload::Error e); + + private: + Swift::JID m_jid; + Component *m_component; + UserManager *m_userManager; + UserInfo m_userInfo; +}; + +} diff --git a/spectrum/src/frontends/slack/SlackUserManager.cpp b/spectrum/src/frontends/slack/SlackUserManager.cpp new file mode 100644 index 00000000..7d3e4cbe --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUserManager.cpp @@ -0,0 +1,52 @@ +/** + * 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 + */ + +#include "SlackUserManager.h" +#include "SlackUserRegistration.h" +#include "SlackFrontend.h" + +#include "transport/User.h" +#include "transport/Transport.h" +#include "transport/StorageBackend.h" +#include "transport/Logging.h" + +namespace Transport { + +DEFINE_LOGGER(logger, "SlackUserManager"); + +SlackUserManager::SlackUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend) : UserManager(component, userRegistry, storageBackend) { + m_component = component; + m_userRegistration = new SlackUserRegistration(component, this, storageBackend); +} + +SlackUserManager::~SlackUserManager() { + delete m_userRegistration; +} + +void SlackUserManager::sendVCard(unsigned int id, Swift::VCard::ref vcard) { + +} + + +UserRegistration *SlackUserManager::getUserRegistration() { + return m_userRegistration; +} + +} diff --git a/spectrum/src/frontends/slack/SlackUserManager.h b/spectrum/src/frontends/slack/SlackUserManager.h new file mode 100644 index 00000000..61fafa0e --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUserManager.h @@ -0,0 +1,58 @@ +/** + * 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 "transport/UserManager.h" + +#include "Swiften/Elements/Message.h" +#include "Swiften/Elements/Presence.h" +#include "Swiften/Elements/DiscoInfo.h" + +#include +#include + +namespace Transport { + +class Component; +class StorageBackend; +class StorageResponder; +class VCardResponder; +class XMPPUserRegistration; +class GatewayResponder; +class AdHocManager; +class SettingsAdHocCommandFactory; + +class SlackUserManager : public UserManager { + public: + SlackUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend = NULL); + + virtual ~SlackUserManager(); + + virtual void sendVCard(unsigned int id, Swift::VCard::ref vcard); + + UserRegistration *getUserRegistration(); + + private: + Component *m_component; + UserRegistration *m_userRegistration; +}; + +} diff --git a/spectrum/src/frontends/slack/SlackUserRegistration.cpp b/spectrum/src/frontends/slack/SlackUserRegistration.cpp new file mode 100644 index 00000000..cd33b8a1 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUserRegistration.cpp @@ -0,0 +1,67 @@ +/** + * 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 + */ + +#include "SlackUserRegistration.h" +#include "SlackRosterManager.h" +#include "SlackFrontend.h" + +#include "transport/UserManager.h" +#include "transport/StorageBackend.h" +#include "transport/Transport.h" +#include "transport/RosterManager.h" +#include "transport/User.h" +#include "transport/Logging.h" +#include "transport/Buddy.h" +#include "transport/Config.h" + +#include +#include +#include +#include + +using namespace Swift; + +namespace Transport { + +DEFINE_LOGGER(logger, "SlackUserRegistration"); + +SlackUserRegistration::SlackUserRegistration(Component *component, UserManager *userManager, + StorageBackend *storageBackend) +: UserRegistration(component, userManager, storageBackend) { + m_component = component; + m_config = m_component->getConfig(); + m_storageBackend = storageBackend; + m_userManager = userManager; +} + +SlackUserRegistration::~SlackUserRegistration(){ +} + +bool SlackUserRegistration::doUserRegistration(const UserInfo &row) { + return true; +} + +bool SlackUserRegistration::doUserUnregistration(const UserInfo &row) { + return true; +} + + + +} diff --git a/spectrum/src/frontends/slack/SlackUserRegistration.h b/spectrum/src/frontends/slack/SlackUserRegistration.h new file mode 100644 index 00000000..5b6e8b29 --- /dev/null +++ b/spectrum/src/frontends/slack/SlackUserRegistration.h @@ -0,0 +1,53 @@ +/** + * 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 "transport/UserRegistration.h" + +#include + +namespace Transport { + +struct UserInfo; +class Component; +class StorageBackend; +class UserManager; +class Config; + +class SlackUserRegistration : public UserRegistration { + public: + SlackUserRegistration(Component *component, UserManager *userManager, StorageBackend *storageBackend); + + ~SlackUserRegistration(); + + virtual bool doUserRegistration(const UserInfo &userInfo); + + virtual bool doUserUnregistration(const UserInfo &userInfo); + + private: + Component *m_component; + StorageBackend *m_storageBackend; + UserManager *m_userManager; + Config *m_config; + +}; + +} diff --git a/spectrum/src/frontends/xmpp/XMPPRosterManager.h b/spectrum/src/frontends/xmpp/XMPPRosterManager.h index 4438697f..7842b0b0 100644 --- a/spectrum/src/frontends/xmpp/XMPPRosterManager.h +++ b/spectrum/src/frontends/xmpp/XMPPRosterManager.h @@ -73,10 +73,6 @@ class XMPPRosterManager : public RosterManager { return m_supportRemoteRoster; } - boost::signal onBuddyAdded; - - boost::signal onBuddyRemoved; - void handleBuddyChanged(Buddy *buddy); void sendBuddyRosterPush(Buddy *buddy); diff --git a/spectrum/src/main.cpp b/spectrum/src/main.cpp index a5303e25..b535a2f1 100644 --- a/spectrum/src/main.cpp +++ b/spectrum/src/main.cpp @@ -14,6 +14,7 @@ #include "transport/Util.h" #include "transport/Logging.h" #include "frontends/xmpp/XMPPFrontend.h" +#include "frontends/slack/SlackFrontend.h" #include "Swiften/EventLoop/SimpleEventLoop.h" #include "Swiften/Network/BoostNetworkFactories.h" #include @@ -210,9 +211,18 @@ int mainloop() { Swift::BoostNetworkFactories *factories = new Swift::BoostNetworkFactories(&eventLoop); UserRegistry userRegistry(config_, factories); - XMPPFrontend frontend; + + Frontend *frontend = NULL; + + std::string frontend_name = CONFIG_STRING_DEFAULTED(config_, "service.frontend", "xmpp"); + if (frontend_name == "xmpp") { + frontend = new XMPPFrontend(); + } + else if (frontend_name == "slack") { + frontend = new SlackFrontend(); + } - Component transport(&frontend, &eventLoop, factories, config_, NULL, &userRegistry); + Component transport(frontend, &eventLoop, factories, config_, NULL, &userRegistry); component_ = &transport; std::string error; @@ -230,7 +240,7 @@ int mainloop() { Logging::redirect_stderr(); - userManager = frontend.createUserManager(&transport, &userRegistry, storageBackend);; + userManager = frontend->createUserManager(&transport, &userRegistry, storageBackend);; UserRegistration *userRegistration = userManager->getUserRegistration(); UsersReconnecter *usersReconnecter = NULL;