Merge lp:~boiko/messaging-app/uri_handler into lp:messaging-app

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 48
Merged at revision: 46
Proposed branch: lp:~boiko/messaging-app/uri_handler
Merge into: lp:messaging-app
Diff against target: 509 lines (+26/-276)
11 files modified
CMakeLists.txt (+0/-7)
debian/messaging-app.install (+0/-1)
src/CMakeLists.txt (+3/-8)
src/MessagingApp.xml (+0/-43)
src/com.canonical.MessagingApp.service.in (+0/-3)
src/messagingappdbus.cpp (+0/-76)
src/messagingappdbus.h (+0/-53)
src/messagingapplication.cpp (+8/-70)
src/messagingapplication.h (+0/-7)
src/qml/Messages.qml (+5/-7)
src/qml/messaging-app.qml (+10/-1)
To merge this branch: bzr merge lp:~boiko/messaging-app/uri_handler
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
Tiago Salem Herrmann (community) Approve
Michael Terry Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+189428@code.launchpad.net

Commit message

Change the messaging-app to use the new URL dispatcher mechanism.

Description of the change

Change the messaging-app to use the new URL dispatcher mechanism.

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

Looks like we remove some functionality ("go to a specific message" and "start a new message"). Do we know those aren't used?

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

On IRC, boiko cleared up that we don't use those functions anymore.

This works fine in testing (both receiving and launching requests). Code seems fine too.

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

looks good.

review: Approve
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-07-15 20:33:33 +0000
3+++ CMakeLists.txt 2013-10-07 19:24:17 +0000
4@@ -31,13 +31,6 @@
5 # Instruct CMake to run moc automatically when needed.
6 set(CMAKE_AUTOMOC ON)
7
8-# Check if should build using ubuntu platform api
9-check_include_file_cxx("ubuntu/ui/ubuntu_ui_session_service.h" USE_UBUNTU_PLATFORM_API)
10-
11-if (USE_UBUNTU_PLATFORM_API)
12- add_definitions(-DUSE_UBUNTU_PLATFORM_API)
13-endif (USE_UBUNTU_PLATFORM_API)
14-
15 configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
16
17 find_package(Qt5Core)
18
19=== modified file 'debian/messaging-app.install'
20--- debian/messaging-app.install 2013-08-12 20:50:13 +0000
21+++ debian/messaging-app.install 2013-10-07 19:24:17 +0000
22@@ -1,5 +1,4 @@
23 usr/share/applications/messaging-app*.desktop
24-usr/share/dbus-1/services/*MessagingApp*.service
25 usr/share/locale/*/LC_MESSAGES/messaging-app.mo
26 usr/share/messaging-app/*.qml
27 usr/share/messaging-app/*.js
28
29=== modified file 'src/CMakeLists.txt'
30--- src/CMakeLists.txt 2013-07-15 20:33:33 +0000
31+++ src/CMakeLists.txt 2013-10-07 19:24:17 +0000
32@@ -2,14 +2,13 @@
33
34 set(messaging_app_HDRS
35 messagingapplication.h
36- messagingappdbus.h)
37+ )
38
39 set(messaging_app_SRCS
40 messagingapplication.cpp
41- messagingappdbus.cpp
42- main.cpp)
43+ main.cpp
44+ )
45
46-qt5_add_dbus_adaptor(messaging_app_SRCS MessagingApp.xml messagingappdbus.h MessagingAppDBus)
47 add_executable(${MESSAGING_APP}
48 ${messaging_app_SRCS}
49 )
50@@ -24,10 +23,6 @@
51 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
52 )
53
54-
55-configure_file(com.canonical.MessagingApp.service.in com.canonical.MessagingApp.service)
56-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/com.canonical.MessagingApp.service DESTINATION share/dbus-1/services)
57-
58 # Handle i18n in the desktop file
59 set(DESKTOP_FILE ${MESSAGING_APP}.desktop)
60 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE})
61
62=== removed file 'src/MessagingApp.xml'
63--- src/MessagingApp.xml 2013-07-15 20:33:33 +0000
64+++ src/MessagingApp.xml 1970-01-01 00:00:00 +0000
65@@ -1,43 +0,0 @@
66-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
67-<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
68- <dox:d><![CDATA[
69- @mainpage
70-
71- An interface to the messaging application.
72- ]]></dox:d>
73- <interface name="com.canonical.MessagingApp" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
74- <dox:d>
75- An interface to the messaging application.
76- </dox:d>
77- <method name="ShowMessages">
78- <dox:d><![CDATA[
79- Request to open the messages tab.
80- ]]></dox:d>
81- <arg name="number" type="s" direction="in"/>
82- </method>
83- <method name="ShowMessage">
84- <dox:d><![CDATA[
85- Request to open the messages tab and show the given message.
86- ]]></dox:d>
87- <arg name="messageId" type="s" direction="in"/>
88- </method>
89- <method name="NewMessage">
90- <dox:d><![CDATA[
91- Request to open the messages tab to send a new message.
92- ]]></dox:d>
93- </method>
94- <method name="SendMessage">
95- <dox:d><![CDATA[
96- Request to send a message to a contact.
97- ]]></dox:d>
98- <arg name="number" type="s" direction="in"/>
99- <arg name="message" type="s" direction="in"/>
100- </method>
101- <method name="SendAppMessage">
102- <dox:d><![CDATA[
103- Send a message to the running application.
104- ]]></dox:d>
105- <arg name="message" type="s" direction="in"/>
106- </method>
107- </interface>
108-</node>
109
110=== removed file 'src/com.canonical.MessagingApp.service.in'
111--- src/com.canonical.MessagingApp.service.in 2013-07-15 20:33:33 +0000
112+++ src/com.canonical.MessagingApp.service.in 1970-01-01 00:00:00 +0000
113@@ -1,3 +0,0 @@
114-[D-BUS Service]
115-Name=com.canonical.MessagingApp
116-Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/messaging-app
117
118=== removed file 'src/messagingappdbus.cpp'
119--- src/messagingappdbus.cpp 2013-07-31 03:29:25 +0000
120+++ src/messagingappdbus.cpp 1970-01-01 00:00:00 +0000
121@@ -1,76 +0,0 @@
122-/*
123- * Copyright (C) 2012-2013 Canonical, Ltd.
124- *
125- * Authors:
126- * Ugo Riboni <ugo.riboni@canonical.com>
127- *
128- * This file is part of messaging-app.
129- *
130- * messaging-app is free software; you can redistribute it and/or modify
131- * it under the terms of the GNU General Public License as published by
132- * the Free Software Foundation; version 3.
133- *
134- * messaging-app is distributed in the hope that it will be useful,
135- * but WITHOUT ANY WARRANTY; without even the implied warranty of
136- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137- * GNU General Public License for more details.
138- *
139- * You should have received a copy of the GNU General Public License
140- * along with this program. If not, see <http://www.gnu.org/licenses/>.
141- */
142-
143-#include "messagingappdbus.h"
144-#include "messagingappadaptor.h"
145-
146-// Qt
147-#include <QtDBus/QDBusConnection>
148-
149-static const char* DBUS_SERVICE = "com.canonical.MessagingApp";
150-static const char* DBUS_OBJECT_PATH = "/com/canonical/MessagingApp";
151-
152-MessagingAppDBus::MessagingAppDBus(QObject* parent) : QObject(parent)
153-{
154-}
155-
156-MessagingAppDBus::~MessagingAppDBus()
157-{
158-}
159-
160-bool
161-MessagingAppDBus::connectToBus()
162-{
163- bool ok = QDBusConnection::sessionBus().registerService(DBUS_SERVICE);
164- if (!ok) {
165- return false;
166- }
167- new MessagingAppAdaptor(this);
168- QDBusConnection::sessionBus().registerObject(DBUS_OBJECT_PATH, this);
169-
170- return true;
171-}
172-
173-void
174-MessagingAppDBus::ShowMessages(const QString &number)
175-{
176- Q_EMIT request(QString("messages://%1").arg(number));
177-}
178-
179-void MessagingAppDBus::ShowMessage(const QString &messageId)
180-{
181- Q_EMIT request(QString("messageId://%1").arg(messageId));
182-}
183-
184-void MessagingAppDBus::NewMessage()
185-{
186- Q_EMIT request(QString("messages://"));
187-}
188-
189-void MessagingAppDBus::SendMessage(const QString &number, const QString &message)
190-{
191- Q_EMIT messageSendRequested(number, message);
192-}
193-
194-void MessagingAppDBus::SendAppMessage(const QString &message)
195-{
196- Q_EMIT request(message);
197-}
198
199=== removed file 'src/messagingappdbus.h'
200--- src/messagingappdbus.h 2013-07-15 20:33:33 +0000
201+++ src/messagingappdbus.h 1970-01-01 00:00:00 +0000
202@@ -1,53 +0,0 @@
203-/*
204- * Copyright (C) 2012-2013 Canonical, Ltd.
205- *
206- * Authors:
207- * Ugo Riboni <ugo.riboni@canonical.com>
208- *
209- * This file is part of messaging-app.
210- *
211- * messaging-app is free software; you can redistribute it and/or modify
212- * it under the terms of the GNU General Public License as published by
213- * the Free Software Foundation; version 3.
214- *
215- * messaging-app is distributed in the hope that it will be useful,
216- * but WITHOUT ANY WARRANTY; without even the implied warranty of
217- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
218- * GNU General Public License for more details.
219- *
220- * You should have received a copy of the GNU General Public License
221- * along with this program. If not, see <http://www.gnu.org/licenses/>.
222- */
223-
224-#ifndef MESSAGINGAPPDBUS_H
225-#define MESSAGINGAPPDBUS_H
226-
227-#include <QtCore/QObject>
228-#include <QtDBus/QDBusContext>
229-
230-/**
231- * DBus interface for the messaging app
232- */
233-class MessagingAppDBus : public QObject, protected QDBusContext
234-{
235- Q_OBJECT
236-
237-public:
238- MessagingAppDBus(QObject* parent=0);
239- ~MessagingAppDBus();
240-
241- bool connectToBus();
242-
243-public Q_SLOTS:
244- Q_NOREPLY void ShowMessages(const QString &number);
245- Q_NOREPLY void ShowMessage(const QString &messageId);
246- Q_NOREPLY void NewMessage();
247- Q_NOREPLY void SendMessage(const QString &number, const QString &message);
248- Q_NOREPLY void SendAppMessage(const QString &message);
249-
250-Q_SIGNALS:
251- void request(const QString &message);
252- void messageSendRequested(const QString &phoneNumber, const QString &message);
253-};
254-
255-#endif // MESSAGINGAPPDBUS_H
256
257=== modified file 'src/messagingapplication.cpp'
258--- src/messagingapplication.cpp 2013-07-31 03:49:02 +0000
259+++ src/messagingapplication.cpp 2013-10-07 19:24:17 +0000
260@@ -31,15 +31,13 @@
261 #include <QDBusConnectionInterface>
262 #include <QLibrary>
263 #include "config.h"
264-#include "messagingappdbus.h"
265 #include <QQmlEngine>
266
267 static void printUsage(const QStringList& arguments)
268 {
269 qDebug() << "usage:"
270 << arguments.at(0).toUtf8().constData()
271- << "[messages://PHONE_NUMBER]"
272- << "[messageId://MESSAGE_ID]"
273+ << "[message:///PHONE_NUMBER]"
274 << "[--fullscreen]"
275 << "[--help]"
276 << "[-testability]";
277@@ -49,7 +47,6 @@
278 : QGuiApplication(argc, argv), m_view(0), m_applicationIsReady(false)
279 {
280 setApplicationName("MessagingApp");
281- m_dbus = new MessagingAppDBus(this);
282 }
283
284 bool MessagingApplication::setup()
285@@ -58,8 +55,7 @@
286 bool fullScreen = false;
287
288 if (validSchemes.isEmpty()) {
289- validSchemes << "messages";
290- validSchemes << "messageId";
291+ validSchemes << "message";
292 }
293
294 QStringList arguments = this->arguments();
295@@ -114,27 +110,12 @@
296 }
297 }
298
299- // check if the app is already running, if it is, send the message to the running instance
300- QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered("com.canonical.MessagingApp");
301- if (reply.isValid() && reply.value()) {
302- QDBusInterface appInterface("com.canonical.MessagingApp",
303- "/com/canonical/MessagingApp",
304- "com.canonical.MessagingApp");
305- appInterface.call("SendAppMessage", m_arg);
306- return false;
307- }
308-
309- if (!m_dbus->connectToBus()) {
310- qWarning() << "Failed to expose com.canonical.MessagingApp on DBUS.";
311- }
312-
313 m_view = new QQuickView();
314 QObject::connect(m_view, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(onViewStatusChanged(QQuickView::Status)));
315 QObject::connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));
316 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
317 m_view->setTitle("Messaging");
318 m_view->rootContext()->setContextProperty("application", this);
319- m_view->rootContext()->setContextProperty("dbus", m_dbus);
320 m_view->engine()->setBaseUrl(QUrl::fromLocalFile(messagingAppDirectory()));
321
322 QString pluginPath = ubuntuPhonePluginPath();
323@@ -149,13 +130,6 @@
324 m_view->show();
325 }
326
327- connect(m_dbus,
328- SIGNAL(request(QString)),
329- SLOT(onMessageReceived(QString)));
330- connect(m_dbus,
331- SIGNAL(messageSendRequested(QString,QString)),
332- SLOT(onMessageSendRequested(QString,QString)));
333-
334 return true;
335 }
336
337@@ -186,60 +160,24 @@
338 m_arg.clear();
339 }
340
341-void MessagingApplication::onMessageSendRequested(const QString &phoneNumber, const QString &message)
342-{
343- QQuickItem *mainView = m_view->rootObject();
344- if (!mainView) {
345- return;
346- }
347- const QMetaObject *mo = mainView->metaObject();
348- int index = mo->indexOfMethod("sendMessage(QVariant,QVariant)");
349- if (index != -1) {
350- QMetaMethod method = mo->method(index);
351- method.invoke(mainView,
352- Q_ARG(QVariant, QVariant(phoneNumber)),
353- Q_ARG(QVariant, QVariant(message)));
354- }
355-}
356-
357 void MessagingApplication::parseArgument(const QString &arg)
358 {
359 if (arg.isEmpty()) {
360 return;
361 }
362
363- QStringList args = arg.split("://");
364- if (args.size() != 2) {
365- return;
366- }
367-
368- QString scheme = args[0];
369- QString value = args[1];
370+ QUrl url(arg);
371+ QString scheme = url.scheme();
372+ // Remove the first "/"
373+ QString value = url.path().right(url.path().length() -1);
374
375 QQuickItem *mainView = m_view->rootObject();
376 if (!mainView) {
377 return;
378 }
379
380- if (scheme == "messages") {
381- if (value.isEmpty()) {
382- QMetaObject::invokeMethod(mainView, "startNewMessage");
383- } else {
384- QMetaObject::invokeMethod(mainView, "startChat", Q_ARG(QVariant, value));
385- }
386- } else if (scheme == "messageId") {
387- QMetaObject::invokeMethod(mainView, "showMessage", Q_ARG(QVariant, value));
388- }
389-}
390-
391-void MessagingApplication::onMessageReceived(const QString &message)
392-{
393- if (m_applicationIsReady) {
394- parseArgument(message);
395- m_arg.clear();
396- activateWindow();
397- } else {
398- m_arg = message;
399+ if (scheme == "message") {
400+ QMetaObject::invokeMethod(mainView, "startChat", Q_ARG(QVariant, value));
401 }
402 }
403
404
405=== modified file 'src/messagingapplication.h'
406--- src/messagingapplication.h 2013-07-15 20:33:33 +0000
407+++ src/messagingapplication.h 2013-10-07 19:24:17 +0000
408@@ -23,8 +23,6 @@
409 #include <QQuickView>
410 #include <QGuiApplication>
411
412-class MessagingAppDBus;
413-
414 class MessagingApplication : public QGuiApplication
415 {
416 Q_OBJECT
417@@ -37,19 +35,14 @@
418
419 public Q_SLOTS:
420 void activateWindow();
421-
422-private:
423 void parseArgument(const QString &arg);
424
425 private Q_SLOTS:
426- void onMessageReceived(const QString &message);
427 void onViewStatusChanged(QQuickView::Status status);
428 void onApplicationReady();
429- void onMessageSendRequested(const QString &phoneNumber, const QString &message);
430
431 private:
432 QQuickView *m_view;
433- MessagingAppDBus *m_dbus;
434 QString m_arg;
435 bool m_applicationIsReady;
436 };
437
438=== modified file 'src/qml/Messages.qml'
439--- src/qml/Messages.qml 2013-09-27 17:22:42 +0000
440+++ src/qml/Messages.qml 2013-10-07 19:24:17 +0000
441@@ -69,8 +69,7 @@
442 text: i18n.tr("Create new contact")
443 color: UbuntuColors.warmGrey
444 onClicked: {
445- applicationUtils.switchToAddressbookApp("addressbook://create" +
446- "?phone=" + encodeURIComponent(contactWatcher.phoneNumber))
447+ Qt.openUrlExternally("addressbook:///create?phone=" + encodeURIComponent(contactWatcher.phoneNumber));
448 PopupUtils.close(dialogue)
449 }
450 }
451@@ -104,9 +103,8 @@
452 ContactListView {
453 anchors.fill: parent
454 onContactClicked: {
455- applicationUtils.switchToAddressbookApp("addressbook://addphone" +
456- "?id=" + encodeURIComponent(contact.contactId) +
457- "&phone=" + encodeURIComponent(contactWatcher.phoneNumber))
458+ Qt.openUrlExternally("addressbook:///addphone?id=" + encodeURIComponent(contact.contactId) +
459+ "&phone=" + encodeURIComponent(contactWatcher.phoneNumber))
460 PopupUtils.close(sheet)
461 }
462 }
463@@ -179,7 +177,7 @@
464 iconSource: Qt.resolvedUrl("assets/contact.svg")
465 text: i18n.tr("Contact")
466 onTriggered: {
467- applicationUtils.switchToAddressbookApp("addressbook://contact?id=" + encodeURIComponent(contactWatcher.contactId))
468+ Qt.openUrlExternally("addressbook:///contact?id=" + encodeURIComponent(contactWatcher.contactId))
469 messagesToolbar.opened = false
470 }
471 }
472@@ -191,7 +189,7 @@
473 iconSource: Qt.resolvedUrl("assets/call-start.svg")
474 text: i18n.tr("Call")
475 onTriggered: {
476- applicationUtils.switchToDialerApp("call://" + contactWatcher.phoneNumber)
477+ Qt.openUrlExternally("tel:///" + encodeURIComponent(contactWatcher.phoneNumber))
478 messagesToolbar.opened = false
479 }
480 }
481
482=== modified file 'src/qml/messaging-app.qml'
483--- src/qml/messaging-app.qml 2013-09-13 16:53:30 +0000
484+++ src/qml/messaging-app.qml 2013-10-07 19:24:17 +0000
485@@ -56,6 +56,15 @@
486 mainStack.push(Qt.resolvedUrl("Messages.qml"), properties)
487 }
488
489+ Connections {
490+ target: UriHandler
491+ onOpened: {
492+ for (var i = 0; i < uris.length; ++i) {
493+ application.parseArgument(uris[i])
494+ }
495+ }
496+ }
497+
498 Component {
499 id: newcontactPopover
500
501@@ -72,7 +81,7 @@
502 ListItem.Standard {
503 text: i18n.tr("Create new contact")
504 onClicked: {
505- applicationUtils.switchToAddressbookApp("create://" + newPhoneNumber)
506+ Qt.openUrlExternally("addressbook:///create?phone=" + encodeURIComponent(newPhoneNumber))
507 popover.hide()
508 }
509 }

Subscribers

People subscribed via source and target branches