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

Diff of /smsdaemon/SmsDaemon.cpp

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

revision 157 by torben, Mon Dec 8 21:28:40 2008 UTC revision 675 by torben, Tue Apr 27 20:07:12 2010 UTC
# Line 5  Line 5 
5  #include <sstream>  #include <sstream>
6  #include <stdlib.h>  #include <stdlib.h>
7    
8  #include "common.h"  #include "Common.h"
9    
10  #include "ISmsTransceiver.h"  #include "ISmsTransceiver.h"
11    
12  #include "Plugin.h"  #include "Plugin.h"
13  #include "kbhit.h"  #include "kbhit.h"
14    
15  #include "util.h"  #include "Util.h"
16    
17  #include "TaskManager.h"  #include "TaskManager.h"
18  #include "PluginManager.h"  #include "PluginManager.h"
19  #include "ConfigFile.h"  #include "ConfigFile.h"
20  #include "Logger.h"  #include "Logger.h"
21    #include "AccessManager.h"
22    #include "embedded-http/embeddedhttp.h"
23    
24  #include "version.h"  #include "version.h"
25    
26    
27  using namespace std;  using namespace std;
28    
29  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)  void SmsDaemon::CreateLogMessage(SMS& sms,bool hasPlugin)
# Line 52  void SmsDaemon::CheckSms() Line 55  void SmsDaemon::CheckSms()
55          for (unsigned int i=0; i<sms.size(); ++i)          for (unsigned int i=0; i<sms.size(); ++i)
56          {          {
57                  string cmd = sms[i].ExtractCommand();                  string cmd = sms[i].ExtractCommand();
58                            
59                  cmd = Util::str_tolower(cmd);                  cmd = Util::str_tolower(cmd);
60    
61                  Plugin* pl = manager->GetPlugin(cmd);                  Plugin* pl = manager->GetPlugin(cmd);
# Line 68  void SmsDaemon::CheckSms() Line 71  void SmsDaemon::CheckSms()
71                          _modem.SendSms(sms[i].GetSender(), "Unknown command!", false);                          _modem.SendSms(sms[i].GetSender(), "Unknown command!", false);
72                  }                  }
73    
                 _modem.DeleteSms(sms[i].GetIndex());  
74                  cmn->smsCounter.incomming++;                  cmn->smsCounter.incomming++;
75          }          }
76  }  }
# Line 78  void SmsDaemon::MainLoop() Line 80  void SmsDaemon::MainLoop()
80  {  {
81          Common* cmn = Common::instance();          Common* cmn = Common::instance();
82          volatile bool& mainContinue = cmn->mainContinue;          volatile bool& mainContinue = cmn->mainContinue;
83            volatile bool& reloadConfig = cmn->reloadConfig;
84    
85          mainContinue = true;          mainContinue = true;
86    
# Line 92  void SmsDaemon::MainLoop() Line 94  void SmsDaemon::MainLoop()
94                  if (cmn->isDebug && kbhit())                  if (cmn->isDebug && kbhit())
95                          break;                          break;
96    
97                    if (reloadConfig)
98                            ReloadConfig();
99    
100                  Util::Sleep(100);                  Util::Sleep(100);
101    
102          }          }
103  }  }
104    
105    void SmsDaemon::ReloadConfig()
106    {
107            Common* cmn = Common::instance();
108            cmn->reloadConfig = false;
109    
110            cmn->GetConfigfile()->Reload();
111    
112            cmn->GetPluginManager()->DestroyPlugins();
113            cmn->GetPluginManager()->LoadPlugins();
114    
115            cmn->GetTaskManager()->DestroyTasks();
116            cmn->GetTaskManager()->LoadTasks();
117    
118            AccessManager::Load(); //reload blaclist & privileged list
119    }
120    
121  void SmsDaemon::Start()  void SmsDaemon::Start()
122  {  {
123          Common* cmn = Common::instance();          Common* cmn = Common::instance();
# Line 112  void SmsDaemon::Start() Line 133  void SmsDaemon::Start()
133          Logger::logMessage( SVNVERSION );          Logger::logMessage( SVNVERSION );
134          Logger::logMessage( string("Transceiver: ") + transceiver );          Logger::logMessage( string("Transceiver: ") + transceiver );
135    
136            AccessManager::Load(); //reload blaclist & privileged list
137          cmn->GetTaskManager()->LoadTasks();          cmn->GetTaskManager()->LoadTasks();
138          cmn->GetPluginManager()->LoadPlugins();          cmn->GetPluginManager()->LoadPlugins();
139          Logger::logMessage("SMS daemon started");          Logger::logMessage("SMS daemon started");
140    
141          _modem.DeleteAllSms();          embeddedHttp = new EmbeddedHttp();
142                    embeddedHttp->startServer();
143    
144          try          try
145          {          {
146                  MainLoop();                  MainLoop();
# Line 131  void SmsDaemon::Start() Line 154  void SmsDaemon::Start()
154                  Logger::logMessage( "Caught unknown exception" );                  Logger::logMessage( "Caught unknown exception" );
155          }          }
156    
157            embeddedHttp->stopServer();
158    
159            cmn->GetPluginManager()->DestroyPlugins();
160    
161          Logger::logMessage( cmn->getStatusMessage() );          Logger::logMessage( cmn->getStatusMessage() );
162  }  }

Legend:
Removed from v.157  
changed lines
  Added in v.675

  ViewVC Help
Powered by ViewVC 1.1.20