/[projects]/smsdaemon/SmsDaemon.cpp
ViewVC logotype

Diff of /smsdaemon/SmsDaemon.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 88 by torben, Mon Jun 16 09:04:05 2008 UTC revision 95 by torben, Mon Jun 16 12:21:30 2008 UTC
# Line 12  Line 12 
12    
13  #include "util.h"  #include "util.h"
14    
15    #include "TaskManager.h"
16    #include "PluginManager.h"
17    
18    #include "version.h"
19    
20  using namespace std;  using namespace std;
21    
22    
# Line 28  void SmsDaemon::CreateLogMessage(SMS& sm Line 33  void SmsDaemon::CreateLogMessage(SMS& sm
33    
34  void SmsDaemon::CheckSms()  void SmsDaemon::CheckSms()
35  {  {
36            const int INTERVAL = 250; //no of milliseconds between sms checks
37            timeval now = Util::GetTimeOfDay();
38    
39            if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL)
40                    return;
41    
42            _lastSmsCheck = now;
43    
44          Common* cmn = Common::instance();          Common* cmn = Common::instance();
45    
46          PluginManager& manager = cmn->pluginManager;          PluginManager* manager = cmn->GetPluginManager();
47          vector<SMS> sms = _modem.ReadSms();          vector<SMS> sms = _modem.ReadSms();
48    
49          for (unsigned int i=0; i<sms.size(); ++i)          for (unsigned int i=0; i<sms.size(); ++i)
# Line 39  void SmsDaemon::CheckSms() Line 52  void SmsDaemon::CheckSms()
52                                                    
53                  cmd = Util::str_tolower(cmd);                  cmd = Util::str_tolower(cmd);
54    
55                  Plugin* pl = manager.GetPlugin(cmd);                  Plugin* pl = manager->GetPlugin(cmd);
56    
57                  CreateLogMessage(sms[i], pl != 0);                  CreateLogMessage(sms[i], pl != 0);
58    
# Line 71  void SmsDaemon::MainLoop() Line 84  void SmsDaemon::MainLoop()
84    
85                  CheckSms();                  CheckSms();
86    
87                  cmn->taskManager.ExecuteTasks();                  cmn->GetTaskManager()->ExecuteTasks(_modem);
88    
89                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
90                          break;                          break;
# Line 87  void SmsDaemon::Start() Line 100  void SmsDaemon::Start()
100    
101    
102          cmn->daemonStart = time(0);          cmn->daemonStart = time(0);
103            _lastSmsCheck = Util::GetTimeOfDay();
104    
105          cmn->logMessage("--------------------------------");          cmn->logMessage("--------------------------------");
106            cmn->logMessage( VERSION );
107            cmn->logMessage( SVNVER );
108    
109          cmn->taskManager.LoadTasks();          cmn->GetTaskManager()->LoadTasks();
110          cmn->pluginManager.LoadPlugins();          cmn->GetPluginManager()->LoadPlugins();
111          cmn->logMessage("SMS daemon started");          cmn->logMessage("SMS daemon started");
112    
113          _modem.DeleteAllSms();          _modem.DeleteAllSms();

Legend:
Removed from v.88  
changed lines
  Added in v.95

  ViewVC Help
Powered by ViewVC 1.1.20