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

Diff of /smsdaemon/SmsDaemon.cpp

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

revision 95 by torben, Mon Jun 16 12:21:30 2008 UTC revision 151 by torben, Mon Dec 8 10:42:04 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 "ISmsTransceiver.h"
11    
12  #include "Plugin.h"  #include "Plugin.h"
13  #include "kbhit.h"  #include "kbhit.h"
# Line 14  Line 16 
16    
17  #include "TaskManager.h"  #include "TaskManager.h"
18  #include "PluginManager.h"  #include "PluginManager.h"
19    #include "ConfigFile.h"
20    
21  #include "version.h"  #include "version.h"
22    
23  using namespace std;  using namespace std;
24    
   
25  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)
26  {  {
27          ostringstream os;          ostringstream os;
28          os << "Recieved sms from " << sms.sender << " ; command=" << GetSmsCommand(sms);          os << "Recieved sms from " << sms.GetSender() << " ; command=" << sms.ExtractCommand();
29          if (!hasPlugin)          if (!hasPlugin)
30                  os << " -- PLUGIN NOT FOUND";                  os << " -- PLUGIN NOT FOUND";
31    
# Line 33  void SmsDaemon::CreateLogMessage(SMS& sm Line 35  void SmsDaemon::CreateLogMessage(SMS& sm
35    
36  void SmsDaemon::CheckSms()  void SmsDaemon::CheckSms()
37  {  {
38          const int INTERVAL = 250; //no of milliseconds between sms checks          const int INTERVAL = 1000; //no of milliseconds between sms checks
39          timeval now = Util::GetTimeOfDay();          timeval now = Util::GetTimeOfDay();
40    
41          if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL)          if ( Util::mTimeDiff(_lastSmsCheck,now) < INTERVAL)
# Line 48  void SmsDaemon::CheckSms() Line 50  void SmsDaemon::CheckSms()
50    
51          for (unsigned int i=0; i<sms.size(); ++i)          for (unsigned int i=0; i<sms.size(); ++i)
52          {          {
53                  string cmd = GetSmsCommand(sms[i]);                  string cmd = sms[i].ExtractCommand();
54                                                    
55                  cmd = Util::str_tolower(cmd);                  cmd = Util::str_tolower(cmd);
56    
# Line 62  void SmsDaemon::CheckSms() Line 64  void SmsDaemon::CheckSms()
64                  }                  }
65                  else                  else
66                  {                  {
67                          _modem.SendSms(sms[i].sender, "Unknown command!", false);                          _modem.SendSms(sms[i].GetSender(), "Unknown command!", false);
68                  }                  }
69    
70                  _modem.DeleteSms(sms[i].sms_index);                  _modem.DeleteSms(sms[i].GetIndex());
71                  cmn->smsCounter.incomming++;                  cmn->smsCounter.incomming++;
72          }          }
73  }  }
# Line 89  void SmsDaemon::MainLoop() Line 91  void SmsDaemon::MainLoop()
91                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
92                          break;                          break;
93    
94                  Util::Sleep(10);                  Util::Sleep(100);
95    
96          }          }
97  }  }
# Line 97  void SmsDaemon::MainLoop() Line 99  void SmsDaemon::MainLoop()
99  void SmsDaemon::Start()  void SmsDaemon::Start()
100  {  {
101          Common* cmn = Common::instance();          Common* cmn = Common::instance();
102            string transceiver = cmn->GetConfigfile()->GetValue("smsdaemon","transceiver");
103    
104            srand(time(0));
105    
106          cmn->daemonStart = time(0);          cmn->daemonStart = time(0);
107          _lastSmsCheck = Util::GetTimeOfDay();          _lastSmsCheck = Util::GetTimeOfDay();
108    
109          cmn->logMessage("--------------------------------");          cmn->logMessage("--------------------------------");
110          cmn->logMessage( VERSION );          cmn->logMessage( VERSION );
111          cmn->logMessage( SVNVER );          cmn->logMessage( SVNVERSION );
112            cmn->logMessage( string("Transceiver: ") + transceiver );
113    
114          cmn->GetTaskManager()->LoadTasks();          cmn->GetTaskManager()->LoadTasks();
115          cmn->GetPluginManager()->LoadPlugins();          cmn->GetPluginManager()->LoadPlugins();

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

  ViewVC Help
Powered by ViewVC 1.1.20