SIGSEGV Fixed
authorSudheer K <scifi1947 at gmail.com>
Sun, 8 Jan 2012 08:02:18 +0000 (00:02 -0800)
committerSudheer K <scifi1947 at gmail.com>
Sun, 8 Jan 2012 08:02:18 +0000 (00:02 -0800)
28 files changed:
qtc_packaging/debian_harmattan/manifest.aegis_old [deleted file]
qtc_packaging/debian_harmattan/postinst_DONTUSE [deleted file]
qtc_packaging/debian_harmattan/postrm [deleted file]
qtc_packaging/debian_harmattan/prerm
qtc_packaging/debian_harmattan/rules
qtc_packaging/debian_harmattan/vicar.aegis
qtc_packaging/debian_harmattan/vicar.substvars
src/data/accounts/vicar.service
src/data/xml/org.freedesktop.Connection.sofiasip.sip.whitenoise_40sipsorcery_2ecom.xml [deleted file]
src/data/xml/org.sip.connection.properties [deleted file]
src/vicar-config-qml/qml/vicarconfigqml/Library/js/DBUtility.js
src/vicar-config/cpp/profileswindow.cpp
src/vicar-daemon/cpp/callrouter.cpp
src/vicar-daemon/cpp/callrouter.h
src/vicar-daemon/vicar-daemon.pro
src/vicar-lib/cpp/databaseutility.cpp
src/vicar-lib/cpp/databaseutility.h
src/vicar-lib/cpp/gconfutility.cpp [deleted file]
src/vicar-lib/cpp/gconfutility.h [deleted file]
src/vicar-lib/cpp/logutility.h
src/vicar-lib/cpp/telepathyutility.cpp
src/vicar-lib/vicar-lib.pro
src/vicar-telepathy/cpp/connection.cpp
src/vicar-telepathy/cpp/connectioninterfacerequestsadaptor.cpp
src/vicar-telepathy/cpp/connectionmanager.cpp
src/vicar-telepathy/cpp/main.cpp
src/vicar-telepathy/vicar-telepathy.pro
src/vicar-utils/cpp/main.cpp

diff --git a/qtc_packaging/debian_harmattan/manifest.aegis_old b/qtc_packaging/debian_harmattan/manifest.aegis_old
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/qtc_packaging/debian_harmattan/postinst_DONTUSE b/qtc_packaging/debian_harmattan/postinst_DONTUSE
deleted file mode 100644 (file)
index e608d4c..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-# postinst script for vicar
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    configure)
-
-       eval $(dbus-launch --sh-syntax)
-       export DBUS_SESSION_BUS_ADDRESS
-       export DBUS_SESSION_BUS_PID
-
-       # Kill any running instances of the daemon (only used on Linux based systems)
-       #killall -q vicar-daemon || true
-       #killall -q vicar-telepathy || true
-
-       echo "Checking for log folder ..."
-        [[ ! -d /var/log/vicar ]] && mkdir /var/log/vicar
-
-       echo "Checking for log file ..."
-        [[ ! -e /var/log/vicar/vicar.log ]] && touch /var/log/vicar/vicar.log && chown -R user:users /var/log/vicar
-
-        echo "Starting Vicar daemon ..."
-        #[[ -x /opt/vicar/bin/vicar-daemon ]] && su - user -c "exec /opt/vicar/bin/vicar-daemon& >/dev/null"
-
-        echo "Starting Vicar-Telepathy ..."
-        #[[ -x /opt/vicar/bin/vicar-telepathy ]] && su - user -c "exec /opt/vicar/bin/vicar-telepathy& >/dev/null"
-
-        echo "Creating Vicar Telepathy account ..."
-        #[[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils INSTALL"
-
-        echo "Updating permissions on Vicar DB file ..."
-        #[[ -e /home/user/vicar.db.sqlite ]] && chown user:users /home/user/vicar.db.sqlite
-
-        echo "Creating Vicar Profiles database ..."
-        #[[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils CREATEDB"
-
-    ;;
-
-    abort-upgrade|abort-remove|abort-deconfigure)
-    ;;
-
-    *)
-        echo "postinst called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-
diff --git a/qtc_packaging/debian_harmattan/postrm b/qtc_packaging/debian_harmattan/postrm
deleted file mode 100755 (executable)
index 715c06a..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-# postrm script for vicar
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postrm> `remove'
-#        * <postrm> `purge'
-#        * <old-postrm> `upgrade' <new-version>
-#        * <new-postrm> `failed-upgrade' <old-version>
-#        * <new-postrm> `abort-install'
-#        * <new-postrm> `abort-install' <old-version>
-#        * <new-postrm> `abort-upgrade' <old-version>
-#        * <disappearer's-postrm> `disappear' <overwriter>
-#          <overwriter-version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-    purge)
-        echo "Removing logs ..."
-        #[[ -d /var/log/vicar ]] && rm -rf /var/log/vicar
-    ;;
-
-    remove|abort-install)
-    ;;
-
-    upgrade|failed-upgrade|abort-upgrade|disappear)
-    ;;
-
-    *)
-        echo "postrm called with unknown argument \`$1'" >&2
-        exit 1
-    ;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
-
-
index 0d0de12..e650ab5 100755 (executable)
@@ -20,15 +20,14 @@ set -e
 case "$1" in
     remove|deconfigure)
 
-       eval $(dbus-launch --sh-syntax)
-       export DBUS_SESSION_BUS_ADDRESS
-       export DBUS_SESSION_BUS_PID
-
         echo "Deleting Vicar Telepathy account ..."
-        #[[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils REMOVE"
+        [[ -x /opt/vicar/bin/vicar-utils ]] && /opt/vicar/bin/vicar-utils REMOVE
+
+        echo "Deleting Vicar Harmattan account ..."
+        [[ -x /opt/vicar/bin/vicar-utils ]] && /opt/vicar/bin/vicar-utils --delete-account
 
-        echo "Deleting Vicar Profiles database ..."
-        #[[ -x /opt/vicar/bin/vicar-utils ]] && su - user -c "exec /opt/vicar/bin/vicar-utils DROPDB"
+        #echo "Deleting Vicar Profiles database ..."
+        #[[ -d /home/user/.vicar ]] && rm -rf /home/user/.vicar/
 
        # Kill any running instances of the daemon (only used on Linux based systems)
        killall -q vicar-daemon || true
index 46da245..3273a26 100755 (executable)
@@ -62,7 +62,7 @@ binary-arch: build install
        dh_testroot
        dh_installchangelogs 
        dh_installdocs
-       dh_installexamples
+#      dh_installexamples
 #      dh_install
 #      dh_installmenu
 #      dh_installdebconf       
@@ -74,15 +74,15 @@ binary-arch: build install
 #      dh_installinit
 #      dh_installcron
 #      dh_installinfo
-       dh_installman
+#      dh_installman
        dh_link
-       dh_strip
+       dh_strip #Uncomment to remove debug symbols
        dh_compress
        dh_fixperms
 #      dh_perl
 #      dh_makeshlibs
        dh_installdeb
-       # dh_shlibdeps # Uncomment this line for use without Qt Creator
+       dh_shlibdeps # Uncomment this line for use without Qt Creator
        dh_gencontrol
        dh_md5sums
        dh_builddeb
index 319b253..4c310f9 100644 (file)
@@ -8,7 +8,7 @@
      Modify the file or remove the checksum to disable this functionality. -->
 <aegis>
 
-        <!-- provide>
+        <!--provide>
            <dbus name="org.freedesktop.Telepathy.Connection.vicar.tel.vicar" own="Cellular" bus="session">
                <node name="/">
                        <interface name="org.freedesktop.Telepathy.Connection">
                <for path="/opt/vicar/bin/vicar-telepathy" />
                <for path="/opt/vicar/bin/vicar-daemon" />
                <for path="/opt/vicar/bin/vicar-utils" />
-               <!-- These entries to be used only when debug package is included
-               <for path="/usr/lib/debug/opt/vicar/bin/vicar-telepathy" />
-               <for path="/usr/lib/debug/opt/vicar/bin/vicar-daemon" />
-               <for path="/usr/lib/debug/opt/vicar/bin/vicar-utils" /> -->
        </request>
 
        <request context="INSTALL">
index abd3ebe..218df44 100644 (file)
@@ -1 +1,2 @@
+shlibs:Depends=applauncherd-launcher, libaccounts-qt1, libc6 (>= 2.4), libdbus-1-3 (>= 1.0.2), libdbus-glib-1-2 (>= 0.71), libgcc1 (>= 1:4.1.1), libgconf2-6 (>= 2.13.5), libglib2.0-0 (>= 2.12.0), libqt4-dbus (>= 4.7.4~git20110517), libqt4-declarative (>= 4.7.4~git20110517), libqt4-sql (>= 4.7.4~git20110517), libqt4-xml (>= 4.7.4~git20110517), libqtcore4 (>= 4.7.4~git20110517), libqtgui4 (>= 4.7.4~git20110517), libstdc++6 (>= 4.4.0)
 misc:Depends=
index 47db52c..13a981d 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <service id="vicar">
   <type>IM</type>
-  <name>VICaR Service Name</name>
+  <name>Vicar</name>
   <provider>vicar</provider>
   <icon>icon-m-service-vicar</icon>
 
diff --git a/src/data/xml/org.freedesktop.Connection.sofiasip.sip.whitenoise_40sipsorcery_2ecom.xml b/src/data/xml/org.freedesktop.Connection.sofiasip.sip.whitenoise_40sipsorcery_2ecom.xml
deleted file mode 100644 (file)
index 879219a..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
-  <interface name="org.freedesktop.DBus.Introspectable">
-    <method name="Introspect">
-      <arg name="data" direction="out" type="s"/>
-    </method>
-  </interface>
-  <interface name="org.freedesktop.DBus.Properties">
-    <method name="Get">
-      <arg name="interface" direction="in" type="s"/>
-      <arg name="propname" direction="in" type="s"/>
-      <arg name="value" direction="out" type="v"/>
-    </method>
-    <method name="Set">
-      <arg name="interface" direction="in" type="s"/>
-      <arg name="propname" direction="in" type="s"/>
-      <arg name="value" direction="in" type="v"/>
-    </method>
-    <method name="GetAll">
-      <arg name="interface" direction="in" type="s"/>
-      <arg name="props" direction="out" type="a{sv}"/>
-    </method>
-  </interface>
-  <interface name="org.freedesktop.Telepathy.Connection.Interface.Aliasing">
-    <method name="SetAliases">
-      <arg name="Aliases" type="a{us}" direction="in"/>
-    </method>
-    <method name="GetAliases">
-      <arg name="Contacts" type="au" direction="in"/>
-      <arg name="Aliases" type="a{us}" direction="out"/>
-    </method>
-    <method name="RequestAliases">
-      <arg name="Contacts" type="au" direction="in"/>
-      <arg name="Aliases" type="as" direction="out"/>
-    </method>
-    <method name="GetAliasFlags">
-      <arg name="Alias_Flags" type="u" direction="out"/>
-    </method>
-    <signal name="AliasesChanged">
-      <arg type="a(us)"/>
-    </signal>
-  </interface>
-  <interface name="org.freedesktop.Telepathy.Connection.Interface.Contacts">
-    <method name="GetContactAttributes">
-      <arg name="Handles" type="au" direction="in"/>
-      <arg name="Interfaces" type="as" direction="in"/>
-      <arg name="Hold" type="b" direction="in"/>
-      <arg name="Attributes" type="a{ua{sv}}" direction="out"/>
-    </method>
-  </interface>
-  <interface name="org.freedesktop.Telepathy.Connection.Interface.Requests">
-    <method name="EnsureChannel">
-      <arg name="Request" type="a{sv}" direction="in"/>
-      <arg name="Yours" type="b" direction="out"/>
-      <arg name="Channel" type="o" direction="out"/>
-      <arg name="Properties" type="a{sv}" direction="out"/>
-    </method>
-    <method name="CreateChannel">
-      <arg name="Request" type="a{sv}" direction="in"/>
-      <arg name="Channel" type="o" direction="out"/>
-      <arg name="Properties" type="a{sv}" direction="out"/>
-    </method>
-    <signal name="ChannelClosed">
-      <arg type="o"/>
-    </signal>
-    <signal name="NewChannels">
-      <arg type="a(oa{sv})"/>
-    </signal>
-  </interface>
-  <interface name="org.freedesktop.DBus.Properties">
-    <method name="GetAll">
-      <arg name="Interface_Name" type="s" direction="in"/>
-      <arg name="Properties" type="a{sv}" direction="out"/>
-    </method>
-    <method name="Set">
-      <arg name="Interface_Name" type="s" direction="in"/>
-      <arg name="Property_Name" type="s" direction="in"/>
-      <arg name="Value" type="v" direction="in"/>
-    </method>
-    <method name="Get">
-      <arg name="Interface_Name" type="s" direction="in"/>
-      <arg name="Property_Name" type="s" direction="in"/>
-      <arg name="Value" type="v" direction="out"/>
-    </method>
-    <signal name="PropertiesChanged">
-      <arg type="s"/>
-      <arg type="a{sv}"/>
-      <arg type="as"/>
-    </signal>
-  </interface>
-  <interface name="org.freedesktop.Telepathy.Connection">
-    <method name="RemoveClientInterest">
-      <arg name="Tokens" type="as" direction="in"/>
-    </method>
-    <method name="AddClientInterest">
-      <arg name="Tokens" type="as" direction="in"/>
-    </method>
-    <method name="RequestHandles">
-      <arg name="Handle_Type" type="u" direction="in"/>
-      <arg name="Identifiers" type="as" direction="in"/>
-      <arg name="Handles" type="au" direction="out"/>
-    </method>
-    <method name="RequestChannel">
-      <arg name="Type" type="s" direction="in"/>
-      <arg name="Handle_Type" type="u" direction="in"/>
-      <arg name="Handle" type="u" direction="in"/>
-      <arg name="Suppress_Handler" type="b" direction="in"/>
-      <arg name="Object_Path" type="o" direction="out"/>
-    </method>
-    <method name="ReleaseHandles">
-      <arg name="Handle_Type" type="u" direction="in"/>
-      <arg name="Handles" type="au" direction="in"/>
-    </method>
-    <method name="ListChannels">
-      <arg name="Channel_Info" type="a(osuu)" direction="out"/>
-    </method>
-    <method name="InspectHandles">
-      <arg name="Handle_Type" type="u" direction="in"/>
-      <arg name="Handles" type="au" direction="in"/>
-      <arg name="Identifiers" type="as" direction="out"/>
-    </method>
-    <method name="HoldHandles">
-      <arg name="Handle_Type" type="u" direction="in"/>
-      <arg name="Handles" type="au" direction="in"/>
-    </method>
-    <method name="GetStatus">
-      <arg name="Status" type="u" direction="out"/>
-    </method>
-    <method name="GetSelfHandle">
-      <arg name="Self_Handle" type="u" direction="out"/>
-    </method>
-    <method name="GetProtocol">
-      <arg name="Protocol" type="s" direction="out"/>
-    </method>
-    <method name="GetInterfaces">
-      <arg name="Interfaces" type="as" direction="out"/>
-    </method>
-    <method name="Disconnect">
-    </method>
-    <method name="Connect">
-    </method>
-    <signal name="StatusChanged">
-      <arg type="u"/>
-      <arg type="u"/>
-    </signal>
-    <signal name="ConnectionError">
-      <arg type="s"/>
-      <arg type="a{sv}"/>
-    </signal>
-    <signal name="NewChannel">
-      <arg type="o"/>
-      <arg type="s"/>
-      <arg type="u"/>
-      <arg type="u"/>
-      <arg type="b"/>
-    </signal>
-    <signal name="SelfHandleChanged">
-      <arg type="u"/>
-    </signal>
-  </interface>
-</node>
diff --git a/src/data/xml/org.sip.connection.properties b/src/data/xml/org.sip.connection.properties
deleted file mode 100644 (file)
index b628aae..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-   array [
-      dict entry(
-         string "HasImmortalHandles"
-         variant             boolean true
-      )
-      dict entry(
-         string "Status"
-         variant             uint32 0
-      )
-      dict entry(
-         string "SelfHandle"
-         variant             uint32 1
-      )
-      dict entry(
-         string "Interfaces"
-         variant             array [
-               string "org.freedesktop.Telepathy.Connection.Interface.Requests"
-               string "org.freedesktop.Telepathy.Connection.Interface.Contacts"
-               string "org.freedesktop.Telepathy.Connection.Interface.Aliasing"
-            ]
-      )
-   ]
-
-type=MethodReturn, service=":1.16", signature="a{sv}", contents=([Argument: a{sv} {"HasImmortalHandles" = [Variant(bool): true], "Status" = [Variant(uint): 0], "SelfHandle" = [Variant(uint): 1], "Interfaces" = [Variant(QStringList): {"org.freedesktop.Telepathy.Connection.Interface.Requests", "org.freedesktop.Telepathy.Connection.Interface.Contacts", "org.freedesktop.Telepathy.Connection.Interface.Capabilities", "org.freedesktop.Telepathy.Connection.Interface.ServicePoint", "org.freedesktop.Telepathy.Connection.Interface.Cellular", "org.freedesktop.Telepathy.Connection.Interface.Anonymity", "com.nokia.Telepathy.Connection.Interface.StoredMessages"}]}]) 
index 0583583..f5b1fe3 100644 (file)
@@ -26,7 +26,7 @@ function initialize() {
             // Create the settings table if it doesn't already exist
             // If the table exists, this is skipped
             tx.executeSql('CREATE TABLE IF NOT EXISTS settings(setting TEXT PRIMARY KEY, value TEXT)');
-            tx.executeSql('CREATE TABLE IF NOT EXISTS rules(id INTEGER PRIMARY KEY, numberpattern TEXT, gatewaynumber TEXT, dtmfformat TEXT, dtmfprefix TEXT, dtmfsuffix TEXT)');
+            tx.executeSql('CREATE TABLE IF NOT EXISTS profiles(id INTEGER PRIMARY KEY, numberpattern TEXT, gatewaynumber TEXT, dtmfformat TEXT, dtmfprefix TEXT, dtmfsuffix TEXT)');
           },
         function(error) {
             logMessage("Error ["+error.code +"] - " + error.DOMString+" occurred.");
@@ -75,13 +75,13 @@ function setSetting(setting, value) {
 }
 
 function addRule(ruleObj){
-    logMessage('SQL> INSERT INTO rules(id, numberpattern, gatewaynumber, dtmfformat, dtmfprefix, dtmfsuffix) VALUES (NULL, '+[ruleObj.numberpattern, ruleObj.gatewaynumber, ruleObj.dtmfformat, ruleObj.dtmfprefix, ruleObj.dtmfsuffix]+')');
+    logMessage('SQL> INSERT INTO profiles(id, numberpattern, gatewaynumber, dtmfformat, dtmfprefix, dtmfsuffix) VALUES (NULL, '+[ruleObj.numberpattern, ruleObj.gatewaynumber, ruleObj.dtmfformat, ruleObj.dtmfprefix, ruleObj.dtmfsuffix]+')');
     var db = getDatabase();
     var res = "";
     logMessage("Opened VICaR database..");
 
     db.transaction(function(tx) {
-               var rs = tx.executeSql('INSERT INTO rules(id, numberpattern, gatewaynumber, dtmfformat, dtmfprefix, dtmfsuffix) VALUES (NULL, ?, ?, ?, ?, ?);', [ruleObj.numberpattern, ruleObj.gatewaynumber, ruleObj.dtmfformat, ruleObj.dtmfprefix, ruleObj.dtmfsuffix]);
+               var rs = tx.executeSql('INSERT INTO profiles(id, numberpattern, gatewaynumber, dtmfformat, dtmfprefix, dtmfsuffix) VALUES (NULL, ?, ?, ?, ?, ?);', [ruleObj.numberpattern, ruleObj.gatewaynumber, ruleObj.dtmfformat, ruleObj.dtmfprefix, ruleObj.dtmfsuffix]);
                logMessage("Inserted "+rs.rowsAffected+" rows");
                if (rs.rowsAffected > 0) {
                  res = "OK";
@@ -97,7 +97,7 @@ function addRule(ruleObj){
 }
 
 function updateRule(id,ruleObj){
-    logMessage('SQL> UPDATE rules set numberpattern = '+[ruleObj.numberpattern]+
+    logMessage('SQL> UPDATE profiles set numberpattern = '+[ruleObj.numberpattern]+
                ', gatewaynumber = '+[ruleObj.gatewaynumber]+
                ', dtmfformat = '+[ruleObj.dtmfformat]+
                ', dtmfprefix = '+[ruleObj.dtmfprefix]+
@@ -106,7 +106,7 @@ function updateRule(id,ruleObj){
     var db = getDatabase();
     var res = "";
     db.transaction(function(tx) {
-           var rs = tx.executeSql('UPDATE rules set numberpattern = ?, gatewaynumber = ?, dtmfformat = ?, dtmfprefix = ?, dtmfsuffix = ? WHERE id = ?;',
+           var rs = tx.executeSql('UPDATE profiles set numberpattern = ?, gatewaynumber = ?, dtmfformat = ?, dtmfprefix = ?, dtmfsuffix = ? WHERE id = ?;',
                             [ruleObj.numberpattern, ruleObj.gatewaynumber, ruleObj.dtmfformat, ruleObj.dtmfprefix, ruleObj.dtmfsuffix, id]);
            logMessage("Updated "+rs.rowsAffected+" rows");
            if (rs.rowsAffected > 0) {
@@ -123,11 +123,11 @@ function updateRule(id,ruleObj){
 }
 
 function removeRule(id){
-    logMessage('SQL> DELETE FROM rules WHERE id = '+[id]);
+    logMessage('SQL> DELETE FROM profiles WHERE id = '+[id]);
     var db = getDatabase();
     var res = "";
     db.transaction(function(tx) {
-         var rs = tx.executeSql('DELETE FROM rules WHERE id = ?;', [id]);
+         var rs = tx.executeSql('DELETE FROM profiles WHERE id = ?;', [id]);
                logMessage("Deleted "+rs.rowsAffected+" rows");
                if (rs.rowsAffected > 0) {
                  res = "OK";
@@ -147,7 +147,7 @@ function getAllRules(){
     var rulesArray = new Array();
     var ruleObj;
     db.transaction(function(tx) {
-           var rs = tx.executeSql('SELECT * FROM rules');
+           var rs = tx.executeSql('SELECT * FROM profiles');
            logMessage("Fetched "+rs.rows.length+" rows");
            var i = 0;
            for (i = 0; i < rs.rows.length; i++){
@@ -179,8 +179,8 @@ function getRuleByID(id){
     var db = getDatabase();
     var ruleObj;
     db.transaction(function(tx) {
-           logMessage('SQL> SELECT * FROM rules WHERE id = '+[id]);
-           var rs = tx.executeSql('SELECT * FROM rules WHERE id = '+[id]);
+           logMessage('SQL> SELECT * FROM profiles WHERE id = '+[id]);
+           var rs = tx.executeSql('SELECT * FROM profiles WHERE id = '+[id]);
            logMessage("Fetched "+rs.rows.length+" rows");
            if (rs.rows.length > 0){
                ruleObj = new Object();
index 88fdfdd..11bd8a8 100644 (file)
@@ -7,7 +7,6 @@
 #include "profileswindow.h"
 #include "ui_profileswindow.h"
 #include "profilesettingsdialog.h"
-#include "gconfutility.h"
 #include "dbusutility.h"
 #include "telepathyutility.h"
 #include "databaseutility.h"
@@ -18,7 +17,6 @@ class ProfilesWindowPrivate
 {
 public:
     ProfilesWindowPrivate(ProfilesWindow * p) :
-            gconfUtility(new GConfUtility(p)),
             dbusUtility(new DbusUtility(p)),
             tpUtility(new TelepathyUtility(p)),
             databaseUtility(new DatabaseUtility(p)),
@@ -34,7 +32,6 @@ public:
         qDebug() << "VICaR: ProfilesWindowPrivate Destructing";
     }
 
-    GConfUtility * gconfUtility;
     DbusUtility * dbusUtility;
     TelepathyUtility *tpUtility;
     DatabaseUtility *databaseUtility;
@@ -52,11 +49,11 @@ ProfilesWindow::ProfilesWindow(QWidget *parent) :
     ui->setupUi(this);
     loadProfilesList();
 
-    ui->actionRoutingEnabled->setChecked(d->tpUtility->accountExists());
-
-    bool routeOnDefault = d->gconfUtility->getGconfValueBoolean("route_on_default");
-    ui->actionRouteOnDefault->setChecked(routeOnDefault);
+    ui->actionRoutingEnabled->setChecked(d->tpUtility->accountExists());        
 
+    //bool routeOnDefault = d->gconfUtility->getGconfValueBoolean("route_on_default");
+    QString routeOnDefaultSetting = d->databaseUtility->getSetting("route_on_default");
+    ui->actionRouteOnDefault->setChecked(routeOnDefaultSetting == "1"?true:false);
 }
 
 ProfilesWindow::~ProfilesWindow()
@@ -206,7 +203,8 @@ void ProfilesWindow::on_actionRoutingEnabled_triggered(bool checked){
 }
 
 void ProfilesWindow::on_actionRouteOnDefault_triggered(bool checked){
-    d->gconfUtility->setGconfValueBoolean("route_on_default",checked);
+    d->databaseUtility->setSetting("route_on_default",checked?"1":"0");
+    //d->gconfUtility->setGconfValueBoolean("route_on_default",checked);
 }
 
 void ProfilesWindow::on_actionEditDefaultProfile_triggered(){
index 7a5d8ed..0b95d92 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;
@@ -110,7 +108,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);
index 65288b1..e9376df 100755 (executable)
@@ -10,7 +10,6 @@
 #include <QObject>
 #include <QDBusMessage>
 #include <dbusutility.h>
-#include <gconfutility.h>
 #include "vicardbusadaptor.h"
 
 #define APPLICATION_DBUS_PATH "/org/maemo/vicar"
index 4f89a0a..f7134d9 100755 (executable)
@@ -9,13 +9,13 @@ PKGCONFIG += glib-2.0 gconf-2.0
 
 LIBS += ../lib/libvicar.a
 
-CONFIG += qt debug
+CONFIG += qt debug console
+CONFIG -= app_bundle
+
 QT += dbus sql
 QT -= gui
 TEMPLATE = app
 TARGET = vicar-daemon
-CONFIG += console
-CONFIG -= app_bundle
 
 VPATH += cpp
 MOC_DIR = cpp/.mocs
index e2df72b..b00cdef 100644 (file)
@@ -1,4 +1,5 @@
 #include "databaseutility.h"
+#include <QCryptographicHash>
 #include <QSqlDatabase>
 #include <QSqlError>
 #include <QSqlQuery>
@@ -16,45 +17,51 @@ DatabaseUtility::~DatabaseUtility(){
 }
 
 bool DatabaseUtility::openDatabase(){
-    profilesDB = QSqlDatabase::addDatabase("QSQLITE");
-    //QString path(QDir::home().path());
-    //path.append(QDir::separator()).append("vicar.db.sqlite");
+    vicarDB = QSqlDatabase::addDatabase("QSQLITE");
+#if defined(Q_WS_MAEMO_5)
     QString path("/home/user/vicar.db.sqlite");
+#elif defined(Q_WS_MAEMO_6)
+    QString path("/home/user/.local/share/data/QML/OfflineStorage/Databases/");
+    path.append(QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex()).append(".sqlite");
+#endif
     path = QDir::toNativeSeparators(path);
     qDebug()<< "Opening database at "<<path;
-    profilesDB.setDatabaseName(path);
-    return profilesDB.open();
+    vicarDB.setDatabaseName(path);
+    return vicarDB.open();
 }
 
 bool DatabaseUtility::deleteDatabase(){
     closeDatabase();
-    //QString path(QDir::home().path());
-    //path.append(QDir::separator()).append("vicar.db.sqlite");
+#if defined(Q_WS_MAEMO_5)
     QString path("/home/user/vicar.db.sqlite");
+#elif defined(Q_WS_MAEMO_6)
+    QString path("/home/user/.local/share/data/QML/OfflineStorage/Databases/");
+    path.append(QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex()).append(".sqlite");
+#endif
     path = QDir::toNativeSeparators(path);
     return QFile::remove(path);
 }
 
 void DatabaseUtility::closeDatabase(){
-    if (profilesDB.isOpen()){
-        profilesDB.close();
+    if (vicarDB.isOpen()){
+        vicarDB.close();
     }
 }
 
 bool DatabaseUtility::tableExists(QString tableName){
     bool exists = false;
-    if (profilesDB.isOpen()){
-        QStringList tablesList = profilesDB.tables();
+    if (vicarDB.isOpen()){
+        QStringList tablesList = vicarDB.tables();
         exists = tablesList.contains(tableName,Qt::CaseInsensitive);
     }
     return exists;
 }
 
-bool DatabaseUtility::createProfilesTable(){
-    bool result = false;
-    if (profilesDB.isOpen()){
+bool DatabaseUtility::prepareTables(){
+    bool result = true;
+    if (vicarDB.isOpen()){
         QSqlQuery query;
-        QString strQuery = "create table profiles"
+        QString strQuery = "create table if not exists profiles"
                            "(id integer primary key,"
                            "numberpattern varchar(20),"
                            "gatewaynumber varchar(30),"
@@ -62,6 +69,40 @@ bool DatabaseUtility::createProfilesTable(){
                            "dtmfprefix varchar(20),"
                            "dtmfsuffix varchar(20)"
                            ")";
+        if (!query.exec(strQuery)){
+            qDebug() << "Error creating profiles table";
+            result = false;
+        }
+
+        strQuery = "CREATE TABLE IF NOT EXISTS settings(setting TEXT UNIQUE, value TEXT)";
+        if (!query.exec(strQuery)){
+            qDebug() << "Error creating settings table";
+            result = false;
+        }
+    }
+    return result;
+}
+
+QString DatabaseUtility::getSetting(QString setting){
+    QString value = "Unknown";
+    if (vicarDB.isOpen()){
+        QString strQuery = QString("'SELECT value FROM settings WHERE setting='%1'").arg(setting);
+        qDebug() << "SQL>"<<strQuery;
+        QSqlQuery query(strQuery);
+        if (query.next()){
+            value = query.value(0).toString();
+        }
+    }
+    return value;
+}
+
+bool DatabaseUtility::setSetting(QString setting, QString value){
+    bool result = false;
+    if (vicarDB.isOpen()){
+        QSqlQuery query;
+        QString strQuery = QString("INSERT OR REPLACE INTO settings VALUES ('%1','%2')")
+                           .arg(setting).arg(value);
+        qDebug() << "SQL>"<<strQuery;
         result = query.exec(strQuery);
     }
     return result;
@@ -69,7 +110,7 @@ bool DatabaseUtility::createProfilesTable(){
 
 bool DatabaseUtility::selectProfile(int id,org::maemo::vicar::Profile* profile){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QString strQuery = QString("select * from profiles where id = %1").arg(id);
         qDebug() << "SQL>"<<strQuery;
         QSqlQuery query(strQuery);
@@ -88,7 +129,7 @@ bool DatabaseUtility::selectProfile(int id,org::maemo::vicar::Profile* profile){
 
 bool DatabaseUtility::getAllProfiles(org::maemo::vicar::ProfileList* profileList){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QString strQuery = QString("select * from profiles order by id");
         qDebug() << "SQL>"<<strQuery;
         QSqlQuery query(strQuery);
@@ -109,7 +150,7 @@ bool DatabaseUtility::getAllProfiles(org::maemo::vicar::ProfileList* profileList
 
 bool DatabaseUtility::findProfileByNumber(QString number,org::maemo::vicar::Profile* profile){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QString strQuery = QString("select * from profiles where '%1' like numberpattern||'%' order by length(numberpattern) desc")
                            .arg(number);
         qDebug() << "SQL>"<<strQuery;
@@ -129,7 +170,7 @@ bool DatabaseUtility::findProfileByNumber(QString number,org::maemo::vicar::Prof
 
 bool DatabaseUtility::getDefaultProfile(org::maemo::vicar::Profile *profile){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QString strQuery = QString("select * from profiles where numberpattern = '%' order by id");
         qDebug() << "SQL>"<<strQuery;
         QSqlQuery query(strQuery);
@@ -149,10 +190,10 @@ bool DatabaseUtility::getDefaultProfile(org::maemo::vicar::Profile *profile){
 int DatabaseUtility::insertProfile(org::maemo::vicar::Profile profile){
     int newId   = -1;
     bool result = false;    
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         bool continueInsert = true;
         if (!this->tableExists("profiles")){
-            continueInsert = this->createProfilesTable();
+            continueInsert = this->prepareTables();
         }
 
         if (continueInsert)
@@ -173,7 +214,7 @@ int DatabaseUtility::insertProfile(org::maemo::vicar::Profile profile){
 
 bool DatabaseUtility::updateProfile(org::maemo::vicar::Profile profile){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QSqlQuery query;
         QString strQuery = QString("update profiles set numberpattern = '%1', "
                                    "gatewaynumber = '%2', dtmfformat = '%3', "
@@ -189,7 +230,7 @@ bool DatabaseUtility::updateProfile(org::maemo::vicar::Profile profile){
 
 bool DatabaseUtility::deleteProfile(int id){
     bool result = false;
-    if (profilesDB.isOpen()){
+    if (vicarDB.isOpen()){
         QSqlQuery query;
         QString strQuery = QString("delete from profiles where id=%1").arg(id);
         qDebug() << "SQL>"<<strQuery;
@@ -199,5 +240,5 @@ bool DatabaseUtility::deleteProfile(int id){
 }
 
 QSqlError DatabaseUtility::lastError(){
-    return profilesDB.lastError();
+    return vicarDB.lastError();
 }
index 716e4ab..9ebffeb 100644 (file)
@@ -22,7 +22,9 @@ public:
     bool deleteDatabase();
     void closeDatabase();
     bool tableExists(QString tableName);
-    bool createProfilesTable();
+    bool prepareTables();
+    QString getSetting(QString setting);
+    bool setSetting(QString setting, QString value);
     int insertProfile(org::maemo::vicar::Profile profile);
     bool updateProfile(org::maemo::vicar::Profile profile);
     bool selectProfile(int id,org::maemo::vicar::Profile* profile);
@@ -33,7 +35,7 @@ public:
     QSqlError lastError();
 
 private:
-    QSqlDatabase profilesDB;
+    QSqlDatabase vicarDB;
 };
 
 #endif // DATABASEUTILITY_H
diff --git a/src/vicar-lib/cpp/gconfutility.cpp b/src/vicar-lib/cpp/gconfutility.cpp
deleted file mode 100755 (executable)
index 231a716..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
-@version: 0.6
-@author: Sudheer K. <scifi1947 at gmail.com>
-@license: GNU General Public License
-*/
-
-#include "gconfutility.h"
-#include <gconf/gconf-client.h>
-#include <QDebug>
-
-GConfUtility::GConfUtility(QObject *parent) :
-    QObject(parent)
-{
-    /* Get a GConf client */
-    gconfClient = gconf_client_get_default();
-    g_assert(GCONF_IS_CLIENT(gconfClient));
-}
-
-GConfUtility::~GConfUtility(){
-    /* release GConf client */
-    g_object_unref(gconfClient);
-    gconfClient = 0;
-}
-
-QString GConfUtility::getGconfValueString(QString strKey){
-
-    char* strValue = NULL;
-
-    if (!strKey.isEmpty()) {
-        strKey.prepend(GCONF_DIR);
-
-        strValue = gconf_client_get_string(gconfClient, strKey.toAscii().constData(), NULL);
-        qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<strValue;
-    }
-
-    return QString(strValue);
-}
-
-void GConfUtility::setGconfValueString(QString strKey,QString strValue){
-
-    if (!strKey.isEmpty()){
-
-        strKey.prepend(GCONF_DIR);
-
-        if (!strValue.isEmpty()){
-                gconf_client_set_string(gconfClient, strKey.toAscii().constData(), strValue.toAscii().constData(),NULL);
-                qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<strValue.toAscii().constData();
-        }
-        else{
-                gconf_client_unset(gconfClient, strKey.toAscii().constData(),NULL);
-                qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to NULL";
-        }
-
-    }
-}
-
-bool GConfUtility::getGconfValueBoolean(QString strKey){
-
-    bool boolValue = false;
-
-    if (!strKey.isEmpty()) {
-        strKey.prepend(GCONF_DIR);
-
-        boolValue = gconf_client_get_bool(gconfClient, strKey.toAscii().constData(), NULL);
-        qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<boolValue;
-    }
-
-    return boolValue;
-}
-
-void GConfUtility::setGconfValueBoolean(QString strKey,bool boolValue){
-
-    if (!strKey.isEmpty()){
-
-        strKey.prepend(GCONF_DIR);
-
-        gconf_client_set_bool(gconfClient, strKey.toAscii().constData(),boolValue,NULL);
-        qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<boolValue;
-    }
-}
-
-int GConfUtility::getGconfValueInteger(QString strKey){
-
-    int intValue = 0;
-
-    if (!strKey.isEmpty()) {
-        strKey.prepend(GCONF_DIR);
-
-        intValue = gconf_client_get_int(gconfClient, strKey.toAscii().constData(), NULL);
-        qDebug() << "Gconf: "<<strKey.toAscii().constData()<< " is "<<intValue;
-    }
-
-    return intValue;
-}
-
-void GConfUtility::setGconfValueInteger(QString strKey,int intValue){
-
-    if (!strKey.isEmpty()){
-
-        strKey.prepend(GCONF_DIR);
-
-        gconf_client_set_int(gconfClient, strKey.toAscii().constData(),intValue,NULL);
-        qDebug() << "Assigned "<<strKey.toAscii().constData()<< " to "<<intValue;
-    }
-}
diff --git a/src/vicar-lib/cpp/gconfutility.h b/src/vicar-lib/cpp/gconfutility.h
deleted file mode 100755 (executable)
index 8106833..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-@version: 0.6
-@author: Sudheer K. <scifi1947 at gmail.com>
-@license: GNU General Public License
-*/
-
-#ifndef GCONFUTILITY_H
-#define GCONFUTILITY_H
-
-#include <QObject>
-#include <gconf/gconf-client.h>
-
-#define APPLICATION_NAME "vicar"
-#define GCONF_DIR "/apps/Maemo/" APPLICATION_NAME "/"
-
-class GConfUtility : public QObject
- {
-Q_OBJECT
-public:
-    GConfUtility(QObject *parent = 0);
-    ~GConfUtility();
-    void setGconfValueString(QString strKey,QString strValue);
-    QString getGconfValueString(QString strKey);
-
-    void setGconfValueBoolean(QString strKey,bool boolValue);
-    bool getGconfValueBoolean(QString strKey);
-
-    void setGconfValueInteger(QString strKey,int intValue);
-    int getGconfValueInteger(QString strKey);
-
-private:
-     GConfClient *gconfClient;
-};
-
-#endif // GCONFUTILITY_H
index ebca69e..5d1c255 100644 (file)
@@ -1,56 +1,71 @@
 /*
-@version: 0.6
+@version: 0.4
 @author: Sudheer K. <scifi1947 at gmail.com>
 @license: GNU General Public License
 */
 
 #ifndef LOGUTILITY_H
 #define LOGUTILITY_H
+#include <QDebug>
 #include <QFile>
 #include <QIODevice>
-#include <QTextStream>
 #include <QDateTime>
-#include <QDebug>
+#include <QDir>
 
 class LogUtility : public QObject
 {
     Q_OBJECT
 
+private:
+    QFile * logFile;
+
 public:
-    LogUtility(QString logPath,QObject *parent = 0) :
+    LogUtility(QObject *parent = 0) :
         QObject(parent){
-        logFilePath = logPath;
+        QString strPath;
+
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+        //For maemo fremantle or harmattan use a common path                
+        QDir logDir = QDir(QDir().homePath() + "/.vicar");
+        if (!logDir.exists()){
+            if (QDir().mkpath(logDir.absolutePath())){
+                qDebug() << "Vicar: Log directory created successfully";
+            }
+            else{
+                qDebug() << "Vicar: Error creating log directory";
+            }
+        }
+        strPath = logDir.absolutePath() + "/vicar.log";
+#else
+        strPath = "vicar.log";
+#endif
+        logFile = new QFile(strPath,this);
+
+        if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
+            qDebug() << "Vicar: Error opening logfile for writing at path " << strPath;
+        }
     }
 
     ~LogUtility(){
+        if (logFile->isOpen())
+            logFile->close();
+        qDebug() << "Vicar: In LogUtility object destructor..";
     }
 
 public slots:
-    void logMessage(QString strMessage, bool appendMode = true) {
-
-        QFile logFile(logFilePath);
-
-        bool success = false;
-
-        if (appendMode){
-            success = logFile.open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text);
-        }
-        else{
-            success = logFile.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text);
-        }
+    void logMessage(QString strMessage) {
 
         QString strTimeNow = QDateTime::currentDateTime().toString("dd-MMM-yyyy HH:mm:ss");
-        if (success) {
-            QTextStream logStream(&logFile);
-            logStream <<  strTimeNow << " - " << strMessage << endl;
+
+        if (logFile->isOpen() && logFile->isWritable()) {
+            QTextStream logStream(logFile);
+            logStream <<  QString("[%1] - %2").arg(strTimeNow,strMessage) << endl;
+            qDebug() << QString("Vicar: [%1] - %2").arg(strTimeNow,strMessage);
         }
         else{
-            qDebug() <<  "ERROROPENINGLOGFILE" << " - " << strMessage;
+            qDebug() <<  "ERROROPENINGLOGFILE" << QString("Vicar: [%1] - %2").arg(strTimeNow,strMessage);
         }
     }
-
-private:
-    QString logFilePath;
 };
 
 #endif // LOGUTILITY_H
index 068f3fe..5290910 100644 (file)
@@ -14,6 +14,7 @@
 #include <QStringList>
 #include <QDBusPendingReply>
 #include <QDBusObjectPath>
+#include <QDBusError>
 #include <QDebug>
 
 using namespace org::freedesktop::Telepathy;
@@ -32,32 +33,47 @@ QList<QDBusObjectPath> TelepathyUtility::getAllAccounts(){
 
     QList<QDBusObjectPath> objPathList;
 
-    QDBusInterface *iface = new QDBusInterface(AM_SERVICE,AM_OBJ_PATH,DBUS_PROPS_IFACE,QDBusConnection::sessionBus(),this);
-    if (iface->isValid()){
-        QDBusReply<QDBusVariant> reply = iface->call(QDBus::AutoDetect,"Get",AM_INTERFACE,"ValidAccounts");
-
-        if (reply.isValid()){;
-            QDBusVariant validAccounts = reply.value();
-            const QVariant var = validAccounts.variant();
-            const QDBusArgument arg = var.value<QDBusArgument>();
-
-            arg.beginArray();
-            while (!arg.atEnd()){
-                QDBusObjectPath opath;
-                arg >> opath;
-                if (opath.path().contains("tel")){
-                    qDebug() << opath.path();
+    QDBusConnection sessionBus = QDBusConnection::sessionBus();
+
+    if (sessionBus.isConnected()){
+        QDBusInterface *iface = new QDBusInterface(AM_SERVICE,AM_OBJ_PATH,DBUS_PROPS_IFACE,sessionBus,this);
+
+        if (iface->isValid()){
+            QDBusReply<QDBusVariant> reply = iface->call(QDBus::AutoDetect,"Get",AM_INTERFACE,"ValidAccounts");
+
+            if (reply.isValid()){;
+                QDBusVariant validAccounts = reply.value();
+                const QVariant var = validAccounts.variant();
+                const QDBusArgument arg = var.value<QDBusArgument>();
+
+                arg.beginArray();
+                while (!arg.atEnd()){
+                    QDBusObjectPath opath;
+                    arg >> opath;
+
+                    if (opath.path().contains("tel")){
+                        qDebug() << opath.path();
+                    }
+                    objPathList.append(opath);
                 }
-                objPathList.append(opath);
+                arg.endArray();
+            }
+            else{
+                qDebug() << "Error occurred while fetching accounts list "<<reply.error();
             }
-            arg.endArray();
         }
         else{
-            qDebug() << "Error occurred while fetching accounts list "<<reply.error();
+            QDBusError dbusError = QDBusConnection::sessionBus().lastError();
+            if (dbusError.isValid()) {
+                qDebug () << "DBUS Error - " << dbusError.message();
+            }
+            else{
+                qDebug () << "Debug - Invalid Interface";
+            }
         }
     }
     else{
-        qDebug() << "Error occurred while connecting to DBus interface";
+        qDebug() << "Error occurred while connecting to DBus interface";                
     }
 
     return objPathList;
@@ -70,6 +86,7 @@ bool TelepathyUtility::accountExists(){
     QList<QDBusObjectPath> accountsList = this->getAllAccounts();
     QDBusObjectPath account;
     foreach (account,accountsList){
+        qDebug() << account.path();
         if (account.path().contains("vicar/tel/vicar")){
             vicarAccountExists = true;
             break;
@@ -134,17 +151,13 @@ bool TelepathyUtility::createAccount(){
     accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Enabled",true);
     accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.ConnectAutomatically",true);
     accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.RequestedPresence",QVariant::fromValue(presence));
-    accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Service","vicar"); //Required when service can't be determined by the protocol name
+    //accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Service","vicar"); //Required when service can't be determined by the protocol name
     accountPropertiesMap.insert("com.nokia.Account.Interface.Compat.Profile","vicar");
 
     QStringList valuesList;
     valuesList.append("TEL");
     accountPropertiesMap.insert("com.nokia.Account.Interface.Compat.SecondaryVCardFields",valuesList);
 
-    //QStringList uriSchemeList;
-    //uriSchemeList.append("tel");
-    //accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Interface.Addressing.DRAFT.URISchemes",uriSchemeList);
-
     QDBusPendingReply<QDBusObjectPath> reply = amProxy->CreateAccount("vicar","tel","Vicar",connectionParametersMap,accountPropertiesMap);
     reply.waitForFinished();
 
index 725dd40..d799730 100755 (executable)
@@ -19,7 +19,6 @@ OBJECTS_DIR = cpp/.objs
 DESTDIR = ../lib
 
 SOURCES += cpp/dbusutility.cpp \
-    cpp/gconfutility.cpp \
     cpp/telepathyutility.cpp \
     cpp/accountmanagerproxy.cpp \
     cpp/accountproxy.cpp \
@@ -29,7 +28,6 @@ SOURCES += cpp/dbusutility.cpp \
     cpp/databaseutility.cpp \
     cpp/harmattanaccountutility.cpp
 HEADERS += cpp/dbusutility.h \
-    cpp/gconfutility.h \
     cpp/telepathyutility.h \
     cpp/accountmanagerproxy.h \
     cpp/accountproxy.h \
index 58bbe92..3f71330 100644 (file)
@@ -42,6 +42,8 @@ Based on Telepathy-SNOM with copyright notice below.
 #include <QDBusMessage>
 #include <QDBusReply>
 
+#define SELF_HANDLE 1  //Any non-zero
+
 
 namespace
 {
@@ -64,7 +66,7 @@ public:
         connection_status(Connection::Disconnected),
         adaptor(new ConnectionAdaptor(p)),
         connIfaceReqsAdaptor(new ConnectionInterfaceRequestsAdaptor(p)),
-        logUtility(new LogUtility("/var/log/vicar/vicar.log",p)),
+        logUtility(new LogUtility(p)),
         parent(p)
     {
         Q_ASSERT(0 != adaptor);
@@ -94,7 +96,6 @@ Connection::Connection(const QString & account,
 
     QString strMessage;
     strMessage = "DEBUG: In Connection Constructor";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     Q_ASSERT(0 != d);
@@ -117,7 +118,15 @@ Connection::Connection(const QString & account,
     this->setProperty("HasImmortalHandles",true);
 
     this->setProperty("Status",org::freedesktop::Telepathy::CONNECTION_STATUS_CONNECTED);
-    this->setProperty("SelfHandle",org::freedesktop::Telepathy::HANDLE_TYPE_CONTACT);
+
+
+    //this->setProperty("SelfHandle",org::freedesktop::Telepathy::HANDLE_TYPE_CONTACT);
+    uint selfHandle(SELF_HANDLE);
+    this->setProperty("SelfHandle",selfHandle);
+
+    strMessage = "VICaR Connection: Emitting SelfHandleChanged.";
+    d->logUtility->logMessage(strMessage);
+    emit SelfHandleChanged(selfHandle);
 
     //Set the property RequestableChannelClasses
     org::freedesktop::Telepathy::RequestableChannelClassList requestableChannelClasses;
@@ -156,7 +165,6 @@ Connection::Connection(const QString & account,
 
     strMessage = "VICaR Connection: Connection set up.";
 
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 }
 
@@ -174,7 +182,6 @@ bool Connection::registerObject()
         if (!QDBusConnection::sessionBus().registerService(serviceName()))
         {
             strMessage = "VICaR Connection: Problem registering connection service:" + serviceName();
-            qDebug() << strMessage;
             d->logUtility->logMessage(strMessage);
             return false;
         }
@@ -183,14 +190,12 @@ bool Connection::registerObject()
                                                           this))
         {
             strMessage = "VICaR Connection: Problem registering object path:" + objectPath().path();
-            qDebug() << strMessage;
             d->logUtility->logMessage(strMessage);
             return false;
         }
     }
     else{
         strMessage = "VICaR Connection: " + serviceName()+" is already registered on DBus";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
     }
     return true;
@@ -199,7 +204,6 @@ bool Connection::registerObject()
 void Connection::unregisterObject()
 {
     QString strMessage = "VICaR Connection: Unregistering Connection object from DBus";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     QDBusConnection::sessionBus().unregisterObject(objectPath().path());
     QDBusConnection::sessionBus().unregisterService(serviceName());
@@ -226,13 +230,11 @@ void Connection::Connect()
        I am not connecting to anything.
      */
     QString strMessage = "VICaR Connection: Changing status to Connected...";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     d->connection_status = Connection::Connected;
 
     //Let all the Telepathy clients know that connection status has changed
     strMessage = "VICaR Connection: Emitting StatusChanged.";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     emit StatusChanged(d->connection_status, ReasonRequested);
 }
@@ -240,13 +242,11 @@ void Connection::Connect()
 void Connection::Disconnect()
 {
     QString strMessage = "VICaR Connection: Changing status to Disconnected...";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     //We don't have any Handles to release here. So just change the status to Disconnected
     d->connection_status = Connection::Disconnected;
 
     strMessage = "VICaR Connection: Emitting StatusChanged";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     emit StatusChanged(d->connection_status, ReasonRequested);
 
@@ -258,6 +258,10 @@ void Connection::Disconnect()
 QStringList Connection::GetInterfaces()
 {
     QStringList result;
+
+    QString strMessage = "VICaR Connection: GetInterfaces.";
+    d->logUtility->logMessage(strMessage);
+
     if (d->connection_status != Connected)
     {
         sendErrorReply("org.freedesktop.Telepathy.Error.Disconnected",
@@ -269,30 +273,35 @@ QStringList Connection::GetInterfaces()
 }
 
 QString Connection::GetProtocol()
-{ return protocol_vicar; }
+{
+    QString strMessage = "VICaR Connection: GetProtocol.";
+    d->logUtility->logMessage(strMessage);
+    return protocol_vicar;
+}
 
 uint Connection::GetStatus()
-{ return static_cast<uint>(d->connection_status); }
+{
+    QString strMessage = "VICaR Connection: GetStatus.";
+    d->logUtility->logMessage(strMessage);
+    return static_cast<uint>(d->connection_status);
+}
 
 uint Connection::GetSelfHandle()
 {
     QString strMessage = "VICaR Connection: GetSelfHandle";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     if (d->connection_status != Connected)
     {
         sendErrorReply("org.freedesktop.Telepathy.Error.Disconnected",
                        "VICaR - Unable to get Self Handle. The connection is no longer available.");
         strMessage = "VICaR Connection: NOT CONNECTED when requesting selfhandle!";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
         return 0;
     }
 
     //WARNING: Incomplete implemenation
-    uint handle = 0;
-    strMessage = "VICaR Connection: Returning Handle " + QString(handle) + "as self handle.";
-    qDebug() << strMessage;
+    uint handle(SELF_HANDLE);
+    strMessage = "VICaR Connection: Returning Handle " + QString::number(handle) + "as self handle.";
     d->logUtility->logMessage(strMessage);
     return handle;
 }
@@ -300,6 +309,9 @@ uint Connection::GetSelfHandle()
 QList<uint> Connection::RequestHandles(uint handle_type,
                                        const QStringList & names)
 {
+    QString strMessage = "VICaR Connection: RequestHandles.";
+    d->logUtility->logMessage(strMessage);
+
     Q_UNUSED(names);
     QList<uint> result;
 
@@ -318,6 +330,7 @@ QList<uint> Connection::RequestHandles(uint handle_type,
     }
 
     //WARNING: Incomplete implementation. Create a handle and return the value here.
+    result.append(this->GetSelfHandle());
     return result;
 }
 
@@ -325,13 +338,11 @@ void Connection::HoldHandles(const uint handle_type, const QList<uint> &handles)
 {
     Q_UNUSED(handles);
     QString strMessage = "VICaR Connection: HoldHandles.";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     if (d->connection_status != Connected)
     {
 
         strMessage = "VICaR Connection: HoldHandles - Not Connected.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
 
         sendErrorReply("org.freedesktop.Telepathy.Error.Disconnected",
@@ -342,7 +353,6 @@ void Connection::HoldHandles(const uint handle_type, const QList<uint> &handles)
     {
 
         strMessage = "VICaR Connection: HoldHandles - Invalid Handle Type.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
 
         sendErrorReply("org.freedesktop.Telepathy.Error.InvalidArgument",
@@ -360,10 +370,9 @@ QStringList Connection::InspectHandles(const uint handle_type,
     QStringList handlesList;
 
     QString strMessage = "VICaR Connection: InspectHandles.";
-    qDebug() << strMessage;
-    d->logUtility->logMessage(strMessage);
+    //d->logUtility->logMessage(strMessage);
 
-        // check input:
+     // check input:
     if (d->connection_status != Connected)
     {
         sendErrorReply("org.freedesktop.Telepathy.Error.Disconnected",
@@ -377,15 +386,19 @@ QStringList Connection::InspectHandles(const uint handle_type,
         return handlesList;
     }
 
-    uint handle = 0;
+    uint handle;
+
+    qDebug() << "VICaR Connction: " << handles.length()<< " handles passed to us";
     for (int i = 0 ; i < handles.length(); i++) {
         handle = handles.at(i);
-        strMessage = "VICaR Connection: Inspecting handle "+QString(handle);
-        qDebug() << strMessage;
+        strMessage = "VICaR Connection: Inspecting handle "+QString::number(handle);
         d->logUtility->logMessage(strMessage);
-        handlesList.append(QString(handle));
+        handlesList.append(QString::number(handle));
     }
 
+    strMessage = "VICaR Connection: Handle inspection completed";
+    d->logUtility->logMessage(strMessage);
+
     //WARNING: Incomplete implementation
     return handlesList;
 }
@@ -393,13 +406,14 @@ QStringList Connection::InspectHandles(const uint handle_type,
 void Connection::ReleaseHandles(const uint handle_type, const QList<uint> &handles)
 {
     Q_UNUSED(handles);
-    QString strMessage;
+    QString strMessage = "VICaR Connection: ReleaseHandles.";
+    d->logUtility->logMessage(strMessage);
+
     if (d->connection_status != Connected)
     {
         sendErrorReply("org.freedesktop.Telepathy.Error.Disconnected",
                        "VICaR - Unable to release handle. The connection is no longer available.");
         strMessage = "VICaR Connection: Releasing Handle while connection is no longer connected.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
         return;
     }
@@ -408,7 +422,6 @@ void Connection::ReleaseHandles(const uint handle_type, const QList<uint> &handl
         sendErrorReply("org.freedesktop.Telepathy.Error.InvalidArgument",
                        "VICaR - Supports handles of type Contact only.");
         strMessage =  "VICaR Connection: Trying to release a Handle that is not a contact.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
         return;
     }
@@ -418,6 +431,10 @@ void Connection::ReleaseHandles(const uint handle_type, const QList<uint> &handl
 
 org::freedesktop::Telepathy::ChannelInfoList Connection::ListChannels()
 {
+
+    QString strMessage = "VICaR Connection: ListChannels.";
+    d->logUtility->logMessage(strMessage);
+
     org::freedesktop::Telepathy::ChannelInfoList result;
     if (d->connection_status != Connected)
     {
@@ -440,6 +457,11 @@ QDBusObjectPath Connection::RequestChannel(const QString &type,
     Q_UNUSED(suppress_handler);
     //This method is deprecated and no longer used as per latest Telepathy spec
 
+
+    QString strMessage = "VICaR Connection: RequestChannel.";
+    d->logUtility->logMessage(strMessage);
+
+
     if (type != QString("org.freedesktop.Telepathy.Channel.Type.StreamedMedia"))
     {
         sendErrorReply("org.freedesktop.Telepathy.Error.NotImplemented",
@@ -463,6 +485,7 @@ QDBusObjectPath Connection::RequestChannel(const QString &type,
 
     //WARNING: Incomplete implementation, we are not creating any channels here at all.
     QDBusObjectPath channel_path;
+    qDebug() << "VICaR Connection: Returning null channel object path";
     return channel_path;
 }
 
@@ -474,7 +497,6 @@ QDBusObjectPath Connection::CreateChannel(const QVariantMap &request,
     Q_ASSERT(!request.isEmpty());
     QString strMessage;
     strMessage = "VICaR Connection: CreateChannel";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     qDebug() << " Request details are: "<< request;
 
@@ -493,7 +515,6 @@ bool Connection::EnsureChannel(const QVariantMap &request,
     Q_UNUSED(channel_properties);
     Q_ASSERT(!request.isEmpty());
     QString strMessage = "VICaR Connection: EnsureChannel";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     qDebug() << " Request details are: "<< request;
 
@@ -506,7 +527,6 @@ bool Connection::EnsureChannel(const QVariantMap &request,
 QDBusObjectPath Connection::processChannel(const QVariantMap &request){
 
     QString strMessage = "VICaR Connection: ProcessChannel";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     QDBusObjectPath channel_path;
@@ -570,7 +590,6 @@ QDBusObjectPath Connection::processChannel(const QVariantMap &request){
 
     strMessage = "VICaR Connection: Call is processed.";
 
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     return channel_path;
@@ -583,7 +602,6 @@ void Connection::AddClientInterest(const QStringList &tokens){
     QString strMessage;
 
     strMessage = "VICaR Connection: AddClientInterest";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 }
 
@@ -593,7 +611,6 @@ void Connection::RemoveClientInterest(const QStringList &tokens){
     QString strMessage;
 
     strMessage = "VICaR Connection: RemoveClientInterest";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 }
 
index 3742f93..e463ad9 100644 (file)
@@ -9,6 +9,8 @@
  */
 
 #include "connectioninterfacerequestsadaptor.h"
+#include "connectioninterfacerequeststypes.h"
+#include "connection.h"
 #include <QtCore/QMetaObject>
 #include <QtCore/QByteArray>
 #include <QtCore/QList>
@@ -16,6 +18,7 @@
 #include <QtCore/QString>
 #include <QtCore/QStringList>
 #include <QtCore/QVariant>
+#include <QDebug>
 
 /*
  * Implementation of adaptor class ConnectionInterfaceRequestsAdaptor
@@ -48,12 +51,14 @@ org::freedesktop::Telepathy::RequestableChannelClassList ConnectionInterfaceRequ
 QDBusObjectPath ConnectionInterfaceRequestsAdaptor::CreateChannel(const QVariantMap &request, QVariantMap &channel_properties)
 {
     // handle method call org.freedesktop.Telepathy.Connection.Interface.Requests.CreateChannel
-    //return static_cast<YourObjectType *>(parent())->CreateChannel(request, channel_properties);
+    //This method should return a Channel object path
+    return static_cast<Connection *>(parent())->CreateChannel(request, channel_properties);
 }
 
 bool ConnectionInterfaceRequestsAdaptor::EnsureChannel(const QVariantMap &request, QDBusObjectPath &channel_object, QVariantMap &channel_properties)
 {
     // handle method call org.freedesktop.Telepathy.Connection.Interface.Requests.EnsureChannel
-    //return static_cast<YourObjectType *>(parent())->EnsureChannel(request, channel_object, channel_properties);
+    //This method should return a Channel object path
+    return static_cast<Connection *>(parent())->EnsureChannel(request, channel_object, channel_properties);
 }
 
index b4495f0..599856f 100644 (file)
@@ -43,7 +43,7 @@ class ConnectionManagerPrivate
 public:
     ConnectionManagerPrivate(ConnectionManager * parent) :
         adaptor(new ConnectionManagerAdaptor(parent)),
-        logUtility(new LogUtility("/var/log/vicar/vicar.log",parent))
+        logUtility(new LogUtility(parent))
     {
         Q_ASSERT(0 != adaptor);
         activeConnection = 0;
@@ -73,7 +73,6 @@ ConnectionManager::GetParameters(const QString &proto)
     Q_ASSERT(!proto.isEmpty());    
     Q_UNUSED(proto);
     strMessage = "VICAR: ConnectionManager::GetParameters(const QString &prot)";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     org::freedesktop::Telepathy::ParameterDefinitionList result;
     org::freedesktop::Telepathy::ParameterDefinition param;
@@ -123,7 +122,6 @@ ConnectionManager::GetParameters(const QString &proto)
 QStringList ConnectionManager::ListProtocols()
 {
     QString strMessage = "VICaR ConnectionManager::ListProtocols()";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     return QStringList(protocol_name);
 }
@@ -133,7 +131,6 @@ QString ConnectionManager::RequestConnection(const QString & proto,
                                              QDBusObjectPath & object_path)
 {
     QString strMessage =  "VICaR CM: Connection Requested for protocol "+proto;
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
     QString connection_service;    
     //object_path = QDBusObjectPath();
@@ -145,13 +142,11 @@ QString ConnectionManager::RequestConnection(const QString & proto,
                        "VICaR - Unable to create Connection. Requested protocol is not implemented.");
         */
         strMessage =  "VICaR CM::RequestConnection: proto mismatch.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
         return connection_service;
     }
     if (d->activeConnection != 0){
         strMessage =  "VICaR CM::RequestConnection: An active connection already exists at "+d->activeConnection->serviceName();
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
 
         object_path = d->activeConnection->objectPath();
@@ -190,34 +185,29 @@ QString ConnectionManager::RequestConnection(const QString & proto,
                            "VICaR - Unable to create Connection. Invalid parameters specified.");
             */
             strMessage =  "VICaR CM::RequestConnection: invalid parameter" + param + "found.";
-            qDebug() << strMessage;
             d->logUtility->logMessage(strMessage);
             return connection_service;
         }
     }
 
     strMessage =  "DEBUG CM: Trying to create new connection with account "+account;
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     Connection * new_connection = new Connection(account, this);
     Q_ASSERT(0 != new_connection);
 
     strMessage =  "DEBUG CM: Trying to register new connection";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     if (!new_connection->registerObject())
     {
         strMessage = "VICaR CM: Error while registering Connection object with DBus.";
-        qDebug() << strMessage;
         d->logUtility->logMessage(strMessage);
         new_connection->deleteLater();
         return QString();
     }
 
     strMessage =  "VICaR CM: New Connection Created. Status is " + QString(new_connection->GetStatus());
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
 
@@ -225,7 +215,6 @@ QString ConnectionManager::RequestConnection(const QString & proto,
     connection_service = new_connection->serviceName();
 
     strMessage =  "VICaR CM: Emitting New Connection Signal";
-    qDebug() << strMessage;
     d->logUtility->logMessage(strMessage);
 
     emit NewConnection(connection_service, object_path, "tel");
index b6024ca..256a294 100644 (file)
@@ -26,9 +26,6 @@ Based on Telepathy-SNOM with copyright notice below.
  * 51 Franklin SQObject::treet, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <iostream>
-#include <fstream>
-
 #include <QtCore/QCoreApplication>
 #include <QtCore/QDebug>
 
@@ -49,37 +46,9 @@ Based on Telepathy-SNOM with copyright notice below.
 
 using namespace std;
 
-/*
-ofstream logfile;
-
-void MyOutputHandler(QtMsgType type, const char *msg) {
-    switch (type) {
-        case QtDebugMsg:
-            logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n";
-            break;
-        case QtCriticalMsg:
-            logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n";
-            break;
-        case QtWarningMsg:
-            logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n";
-            break;
-        case QtFatalMsg:
-            logfile << QTime::currentTime().toString().toAscii().data() <<  " Fatal: " << msg << "\n";
-            abort();
-    }
-}
-
-*/
-
 int main(int argc, char ** argv)
 {
 
-//    logfile.open("/var/log/logfile.txt", ios::app);
-//    #ifndef QT_NO_DEBUG_OUTPUT
-//    qInstallMsgHandler(MyOutputHandler);
-//    #endif
-
-
     QCoreApplication app(argc, argv);
 
     // register types:
@@ -94,7 +63,7 @@ int main(int argc, char ** argv)
     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityPair>();
     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityPairList>();
     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityChange>();
-    qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityChangeList>();    
+    qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityChangeList>();
     qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
     qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
 
index 08b0fef..87b28d1 100644 (file)
@@ -1,7 +1,7 @@
 #INCLUDEPATH += /usr/include/telepathy-1.0
 #LIBS += /usr/lib/libtelepathy-qt4.so
 
-exists($$QMAKE_INCDIR_QT"/../qmsystem2/qmkeys.h"){
+contains(MEEGO_EDITION,harmattan){
    DEFINES += Q_WS_MAEMO_6
 }
 
index a5a19da..545cb03 100755 (executable)
 #include "connectioninterfacerequeststypes.h"
 #include "harmattanaccountutility.h"
 #include <QDebug>
-#include <QCoreApplication> //DEBUG - Delete this
+#include <QCoreApplication>
 #include "dbusutility.h"
 #include <QDBusMetaType>
 #include <QDBusConnection>
+#include <QCryptographicHash> //DEBUG
+
+
+#include <QDBusInterface>
+#include <QDBusObjectPath>
+#include <QDBusArgument>
+
+#define AM_SERVICE          "org.freedesktop.Telepathy.AccountManager"
+#define AM_OBJ_PATH         "/org/freedesktop/Telepathy/AccountManager"
+#define AM_INTERFACE        "org.freedesktop.Telepathy.AccountManager"
+#define RING_CONN_SERVICE   "org.freedesktop.Telepathy.Connection.ring.tel.ring"
+#define RING_CONN_PATH      "/org/freedesktop/Telepathy/Connection/ring/tel/ring"
+#define DBUS_SERVICE        "org.freedesktop.DBus.Properties"
+#define DBUS_OBJ_PATH       "/org/freedesktop/DBus/Properties"
+#define DBUS_PROPS_IFACE     "org.freedesktop.DBus.Properties"
 
 int main(int argc, char *argv[])
 {
@@ -37,7 +52,7 @@ int main(int argc, char *argv[])
     if (argc > 1 && argv[1]){
         QString instruction = QString(argv[1]);
         if (instruction == "INSTALL"){
-            //Check if Account already exists
+            //Check if Account already exists                                                            
             if (!tpUtility->accountExists()){
                 qDebug() << "VICaR account not found. Creating ..";
                 bool result = tpUtility->createAccount();
@@ -51,98 +66,61 @@ int main(int argc, char *argv[])
             bool result = tpUtility->deleteAccount();
             if (!result) exit(2);
         }
-
+        else if (instruction == "TESTING"){
+            tpUtility->callNumberWithRing(argv[2]);
+        }
+        else if (instruction == "TPACCOUNTSTATUS"){
+            QString status = tpUtility->getAccountStatus();
+            qDebug() << "Account Status is "<< status;
+        }
+#if defined(Q_WS_MAEMO_5)
         else if (instruction == "CREATEDB"){
             bool result = databaseUtility->openDatabase();
             if (!result){
-                qDebug() <<"Error creating profiles database. "
+                qDebug() <<"Error creating vicar database. "
                         <<databaseUtility->lastError();
                 exit(3);
             }
-            qDebug() << "VICaR profiles database opened.";
 
-            if (!databaseUtility->tableExists("profiles")){
-                qDebug() << "Creating VICaR profiles table..";
-                result = databaseUtility->createProfilesTable();
-                if (!result){
-                    qDebug() <<"Error creating profiles table. "
-                            <<databaseUtility->lastError();
-                    exit(4);
-                }
-            }
-            else{
-                qDebug()<<"Profiles table exists";
+            qDebug() << "VICaR database opened.";
+            qDebug() << "Preparing VICaR tables..";
+            result = databaseUtility->prepareTables();
+            if (!result){
+                qDebug() <<"Error creating tables. "
+                        <<databaseUtility->lastError();
+                exit(4);
             }
+
             databaseUtility->closeDatabase();
         }
         else if (instruction == "DROPDB"){
             bool result = databaseUtility->deleteDatabase();
             if (!result){
-                qDebug() <<"Error deleting profiles database. "
+                qDebug() <<"Error deleting vicar database. "
                         <<databaseUtility->lastError();
                 exit(5);
             }
-            qDebug() << "VICaR profiles database deleted.";
-        }
-        else if (instruction == "TPACCOUNTSTATUS"){
-            QString status = tpUtility->getAccountStatus();
-            qDebug() << "Account Status is "<< status;
-        }
+            qDebug() << "VICaR database deleted.";
+        }    
+#elif defined(Q_WS_MAEMO_6)
         else if (instruction == "--create-account"){
-#if defined(Q_WS_MAEMO_6)
             qDebug() << "Creating account";
             accountUtility->addAccount();
-#else
-            qDebug() << "This command is applicable only in harmattan";
-#endif
         }
         else if (instruction == "--delete-account"){
-#if defined(Q_WS_MAEMO_6)
             qDebug() << "Deleting account";
             accountUtility->removeAccount();
-#else
-            qDebug() << "This command is applicable only in harmattan";
-#endif
         }
-        else if (instruction == "TESTING"){
-            tpUtility->callNumberWithRing(argv[2]);
+#endif
+        else {
+            qDebug() << "This command is not recognized";
         }
     }
     else{                        
 
-        qDebug() << "Sending Introspect method call";
-
-        DbusUtility dbusUtility(&app);
-        QList<QVariant> argsToSend;
+        qDebug() << QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex();
 
-
-        bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.Connection.ring.tel.ring",
-                                   "/org/freedesktop/Telepathy/Connection/ring/tel/ring",
-                                   "org.freedesktop.DBus.Introspectable",
-                                   "Introspect",argsToSend,false);
-
-        success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.ConnectionManager.ring",
-                                   "/org/freedesktop/Telepathy/ConnectionManager/ring",
-                                   "org.freedesktop.DBus.Introspectable",
-                                   "Introspect",argsToSend,false);
-
-        /*
-
-        bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.AccountManager",
-                                   "/org/freedesktop/Telepathy/Account/ring/tel/ring",
-                                   "org.freedesktop.Telepathy.Account",
-                                   "Reconnect",argsToSend,false);
-        */
-
-        if (!success){
-            qDebug() << dbusUtility.getErrorMessage();
-        }
-        else{
-            qDebug() << "Method call executed successfully";
-        }
-        app.exec();
     }
-
     delete (tpUtility);
     delete (databaseUtility);
     delete (accountUtility);