--- smsdaemon/common.cpp 2008/06/09 18:15:53 26 +++ smsdaemon/common.cpp 2008/08/24 17:57:04 109 @@ -1,5 +1,8 @@ #include "common.h" + +#include "version.h" + #include #include #include @@ -7,8 +10,11 @@ #include #include +#include "TaskManager.h" +#include "PluginManager.h" + using namespace std; -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"}; Common* Common::instance() { @@ -17,6 +23,33 @@ } +Common::Common() + : _pluginManager(0), _taskManager(0) +{ + _pluginManager = new PluginManager(); + _taskManager = new TaskManager(); +} + + +Common::~Common() +{ + if (_pluginManager) + delete _pluginManager; + + if (_taskManager) + delete _taskManager; +} + +PluginManager* Common::GetPluginManager() +{ + return _pluginManager; +} + +TaskManager* Common::GetTaskManager() +{ + return _taskManager; +} + void Common::logMessage(string msg) { time_t t = time(0); @@ -52,6 +85,7 @@ void Common::printUsage() { cout << VERSION << endl; + cout << SVNVERSION << endl << endl; cout << "Usage --daemon|--debug [arguments]" << endl; cout << "Commandline arguments :" << endl; cout << " --daemon : Run in daemon (background) mode" << endl; @@ -87,11 +121,26 @@ } else { - cout << VERSION; - cout << "Unknown argument : " << current << endl; + cout << "Unknown argument : " << current << endl << endl; } } if (! ( isDaemon || isDebug)) printUsage(); } + + +std::string Common::getStatusMessage() +{ + long int now = time(0); + + long int diff = now - this->daemonStart; + + + std::ostringstream out; + out << "Uptime " << diff << " seconds. "; + out << "Messages received:" << this->smsCounter.incomming << ". "; + out << "Messages sent:" << this->smsCounter.outgoing << "."; + + return out.str(); +}