on xenial help sign in
use url-dispatcher
ce76a49Nick Dedekind
debian/control+1
@@ -19,6 +19,7 @@ Build-Depends: cmake,
19 libqt5xmlpatterns5-dev,
19 libqt5xmlpatterns5-dev,
20 libunity-api-dev (>= 7.82),
20 libunity-api-dev (>= 7.82),
21 libunity-mir-dev,
21 libunity-mir-dev,
22+ liburl-dispatcher1-dev,
22 libusermetricsoutput1-dev,
23 libusermetricsoutput1-dev,
23 libxcb1-dev,
24 libxcb1-dev,
24 pkg-config,
25 pkg-config,
plugins/Utils/CMakeLists.txt+8−2
@@ -2,20 +2,23 @@
2include(FindPkgConfig)
2include(FindPkgConfig)
3
3
4pkg_search_module(GIO REQUIRED gio-2.0)
4pkg_search_module(GIO REQUIRED gio-2.0)
5+pkg_search_module(URLDISPATCHER REQUIRED url-dispatcher-1)
5
6
6include_directories(
7include_directories(
7 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_CURRENT_BINARY_DIR}
9 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
10 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
10 ${GIO_INCLUDE_DIRS}
11 ${GIO_INCLUDE_DIRS}
12+ ${URLDISPATCHER_INCLUDE_DIRS}
11)
13)
12
14
13set(QMLPLUGIN_SRC
15set(QMLPLUGIN_SRC
16+ easingcurve.cpp
14 qlimitproxymodelqml.cpp
17 qlimitproxymodelqml.cpp
15 qsortfilterproxymodelqml.cpp
18 qsortfilterproxymodelqml.cpp
16 timeformatter.cpp
19 timeformatter.cpp
17 unitymenumodelpaths.cpp
20 unitymenumodelpaths.cpp
18− easingcurve.cpp
21+ urldispatcher.cpp
19 plugin.cpp
22 plugin.cpp
20 )
23 )
21
24
@@ -23,7 +26,10 @@ add_library(Utils-qml SHARED
23 ${QMLPLUGIN_SRC}
26 ${QMLPLUGIN_SRC}
24 )
27 )
25
28
26−target_link_libraries(Utils-qml ${GIO_LDFLAGS})
29+target_link_libraries(Utils-qml
30+ ${GIO_LDFLAGS}
31+ ${URLDISPATCHER_LDFLAGS}
32+)
27
33
28# Because this is an internal support library, we want
34# Because this is an internal support library, we want
29# to expose all symbols in it. Consider changing this
35# to expose all symbols in it. Consider changing this
plugins/Utils/plugin.cpp+10−1
@@ -26,11 +26,18 @@
26#include "plugin.h"
26#include "plugin.h"
27
27
28// local
28// local
29+#include "easingcurve.h"
29#include "qlimitproxymodelqml.h"
30#include "qlimitproxymodelqml.h"
30#include "qsortfilterproxymodelqml.h"
31#include "qsortfilterproxymodelqml.h"
31#include "timeformatter.h"
32#include "timeformatter.h"
32#include "unitymenumodelpaths.h"
33#include "unitymenumodelpaths.h"
33−#include "easingcurve.h"
34+#include "urldispatcher.h"
35+
36+static QObject* urlDispatcherSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
37+ Q_UNUSED(engine);
38+ Q_UNUSED(scriptEngine);
39+ return new URLDispatcher;
40+}
34
41
35void UtilsPlugin::registerTypes(const char *uri)
42void UtilsPlugin::registerTypes(const char *uri)
36{
43{
@@ -42,6 +49,8 @@ void UtilsPlugin::registerTypes(const char *uri)
42 qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
49 qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
43 qmlRegisterType<GDateTimeFormatter>(uri, 0, 1, "GDateTimeFormatter");
50 qmlRegisterType<GDateTimeFormatter>(uri, 0, 1, "GDateTimeFormatter");
44 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
51 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
52+
53+ qmlRegisterSingletonType<URLDispatcher>(uri, 0, 1, "URLDispatcher", urlDispatcherSingleton);
45}
54}
46
55
47void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
56void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
plugins/Utils/urldispatcher.cppnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Nick Dedekind <nick.dedekind@canonical.com>
17+*/
18+
19+#include "urldispatcher.h"
20+
21+#include <url-dispatcher.h>
22+
23+URLDispatcher::URLDispatcher(QObject *parent):
24+ QObject(parent)
25+{
26+
27+}
28+
29+static void dispatched(const gchar * url, gboolean success, gpointer user_data)
30+{
31+ URLDispatcher* urlDispatcher = (URLDispatcher*)user_data;
32+ urlDispatcher->urlDispatched(QByteArray(url), success);
33+}
34+
35+void URLDispatcher::send(QByteArray const& url)
36+{
37+ url_dispatch_send(url.constData(), dispatched, this);
38+}
plugins/Utils/urldispatcher.hnew file+42
@@ -0,0 +1,42 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Nick Dedekind <nick.dedekind@canonical.com>
17+*/
18+
19+#ifndef URLDISPATCHER_H
20+#define URLDISPATCHER_H
21+
22+#include <QObject>
23+
24+/**
25+ * @brief The URLDispatcher class
26+ *
27+ * This class exposes the url-dispatcher glib API to QML.
28+ */
29+
30+class URLDispatcher: public QObject
31+{
32+ Q_OBJECT
33+public:
34+ URLDispatcher(QObject *parent = 0);
35+
36+ Q_INVOKABLE void send(QByteArray const& url);
37+
38+Q_SIGNALS:
39+ void urlDispatched(QByteArray const& url, bool success);
40+};
41+
42+#endif
qml/Panel/ActiveCallHint.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.0
18import Ubuntu.Telephony 0.1 as Telephony
18import Ubuntu.Telephony 0.1 as Telephony
19import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
20import Unity.Application 0.1
20import Unity.Application 0.1
21+import Utils 0.1
21import "../Components"
22import "../Components"
22
23
23Item {
24Item {
@@ -33,7 +34,7 @@ Item {
33 }
34 }
34
35
35 function activate() {
36 function activate() {
36− ApplicationManager.requestFocusApplication("dialer-app");
37+ URLDispatcher.send("dialer:///?view=liveCall");
37 }
38 }
38
39
39 Component {
40 Component {