--- smsdaemon/main.cpp 2008/12/08 21:28:40 157 +++ smsdaemon/main.cpp 2008/12/18 06:53:29 196 @@ -1,8 +1,9 @@ #include #include +#include #include "daemon.h" -#include "common.h" +#include "Common.h" #include "Logger.h" #include "ModemTransceiver.h" @@ -18,8 +19,8 @@ bool sms_exit(int exitcode) { - if (Common::instance()->isDaemon) - daemonCleanup(); + if (Common::instance()->isDaemon) + daemonCleanup(); exit(exitcode); } @@ -32,16 +33,16 @@ Common* cmn = Common::instance(); ConfigFile* config = cmn->GetConfigfile(); - port = new SerialPort ( config->GetValue("smsdaemon","serialport") ); + port = new SerialPort ( config->GetValue("gsmmodem","serialport") ); try { - port->Open( SerialPort::BAUD_9600, - SerialPort::CHAR_SIZE_8, - SerialPort::PARITY_NONE, - SerialPort::STOP_BITS_1, - SerialPort::FLOW_CONTROL_HARD ); + port->Open( SerialPort::BAUD_9600, + SerialPort::CHAR_SIZE_8, + SerialPort::PARITY_NONE, + SerialPort::STOP_BITS_1, + SerialPort::FLOW_CONTROL_HARD ); } - catch(std::exception &e) + catch (std::exception &e) { Logger::logMessage( string("PortOpen Exception: ") + e.what() ); sms_exit(1); @@ -81,24 +82,27 @@ cmn->daemonStart = time(0); ConfigFile* config = cmn->GetConfigfile(); - + bool res = config->Open( cmn->configFilePath ) ; - if (!res) { - Logger::logMessage(string("Could not open config file:") + cmn->configFilePath); + if (!res) + { + cout << "Could not open config file:" << cmn->configFilePath << endl; return 1; } - + + Logger::initLog(); + ///////////////////// string transconf = config->GetValue("smsdaemon", "transceiver"); - - if (transconf == "internal") + + if (transconf == "internal") { openModemPort(); closeModemPort(); - } - else if ( transconf == "debug" || transconf == "smstools") + } + else if ( transconf == "debug" || transconf == "smstools") { //do nothing } @@ -108,9 +112,9 @@ exit(1); } - - if (Common::instance()->isDaemon) + + if (Common::instance()->isDaemon) { lookup_uid_values(); daemonize(); @@ -125,7 +129,7 @@ else if (transconf =="smstools") { transceiver = new SmsToolTransceiver(); - } + } else if (transconf == "debug") { transceiver = new DebugTransceiver(); @@ -135,11 +139,11 @@ SmsDaemon daemon(*transceiver); - daemon.Start(); + daemon.Start(); //returns here when main-loop exits - if (cmn->isDaemon) - daemonCleanup(); + if (cmn->isDaemon) + daemonCleanup(); if (transconf == "builtin") {