X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3886ef930e3fd54894b8798ab17ef4d3bc0b995a..9d093a68b5f3e5a22e243c92ec2e0bd24b10ea38:/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp new file mode 100644 index 00000000..1b51bbcb --- /dev/null +++ b/projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp @@ -0,0 +1,58 @@ +#include + +#include "base_store.h" +#include "base_settings.h" +#include "common.h" + +// TODO: Fix this shit!!! +#include "../../../users.h" +#include "../../../tariffs.h" +#include "../../../admins.h" +#include "../../../settings.h" + +#include "stgconfig.h" + +STGCONFIG2::STGCONFIG2() + : users(NULL), + tariffs(NULL), + admins(NULL), + store(NULL), + stgSettings(NULL), + ct(admins, tariffs, users, stgSettings) +{ + thread = new boost::thread; +} + +STGCONFIG2::~STGCONFIG2() +{ + delete thread; +} + +int STGCONFIG2::ParseSettings() +{ + return 0; +} + +int STGCONFIG2::Start() +{ + ct.SetClasses(admins, tariffs, users, stgSettings); + *thread = boost::thread(boost::ref(ct)); + return 0; +} + +int STGCONFIG2::Stop() +{ + ct.Stop(); + if (!thread->timed_join(boost::get_system_time() + boost::posix_time::milliseconds(5000))) { + thread->detach(); + printfd(__FILE__, "STGCONFIG2::Stop() Thread not stopped.\n"); + errorStr = "Failed to stop config thread."; + return -1; + } + return 0; +} + +bool STGCONFIG2::IsRunning() +{ + return true; +}