/[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 132 by torben, Sun Dec 7 00:59:05 2008 UTC
# Line 3  Line 3 
3  #include <string>  #include <string>
4    
5  #include <sstream>  #include <sstream>
6    #include <stdlib.h>
7    
8  #include "common.h"  #include "common.h"
9    
10  #include "GsmModem.h"  #include "GsmModem.h"
# Line 12  Line 14 
14    
15  #include "util.h"  #include "util.h"
16    
17  using namespace std;  #include "TaskManager.h"
18    #include "PluginManager.h"
19    
20    #include "version.h"
21    
22    using namespace std;
23    
24  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)
25  {  {
# Line 28  void SmsDaemon::CreateLogMessage(SMS& sm Line 34  void SmsDaemon::CreateLogMessage(SMS& sm
34    
35  void SmsDaemon::CheckSms()  void SmsDaemon::CheckSms()
36  {  {
37            const int INTERVAL = 1000; //no of milliseconds between sms checks
38            timeval now = Util::GetTimeOfDay();
39    
40            if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL)
41                    return;
42    
43            _lastSmsCheck = now;
44    
45          Common* cmn = Common::instance();          Common* cmn = Common::instance();
46    
47          PluginManager& manager = cmn->pluginManager;          PluginManager* manager = cmn->GetPluginManager();
48          vector<SMS> sms = _modem.ReadSms();          vector<SMS> sms = _modem.ReadSms();
49    
50          for (unsigned int i=0; i<sms.size(); ++i)          for (unsigned int i=0; i<sms.size(); ++i)
# Line 39  void SmsDaemon::CheckSms() Line 53  void SmsDaemon::CheckSms()
53                                                    
54                  cmd = Util::str_tolower(cmd);                  cmd = Util::str_tolower(cmd);
55    
56                  Plugin* pl = manager.GetPlugin(cmd);                  Plugin* pl = manager->GetPlugin(cmd);
57    
58                  CreateLogMessage(sms[i], pl != 0);                  CreateLogMessage(sms[i], pl != 0);
59    
# Line 71  void SmsDaemon::MainLoop() Line 85  void SmsDaemon::MainLoop()
85    
86                  CheckSms();                  CheckSms();
87    
88                  cmn->taskManager.ExecuteTasks();                  cmn->GetTaskManager()->ExecuteTasks(_modem);
89    
90                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
91                          break;                          break;
92    
93                  Util::Sleep(10);                  Util::Sleep(100);
94    
95          }          }
96  }  }
# Line 85  void SmsDaemon::Start() Line 99  void SmsDaemon::Start()
99  {  {
100          Common* cmn = Common::instance();          Common* cmn = Common::instance();
101    
102            srand(time(0));
103    
104          cmn->daemonStart = time(0);          cmn->daemonStart = time(0);
105            _lastSmsCheck = Util::GetTimeOfDay();
106    
107          cmn->logMessage("--------------------------------");          cmn->logMessage("--------------------------------");
108            cmn->logMessage( VERSION );
109            cmn->logMessage( SVNVERSION );
110    
111          cmn->taskManager.LoadTasks();          cmn->GetTaskManager()->LoadTasks();
112          cmn->pluginManager.LoadPlugins();          cmn->GetPluginManager()->LoadPlugins();
113          cmn->logMessage("SMS daemon started");          cmn->logMessage("SMS daemon started");
114    
115          _modem.DeleteAllSms();          _modem.DeleteAllSms();

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

  ViewVC Help
Powered by ViewVC 1.1.20