Merge branch 'master' of ssh://drop.maemo.org/git/vicar
[vicar] / src / vicar-daemon / cpp / callrouter.cpp
index 7a5d8ed..0ea72cb 100755 (executable)
@@ -7,7 +7,6 @@
 #include "callrouter.h"
 #include "vicardbusadaptor.h"
 #include <dbusutility.h>
-#include <gconfutility.h>
 #include <databaseutility.h>
 #include <telepathyutility.h>
 #include <QDebug>
@@ -23,13 +22,13 @@ public:
         databaseUtility(new DatabaseUtility(p)),
         dbusAdaptor(new VicarDbusAdaptor(p)),
         dbusUtility(new DbusUtility(p)),        
-        gconfUtility(new GConfUtility(p)),
         tpUtility(new TelepathyUtility(p)),
         parent(p)
     {
         Q_ASSERT(0 != dbusAdaptor);
         //Do not open here - Unable to capture changes to DB if it is open too early and closed late.
         //databaseUtility->openDatabase();
+        qDebug () << "In Private Constructor";
     }
 
     ~CallRouterPrivate()
@@ -41,7 +40,6 @@ public:
     DatabaseUtility *databaseUtility;
     VicarDbusAdaptor * dbusAdaptor;
     DbusUtility * dbusUtility;
-    GConfUtility * gconfUtility;
     TelepathyUtility *tpUtility;
     QString strLastDialedNumber;
     QString strLastDTMFCode;
@@ -56,8 +54,7 @@ CallRouter::CallRouter(QObject *parent) :
     d(new CallRouterPrivate(this))
 {
         Q_ASSERT(0 != d);
-        this->registerDBusService();
-        qDebug() << "Vicar-Daemon: Registered DBus Service " << APPLICATION_DBUS_SERVICE;
+        this->registerDBusService();        
 }
 
 CallRouter::~CallRouter(){
@@ -70,16 +67,23 @@ void CallRouter::registerDBusService(){
     if (!connection.interface()->isServiceRegistered(APPLICATION_DBUS_SERVICE)){
 
         if (!connection.registerService(APPLICATION_DBUS_SERVICE)) {
-            qDebug() << "Vicar-Daemon: " << d->dbusUtility->getErrorMessage();
+            qDebug() << "Vicar-Daemon: Error registering D-Bus service " << d->dbusUtility->getErrorMessage();
+            qDebug() << "Vicar-Daemon: Exiting";
             exit(1);
         }
+        else{
+            qDebug() << "Vicar-Daemon: Registered DBus Service " << APPLICATION_DBUS_SERVICE;
+        }
     }
 
     if (!connection.registerObject(APPLICATION_DBUS_PATH, this, QDBusConnection::ExportAdaptors)) {
         qDebug() << "Vicar-Daemon: " << d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Exiting";
         exit(2);
     }
-
+    else{
+        qDebug() << "Vicar-Daemon: Registered DBus Object " << APPLICATION_DBUS_PATH;
+    }
 }
 
 
@@ -110,7 +114,10 @@ QString CallRouter::callViaCallingCard(QString strDestinationNumber){
             strErrorMessage = QString("Vicar-Daemon: Error finding VICaR profile. %1").arg(d->databaseUtility->lastError().text());
         }
         else if (d->currentProfile->profileID == 0){
-            bool routeOnDefault = d->gconfUtility->getGconfValueBoolean("route_on_default");
+            QString routeOnDefaultSetting = d->databaseUtility->getSetting("route_on_default");
+            //bool routeOnDefault = d->gconfUtility->getGconfValueBoolean("route_on_default");
+            bool routeOnDefault = routeOnDefaultSetting == "1"? true:false;
+
             if (routeOnDefault){
                 qDebug() << "Vicar-Daemon: Routing directly as per configuration";
                this->placeCall(strDestinationNumber);