7 |
#include <sstream> |
#include <sstream> |
8 |
#include <time.h> |
#include <time.h> |
9 |
|
|
10 |
|
#include "TaskManager.h" |
11 |
|
#include "PluginManager.h" |
12 |
|
|
13 |
using namespace std; |
using namespace std; |
14 |
char* Months[] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"}; |
const char* Months[] = { "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"}; |
15 |
|
|
16 |
Common* Common::instance() |
Common* Common::instance() |
17 |
{ |
{ |
20 |
} |
} |
21 |
|
|
22 |
|
|
23 |
|
Common::Common() |
24 |
|
: _pluginManager(0), _taskManager(0) |
25 |
|
{ |
26 |
|
_pluginManager = new PluginManager(); |
27 |
|
_taskManager = new TaskManager(); |
28 |
|
} |
29 |
|
|
30 |
|
|
31 |
|
Common::~Common() |
32 |
|
{ |
33 |
|
if (_pluginManager) |
34 |
|
delete _pluginManager; |
35 |
|
|
36 |
|
if (_taskManager) |
37 |
|
delete _taskManager; |
38 |
|
} |
39 |
|
|
40 |
|
PluginManager* Common::GetPluginManager() |
41 |
|
{ |
42 |
|
return _pluginManager; |
43 |
|
} |
44 |
|
|
45 |
|
TaskManager* Common::GetTaskManager() |
46 |
|
{ |
47 |
|
return _taskManager; |
48 |
|
} |
49 |
|
|
50 |
void Common::logMessage(string msg) |
void Common::logMessage(string msg) |
51 |
{ |
{ |
52 |
time_t t = time(0); |
time_t t = time(0); |
125 |
if (! ( isDaemon || isDebug)) |
if (! ( isDaemon || isDebug)) |
126 |
printUsage(); |
printUsage(); |
127 |
} |
} |
128 |
|
|
129 |
|
|
130 |
|
std::string Common::getStatusMessage() |
131 |
|
{ |
132 |
|
long int now = time(0); |
133 |
|
|
134 |
|
long int diff = now - this->daemonStart; |
135 |
|
|
136 |
|
|
137 |
|
std::ostringstream out; |
138 |
|
out << "Uptime " << diff << " seconds. "; |
139 |
|
out << "Messages received:" << this->smsCounter.incomming << ". "; |
140 |
|
out << "Messages sent:" << this->smsCounter.outgoing << "."; |
141 |
|
|
142 |
|
return out.str(); |
143 |
|
} |