/[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 125 by torben, Sat Dec 6 14:06:17 2008 UTC
# Line 12  Line 12 
12    
13  #include "util.h"  #include "util.h"
14    
15  using namespace std;  #include "TaskManager.h"
16    #include "PluginManager.h"
17    
18    #include "version.h"
19    
20    using namespace std;
21    
22  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)
23  {  {
# Line 28  void SmsDaemon::CreateLogMessage(SMS& sm Line 32  void SmsDaemon::CreateLogMessage(SMS& sm
32    
33  void SmsDaemon::CheckSms()  void SmsDaemon::CheckSms()
34  {  {
35            const int INTERVAL = 250; //no of milliseconds between sms checks
36            timeval now = Util::GetTimeOfDay();
37    
38            if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL)
39                    return;
40    
41            _lastSmsCheck = now;
42    
43          Common* cmn = Common::instance();          Common* cmn = Common::instance();
44    
45          PluginManager& manager = cmn->pluginManager;          PluginManager* manager = cmn->GetPluginManager();
46          vector<SMS> sms = _modem.ReadSms();          vector<SMS> sms = _modem.ReadSms();
47    
48          for (unsigned int i=0; i<sms.size(); ++i)          for (unsigned int i=0; i<sms.size(); ++i)
# Line 39  void SmsDaemon::CheckSms() Line 51  void SmsDaemon::CheckSms()
51                                                    
52                  cmd = Util::str_tolower(cmd);                  cmd = Util::str_tolower(cmd);
53    
54                  Plugin* pl = manager.GetPlugin(cmd);                  Plugin* pl = manager->GetPlugin(cmd);
55    
56                  CreateLogMessage(sms[i], pl != 0);                  CreateLogMessage(sms[i], pl != 0);
57    
# Line 66  void SmsDaemon::MainLoop() Line 78  void SmsDaemon::MainLoop()
78    
79          mainContinue = true;          mainContinue = true;
80    
81            int loopcount = 0;
82          while (mainContinue)          while (mainContinue)
83          {          {
84                    if (loopcount > 100 )
85                    {
86                            CheckSms();
87    
88                  CheckSms();                          cmn->GetTaskManager()->ExecuteTasks(_modem);
89    
90                  cmn->taskManager.ExecuteTasks();                          loopcount = 0;
91                    }
92    
93                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
94                          break;                          break;
# Line 87  void SmsDaemon::Start() Line 104  void SmsDaemon::Start()
104    
105    
106          cmn->daemonStart = time(0);          cmn->daemonStart = time(0);
107            _lastSmsCheck = Util::GetTimeOfDay();
108    
109          cmn->logMessage("--------------------------------");          cmn->logMessage("--------------------------------");
110            cmn->logMessage( VERSION );
111            cmn->logMessage( SVNVERSION );
112    
113          cmn->taskManager.LoadTasks();          cmn->GetTaskManager()->LoadTasks();
114          cmn->pluginManager.LoadPlugins();          cmn->GetPluginManager()->LoadPlugins();
115          cmn->logMessage("SMS daemon started");          cmn->logMessage("SMS daemon started");
116    
117          _modem.DeleteAllSms();          _modem.DeleteAllSms();

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

  ViewVC Help
Powered by ViewVC 1.1.20