-void CallRouter::disconnectFromDBusSignals(){
-
- QDBusConnection connection = dbusUtility.getConnection();
-
- // Disconnect from the signal to enable call routing
- bool success = connection.disconnect(QString(""),QString(""),
- APPLICATION_DBUS_INTERFACE,
- QString("startOutgoingCallMonitor"),this,
- SLOT(startOutgoingCallMonitor()));
-
- if (success){
- qDebug() << "Successfully disconnected from Dbus signal org.maemo.vicar.startOutgoingCallMonitor";
- }
- else{
- qDebug() << "Failed to disconnect from Dbus signal org.maemo.vicar.startOutgoingCallMonitor";
- qDebug() <<"DBus Error: "<< qPrintable(dbusUtility.getErrorMessage());
- }
-
- // Disconnect from the signal to disable call routing
- success = connection.connect(QString(""),QString(""),
- APPLICATION_DBUS_INTERFACE,
- QString("stopOutgoingCallMonitor"),this,
- SLOT(stopOutgoingCallMonitor()));
-
- if (success){
- qDebug() << "Successfully disconnected from Dbus signal org.maemo.vicar.stopOutgoingCallMonitor";
- }
- else{
- qDebug() << "Failed to disconnect from Dbus signal org.maemo.vicar.stopOutgoingCallMonitor";
- qDebug() <<"DBus Error: "<< qPrintable(dbusUtility.getErrorMessage());
- }
-
-}
-
-void CallRouter::startOutgoingCallMonitor(){
-
- // Connect to DBus to monitor all outgoing calls
-
- QDBusConnection connection = dbusUtility.getConnection();
-
-
- // Declare the slot to be executed when new calls are placed
-
- bool success = connection.connect(QString(""),
- CSD_CALL_PATH,
- CSD_CALL_INTERFACE,
- QString("CreateRequested"),this,
- SLOT(processOutgoingCall(const QDBusMessage&)));
-
- if (success){
- qDebug() << "Successfully connected to Dbus signal CreateRequested in interface "<< CSD_CALL_INTERFACE;
- }
- else{
- qDebug() << "Failed to connect to Dbus signal CreateRequested in interface " << CSD_CALL_INTERFACE;
- qDebug() <<"DBus Error: "<< dbusUtility.getErrorMessage();
- }
-
-
-}
-
-void CallRouter::stopOutgoingCallMonitor(){
-
- this->stopCallStatusMonitors();
-
- //Disconnect the slots from Dbus signals
- QDBusConnection connection = dbusUtility.getConnection();
-
- // Disconnect the slot for new calls
- bool status = connection.disconnect(QString(""),
- CSD_CALL_PATH,
- CSD_CALL_INTERFACE,
- QString("CreateRequested"),this,
- SLOT(processOutgoingCall(const QDBusMessage&)));
-
- if (status){
- qDebug() << "Successfully disconnected from Dbus signal CreateRequested in interface "<< CSD_CALL_INTERFACE;
- }
- else{
- qDebug() << "Failed to disconnect from Dbus signal CreateRequested in interface "<< CSD_CALL_INTERFACE;
- qDebug() <<"DBus Error: "<< dbusUtility.getErrorMessage();
- }
-
-}
-
-void CallRouter::processOutgoingCall(const QDBusMessage& dbusMessage){
-
- //Verify Whether Call Routing is Enabled
- bool isRoutingEnabled = gconfUtility->getGconfValueBoolean("routing_enabled");
-
- if (isRoutingEnabled){
- //User is making a phone call. Get the phone number and verify if it is an international number
- QList<QVariant> listArguments = dbusMessage.arguments();
- QString strInternationalNumber = listArguments.first().toString();
-
- qDebug() << "New Call Identified. Destination number is " << strInternationalNumber;
-
- if (strInternationalNumber.startsWith("+") ||
- strInternationalNumber.startsWith("00"))
- {
- qDebug() << "International number "<< strInternationalNumber << " recognized. Starting proceedings..";
-
- //Check whether this is one of the excluded country codes
- if (!isExcludedNumber(strInternationalNumber)){
-
- //International number. Disconnect the current call (A new call will be placed)
-
- //No arguments required to cancel the current call
- QList<QVariant> argsToSend;
- bool status = dbusUtility.sendMethodCall(CSD_CALL_SERVICE,
- CSD_CALL_PATH,
- CSD_CALL_INTERFACE,
- QString("Release"),argsToSend);
-
- QString strUserMessage;
- if (status){
- strUserMessage = QString("Routing international call via ").append(APPLICATION_FRIENDLY_NAME).append("..");
- qDebug() << strUserMessage;
- strLastDialedNumber = strInternationalNumber;
- }
- else{
- strUserMessage = QString("Call could not be cancelled.");
- qDebug() << dbusUtility.getErrorMessage();
- }
-
- dbusUtility.displayNotification(strUserMessage);
-
- //Wait for a few seconds before the current call is completely disconnected
- QTimer *timer = new QTimer(this);
- timer->setSingleShot(true);
- connect(timer, SIGNAL(timeout()), this, SLOT(callViaCallingCard()));
- timer->start(3000);
- }