diff --git a/spectrum/src/main.cpp b/spectrum/src/main.cpp index 6ac952ed44173c89171e20393690a65d8a051327..14abb292b8f215a5052a42189314fadbf65a4bed 100644 --- a/spectrum/src/main.cpp +++ b/spectrum/src/main.cpp @@ -14,6 +14,9 @@ #include "transport/util.h" #include "transport/gatewayresponder.h" #include "transport/logging.h" +#include "transport/discoitemsresponder.h" +#include "transport/adhocmanager.h" +#include "transport/settingsadhoccommand.h" #include "Swiften/EventLoop/SimpleEventLoop.h" #include #include @@ -122,7 +125,8 @@ int main(int argc, char **argv) bool no_daemon = false; std::string config_file; std::string jid; - + + setlocale(LC_ALL, ""); #ifndef WIN32 if (signal(SIGINT, spectrum_sigint_handler) == SIG_ERR) { @@ -251,6 +255,16 @@ int main(int argc, char **argv) std::cerr << "Can't create service.working_dir directory " << CONFIG_STRING(&config, "service.working_dir") << ".\n"; return 1; } + // create directories + try { + boost::filesystem::create_directories( + boost::filesystem::path(CONFIG_STRING(&config, "service.portfile")).parent_path().string() + ); + } + catch (...) { + std::cerr << "Can't create service.portfile directory " << CONFIG_STRING(&config, "service.portfile") << ".\n"; + return 1; + } #ifndef WIN32 if (!CONFIG_STRING(&config, "service.group").empty() ||!CONFIG_STRING(&config, "service.user").empty() ) { @@ -267,6 +281,20 @@ int main(int argc, char **argv) chown(CONFIG_STRING(&config, "service.working_dir").c_str(), pw->pw_uid, gr->gr_gid); } + char backendport[20]; + FILE* port_file_f; + port_file_f = fopen(CONFIG_STRING(&config, "service.portfile").c_str(), "w+"); + if (port_file_f == NULL) { + std::cerr << "Cannot create port_file file " << CONFIG_STRING(&config, "service.portfile").c_str() << ". Exiting\n"; + exit(1); + } + sprintf(backendport,"%s\n",CONFIG_STRING(&config, "service.backend_port").c_str()); + if (fwrite(backendport,1,strlen(backendport),port_file_f) < strlen(backendport)) { + std::cerr << "Cannot write to port file " << CONFIG_STRING(&config, "service.portfile") << ". Exiting\n"; + exit(1); + } + fclose(port_file_f); + if (!no_daemon) { // daemonize daemonize(CONFIG_STRING(&config, "service.working_dir").c_str(), CONFIG_STRING(&config, "service.pidfile").c_str()); @@ -353,13 +381,24 @@ int main(int argc, char **argv) NetworkPluginServer plugin(&transport, &config, &userManager, &ftManager); - AdminInterface adminInterface(&transport, &userManager, &plugin, storageBackend); + AdminInterface adminInterface(&transport, &userManager, &plugin, storageBackend, userRegistration); + plugin.setAdminInterface(&adminInterface); + StatsResponder statsResponder(&transport, &userManager, &plugin, storageBackend); statsResponder.start(); GatewayResponder gatewayResponder(transport.getIQRouter(), &userManager); gatewayResponder.start(); + DiscoItemsResponder discoItemsResponder(&transport); + discoItemsResponder.start(); + + AdHocManager adhocmanager(&transport, &discoItemsResponder); + adhocmanager.start(); + + SettingsAdHocCommandFactory settings; + adhocmanager.addAdHocCommand(&settings); + eventLoop_ = &eventLoop; eventLoop.run();