Vicar release 0.6-1 (a.k.a I'm still here release)
[vicar] / src / vicar-lib / src / databaseutility.cpp
index 638b6f0..e2df72b 100644 (file)
@@ -127,6 +127,25 @@ bool DatabaseUtility::findProfileByNumber(QString number,org::maemo::vicar::Prof
     return result;
 }
 
+bool DatabaseUtility::getDefaultProfile(org::maemo::vicar::Profile *profile){
+    bool result = false;
+    if (profilesDB.isOpen()){
+        QString strQuery = QString("select * from profiles where numberpattern = '%' order by id");
+        qDebug() << "SQL>"<<strQuery;
+        QSqlQuery query(strQuery);
+        if (query.next()){
+            profile->profileID = query.value(0).toInt();
+            profile->phoneNumberPattern = query.value(1).toString();
+            profile->gatewayNumber = query.value(2).toString();
+            profile->dtmfFormat = query.value(3).toString();
+            profile->dtmfPrefix = query.value(4).toString();
+            profile->dtmfSuffix = query.value(5).toString();
+            result = true;
+        }
+    }
+    return result;
+}
+
 int DatabaseUtility::insertProfile(org::maemo::vicar::Profile profile){
     int newId   = -1;
     bool result = false;    
@@ -172,7 +191,9 @@ bool DatabaseUtility::deleteProfile(int id){
     bool result = false;
     if (profilesDB.isOpen()){
         QSqlQuery query;
-        result = query.exec(QString("delete from profiles where id=%1").arg(id));
+        QString strQuery = QString("delete from profiles where id=%1").arg(id);
+        qDebug() << "SQL>"<<strQuery;
+        result = query.exec(strQuery);
     }
     return result;
 }