1 #include "confmanager.h"
5 confManager::confManager(QObject *parent) :
12 void confManager::setProfile(Profile &p)
19 void confManager::continueSendDTMF()
21 qDebug() << "In ContinueSendDTF for mInStep " << mInStep;
22 // We have now waited for the required period of seconds
23 // Lets send the DTMF now
24 Steps step = mProfileInUse.mSteps.at(mInStep);
26 // Increment the steps as we want to point to the next one
29 QList<QVariant> argsToSend;
30 qDebug() << "DTMF = " << step.value();
31 argsToSend.append(step.value());
32 // argsToSend.append(0);
34 bool status = mDBusUtility.sendMethodCall(CSD_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
35 QString("SendDTMF"),argsToSend);
39 qDebug() << "Unable to send DTMF code.";
40 QString error = "DBus Error (continueSendDTMF): " + mDBusUtility.getErrorMessage();
41 mDBusUtility.displayNotification(error);
44 mDBusUtility.displayNotification(step.value());
46 // Check if we are over with the sequence or we need to continue
47 if(mInStep >= mProfileInUse.mNoOfSteps)
53 step = mProfileInUse.mSteps.at(mInStep);
54 QTimer *timer = new QTimer(this);
55 timer->setSingleShot(true);
56 connect(timer, SIGNAL(timeout()), this, SLOT(continueSendDTMF()));
57 qDebug() << "Setting delay for " << step.delay() << "seconds...";
58 timer->start(step.delay()*1000);
61 void confManager::sendDTMF(const QDBusMessage &dBusMessage)
63 QList<QVariant> listArguments = dBusMessage.arguments();
64 bool audioConnect = listArguments.first().toBool();
66 if(mInStep >= mProfileInUse.mNoOfSteps)
72 Steps step = mProfileInUse.mSteps.at(mInStep);
76 qDebug() << "Call Active...";
77 //Wait for specified delay in the step
78 QTimer *timer = new QTimer(this);
79 timer->setSingleShot(true);
80 connect(timer, SIGNAL(timeout()), this, SLOT(continueSendDTMF()));
81 qDebug() << "Setting delay for " << step.delay() << "seconds...";
82 timer->start(step.delay()*1000);
86 void confManager::StartCallMonitors()
88 QDBusConnection connection = mDBusUtility.getConnection();
89 /* Declare the slot to be executed when a call is picked up by other party (Audio connection established).
90 We need this to confirm whether a call went though successfully.
92 bool status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
93 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
97 qDebug() << "Failed to connect to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
98 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
99 mDBusUtility.displayNotification(error);
100 qDebug() << "Error is: " << error;
103 qDebug() << "Successfully connected to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
105 /* Declare the slot to be executed when the call is terminated (due to connection errors etc).
106 We need this to avoid sending DTMF code on wrong calls.
108 status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
109 QString("Terminated"),this, SLOT(StopCallMonitors()));
113 qDebug() << "Failed to connect to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
114 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
115 mDBusUtility.displayNotification(error);
116 qDebug() << "Error is: " << error;
119 qDebug() << "Successfully connected to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
121 /* Declare the slot to be executed when a call is received
122 (before we can place the call to calling card number).
123 It is extremely rare that somebody should get a call within these few seconds.
124 In any case, we need this to avoid sending DTMF code on the received call.
126 Btw - I don't care for the incoming number here. If anyone is calling the user before we can send DTMF code,
127 then we stop sending the DTMF code even if user does not respond to the call.
130 status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
131 QString("Coming"),this, SLOT(StopCallMonitors()));
135 qDebug() << "Failed to connect to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
136 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
137 mDBusUtility.displayNotification(error);
138 qDebug() << "Error is: " << error;
140 qDebug() << "Successfully connected to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
143 void confManager::StopCallMonitors()
148 QDBusConnection connection = mDBusUtility.getConnection();
150 // Disconnect the slot for audio connection status
151 bool status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
152 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
156 qDebug() << "Failed to disconnect from Dbus signal AudioConnect in interface" << CSD_CALL_INSTANCE_INTERFACE;
157 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
158 mDBusUtility.displayNotification(error);
159 qDebug() << "Error is: " << error;
161 qDebug() << "Successfully disconnected from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
163 // Disconnect the slot for monitoring terminated calls
164 status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
165 QString("Terminated"),this, SLOT(StopCallMonitors()));
169 qDebug() << "Failed to disconnect from Dbus signal Terminated in interface" << CSD_CALL_INSTANCE_INTERFACE;
170 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
171 mDBusUtility.displayNotification(error);
172 qDebug() << "Error is: " << error;
174 qDebug() << "Successfully disconnected from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
176 // Disconnect the slot for monitoring incoming calls
177 status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_PATH, CSD_CALL_INTERFACE,
178 QString("Coming"),this, SLOT(StopCallMonitors()));
182 qDebug() << "Failed to disconnect from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
183 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
184 mDBusUtility.displayNotification(error);
185 qDebug() << "Error is: " << error;
187 qDebug() << "Successfully disconnected from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
190 void confManager::startConference()
195 qDebug() << "Please set the profile to use with Conference Manager first!";
198 //Assume that the first number is always a phone number...
199 Steps step = mProfileInUse.mSteps.at(mInStep);
201 QList<QVariant> sendArgs;
202 sendArgs.append(step.value());
204 bool status = mDBusUtility.sendMethodCall(CSD_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
205 QString("CreateWith"), sendArgs);
208 QString error = "Error while dialing: " + mDBusUtility.getErrorMessage();
210 mDBusUtility.displayNotification(error);