]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig-ng/stgconfig.cpp
Rename BASE_AUTH and BASE_STORE to AUTH and STORE
[stg.git] / projects / stargazer / plugins / configuration / sgconfig-ng / stgconfig.cpp
1 #include <boost/thread.hpp>
2
3 #include "store.h"
4 #include "module_settings.h"
5 #include "common.h"
6 #include "users.h"
7 #include "tariffs.h"
8 #include "admins.h"
9
10 // TODO: Fix this shit!!!
11 #include "../../../settings.h"
12
13 #include "stgconfig.h"
14
15 STGCONFIG2::STGCONFIG2()
16     : users(NULL),
17       tariffs(NULL),
18       admins(NULL),
19       store(NULL),
20       stgSettings(NULL),
21       ct(admins, tariffs, users, stgSettings)
22 {
23     thread = new boost::thread;
24 }
25
26 STGCONFIG2::~STGCONFIG2()
27 {
28     delete thread;
29 }
30
31 int STGCONFIG2::ParseSettings()
32 {
33     return 0;
34 }
35
36 int STGCONFIG2::Start()
37 {
38     ct.SetClasses(admins, tariffs, users, stgSettings);
39     *thread = boost::thread(boost::ref(ct));
40     return 0;
41 }
42
43 int STGCONFIG2::Stop()
44 {
45     ct.Stop();
46     if (!thread->timed_join(boost::get_system_time() + boost::posix_time::milliseconds(5000))) {
47         thread->detach();
48         printfd(__FILE__, "STGCONFIG2::Stop() Thread not stopped.\n");
49         errorStr = "Failed to stop config thread.";
50         return -1;
51     }
52     return 0;
53 }
54
55 bool STGCONFIG2::IsRunning()
56 {
57     return true;
58 }