Added option to skip the leading zero of an incoming call.
[jenirok] / src / daemon / calllistener.cpp
index c76cfdc..bdc6529 100644 (file)
@@ -43,7 +43,7 @@ QDBusConnection CallListener::systemBus_ = QDBusConnection::systemBus();
 
 CallListener::CallListener(): source_(0),
 closeConnection_(false), initialized_(false), box_(0), label_(0),
-retries_(-1), timer_(0), currentCall_(0)
+retries_(-1), timer_(0), currentCall_(0), ignoreFirstZero_(false)
 {
 }
 
@@ -68,6 +68,8 @@ bool CallListener::begin()
     sourceConfig_ = tmpConfig;
     delete config;
 
+    ignoreFirstZero_ = (Settings::instance()->get("ignore_first_zero") == "1");
+
     systemBus_.connect(CALL_SERVICE_NAME,
                        CALL_SERVICE_PATH,
                        CALL_SERVICE_INTERFACE,
@@ -271,6 +273,13 @@ void CallListener::incomingCall(QDBusObjectPath path, QString number)
         return;
     }
 
+    // If the call has come through some kind of switch board
+    // there might be a leading zero added
+    if(ignoreFirstZero_)
+    {
+        number = number.replace(QRegExp("^00"), "0");
+    }
+
     ContactManager cm;
 
     if(!cm.numberExists(number))