Merge lp:~boiko/telephony-service/uri_handler into lp:telephony-service

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 757
Merged at revision: 755
Proposed branch: lp:~boiko/telephony-service/uri_handler
Merge into: lp:telephony-service
Diff against target: 363 lines (+25/-188)
8 files modified
Ubuntu/Telephony/components.cpp (+0/-2)
Ubuntu/Telephony/tests/tst_contextProperties.qml (+0/-4)
approver/approver.cpp (+1/-1)
approver/approver.h (+0/-2)
indicator/messagingmenu.cpp (+4/-4)
indicator/textchannelobserver.cpp (+2/-2)
libtelephonyservice/applicationutils.cpp (+16/-145)
libtelephonyservice/applicationutils.h (+2/-28)
To merge this branch: bzr merge lp:~boiko/telephony-service/uri_handler
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
Michael Terry Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+189431@code.launchpad.net

Commit message

Use the URL dispatcher to invoke the dialer and messaging apps.

Description of the change

Use the URL dispatcher to invoke the dialer and messaging apps.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

This worked fine for me, BTW.

review: Approve
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Ubuntu/Telephony/components.cpp'
2--- Ubuntu/Telephony/components.cpp 2013-08-23 20:39:04 +0000
3+++ Ubuntu/Telephony/components.cpp 2013-10-07 19:21:05 +0000
4@@ -21,7 +21,6 @@
5 */
6
7 #include "components.h"
8-#include "applicationutils.h"
9 #include "telepathyhelper.h"
10 #include "callmanager.h"
11 #include "channelobserver.h"
12@@ -50,7 +49,6 @@
13 SIGNAL(accountReady()),
14 SLOT(onAccountReady()));
15
16- mRootContext->setContextProperty("applicationUtils", ApplicationUtils::instance());
17 mRootContext->setContextProperty("telepathyHelper", TelepathyHelper::instance());
18 mRootContext->setContextProperty("chatManager", ChatManager::instance());
19 mRootContext->setContextProperty("callManager", CallManager::instance());
20
21=== modified file 'Ubuntu/Telephony/tests/tst_contextProperties.qml'
22--- Ubuntu/Telephony/tests/tst_contextProperties.qml 2013-08-14 03:01:42 +0000
23+++ Ubuntu/Telephony/tests/tst_contextProperties.qml 2013-10-07 19:21:05 +0000
24@@ -24,10 +24,6 @@
25 id: contextPropertiesTest
26 name: "ContextPropertiesTest"
27
28- function test_applicationUtils() {
29- verify(applicationUtils != undefined, "applicationUtils is not defined");
30- }
31-
32 function test_telepathyHelper() {
33 verify(telepathyHelper != undefined, "telepathyHelper is not defined");
34 }
35
36=== modified file 'approver/approver.cpp'
37--- approver/approver.cpp 2013-09-30 23:49:04 +0000
38+++ approver/approver.cpp 2013-10-07 19:21:05 +0000
39@@ -307,7 +307,7 @@
40 dispatchOp->handleWith(TELEPHONY_SERVICE_HANDLER);
41
42 // and then launch the dialer-app
43- ApplicationUtils::instance()->switchToDialerApp();
44+ ApplicationUtils::openUrl(QUrl("application:///dialer-app.desktop"));
45
46 mDispatchOps.removeAll(dispatchOp);
47 }
48
49=== modified file 'approver/approver.h'
50--- approver/approver.h 2013-08-22 17:51:46 +0000
51+++ approver/approver.h 2013-10-07 19:21:05 +0000
52@@ -31,8 +31,6 @@
53 #include <TelepathyQt/PendingReady>
54 #include <TelepathyQt/ChannelDispatchOperation>
55
56-class ApplicationUtils;
57-
58 class Approver : public QObject, public Tp::AbstractClientApprover
59 {
60 Q_OBJECT
61
62=== modified file 'indicator/messagingmenu.cpp'
63--- indicator/messagingmenu.cpp 2013-08-22 21:51:42 +0000
64+++ indicator/messagingmenu.cpp 2013-10-07 19:21:05 +0000
65@@ -19,8 +19,8 @@
66 * along with this program. If not, see <http://www.gnu.org/licenses/>.
67 */
68
69+#include "applicationutils.h"
70 #include "config.h"
71-#include "applicationutils.h"
72 #include "contactutils.h"
73 #include "phoneutils.h"
74 #include "messagingmenu.h"
75@@ -319,14 +319,14 @@
76 void MessagingMenu::showMessage(const QString &messageId)
77 {
78 QString phoneNumber = mMessages[messageId];
79- ApplicationUtils::instance()->switchToMessagingApp(QString("messages://%1").arg(phoneNumber));
80+ ApplicationUtils::openUrl(QString("message:///%1").arg(QString(QUrl::toPercentEncoding(phoneNumber))));
81 }
82
83 void MessagingMenu::callBack(const QString &messageId)
84 {
85 QString phoneNumber = callFromMessageId(messageId).number;
86 qDebug() << "TelephonyService/MessagingMenu: Calling back" << phoneNumber;
87- ApplicationUtils::instance()->switchToDialerApp(QString("call://%1").arg(phoneNumber));
88+ ApplicationUtils::openUrl(QString("tel:///%1").arg(QString(QUrl::toPercentEncoding(phoneNumber))));
89 }
90
91 void MessagingMenu::replyWithMessage(const QString &messageId, const QString &reply)
92@@ -339,7 +339,7 @@
93 void MessagingMenu::callVoicemail(const QString &messageId)
94 {
95 qDebug() << "TelephonyService/MessagingMenu: Calling voicemail for messageId" << messageId;
96- ApplicationUtils::instance()->switchToDialerApp("voicemail://");
97+ ApplicationUtils::openUrl(QUrl("tel:///voicemail"));
98 }
99
100 Call MessagingMenu::callFromMessageId(const QString &messageId)
101
102=== modified file 'indicator/textchannelobserver.cpp'
103--- indicator/textchannelobserver.cpp 2013-10-02 21:03:25 +0000
104+++ indicator/textchannelobserver.cpp 2013-10-07 19:21:05 +0000
105@@ -20,8 +20,8 @@
106 */
107
108 #include <libnotify/notify.h>
109+#include "applicationutils.h"
110 #include "textchannelobserver.h"
111-#include "applicationutils.h"
112 #include "messagingmenu.h"
113 #include "metrics.h"
114 #include "chatmanager.h"
115@@ -57,7 +57,7 @@
116 NotificationData *notificationData = (NotificationData*) data;
117 if (notificationData != NULL) {
118 // launch the messaging-app to show the message
119- ApplicationUtils::instance()->switchToMessagingApp(QString("messages://%1").arg(notificationData->phoneNumber));
120+ ApplicationUtils::openUrl(QString("message:///%1").arg(QString(QUrl::toPercentEncoding(notificationData->phoneNumber))));
121 }
122 g_object_unref(notification);
123 }
124
125=== modified file 'libtelephonyservice/applicationutils.cpp'
126--- libtelephonyservice/applicationutils.cpp 2013-08-02 18:46:48 +0000
127+++ libtelephonyservice/applicationutils.cpp 2013-10-07 19:21:05 +0000
128@@ -30,34 +30,13 @@
129 #include <TelepathyQt/Constants>
130
131 #ifdef USE_UBUNTU_PLATFORM_API
132-#include <ubuntu/ui/ubuntu_ui_session_service.h>
133+#include <ubuntu/application/url_dispatcher/service.h>
134+#include <ubuntu/application/url_dispatcher/session.h>
135 #endif
136
137-#define ADDRESSBOOK_APP_SERVICE "com.canonical.AddressBookApp"
138-#define DIALER_APP_SERVICE "com.canonical.DialerApp"
139-#define MESSAGING_APP_SERVICE "com.canonical.MessagingApp"
140-
141 ApplicationUtils::ApplicationUtils(QObject *parent) :
142 QObject(parent)
143 {
144- // Setup a DBus watcher to check if the telephony-service is running
145- mApplicationWatcher.setConnection(QDBusConnection::sessionBus());
146- mApplicationWatcher.setWatchMode(QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration);
147- mApplicationWatcher.addWatchedService(ADDRESSBOOK_APP_SERVICE);
148- mApplicationWatcher.addWatchedService(DIALER_APP_SERVICE);
149- mApplicationWatcher.addWatchedService(MESSAGING_APP_SERVICE);
150-
151- connect(&mApplicationWatcher,
152- SIGNAL(serviceRegistered(const QString&)),
153- SLOT(onServiceRegistered(const QString&)));
154- connect(&mApplicationWatcher,
155- SIGNAL(serviceUnregistered(const QString&)),
156- SLOT(onServiceUnregistered(const QString&)));
157-
158-
159- mAddressbookAppRunning = checkApplicationRunning(ADDRESSBOOK_APP_SERVICE);
160- mDialerAppRunning = checkApplicationRunning(DIALER_APP_SERVICE);
161- mMessagingAppRunning = checkApplicationRunning(MESSAGING_APP_SERVICE);
162 }
163
164 ApplicationUtils *ApplicationUtils::instance()
165@@ -66,128 +45,6 @@
166 return self;
167 }
168
169-void ApplicationUtils::onServiceRegistered(const QString &serviceName)
170-{
171- if (serviceName == ADDRESSBOOK_APP_SERVICE) {
172- mAddressbookAppRunning = true;
173- Q_EMIT addressbookAppRunningChanged(true);
174- } else if (serviceName == DIALER_APP_SERVICE) {
175- mDialerAppRunning = true;
176- Q_EMIT dialerAppRunningChanged(true);
177- } else if (serviceName == MESSAGING_APP_SERVICE) {
178- mMessagingAppRunning = true;
179- Q_EMIT messagingAppRunningChanged(true);
180- }
181-}
182-
183-void ApplicationUtils::onServiceUnregistered(const QString &serviceName)
184-{
185- if (serviceName == ADDRESSBOOK_APP_SERVICE) {
186- mAddressbookAppRunning = false;
187- Q_EMIT addressbookAppRunningChanged(false);
188- } else if (serviceName == DIALER_APP_SERVICE) {
189- mDialerAppRunning = false;
190- Q_EMIT dialerAppRunningChanged(false);
191- } else if (serviceName == MESSAGING_APP_SERVICE) {
192- mMessagingAppRunning = false;
193- Q_EMIT messagingAppRunningChanged(false);
194- }
195-}
196-
197-void ApplicationUtils::switchToAddressbookApp(const QString &argument)
198-{
199- qDebug() << "Starting address-book-app...";
200-#ifdef USE_UBUNTU_PLATFORM_API
201- ubuntu_ui_session_trigger_switch_to_well_known_application(ADDRESSBOOK_APP);
202-#else
203- if (!mAddressbookAppRunning) {
204- QProcess::startDetached("address-book-app");
205- }
206-#endif
207-
208- // block until the app is registered
209- while (!mAddressbookAppRunning) {
210- QCoreApplication::processEvents();
211- }
212-
213- if (!argument.isEmpty()) {
214- QDBusInterface addressbookApp("com.canonical.AddressBookApp",
215- "/com/canonical/AddressBookApp",
216- "com.canonical.AddressBookApp");
217- addressbookApp.call("SendAppMessage", argument);
218- }
219-
220- qDebug() << "... succeeded!";
221-}
222-
223-void ApplicationUtils::switchToDialerApp(const QString &argument)
224-{
225- qDebug() << "Starting dialer-app...";
226-#ifdef USE_UBUNTU_PLATFORM_API
227- ubuntu_ui_session_trigger_switch_to_well_known_application(DIALER_APP);
228-#else
229- if (!mDialerAppRunning) {
230- QProcess::startDetached("dialer-app");
231- }
232-#endif
233-
234- // block until the app is registered
235- while (!mDialerAppRunning) {
236- QCoreApplication::processEvents();
237- }
238-
239- if (!argument.isEmpty()) {
240- QDBusInterface dialerApp("com.canonical.DialerApp",
241- "/com/canonical/DialerApp",
242- "com.canonical.DialerApp");
243- dialerApp.call("SendAppMessage", argument);
244- }
245-
246- qDebug() << "... succeeded!";
247-}
248-
249-void ApplicationUtils::switchToMessagingApp(const QString &argument)
250-{
251- qDebug() << "Starting messaging-app...";
252-#ifdef USE_UBUNTU_PLATFORM_API
253- ubuntu_ui_session_trigger_switch_to_well_known_application(MESSAGING_APP);
254-#else
255- if (!mMessagingAppRunning) {
256- QProcess::startDetached("messaging-app");
257- }
258-#endif
259-
260- // block until the app is registered
261- while (!mMessagingAppRunning) {
262- QCoreApplication::processEvents();
263- }
264-
265- if (!argument.isEmpty()) {
266- QDBusInterface messagingApp("com.canonical.MessagingApp",
267- "/com/canonical/MessagingApp",
268- "com.canonical.MessagingApp");
269- messagingApp.call("SendAppMessage", argument);
270- }
271-
272- qDebug() << "... succeeded!";
273-}
274-
275-bool ApplicationUtils::addressbookAppRunning()
276-{
277- return mAddressbookAppRunning;
278-}
279-
280-bool ApplicationUtils::dialerAppRunning()
281-{
282- return mDialerAppRunning;
283-}
284-
285-bool ApplicationUtils::messagingAppRunning()
286-{
287- return mMessagingAppRunning;
288-}
289-
290-
291 bool ApplicationUtils::checkApplicationRunning(const QString &serviceName)
292 {
293 bool result = false;
294@@ -198,3 +55,17 @@
295
296 return result;
297 }
298+
299+bool ApplicationUtils::openUrl(const QUrl &url)
300+{
301+#ifdef USE_UBUNTU_PLATFORM_API
302+ UAUrlDispatcherSession* session = ua_url_dispatcher_session();
303+ if (!session)
304+ return false;
305+
306+ ua_url_dispatcher_session_open(session, url.toEncoded().constData(), NULL, NULL);
307+
308+ free(session);
309+#endif
310+ return true;
311+}
312
313=== modified file 'libtelephonyservice/applicationutils.h'
314--- libtelephonyservice/applicationutils.h 2013-08-21 20:50:50 +0000
315+++ libtelephonyservice/applicationutils.h 2013-10-07 19:21:05 +0000
316@@ -24,45 +24,19 @@
317
318 #include <QObject>
319 #include <QDBusServiceWatcher>
320+#include <QUrl>
321
322 class ApplicationUtils : public QObject
323 {
324 Q_OBJECT
325- Q_ENUMS(Application)
326- Q_PROPERTY(bool addressbookAppRunning READ addressbookAppRunning NOTIFY addressbookAppRunningChanged)
327- Q_PROPERTY(bool dialerAppRunning READ dialerAppRunning NOTIFY dialerAppRunningChanged)
328- Q_PROPERTY(bool messagingAppRunning READ messagingAppRunning NOTIFY messagingAppRunningChanged)
329
330 public:
331 static ApplicationUtils *instance();
332-
333- Q_INVOKABLE void switchToAddressbookApp(const QString &argument = QString::null);
334- Q_INVOKABLE void switchToDialerApp(const QString &argument = QString::null);
335- Q_INVOKABLE void switchToMessagingApp(const QString &argument = QString::null);
336-
337- bool addressbookAppRunning();
338- bool dialerAppRunning();
339- bool messagingAppRunning();
340 static bool checkApplicationRunning(const QString &serviceName);
341-
342-Q_SIGNALS:
343- void addressbookAppRunningChanged(bool running);
344- void dialerAppRunningChanged(bool running);
345- void messagingAppRunningChanged(bool running);
346-
347-
348-protected Q_SLOTS:
349- void onServiceRegistered(const QString &serviceName);
350- void onServiceUnregistered(const QString &serviceName);
351+ static bool openUrl(const QUrl &url);
352
353 private:
354 explicit ApplicationUtils(QObject *parent = 0);
355-
356- QDBusServiceWatcher mApplicationWatcher;
357- bool mAddressbookAppRunning;
358- bool mDialerAppRunning;
359- bool mMessagingAppRunning;
360-
361 };
362
363 #endif // APPLICATIONUTILS_H

Subscribers

People subscribed via source and target branches