From 5e3ee6e03bc18e941eb99dc5b7f9cfde7ff86a51 Mon Sep 17 00:00:00 2001 From: Sudheer K Date: Sun, 7 Nov 2010 23:12:52 -0800 Subject: [PATCH] Fix for publish/subscribe error --- debian/changelog | 7 +- debian/files | 2 +- debian/postinst | 4 + debian/prerm | 4 + ...kia.Telepathy.Channel.Interface.DialStrings.xml | 26 +++++ src/vicar-config/uis/profilesettingsdialog.ui | 8 +- src/vicar-daemon/src/callrouter.cpp | 102 +++++++++++++------- src/vicar-daemon/src/callrouter.h | 1 + .../src/connectioninterfacerequeststypes.cpp | 75 ++++++++++++++ .../src/connectioninterfacerequeststypes.h | 78 +++++++++++++++ src/vicar-lib/src/connifacereqproxy.cpp | 26 +++++ src/vicar-lib/src/connifacereqproxy.h | 95 ++++++++++++++++++ src/vicar-lib/src/databaseutility.cpp | 2 +- src/vicar-lib/src/telepathyutility.cpp | 36 ++++++- src/vicar-lib/src/telepathyutility.h | 4 + src/vicar-lib/vicar-lib.pro | 4 + src/vicar-telepathy/src/connection.cpp | 12 +++ src/vicar-telepathy/src/main.cpp | 8 +- src/vicar-utils/src/main.cpp | 10 ++ 19 files changed, 454 insertions(+), 50 deletions(-) create mode 100644 src/data/xml/com.Nokia.Telepathy.Channel.Interface.DialStrings.xml mode change 100755 => 100644 src/data/xml/org.maemo.vicar.xml create mode 100644 src/vicar-lib/src/connectioninterfacerequeststypes.cpp create mode 100644 src/vicar-lib/src/connectioninterfacerequeststypes.h create mode 100644 src/vicar-lib/src/connifacereqproxy.cpp create mode 100644 src/vicar-lib/src/connifacereqproxy.h diff --git a/debian/changelog b/debian/changelog index 23aeca2..f85ba85 100755 --- a/debian/changelog +++ b/debian/changelog @@ -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. Fri, 03 Sep 2010 08:10:00 +0530 + -- Sudheer K. Fri, 07 Nov 2010 23:10:00 -0800 diff --git a/debian/files b/debian/files index a9cf3e7..e288da5 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -vicar_0.5-1_armel.deb user/network extra +vicar_0.5-3_armel.deb user/network extra diff --git a/debian/postinst b/debian/postinst index 0b39348..df0e349 100755 --- a/debian/postinst +++ b/debian/postinst @@ -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 diff --git a/debian/prerm b/debian/prerm index 9885c6f..24cf8b8 100644 --- a/debian/prerm +++ b/debian/prerm @@ -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 index 0000000..6fc042c --- /dev/null +++ b/src/data/xml/com.Nokia.Telepathy.Channel.Interface.DialStrings.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/data/xml/org.maemo.vicar.xml b/src/data/xml/org.maemo.vicar.xml old mode 100755 new mode 100644 diff --git a/src/vicar-config/uis/profilesettingsdialog.ui b/src/vicar-config/uis/profilesettingsdialog.ui index f55f5ee..9ccfba8 100644 --- a/src/vicar-config/uis/profilesettingsdialog.ui +++ b/src/vicar-config/uis/profilesettingsdialog.ui @@ -99,7 +99,7 @@ - Qt::ImhDigitsOnly + Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers @@ -125,7 +125,7 @@ - Qt::ImhDigitsOnly + Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers @@ -215,7 +215,7 @@ - Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhPreferLowercase|Qt::ImhPreferNumbers + Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers @@ -241,7 +241,7 @@ - Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoAutoUppercase|Qt::ImhNoPredictiveText|Qt::ImhPreferLowercase|Qt::ImhPreferNumbers + Qt::ImhDialableCharactersOnly|Qt::ImhLowercaseOnly|Qt::ImhNoPredictiveText|Qt::ImhPreferNumbers diff --git a/src/vicar-daemon/src/callrouter.cpp b/src/vicar-daemon/src/callrouter.cpp index 9313b2f..71b1fa7 100755 --- a/src/vicar-daemon/src/callrouter.cpp +++ b/src/vicar-daemon/src/callrouter.cpp @@ -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 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; +} diff --git a/src/vicar-daemon/src/callrouter.h b/src/vicar-daemon/src/callrouter.h index e6e994e..b200270 100755 --- a/src/vicar-daemon/src/callrouter.h +++ b/src/vicar-daemon/src/callrouter.h @@ -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 index 0000000..33ea4a6 --- /dev/null +++ b/src/vicar-lib/src/connectioninterfacerequeststypes.cpp @@ -0,0 +1,75 @@ +/* +@version: 0.5 +@author: Sudheer K. +@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 + * + * 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 index 0000000..2b6c884 --- /dev/null +++ b/src/vicar-lib/src/connectioninterfacerequeststypes.h @@ -0,0 +1,78 @@ +/* +@version: 0.5 +@author: Sudheer K. +@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 + * Copyright (C) 2006 by INdT + * @author Andre Moreira Magalhaes + * + * 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 +#include +#include +#include +#include + +namespace org { +namespace freedesktop { +namespace Telepathy { + +class ChannelDetails +{ +public: + QDBusObjectPath channel; + QVariantMap properties; +}; +typedef QList ChannelDetailsList; + +class RequestableChannelClass +{ +public: + QVariantMap fixedProperties; + QStringList allowedProperties; +}; +typedef QList 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 index 0000000..abef41c --- /dev/null +++ b/src/vicar-lib/src/connifacereqproxy.cpp @@ -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 index 0000000..c53359a --- /dev/null +++ b/src/vicar-lib/src/connifacereqproxy.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#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 CreateChannel(const QVariantMap &request) + { + QList argumentList; + argumentList << qVariantFromValue(request); + return asyncCallWithArgumentList(QLatin1String("CreateChannel"), argumentList); + } + inline QDBusReply CreateChannel(const QVariantMap &request, QVariantMap &channel_properties) + { + QList 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(reply.arguments().at(1)); + } + return reply; + } + + inline QDBusPendingReply EnsureChannel(const QVariantMap &request) + { + QList argumentList; + argumentList << qVariantFromValue(request); + return asyncCallWithArgumentList(QLatin1String("EnsureChannel"), argumentList); + } + inline QDBusReply EnsureChannel(const QVariantMap &request, QDBusObjectPath &channel_object, QVariantMap &channel_properties) + { + QList 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(reply.arguments().at(1)); + channel_properties = qdbus_cast(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 diff --git a/src/vicar-lib/src/databaseutility.cpp b/src/vicar-lib/src/databaseutility.cpp index 19ffdf7..638b6f0 100644 --- a/src/vicar-lib/src/databaseutility.cpp +++ b/src/vicar-lib/src/databaseutility.cpp @@ -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(); } diff --git a/src/vicar-lib/src/telepathyutility.cpp b/src/vicar-lib/src/telepathyutility.cpp index 259ad0c..8aca28a 100644 --- a/src/vicar-lib/src/telepathyutility.cpp +++ b/src/vicar-lib/src/telepathyutility.cpp @@ -8,6 +8,7 @@ #include "accountmanagerproxy.h" #include "accountproxy.h" #include "accountcompatproxy.h" +#include "connifacereqproxy.h" #include #include #include @@ -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 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 "< #include int main(int argc, char *argv[]) { qDBusRegisterMetaType(); + //From Connection Interface Requests + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + //From Vicar Profile Types //qDBusRegisterMetaType(); //qDBusRegisterMetaType(); @@ -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); -- 1.7.9.5