--- smsdaemon/main.cpp 2008/12/09 21:44:15 168 +++ smsdaemon/main.cpp 2008/12/21 22:08:20 211 @@ -1,5 +1,6 @@ #include #include +#include #include "daemon.h" #include "Common.h" @@ -8,6 +9,7 @@ #include "ModemTransceiver.h" #include "DebugTransceiver.h" #include "SmsToolTransceiver.h" +#include "ProxyTransceiver.h" #include "serialport/SerialPort.h" #include "SmsDaemon.h" @@ -18,8 +20,8 @@ bool sms_exit(int exitcode) { - if (Common::instance()->isDaemon) - daemonCleanup(); + if (Common::instance()->isDaemon) + daemonCleanup(); exit(exitcode); } @@ -35,13 +37,13 @@ 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 +83,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 +113,9 @@ exit(1); } - - if (Common::instance()->isDaemon) + + if (Common::instance()->isDaemon) { lookup_uid_values(); daemonize(); @@ -125,21 +130,23 @@ else if (transconf =="smstools") { transceiver = new SmsToolTransceiver(); - } + } else if (transconf == "debug") { transceiver = new DebugTransceiver(); } + ProxyTransceiver proxy(*transceiver); + ////////////////////////////////// - SmsDaemon daemon(*transceiver); + SmsDaemon daemon(proxy); - daemon.Start(); + daemon.Start(); //returns here when main-loop exits - if (cmn->isDaemon) - daemonCleanup(); + if (cmn->isDaemon) + daemonCleanup(); if (transconf == "builtin") {