Phone number checking changed a bit.
authoreshe <jessehakanen@gmail.com>
Fri, 11 Jun 2010 13:09:03 +0000 (14:09 +0100)
committereshe <jessehakanen@gmail.com>
Fri, 11 Jun 2010 13:09:03 +0000 (14:09 +0100)
src/common/contactmanager.cpp
src/common/contactmanager.h

index e387e22..974c7a5 100644 (file)
 #include <QtCore/QDebug>
 #include "contactmanager.h"
 
-namespace
-{
-    const int COUNTRY_CODES[] = {358, 45, 46, 47, 354};
-    const int NUM_OF_CODES = 5;
-}
 
 ContactManager::ContactManager(): book_(0)
 {
@@ -47,8 +42,8 @@ bool ContactManager::numberExists(QString const& number)
     EBookQuery* query;
     GList *g_contacts;
 
-    QString copy(number);
-    QString clean = removeCountryCode(copy);
+    // Just check the last 7 digits
+    QString clean = number.right(7);
 
     query = e_book_query_any_field_contains(clean.toLatin1());
 
@@ -140,43 +135,3 @@ bool ContactManager::load()
 
 }
 
-QString& ContactManager::removeCountryCode(QString& number)
-{
-    if(number.isEmpty())
-    {
-        return number;
-    }
-
-    if(number.at(0) == '0')
-    {
-        return number.remove(0, 1);
-    }
-    else if(number.at(0) != '+')
-    {
-        return number;
-    }
-
-    static QRegExp countryCodeCleaner;
-    static bool countryCodeCleanerLoaded = false;
-
-    if(!countryCodeCleanerLoaded)
-    {
-        QString match = "";
-
-        for(int i = 0; i < NUM_OF_CODES; i++)
-        {
-            if(i > 0)
-            {
-                match += "|";
-            }
-
-            match += "\\+" + QString::number(COUNTRY_CODES[i]);
-        }
-
-        countryCodeCleaner = QRegExp("^(" + match + ")");
-        countryCodeCleanerLoaded = true;
-    }
-
-    return number.replace(countryCodeCleaner, "");
-}
-
index 0807519..b719700 100644 (file)
@@ -40,7 +40,6 @@ public:
     ~ContactManager();
     bool addContact(Contact const& contact);
     bool numberExists(QString const& number);
-    static QString& removeCountryCode(QString& number);
 
 private:
     bool load();