on 69812ea help sign in
unity8/plugins/LightDM/plugin.cpp
73 lines 2.6 kB history raw
1/*
2 * Copyright (C) 2012,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 * Authors: Gerry Boland <gerry.boland@canonical.com>
17 * Michael Terry <michael.terry@canonical.com>
18 */
20#include "plugin.h"
21#include "DBusGreeterList.h"
22#include "Greeter.h"
23#include "UsersModel.h"
24#include <libusermetricsoutput/ColorTheme.h>
25#include <libusermetricsoutput/UserMetrics.h>
26#include <QLightDM/UsersModel>
28#include <QAbstractItemModel>
29#include <QDBusConnection>
30#include <QtQml/qqml.h>
32static const char* GREETER_LIST_DBUS_PATH = "/list";
33static const char* GREETER_DBUS_SERVICE = "com.canonical.UnityGreeter";
35static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
37 Q_UNUSED(engine)
38 Q_UNUSED(scriptEngine)
40 Greeter *greeter = new Greeter();
41 QDBusConnection connection = QDBusConnection::sessionBus();
42 DBusGreeterList *list = new DBusGreeterList(greeter, connection, GREETER_LIST_DBUS_PATH);
43 connection.registerObject(GREETER_LIST_DBUS_PATH, list, QDBusConnection::ExportScriptableContents);
44 connection.registerService(GREETER_DBUS_SERVICE);
46 return greeter;
49static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
51 Q_UNUSED(engine)
52 Q_UNUSED(scriptEngine)
53 return new UsersModel();
56static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
58 Q_UNUSED(engine)
59 Q_UNUSED(scriptEngine)
60 return UserMetricsOutput::UserMetrics::getInstance();
63void LightDMPlugin::registerTypes(const char *uri)
65 qmlRegisterType<QAbstractItemModel>();
66 qmlRegisterType<UserMetricsOutput::ColorTheme>();
68 Q_ASSERT(uri == QLatin1String("LightDM"));
69 qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
70 qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
71 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
72 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);