Fix for publish/subscribe error
authorSudheer K <scifi.guy@hotmail.com>
Mon, 8 Nov 2010 07:12:52 +0000 (23:12 -0800)
committerSudheer K <scifi.guy@hotmail.com>
Mon, 8 Nov 2010 07:12:52 +0000 (23:12 -0800)
20 files changed:
debian/changelog
debian/files
debian/postinst
debian/prerm
src/data/xml/com.Nokia.Telepathy.Channel.Interface.DialStrings.xml [new file with mode: 0644]
src/data/xml/org.maemo.vicar.xml [changed mode: 0755->0644]
src/vicar-config/uis/profilesettingsdialog.ui
src/vicar-daemon/src/callrouter.cpp
src/vicar-daemon/src/callrouter.h
src/vicar-lib/src/connectioninterfacerequeststypes.cpp [new file with mode: 0644]
src/vicar-lib/src/connectioninterfacerequeststypes.h [new file with mode: 0644]
src/vicar-lib/src/connifacereqproxy.cpp [new file with mode: 0644]
src/vicar-lib/src/connifacereqproxy.h [new file with mode: 0644]
src/vicar-lib/src/databaseutility.cpp
src/vicar-lib/src/telepathyutility.cpp
src/vicar-lib/src/telepathyutility.h
src/vicar-lib/vicar-lib.pro
src/vicar-telepathy/src/connection.cpp
src/vicar-telepathy/src/main.cpp
src/vicar-utils/src/main.cpp

index 23aeca2..f85ba85 100755 (executable)
@@ -1,6 +1,7 @@
-vicar (0.5-1) unstable; urgency=low
+vicar (0.5-3) unstable; urgency=low
 
-  * Fixed Dbus activation error.
+  * Fix for infrequent "No routing profile defined for this number" error.
+  * Vicar will only process phone numbers with 0-9,+,p,* and #.
 
- -- Sudheer K. <scifi1947 at gmail.com>  Fri,  03 Sep 2010 08:10:00 +0530
+ -- Sudheer K. <scifi1947 at gmail.com>  Fri,  07 Nov 2010 23:10:00 -0800
 
index a9cf3e7..e288da5 100644 (file)
@@ -1 +1 @@
-vicar_0.5-1_armel.deb user/network extra
+vicar_0.5-3_armel.deb user/network extra
index 0b39348..df0e349 100755 (executable)
@@ -21,6 +21,10 @@ set -e
 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
index 9885c6f..24cf8b8 100644 (file)
@@ -20,6 +20,10 @@ 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/vicar-utils ]] && su - user -c "exec /opt/vicar/vicar-utils REMOVE"
 
diff --git a/src/data/xml/com.Nokia.Telepathy.Channel.Interface.DialStrings.xml b/src/data/xml/com.Nokia.Telepathy.Channel.Interface.DialStrings.xml
new file mode 100644 (file)
index 0000000..6fc042c
--- /dev/null
@@ -0,0 +1,26 @@
+<!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="com.Nokia.Telepathy.Channel.Interface.DialStrings">
+    <method name="GetCurrentDialStrings">
+      <arg name="Dial_Strings" type="a{us}" direction="out"/>
+    </method>
+    <method name="CancelDialString">
+      <arg name="Stream_ID" type="u" direction="in"/>
+    </method>
+    <method name="SendDialString">
+      <arg name="Stream_ID" type="u" direction="in"/>
+      <arg name="Dial_String" type="s" direction="in"/>
+      <arg name="Duration" type="u" direction="in"/>
+      <arg name="Pause" type="u" direction="in"/>
+    </method>
+    <signal name="StoppedDialString">
+      <arg type="u"/>
+      <arg type="b"/>
+    </signal>
+    <signal name="SendingDialString">
+      <arg type="u"/>
+      <arg type="s"/>
+    </signal>
+  </interface>
+</node>
old mode 100755 (executable)
new mode 100644 (file)
index f55f5ee..9ccfba8 100644 (file)
@@ -99,7 +99,7 @@
          </size>
         </property>
         <property name="inputMethodHints">
-         <set>Qt::ImhDigitsOnly</set>
+         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers</set>
         </property>
        </widget>
       </item>
          </size>
         </property>
         <property name="inputMethodHints">
-         <set>Qt::ImhDigitsOnly</set>
+         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers</set>
         </property>
        </widget>
       </item>
          </size>
         </property>
         <property name="inputMethodHints">
-         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhPreferLowercase|Qt::ImhPreferNumbers</set>
+         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers</set>
         </property>
        </widget>
       </item>
          </size>
         </property>
         <property name="inputMethodHints">
-         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhPreferLowercase|Qt::ImhPreferNumbers</set>
+         <set>Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers</set>
         </property>
        </widget>
       </item>
index 9313b2f..71b1fa7 100755 (executable)
@@ -60,7 +60,7 @@ CallRouter::CallRouter(QObject *parent) :
 {
         Q_ASSERT(0 != d);
         this->registerDBusService();
-        qDebug() << "Registered DBus Service " << APPLICATION_DBUS_SERVICE;
+        qDebug() << "Vicar-Daemon: Registered DBus Service " << APPLICATION_DBUS_SERVICE;
 }
 
 CallRouter::~CallRouter(){
@@ -73,13 +73,13 @@ void CallRouter::registerDBusService(){
     if (!connection.interface()->isServiceRegistered(APPLICATION_DBUS_SERVICE)){
 
         if (!connection.registerService(APPLICATION_DBUS_SERVICE)) {
-            qDebug() << d->dbusUtility->getErrorMessage();
+            qDebug() << "Vicar-Daemon: " << d->dbusUtility->getErrorMessage();
             exit(1);
         }
     }
 
     if (!connection.registerObject(APPLICATION_DBUS_PATH, this, QDBusConnection::ExportAdaptors)) {
-        qDebug() << d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: " << d->dbusUtility->getErrorMessage();
         exit(2);
     }
 
@@ -94,7 +94,7 @@ void CallRouter::unregisterDBusService(){
     connection.unregisterObject(APPLICATION_DBUS_PATH,QDBusConnection::UnregisterTree);
 
     if (!connection.unregisterService(APPLICATION_DBUS_SERVICE)) {
-        qDebug() << d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: " << d->dbusUtility->getErrorMessage();
         exit(3);
     }
 
@@ -110,37 +110,37 @@ QString CallRouter::callViaCallingCard(QString strDestinationNumber){
 
         QString strErrorMessage;
         if (!result){
-            strErrorMessage = QString("Error finding VICaR profile. %1").arg(d->databaseUtility->lastError().text());
+            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");
             if (routeOnDefault){
-                qDebug() << "Routing directly as per configuration";
+                qDebug() << "Vicar-Daemon: Routing directly as per configuration";
                this->placeCall(strDestinationNumber);
             }
             else{
-                qDebug() << "No profile found. Stopping..";
-                strErrorMessage  = "VICaR: No routing profile defined for this number.";
+                qDebug() << "Vicar-Daemon: No profile found. Stopping..";
+                strErrorMessage  = "Vicar: No routing profile defined for this number.";
                 d->dbusUtility->displayNotification(strErrorMessage );
             }
         }
         else{
             //Now call the calling card number. This is generally a local and/or tollfree number
             QString strCallingCardNumber = d->currentProfile->gatewayNumber;
-            qDebug() << "Initiating call to "<< strCallingCardNumber;
+            qDebug() << "Vicar-Daemon: Initiating call to "<< strCallingCardNumber;
             bool status = this->placeCall(strCallingCardNumber);
             d->strLastDialedNumber = strDestinationNumber;
 
             QString strUserMessage;
 
             if (status){
-                qDebug() << "Call initiated successfully. Connecting DBus slot for audio connection monitor";
+                qDebug() << "Vicar-Daemon: Call initiated successfully. Connecting DBus slot for audio connection monitor";
                  startCallStatusMonitors();
             }
             else {
                 strUserMessage = QString("Unable to initiate new call to ").append(strCallingCardNumber);
                 strErrorMessage = d->dbusUtility->getErrorMessage();
-                qDebug() << strErrorMessage;
+                qDebug() << "Vicar-Daemon: " << strErrorMessage;
                 d->strLastDialedNumber.clear();
                 delete d->currentProfile;
                 d->currentProfile = 0;
@@ -180,11 +180,11 @@ void CallRouter::startCallStatusMonitors(){
                            SLOT(sendNumberAsDTMFCode(const QDBusMessage&)));
 
     if (success){
-        qDebug() << "Successfully connected to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully connected to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
     }
     else{
-        qDebug() << "Failed to connect to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to connect to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 
     /* Declare the slot to be executed when the call is terminated (due to connection errors etc).
@@ -198,11 +198,11 @@ void CallRouter::startCallStatusMonitors(){
                                SLOT(stopCallStatusMonitors()));
 
     if (success){
-        qDebug() << "Successfully connected to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully connected to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
     }
     else{
-        qDebug() << "Failed to connect to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to connect to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 
     /* Declare the slot to be executed when a call is received
@@ -221,11 +221,11 @@ void CallRouter::startCallStatusMonitors(){
                                SLOT(stopCallStatusMonitors()));
 
     if (success){
-        qDebug() << "Successfully connected to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully connected to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
     }
     else{
-        qDebug() << "Failed to connect to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to connect to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 }
 
@@ -245,11 +245,11 @@ void CallRouter::stopCallStatusMonitors(){
                                    SLOT(sendNumberAsDTMFCode(const QDBusMessage&)));
 
     if (status){
-        qDebug() << "Successfully disconnected from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully disconnected from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
     }
     else{
-        qDebug() << "Failed to disconnect from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to disconnect from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 
     // Disconnect the slot for monitoring terminated calls
@@ -260,11 +260,11 @@ void CallRouter::stopCallStatusMonitors(){
                                    SLOT(stopCallStatusMonitors()));
 
     if (status){
-        qDebug() << "Successfully disconnected from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully disconnected from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
     }
     else{
-        qDebug() << "Failed to disconnect from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to disconnect from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 
     // Disconnect the slot for monitoring incoming calls
@@ -275,11 +275,11 @@ void CallRouter::stopCallStatusMonitors(){
                                    SLOT(stopCallStatusMonitors()));
 
     if (status){
-        qDebug() << "Successfully disconnected from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
+        qDebug() << "Vicar-Daemon: Successfully disconnected from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
     }
     else{
-        qDebug() << "Failed to disconnect from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
-        qDebug() <<"DBus Error: "<< d->dbusUtility->getErrorMessage();
+        qDebug() << "Vicar-Daemon: Failed to disconnect from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
+        qDebug() <<"Vicar-Daemon: DBus Error: "<< d->dbusUtility->getErrorMessage();
     }
 }
 
@@ -295,7 +295,7 @@ void CallRouter::sendNumberAsDTMFCode(const QDBusMessage& dbusMessage){
             // Now that the call to Calling card number is successful. We can send the original number as DTMF tones
             QString strDTMFCode = convertToDTMFCode(d->strLastDialedNumber);
 
-            qDebug() << "Audio connection established. Sending DTMF code "<< strDTMFCode;
+            qDebug() << "Vicar-Daemon: Audio connection established. Sending DTMF code "<< strDTMFCode;
 
             QList<QVariant> argsToSend;
             argsToSend.append(strDTMFCode);
@@ -311,7 +311,7 @@ void CallRouter::sendNumberAsDTMFCode(const QDBusMessage& dbusMessage){
                 d->dbusUtility->displayNotification(strMessage);
             }
             else{
-                qDebug() << "Unable to send DTMF code.";
+                qDebug() << "Vicar-Daemon: Unable to send DTMF code.";
             }
 
 
@@ -321,7 +321,7 @@ void CallRouter::sendNumberAsDTMFCode(const QDBusMessage& dbusMessage){
               that the DTMF codes are sent only for the calls placed by this app (i.e calls to Calling card number).
              */
 
-            qDebug() << "Now disconnecting from call status monitors..";
+            qDebug() << "Vicar-Daemon: Now disconnecting from call status monitors..";
             stopCallStatusMonitors();
 
             d->strLastDialedNumber.clear();
@@ -329,12 +329,12 @@ void CallRouter::sendNumberAsDTMFCode(const QDBusMessage& dbusMessage){
             d->currentProfile = 0;
         }
         else{
-            qDebug() << "Audio not yet connected.";
+            qDebug() << "Vicar-Daemon: Audio not yet connected.";
         }
     }
     else
     {
-        qDebug() << "Last dialed number is empty.";
+        qDebug() << "Vicar-Daemon: Last dialed number is empty.";
     }
 }
 
@@ -408,8 +408,18 @@ bool CallRouter::isRunning(){
 //DBus Method used by external applications to call via VICaR
 QString CallRouter::callInternationalNumber(const QString& strDestinationNumber){
 
-    qDebug() << "New call requested by external application. Destination number is " << strDestinationNumber;
-    QString strErrorMessage = this->callViaCallingCard(strDestinationNumber);
+    QString strErrorMessage;
+
+    qDebug() << "Vicar-Daemon: New call requested by external application. Destination number is " << strDestinationNumber;
+
+    if (isValidPhoneNumber(strDestinationNumber)){
+
+        strErrorMessage = this->callViaCallingCard(strDestinationNumber);
+    }
+    else{
+        strErrorMessage = QString("Vicar-Daemon: %1 is not a valid number").arg(strDestinationNumber);
+    }
+
     qDebug() << strErrorMessage;
 
     if (strErrorMessage.isEmpty()){
@@ -419,3 +429,23 @@ QString CallRouter::callInternationalNumber(const QString& strDestinationNumber)
         return strErrorMessage;
     }
  }
+
+//Check whether a string is valid phone number
+bool CallRouter::isValidPhoneNumber(QString strPhoneNumber){
+
+
+/* Remove all dialble characters. The resulting string should be a valid number */    
+    QRegExp regexp = QRegExp("[p+*#]");
+
+    strPhoneNumber = strPhoneNumber.replace(regexp,"");
+
+    qDebug() << "Vicar Daemon: Cleaned up phone number is " << strPhoneNumber;
+
+/* Now remove all digits, the resulting string should be empty, then it is a valid number */
+    regexp = QRegExp("[0-9]");
+
+    strPhoneNumber = strPhoneNumber.replace(regexp,"");
+
+    bool isNumber = strPhoneNumber.isEmpty();
+    return isNumber;
+}
index e6e994e..b200270 100755 (executable)
@@ -40,6 +40,7 @@ public:
     ~CallRouter();
     void registerDBusService();
     void unregisterDBusService();
+    bool isValidPhoneNumber(QString);
 
 protected:
     void startCallStatusMonitors();
diff --git a/src/vicar-lib/src/connectioninterfacerequeststypes.cpp b/src/vicar-lib/src/connectioninterfacerequeststypes.cpp
new file mode 100644 (file)
index 0000000..33ea4a6
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+@version: 0.5
+@author: Sudheer K. <scifi1947 at gmail.com>
+@license: GNU General Public License
+
+Based on QtTelepathy with copyright notice below.
+*/
+
+/*
+ * QtTelepathy, the Tapioca Qt4 Telepathy Client Library
+ * Copyright (C) 2006 by INdT
+ *  @author Andre Moreira Magalhaes <andre.magalhaes@indt.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "connectioninterfacerequeststypes.h"
+
+using namespace org::freedesktop::Telepathy;
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, ChannelDetails &val)
+{
+    argument.beginStructure();
+    argument >> val.channel >> val.properties;
+    argument.endStructure();
+    return argument;
+}
+
+QDBusArgument &operator<<(QDBusArgument &argument, const ChannelDetails &val)
+{
+    argument.beginStructure();
+    argument << val.channel << val.properties;
+    argument.endStructure();
+    return argument;
+}
+
+QDebug &operator<<(QDebug arg,const ChannelDetails &val)
+{
+    arg.space() << "[" << val.channel.path() << "," << val.properties <<"]";
+    return arg.space();
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, RequestableChannelClass &val)
+{
+    argument.beginStructure();
+    argument >> val.fixedProperties >> val.allowedProperties;
+    argument.endStructure();
+    return argument;
+}
+
+QDBusArgument &operator<<(QDBusArgument &argument, const RequestableChannelClass &val)
+{
+    argument.beginStructure();
+    argument << val.fixedProperties << val.allowedProperties;
+    argument.endStructure();
+    return argument;
+}
+
+QDebug &operator<<(QDebug arg,const RequestableChannelClass &val)
+{
+    arg.space() << "[" << val.fixedProperties << "," << val.allowedProperties <<"]";
+    return arg.space();
+}
diff --git a/src/vicar-lib/src/connectioninterfacerequeststypes.h b/src/vicar-lib/src/connectioninterfacerequeststypes.h
new file mode 100644 (file)
index 0000000..2b6c884
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+@version: 0.5
+@author: Sudheer K. <scifi1947 at gmail.com>
+@license: GNU General Public License
+
+Based on QtTelepathy with copyright notice below.
+*/
+
+/*
+ * QtTelepathy, the Tapioca Qt4 Telepathy Client Library
+ * Copyright (C) 2006 by Tobias Hunger <tobias.hunger@basyskom.de>
+ * Copyright (C) 2006 by INdT
+ *  @author Andre Moreira Magalhaes <andre.magalhaes@indt.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef QTTELEPATHY_CONNECTIONINTERFACEREQUESTSTYPES_H
+#define QTTELEPATHY_CONNECTIONINTERFACEREQUESTSTYPES_H
+
+#include <QtCore/QList>
+#include <QtCore/QDebug>
+#include <QtCore/QVariantMap>
+#include <QtDBus/QDBusArgument>
+#include <QtDBus/QDBusObjectPath>
+
+namespace org {
+namespace freedesktop {
+namespace Telepathy {
+
+class ChannelDetails
+{
+public:
+    QDBusObjectPath channel;
+    QVariantMap properties;
+};
+typedef QList<ChannelDetails> ChannelDetailsList;
+
+class RequestableChannelClass
+{
+public:
+    QVariantMap fixedProperties;
+    QStringList allowedProperties;
+};
+typedef QList<RequestableChannelClass> RequestableChannelClassList;
+
+} // namespace Telepathy
+} // namespace freedesktop
+} // namespace org
+
+Q_DECLARE_METATYPE(org::freedesktop::Telepathy::ChannelDetails)
+Q_DECLARE_METATYPE(org::freedesktop::Telepathy::ChannelDetailsList)
+
+const QDBusArgument& operator>>(const QDBusArgument& arg, org::freedesktop::Telepathy::ChannelDetails& val);
+QDBusArgument& operator<<(QDBusArgument& arg, const org::freedesktop::Telepathy::ChannelDetails& val);
+QDebug& operator<<(QDebug arg, const org::freedesktop::Telepathy::ChannelDetails& val);
+
+Q_DECLARE_METATYPE(org::freedesktop::Telepathy::RequestableChannelClass)
+Q_DECLARE_METATYPE(org::freedesktop::Telepathy::RequestableChannelClassList)
+
+const QDBusArgument& operator>>(const QDBusArgument& arg, org::freedesktop::Telepathy::RequestableChannelClass& val);
+QDBusArgument& operator<<(QDBusArgument& arg, const org::freedesktop::Telepathy::RequestableChannelClass& val);
+QDebug& operator<<(QDebug arg, const org::freedesktop::Telepathy::RequestableChannelClass& val);
+
+#endif
+
diff --git a/src/vicar-lib/src/connifacereqproxy.cpp b/src/vicar-lib/src/connifacereqproxy.cpp
new file mode 100644 (file)
index 0000000..abef41c
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -c ConnectionInterfaceRequestsProxy -p connifacereqproxy.h:connifacereqproxy.cpp org.freedesktop.Telepathy.Connection.I.Requests.xml org.freedesktop.Telepathy.Connection.Interface.Requests
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "connifacereqproxy.h"
+
+/*
+ * Implementation of interface class ConnectionInterfaceRequestsProxy
+ */
+
+ConnectionInterfaceRequestsProxy::ConnectionInterfaceRequestsProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+    : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+ConnectionInterfaceRequestsProxy::~ConnectionInterfaceRequestsProxy()
+{
+}
+
diff --git a/src/vicar-lib/src/connifacereqproxy.h b/src/vicar-lib/src/connifacereqproxy.h
new file mode 100644 (file)
index 0000000..c53359a
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -c ConnectionInterfaceRequestsProxy -p connifacereqproxy.h:connifacereqproxy.cpp org.freedesktop.Telepathy.Connection.I.Requests.xml org.freedesktop.Telepathy.Connection.Interface.Requests
+ *
+ * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef CONNIFACEREQPROXY_H_1284203341
+#define CONNIFACEREQPROXY_H_1284203341
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+#include "connectioninterfacerequeststypes.h"
+
+/*
+ * Proxy class for interface org.freedesktop.Telepathy.Connection.Interface.Requests
+ */
+class ConnectionInterfaceRequestsProxy: public QDBusAbstractInterface
+{
+    Q_OBJECT
+public:
+    static inline const char *staticInterfaceName()
+    { return "org.freedesktop.Telepathy.Connection.Interface.Requests"; }
+
+public:
+    ConnectionInterfaceRequestsProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+    ~ConnectionInterfaceRequestsProxy();
+
+    Q_PROPERTY(org::freedesktop::Telepathy::RequestableChannelClassList RequestableChannelClasses READ requestableChannelClasses)
+    inline org::freedesktop::Telepathy::RequestableChannelClassList requestableChannelClasses() const
+    { return qvariant_cast< org::freedesktop::Telepathy::RequestableChannelClassList >(property("RequestableChannelClasses")); }
+
+public Q_SLOTS: // METHODS
+    inline QDBusPendingReply<QDBusObjectPath, QVariantMap> CreateChannel(const QVariantMap &request)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(request);
+        return asyncCallWithArgumentList(QLatin1String("CreateChannel"), argumentList);
+    }
+    inline QDBusReply<QDBusObjectPath> CreateChannel(const QVariantMap &request, QVariantMap &channel_properties)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(request);
+        QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateChannel"), argumentList);
+        if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
+            channel_properties = qdbus_cast<QVariantMap>(reply.arguments().at(1));
+        }
+        return reply;
+    }
+
+    inline QDBusPendingReply<bool, QDBusObjectPath, QVariantMap> EnsureChannel(const QVariantMap &request)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(request);
+        return asyncCallWithArgumentList(QLatin1String("EnsureChannel"), argumentList);
+    }
+    inline QDBusReply<bool> EnsureChannel(const QVariantMap &request, QDBusObjectPath &channel_object, QVariantMap &channel_properties)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(request);
+        QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("EnsureChannel"), argumentList);
+        if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 3) {
+            channel_object = qdbus_cast<QDBusObjectPath>(reply.arguments().at(1));
+            channel_properties = qdbus_cast<QVariantMap>(reply.arguments().at(2));
+        }
+        return reply;
+    }
+
+Q_SIGNALS: // SIGNALS
+    void ChannelClosed(const QDBusObjectPath &removed_channel_object);
+    void NewChannels(org::freedesktop::Telepathy::ChannelDetailsList new_channels);
+};
+
+namespace org {
+  namespace freedesktop {
+    namespace Telepathy {
+      namespace Connection {
+        namespace Interface {
+          typedef ::ConnectionInterfaceRequestsProxy Requests;
+        }
+      }
+    }
+  }
+}
+#endif
index 19ffdf7..638b6f0 100644 (file)
@@ -132,7 +132,7 @@ int DatabaseUtility::insertProfile(org::maemo::vicar::Profile profile){
     bool result = false;    
     if (profilesDB.isOpen()){
         bool continueInsert = true;
-        if (!this->tableExists()){
+        if (!this->tableExists("profiles")){
             continueInsert = this->createProfilesTable();
         }
 
index 259ad0c..8aca28a 100644 (file)
@@ -8,6 +8,7 @@
 #include "accountmanagerproxy.h"
 #include "accountproxy.h"
 #include "accountcompatproxy.h"
+#include "connifacereqproxy.h"
 #include <QDBusInterface>
 #include <QDBusConnection>
 #include <QStringList>
@@ -109,7 +110,7 @@ QString TelepathyUtility::getAccountStatus(){
     return status;
 }
 
-//Create Vicar telepathy account (used installation)
+//Create Vicar telepathy account (used during installation)
 bool TelepathyUtility::createAccount(){
 
     AccountManagerProxy *amProxy = new AccountManagerProxy(AM_SERVICE,AM_OBJ_PATH,QDBusConnection::sessionBus(),this);
@@ -189,6 +190,39 @@ bool TelepathyUtility::deleteAccount(){
     return true;
 }
 
+bool TelepathyUtility::callNumberWithRing(QString number){
+
+    bool result = false;
+
+    ConnectionInterfaceRequestsProxy *requestsProxy = new ConnectionInterfaceRequestsProxy(RING_CONN_SERVICE,RING_CONN_PATH,QDBusConnection::sessionBus(),this);
+    if (requestsProxy->isValid()){
+        QVariantMap channelRequestDetails;
+        uint targetHandleType(1);
+        channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.TargetHandleType",targetHandleType);
+        channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.TargetID",number);
+        channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.ChannelType","org.freedesktop.Telepathy.Channel.Type.StreamedMedia");
+        QDBusPendingReply<QDBusObjectPath,QVariantMap> dbusReply = requestsProxy->CreateChannel(channelRequestDetails);
+        dbusReply.waitForFinished();
+        if (!dbusReply.isError()){
+            QDBusObjectPath objPath = dbusReply.argumentAt<0>();
+            QVariantMap channelProperties = dbusReply.argumentAt<1>();
+            result = true;
+        }
+        else{
+            qDebug() << "Error occurred calling "<<number<< ". Error is "<< dbusReply.error();
+            result = false;
+        }
+    }
+
+    return result;
+}
+
+bool TelepathyUtility::sendDTMFTone(QString tone){
+    bool result = false;
+
+    return result;
+}
+
 // Marshall the Presence data into a D-Bus argument
  QDBusArgument &operator<<(QDBusArgument &argument, const SimplePresence &simplePresence)
  {
index d39f7f3..2410ad9 100644 (file)
@@ -15,6 +15,8 @@
 #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"
@@ -53,6 +55,8 @@ public:
     bool accountExists();
     bool createAccount();
     bool deleteAccount();
+    bool callNumberWithRing(QString number);
+    bool sendDTMFTone(QString tone);
 };
 
 #endif // TELEPATHYUTILITY_H
index 25b0bc3..543e1e1 100755 (executable)
@@ -20,6 +20,8 @@ SOURCES += src/dbusutility.cpp \
     src/accountmanagerproxy.cpp \
     src/accountproxy.cpp \
     src/accountcompatproxy.cpp \
+    src/connifacereqproxy.cpp \
+    src/connectioninterfacerequeststypes.cpp \
     src/databaseutility.cpp
 HEADERS += src/dbusutility.h \
     src/gconfutility.h \
@@ -27,6 +29,8 @@ HEADERS += src/dbusutility.h \
     src/accountmanagerproxy.h \
     src/accountproxy.h \
     src/accountcompatproxy.h \
+    src/connifacereqproxy.h \
+    src/connectioninterfacerequeststypes.h \
     src/databaseutility.h \
     src/vicarprofiletypes.h
 
index 236ded5..c4dbfb4 100644 (file)
@@ -441,6 +441,18 @@ QDBusObjectPath Connection::processChannel(const QVariantMap &request){
         return channel_path;
     }
 
+    //Only allow requests with handle type as contact
+    QVariant vTargetHandleType = request.value("org.freedesktop.Telepathy.Channel.TargetHandleType");
+    uint intTargetHandleType = vTargetHandleType.toUInt();
+    if (intTargetHandleType != HandleContact)
+    {
+        QString strMessage = "VICaR - Supports handles of type Contact only. Recieved handle type ";
+        strMessage.append(vTargetHandleType.toString());
+
+        sendErrorReply("org.freedesktop.Telepathy.Error.InvalidArgument",
+                       strMessage);
+    }
+
     /*
         Send an error reply to Tp Client (Mission Control) to force it to close the active channel.
         Once it recieves the reply, the client does not bother what we return.
index 7ed93eb..d81fc54 100644 (file)
@@ -101,11 +101,11 @@ int main(int argc, char ** argv)
 
         // register CM on D-BUS:
         if (connection.registerService(cm_service_name)){
-            qDebug(qPrintable(QObject::tr("Service %1 registered with session bus.").
+            qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Service %1 registered with session bus.").
                        arg(cm_service_name)));
         }
         else{
-            qDebug(qPrintable(QObject::tr("Unable to register service %1 with session bus.").
+            qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Unable to register service %1 with session bus.").
                        arg(cm_service_name)));
         }
 
@@ -113,11 +113,11 @@ int main(int argc, char ** argv)
 
     ConnectionManager connection_mgr(&app);
     if (!connection.registerObject(cm_object_path,&connection_mgr)){
-        qDebug(qPrintable(QObject::tr("Unable to register VICaR connection manager at path %1 with session bus.").
+        qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Unable to register VICaR connection manager at path %1 with session bus.").
                    arg(cm_object_path)));
     }
 
-    qDebug(qPrintable(QObject::tr("Enternig main loop.")));    
+    qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Enternig main loop.")));
 //    logfile.close();
     return app.exec();
 }
index a88b3fb..bc2f3ab 100755 (executable)
@@ -7,12 +7,19 @@
 #include "telepathyutility.h"
 #include "databaseutility.h"
 #include "vicarprofiletypes.h"
+#include "connectioninterfacerequeststypes.h"
 #include <QDebug>
 #include <QDBusMetaType>
 
 int main(int argc, char *argv[])
 {
     qDBusRegisterMetaType<org::freedesktop::Telepathy::SimplePresence>();
+    //From Connection Interface Requests
+    qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetails>();
+    qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetailsList>();
+    qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
+    qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
+    //From Vicar Profile Types
     //qDBusRegisterMetaType<org::maemo::vicar::Profile>();
     //qDBusRegisterMetaType<org::maemo::vicar::ProfileList>();
 
@@ -73,6 +80,9 @@ int main(int argc, char *argv[])
             QString status = tpUtility->getAccountStatus();
             qDebug() << "Account Status is "<< status;
         }
+        else if (instruction == "TESTING"){
+            tpUtility->callNumberWithRing(argv[2]);
+        }
     }
 
     delete (tpUtility);