@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "URLDispatcher.h"
18+
19+#include <QDBusConnection>
20+
21+class DBusURLDispatcher : public QObject
22+{
23+ Q_OBJECT
24+ Q_CLASSINFO("D-Bus Interface", "com.canonical.URLDispatcher")
25+
26+public:
27+ explicit DBusURLDispatcher(URLDispatcher *parent);
28+
29+ Q_SCRIPTABLE void DispatchURL(const QString &url);
30+
31+private:
32+ URLDispatcher *m_parent;
33+};
34+
35+DBusURLDispatcher::DBusURLDispatcher(URLDispatcher *parent)
36+ : QObject(parent),
37+ m_parent(parent)
38+{
39+}
40+
41+void DBusURLDispatcher::DispatchURL(const QString &url)
42+{
43+ Q_EMIT m_parent->dispatchURL(url);
44+}
45+
46+URLDispatcher::URLDispatcher(QObject *parent)
47+ : QObject(parent)
48+{
49+ // Own url dispatcher on DBus, we want to intercept these calls
50+ QDBusConnection connection = QDBusConnection::sessionBus();
51+ DBusURLDispatcher *dispatcher = new DBusURLDispatcher(this);
52+ connection.registerObject("/com/canonical/URLDispatcher", dispatcher, QDBusConnection::ExportScriptableContents);
53+ connection.registerService("com.canonical.URLDispatcher");
54+}
55+
56+#include "URLDispatcher.moc"