on 37dc525 help sign in
unity8/plugins/LightDM/URLDispatcher.cpp
61 lines 1.9 kB history raw
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 */
17#include "URLDispatcher.h"
19#include <QDBusConnection>
20#include <QProcess>
21#include <unistd.h>
23class URLDispatcherInterface : public QObject
25 Q_OBJECT
26 Q_CLASSINFO("D-Bus Interface", "com.canonical.URLDispatcher")
28public:
29 explicit URLDispatcherInterface(URLDispatcher *parent);
31 Q_SCRIPTABLE void DispatchURL(const QString &url);
33private:
34 URLDispatcher *m_parent;
35};
37URLDispatcherInterface::URLDispatcherInterface(URLDispatcher *parent)
38 : QObject(parent),
39 m_parent(parent)
43void URLDispatcherInterface::DispatchURL(const QString &url)
45 Q_EMIT m_parent->dispatchURL(url);
48URLDispatcher::URLDispatcher(QObject *parent)
49 : QObject(parent)
51 // This class also manages our url-dispatcher interception. We intercept
52 // url-dispatcher because rather than spawning the handler for the URL in
53 // our own session, we want to do notify the user session to do it for us
54 // (and start an unlock in the process).
55 QDBusConnection connection = QDBusConnection::sessionBus();
56 URLDispatcherInterface *dispatcher = new URLDispatcherInterface(this);
57 connection.registerObject("/com/canonical/URLDispatcher", dispatcher, QDBusConnection::ExportScriptableContents);
58 connection.registerService("com.canonical.URLDispatcher");
61#include "URLDispatcher.moc"