| 1 | /* |
| 2 | * Copyright (C) 2014 Canonical Ltd. |
| 3 | * |
| 4 | * Contact: Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This file is part of OnlineAccountsPlugin. |
| 7 | * |
| 8 | * OnlineAccountsClient is free software: you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public License as |
| 10 | * published by the Free Software Foundation, either version 3 of the |
| 11 | * License, or (at your option) any later version. |
| 12 | * |
| 13 | * OnlineAccountsClient is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU Lesser General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public License |
| 19 | * along with OnlineAccountsClient. If not, see |
| 20 | * <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | #include "plugin.h" |
| 24 | |
| 25 | #include "config.hpp" |
| 26 | #include "qml-loopback-server.h" |
| 27 | |
| 28 | #include <libintl.h> |
| 29 | #include <LomiriOnlineAccountsPlugin/application-manager.h> |
| 30 | #include <LomiriOnlineAccountsPlugin/request-handler.h> |
| 31 | #include <QDebug> |
| 32 | #include <QQmlComponent> |
| 33 | #include <QQmlContext> |
| 34 | #include <QQmlEngine> |
| 35 | |
| 36 | using namespace OnlineAccountsPlugin; |
| 37 | |
| 38 | void Plugin::initializeEngine(QQmlEngine *engine, const char *uri) |
| 39 | { |
| 40 | Q_UNUSED(uri); |
| 41 | |
| 42 | std::string localeDir = i18nDirectory().toStdString(); |
| 43 | bindtextdomain("lomiri-online-accounts", localeDir.c_str()); |
| 44 | bind_textdomain_codeset("lomiri-online-accounts", "UTF-8"); |
| 45 | |
| 46 | QQmlContext* context = engine->rootContext(); |
| 47 | context->setContextProperty("ApplicationManager", |
| 48 | OnlineAccountsUi::ApplicationManager::instance()); |
| 49 | } |
| 50 | |
| 51 | void Plugin::registerTypes(const char *uri) |
| 52 | { |
| 53 | qDebug() << Q_FUNC_INFO << uri; |
| 54 | |
| 55 | qmlRegisterType<SignOnUi::RequestHandler>(uri, 1, 0, "RequestHandler"); |
| 56 | qmlRegisterType<QmlLoopbackServer>(uri, 1, 0, "LoopbackServer"); |
| 57 | } |