1 #include "confmanager.h"
5 confManager::confManager(QObject *parent) :
12 void confManager::setProfile(Profile &p)
19 void confManager::continueSendDTMF()
21 // We have now waited for the required period of seconds
22 // Lets send the DTMF now
23 Steps step = mProfileInUse.mSteps.at(mInStep);
25 // Increment the steps as we want to point to the next one
28 QList<QVariant> argsToSend;
29 argsToSend.append(step.value());
31 bool status = mDBusUtility.sendMethodCall(CSD_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
32 QString("SendDTMF"),argsToSend);
36 qDebug() << "Unable to send DTMF code.";
37 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
38 mDBusUtility.displayNotification(error);
41 // Check if we are over with the sequence or we need to continue
42 if(mInStep > mProfileInUse.mNoOfSteps)
48 step = mProfileInUse.mSteps.at(mInStep);
49 QTimer *timer = new QTimer(this);
50 timer->setSingleShot(true);
51 connect(timer, SIGNAL(timeout()), this, SLOT(sendDTMF(const QDBusMessage &)));
52 timer->start(step.delay());
55 void confManager::sendDTMF(const QDBusMessage &dBusMessage)
57 QList<QVariant> listArguments = dBusMessage.arguments();
58 bool audioConnected = listArguments.first().toBool();
60 if(mInStep > mProfileInUse.mNoOfSteps)
66 Steps step = mProfileInUse.mSteps.at(mInStep);
70 qDebug() << "Audio Connected...";
71 //Wait for specified delay in the step
72 QTimer *timer = new QTimer(this);
73 timer->setSingleShot(true);
74 connect(timer, SIGNAL(timeout()), this, SLOT(continueSendDTMF()));
75 timer->start(step.delay());
79 void confManager::StartCallMonitors()
81 QDBusConnection connection = mDBusUtility.getConnection();
82 /* Declare the slot to be executed when a call is picked up by other party (Audio connection established).
83 We need this to confirm whether a call went though successfully.
85 bool status = connection.connect(QString(""), CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
86 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
90 qDebug() << "Failed to connect to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
91 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
92 mDBusUtility.displayNotification(error);
95 qDebug() << "Successfully connected to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
97 /* Declare the slot to be executed when the call is terminated (due to connection errors etc).
98 We need this to avoid sending DTMF code on wrong calls.
100 status = connection.connect(QString(""), CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
101 QString("Terminated"),this, SLOT(StopCallMonitors()));
105 qDebug() << "Failed to connect to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
106 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
107 mDBusUtility.displayNotification(error);
110 qDebug() << "Successfully connected to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
112 /* Declare the slot to be executed when a call is received
113 (before we can place the call to calling card number).
114 It is extremely rare that somebody should get a call within these few seconds.
115 In any case, we need this to avoid sending DTMF code on the received call.
117 Btw - I don't care for the incoming number here. If anyone is calling the user before we can send DTMF code,
118 then we stop sending the DTMF code even if user does not respond to the call.
121 status = connection.connect(QString(""), CSD_CALL_PATH, CSD_CALL_INTERFACE,
122 QString("Coming"),this, SLOT(StopCallMonitors()));
126 qDebug() << "Failed to connect to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
127 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
128 mDBusUtility.displayNotification(error);
130 qDebug() << "Successfully connected to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
133 void confManager::StopCallMonitors()
138 QDBusConnection connection = mDBusUtility.getConnection();
140 // Disconnect the slot for audio connection status
141 bool status = connection.disconnect(QString(""), CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
142 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
146 qDebug() << "Failed to disconnect from Dbus signal AudioConnect in interface" << CSD_CALL_INSTANCE_INTERFACE;
147 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
148 mDBusUtility.displayNotification(error);
150 qDebug() << "Successfully disconnected from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
152 // Disconnect the slot for monitoring terminated calls
153 status = connection.disconnect(QString(""), CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
154 QString("Terminated"),this, SLOT(StopCallMonitors()));
158 qDebug() << "Failed to disconnect from Dbus signal Terminated in interface" << CSD_CALL_INSTANCE_INTERFACE;
159 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
160 mDBusUtility.displayNotification(error);
162 qDebug() << "Successfully disconnected from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
164 // Disconnect the slot for monitoring incoming calls
165 status = connection.disconnect(QString(""), CSD_CALL_PATH, CSD_CALL_INTERFACE,
166 QString("Coming"),this, SLOT(StopCallMonitors()));
170 qDebug() << "Failed to disconnect from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
171 QString error = "DBus Error: " + mDBusUtility.getErrorMessage();
172 mDBusUtility.displayNotification(error);
174 qDebug() << "Successfully disconnected from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
177 void confManager::startConference()
181 qDebug() << "Please set the profile to use with Conference Manager first!";
184 //Assume that the first number is always a phone number...
185 Steps step = mProfileInUse.mSteps.at(mInStep);
187 QList<QVariant> sendArgs;
188 sendArgs.append(step.value());
190 bool status = mDBusUtility.sendMethodCall(CSD_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
191 QString("CreateWith"), sendArgs);
194 QString error = "Error while dialing: " + mDBusUtility.getErrorMessage();
196 mDBusUtility.displayNotification(error);