--- smsdaemon/main.cpp 2008/12/07 00:59:05 132 +++ smsdaemon/main.cpp 2008/12/07 20:58:41 149 @@ -4,10 +4,10 @@ #include "daemon.h" #include "common.h" -#include "GsmModem.h" +#include "ModemTransceiver.h" #include "serialport/SerialPort.h" #include "SmsDaemon.h" - +#include "ConfigFile.h" using namespace std; @@ -20,6 +20,7 @@ exit(exitcode); } + int main(int argc, char* argv[]) { Common* cmn = Common::instance(); @@ -30,22 +31,31 @@ cmn->pidfile = "/var/run/smsdaemon.pid"; cmn->spooldir = "/var/spool/smsdaemon"; - cmn->uid = 1000; - cmn->gid = 1000; cmn->loadConfig(argc,argv); cmn->daemonStart = time(0); + ConfigFile* config = cmn->GetConfigfile(); + + bool res = config->Open( cmn->configFilePath ) ; + if (!res) { + cmn->logMessage(string("Could not open config file:") + cmn->configFilePath); + return 1; + } + ///////////////////// //Write a delimiter line in the logfile to seperate sessions - if (Common::instance()->isDaemon) + if (Common::instance()->isDaemon) + { + lookup_uid_values(); daemonize(); + } - SerialPort port("/dev/ttyUSB0" ); + SerialPort port( config->GetValue("smsdaemon","serialport") ); try { port.Open( SerialPort::BAUD_9600, @@ -60,7 +70,7 @@ sms_exit(1); } - GsmModem modem(port); + ModemTransceiver modem(port); try { @@ -68,7 +78,7 @@ } catch (std::exception& e) { - cmn->logMessage( string("GsmModem Exception: ") + e.what() ); + cmn->logMessage( string("ModemTransceiver Exception: ") + e.what() ); sms_exit(2); }