diff --git a/spectrum/src/main.cpp b/spectrum/src/main.cpp index c0b8fb9b697ee3f6f46c5c31055c09f34b3a1bac..d05bdeb81b13ca6a98d25297973991b29693ff06 100644 --- a/spectrum/src/main.cpp +++ b/spectrum/src/main.cpp @@ -5,12 +5,14 @@ #include "transport/logger.h" #include "transport/sqlite3backend.h" #include "transport/mysqlbackend.h" +#include "transport/pqxxbackend.h" #include "transport/userregistration.h" #include "transport/networkpluginserver.h" #include "transport/admininterface.h" #include "transport/statsresponder.h" #include "transport/usersreconnecter.h" #include "transport/util.h" +#include "transport/gatewayresponder.h" #include "Swiften/EventLoop/SimpleEventLoop.h" #include #include @@ -379,7 +381,23 @@ int main(int argc, char **argv) } #endif - if (CONFIG_STRING(&config, "database.type") != "mysql" && CONFIG_STRING(&config, "database.type") != "sqlite3") { +#ifdef WITH_PQXX + if (CONFIG_STRING(&config, "database.type") == "pqxx") { + storageBackend = new PQXXBackend(&config); + if (!storageBackend->connect()) { + std::cerr << "Can't connect to database. Check the log to find out the reason.\n"; + return -1; + } + } +#else + if (CONFIG_STRING(&config, "database.type") == "pqxx") { + std::cerr << "Spectrum2 is not compiled with pqxx backend.\n"; + return -2; + } +#endif + + if (CONFIG_STRING(&config, "database.type") != "mysql" && CONFIG_STRING(&config, "database.type") != "sqlite3" + && CONFIG_STRING(&config, "database.type") != "pqxx" && CONFIG_STRING(&config, "database.type") != "none") { std::cerr << "Unknown storage backend " << CONFIG_STRING(&config, "database.type") << "\n"; return -2; } @@ -404,6 +422,9 @@ int main(int argc, char **argv) StatsResponder statsResponder(&transport, &userManager, &plugin, storageBackend); statsResponder.start(); + GatewayResponder gatewayResponder(transport.getIQRouter(), &userManager); + gatewayResponder.start(); + eventLoop_ = &eventLoop; eventLoop.run();