diff --git a/CMakeLists.txt b/CMakeLists.txt index 342de95c..84fa46f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ else() endif() if(CMAKE_BUILD_TYPE MATCHES Debug) + ADD_DEFINITIONS(-O0) ADD_DEFINITIONS(-ggdb) ADD_DEFINITIONS(-DDEBUG) ADD_DEFINITIONS(-Wall) @@ -108,10 +109,10 @@ include_directories(${Boost_INCLUDE_DIRS}) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(include) -ADD_SUBDIRECTORY(examples) +#ADD_SUBDIRECTORY(examples) ADD_SUBDIRECTORY(spectrum) ADD_SUBDIRECTORY(backends) -ADD_SUBDIRECTORY(tests) +#ADD_SUBDIRECTORY(tests) if(DOXYGEN_FOUND) message("Docs : yes") diff --git a/include/transport/userregistration.h b/include/transport/userregistration.h index 6a5d2327..3a34480b 100644 --- a/include/transport/userregistration.h +++ b/include/transport/userregistration.h @@ -21,8 +21,7 @@ #pragma once #include "Swiften/Swiften.h" -#include "Swiften/Queries/GetResponder.h" -#include "Swiften/Queries/SetResponder.h" +#include "Swiften/Queries/Responder.h" #include "Swiften/Elements/InBandRegistrationPayload.h" namespace Transport { @@ -34,7 +33,7 @@ class UserManager; class Config; /// Allows users to register the transport using service discovery. -class UserRegistration : Swift::GetResponder, Swift::SetResponder { +class UserRegistration : public Swift::Responder { public: /// Creates new UserRegistration handler. /// \param component Component associated with this class @@ -69,8 +68,8 @@ class UserRegistration : Swift::GetResponder, boost::signal onUserUpdated; private: - bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload); - bool handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload); + virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload); + virtual bool handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload); Component *m_component; StorageBackend *m_storageBackend; diff --git a/src/sqlite3backend.cpp b/src/sqlite3backend.cpp index 565a5f84..d9f65d11 100644 --- a/src/sqlite3backend.cpp +++ b/src/sqlite3backend.cpp @@ -63,6 +63,7 @@ SQLite3Backend::SQLite3Backend(Config *config) { m_config = config; m_db = NULL; m_prefix = CONFIG_STRING(m_config, "database.prefix"); + std::cout << "SQLITE3 " << this << "\n"; } SQLite3Backend::~SQLite3Backend(){ diff --git a/src/userregistration.cpp b/src/userregistration.cpp index 61b05dab..8dd6a9c7 100644 --- a/src/userregistration.cpp +++ b/src/userregistration.cpp @@ -30,13 +30,11 @@ using namespace Swift; namespace Transport { -UserRegistration::UserRegistration(Component *component, UserManager *userManager, StorageBackend *storageBackend) : Swift::GetResponder(component->m_iqRouter), Swift::SetResponder(component->m_iqRouter) { +UserRegistration::UserRegistration(Component *component, UserManager *userManager, StorageBackend *storageBackend) : Swift::Responder(component->m_iqRouter) { m_component = component; m_config = m_component->m_config; m_storageBackend = storageBackend; m_userManager = userManager; - Swift::GetResponder::start(); - Swift::SetResponder::start(); } UserRegistration::~UserRegistration(){ @@ -121,7 +119,7 @@ bool UserRegistration::unregisterUser(const std::string &barejid) { bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload) { if (CONFIG_STRING(m_config, "service.protocol") == "irc") { - Swift::GetResponder::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); return true; } @@ -132,7 +130,7 @@ bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID std::list const &x = CONFIG_LIST(m_config,"service.allowed_servers"); if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) { // Log("UserRegistration", "This user has no permissions to register an account"); - Swift::GetResponder::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); return true; } } @@ -210,14 +208,14 @@ bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID reg->setForm(form); - Swift::GetResponder::sendResponse(from, id, reg); + sendResponse(from, id, reg); return true; } bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr payload) { if (CONFIG_STRING(m_config, "service.protocol") == "irc") { - Swift::GetResponder::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); return true; } @@ -228,7 +226,7 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID std::list const &x = CONFIG_LIST(m_config,"service.allowed_servers"); if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) { // Log("UserRegistration", "This user has no permissions to register an account"); - Swift::SetResponder::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify); return true; } } @@ -284,12 +282,12 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID if (payload->isRemove()) { unregisterUser(barejid); - Swift::SetResponder::sendResponse(from, id, InBandRegistrationPayload::ref()); + sendResponse(from, id, InBandRegistrationPayload::ref()); return true; } if (!payload->getUsername() || !payload->getPassword()) { - Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); return true; } @@ -299,14 +297,14 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID // || localization.getLanguages().find(language) == localization.getLanguages().end() ) { - Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); return true; } if (CONFIG_STRING(m_config, "service.protocol") == "xmpp") { // User tries to register himself. if ((Swift::JID(*payload->getUsername()).toBare() == from.toBare())) { - Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); return true; } @@ -314,7 +312,7 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID UserInfo user_row; bool registered = m_storageBackend->getUser(Swift::JID(*payload->getUsername()).toBare().toString(), user_row); if (registered) { - Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); + sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); return true; } } @@ -330,7 +328,7 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID // if (!m_component->protocol()->isValidUsername(newUsername)) { // Log("UserRegistration", "This is not valid username: "<< newUsername); -// Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); +// sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); // return true; // } @@ -338,7 +336,7 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID // if (!CONFIG_STRING(m_config, "registration.reg_allowed_usernames").empty() && // !g_regex_match_simple(CONFIG_STRING(m_config, "registration.reg_allowed_usernames"), newUsername.c_str(),(GRegexCompileFlags) (G_REGEX_CASELESS | G_REGEX_EXTENDED), (GRegexMatchFlags) 0)) { // Log("UserRegistration", "This is not valid username: "<< newUsername); -// Swift::SetResponder::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); +// sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify); // return true; // } // #endif @@ -362,7 +360,7 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID onUserUpdated(res); } - Swift::SetResponder::sendResponse(from, id, InBandRegistrationPayload::ref()); + sendResponse(from, id, InBandRegistrationPayload::ref()); return true; }