on xenial help sign in
use url-dispatcher
commitce76a49a46cea7ac63e4a4ea32b5f21acd36e685 authorNick Dedekind <nicholas.dedekind@gmail.com> dateMon 23 Jun 2014, 16:26 (12 years ago) parent5a22b81
6 files changed+101−4
debian/control+1 plugins/Utils/CMakeLists.txt+8−2 plugins/Utils/plugin.cpp+10−1 plugins/Utils/urldispatcher.cpp+38 plugins/Utils/urldispatcher.h+42 qml/Panel/ActiveCallHint.qml+2−1
debian/control+1
@@ -19,6 +19,7 @@ Build-Depends: cmake,
1919 libqt5xmlpatterns5-dev,
2020 libunity-api-dev (>= 7.82),
2121 libunity-mir-dev,
22+ liburl-dispatcher1-dev,
2223 libusermetricsoutput1-dev,
2324 libxcb1-dev,
2425 pkg-config,
plugins/Utils/CMakeLists.txt+8−2
@@ -2,20 +2,23 @@
22include(FindPkgConfig)
33
44pkg_search_module(GIO REQUIRED gio-2.0)
5+pkg_search_module(URLDISPATCHER REQUIRED url-dispatcher-1)
56
67include_directories(
78 ${CMAKE_CURRENT_SOURCE_DIR}
89 ${CMAKE_CURRENT_BINARY_DIR}
910 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
1011 ${GIO_INCLUDE_DIRS}
12+ ${URLDISPATCHER_INCLUDE_DIRS}
1113)
1214
1315set(QMLPLUGIN_SRC
16+ easingcurve.cpp
1417 qlimitproxymodelqml.cpp
1518 qsortfilterproxymodelqml.cpp
1619 timeformatter.cpp
1720 unitymenumodelpaths.cpp
18− easingcurve.cpp
21+ urldispatcher.cpp
1922 plugin.cpp
2023 )
2124
@@ -23,7 +26,10 @@ add_library(Utils-qml SHARED
2326 ${QMLPLUGIN_SRC}
2427 )
2528
26−target_link_libraries(Utils-qml ${GIO_LDFLAGS})
29+target_link_libraries(Utils-qml
30+ ${GIO_LDFLAGS}
31+ ${URLDISPATCHER_LDFLAGS}
32+)
2733
2834# Because this is an internal support library, we want
2935# to expose all symbols in it. Consider changing this
plugins/Utils/plugin.cpp+10−1
@@ -26,11 +26,18 @@
2626#include "plugin.h"
2727
2828// local
29+#include "easingcurve.h"
2930#include "qlimitproxymodelqml.h"
3031#include "qsortfilterproxymodelqml.h"
3132#include "timeformatter.h"
3233#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+}
3441
3542void UtilsPlugin::registerTypes(const char *uri)
3643{
@@ -42,6 +49,8 @@ void UtilsPlugin::registerTypes(const char *uri)
4249 qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
4350 qmlRegisterType<GDateTimeFormatter>(uri, 0, 1, "GDateTimeFormatter");
4451 qmlRegisterType<EasingCurve>(uri, 0, 1, "EasingCurve");
52+
53+ qmlRegisterSingletonType<URLDispatcher>(uri, 0, 1, "URLDispatcher", urlDispatcherSingleton);
4554}
4655
4756void 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
1818import Ubuntu.Telephony 0.1 as Telephony
1919import Ubuntu.Components 0.1
2020import Unity.Application 0.1
21+import Utils 0.1
2122import "../Components"
2223
2324Item {
@@ -33,7 +34,7 @@ Item {
3334 }
3435
3536 function activate() {
36− ApplicationManager.requestFocusApplication("dialer-app");
37+ URLDispatcher.send("dialer:///?view=liveCall");
3738 }
3839
3940 Component {