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() << "Sending DTMF = " << step.value();
31 argsToSend.append(step.value());
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 // Check if we are over with the sequence or we need to continue
45 if(mInStep >= mProfileInUse.mNoOfSteps)
51 step = mProfileInUse.mSteps.at(mInStep);
52 QTimer *timer = new QTimer(this);
53 timer->setSingleShot(true);
54 connect(timer, SIGNAL(timeout()), this, SLOT(continueSendDTMF()));
55 qDebug() << "Setting delay for " << step.delay() << "seconds...";
56 timer->start(step.delay()*1000);
59 void confManager::sendDTMF(const QDBusMessage &dBusMessage)
61 QList<QVariant> listArguments = dBusMessage.arguments();
62 bool audioConnect = listArguments.first().toBool();
64 if(mInStep >= mProfileInUse.mNoOfSteps)
70 Steps step = mProfileInUse.mSteps.at(mInStep);
74 qDebug() << "Call Active...";
75 //Wait for specified delay in the step
76 QTimer *timer = new QTimer(this);
77 timer->setSingleShot(true);
78 connect(timer, SIGNAL(timeout()), this, SLOT(continueSendDTMF()));
79 qDebug() << "Setting delay for " << step.delay() << "seconds...";
80 timer->start(step.delay()*1000);
84 void confManager::StartCallMonitors()
86 QDBusConnection connection = mDBusUtility.getConnection();
87 /* Declare the slot to be executed when a call is picked up by other party (Audio connection established).
88 We need this to confirm whether a call went though successfully.
90 bool status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
91 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
95 qDebug() << "Failed to connect to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
96 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
97 mDBusUtility.displayNotification(error);
98 qDebug() << "Error is: " << error;
101 qDebug() << "Successfully connected to Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
103 /* Declare the slot to be executed when the call is terminated (due to connection errors etc).
104 We need this to avoid sending DTMF code on wrong calls.
106 status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
107 QString("Terminated"),this, SLOT(StopCallMonitors()));
111 qDebug() << "Failed to connect to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
112 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
113 mDBusUtility.displayNotification(error);
114 qDebug() << "Error is: " << error;
117 qDebug() << "Successfully connected to Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
119 /* Declare the slot to be executed when a call is received
120 (before we can place the call to calling card number).
121 It is extremely rare that somebody should get a call within these few seconds.
122 In any case, we need this to avoid sending DTMF code on the received call.
124 Btw - I don't care for the incoming number here. If anyone is calling the user before we can send DTMF code,
125 then we stop sending the DTMF code even if user does not respond to the call.
128 status = connection.connect(CSD_CALL_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
129 QString("Coming"),this, SLOT(StopCallMonitors()));
133 qDebug() << "Failed to connect to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
134 QString error = "DBus Error (StartCallMonitors): " + mDBusUtility.getErrorMessage();
135 mDBusUtility.displayNotification(error);
136 qDebug() << "Error is: " << error;
138 qDebug() << "Successfully connected to Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
141 void confManager::StopCallMonitors()
146 QDBusConnection connection = mDBusUtility.getConnection();
148 // Disconnect the slot for audio connection status
149 bool status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
150 QString("AudioConnect"),this, SLOT(sendDTMF(const QDBusMessage&)));
154 qDebug() << "Failed to disconnect from Dbus signal AudioConnect in interface" << CSD_CALL_INSTANCE_INTERFACE;
155 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
156 mDBusUtility.displayNotification(error);
157 qDebug() << "Error is: " << error;
159 qDebug() << "Successfully disconnected from Dbus signal AudioConnect in interface "<< CSD_CALL_INSTANCE_INTERFACE;
161 // Disconnect the slot for monitoring terminated calls
162 status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_INSTANCE_PATH, CSD_CALL_INSTANCE_INTERFACE,
163 QString("Terminated"),this, SLOT(StopCallMonitors()));
167 qDebug() << "Failed to disconnect from Dbus signal Terminated in interface" << CSD_CALL_INSTANCE_INTERFACE;
168 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
169 mDBusUtility.displayNotification(error);
170 qDebug() << "Error is: " << error;
172 qDebug() << "Successfully disconnected from Dbus signal Terminated in interface "<< CSD_CALL_INSTANCE_INTERFACE;
174 // Disconnect the slot for monitoring incoming calls
175 status = connection.disconnect(CSD_CALL_BUS_NAME, CSD_CALL_PATH, CSD_CALL_INTERFACE,
176 QString("Coming"),this, SLOT(StopCallMonitors()));
180 qDebug() << "Failed to disconnect from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
181 QString error = "DBus Error (StopCallMonitors): " + mDBusUtility.getErrorMessage();
182 mDBusUtility.displayNotification(error);
183 qDebug() << "Error is: " << error;
185 qDebug() << "Successfully disconnected from Dbus signal Coming in interface" << CSD_CALL_INTERFACE;
188 void confManager::startConference()
193 qDebug() << "Please set the profile to use with Conference Manager first!";
196 //Assume that the first number is always a phone number...
197 Steps step = mProfileInUse.mSteps.at(mInStep);
199 QList<QVariant> sendArgs;
200 sendArgs.append(step.value());
202 bool status = mDBusUtility.sendMethodCall(CSD_SERVICE, CSD_CALL_PATH, CSD_CALL_INTERFACE,
203 QString("CreateWith"), sendArgs);
206 QString error = "Error while dialing: " + mDBusUtility.getErrorMessage();
208 mDBusUtility.displayNotification(error);