Added option to skip the leading zero of an incoming call.
authoreshe <jessehakanen@gmail.com>
Tue, 26 Oct 2010 13:17:38 +0000 (14:17 +0100)
committereshe <jessehakanen@gmail.com>
Tue, 26 Oct 2010 13:17:38 +0000 (14:17 +0100)
src/common/settings.cpp
src/daemon/calllistener.cpp
src/daemon/calllistener.h

index 6453bb3..78bbc2b 100644 (file)
@@ -185,6 +185,7 @@ QString Settings::getDefaultValue(QString const& name)
         defaultValues["eniro_site"] = tr("fi");
         defaultValues["cache_size"] = "200";
         defaultValues["connection"] = "global";
+        defaultValues["ignore_first_zero"] = "1";
         defaultValuesLoaded = true;
     }
 
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))
index 16b6218..b58f3cb 100644 (file)
@@ -91,6 +91,7 @@ private:
     int retries_;
     int timer_;
     CallDetails* currentCall_;
+    bool ignoreFirstZero_;
 };
 
 #endif // CALLLISTENER_H