File indexing completed on 2024-04-14 15:31:38

0001 /*
0002  *   Copyright (C) 2016 by Aditya Mehra <aix.m@outlook.com>                      *
0003  *   This program is free software; you can redistribute it and/or modify
0004  *   it under the terms of the GNU Library General Public License as
0005  *   published by the Free Software Foundation; either version 2, or
0006  *   (at your option) any later version.
0007  *
0008  *   This program is distributed in the hope that it will be useful,
0009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0011  *   GNU General Public License for more details
0012  *
0013  *   You should have received a copy of the GNU Library General Public
0014  *   License along with this program; if not, write to the
0015  *   Free Software Foundation, Inc.,
0016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0017  */
0018 
0019 #include "mycroftplasmoidmobileplugin.h"
0020 #include "mycroftplasmoid_dbus.h"
0021 #include "launchapp.h"
0022 #include "notify.h"
0023 #include "filereader.h"
0024 #include "msmapp.h"
0025 #include <QtQml>
0026 #include <QtDebug>
0027 #include <QtDBus>
0028 
0029 static QObject *notify_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
0030 {
0031     Q_UNUSED(engine)
0032     Q_UNUSED(scriptEngine)
0033 
0034     return new Notify;
0035 }
0036 
0037 static QObject *launchapp_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
0038 {
0039     Q_UNUSED(engine)
0040     Q_UNUSED(scriptEngine)
0041 
0042     return new LaunchApp;
0043 }
0044 
0045 static QObject *filereader_singleton(QQmlEngine *engine, QJSEngine *scriptEngine)
0046 {
0047     Q_UNUSED(engine)
0048     Q_UNUSED(scriptEngine)
0049 
0050     return new FileReader;
0051 }
0052 
0053 void MycroftPlasmoidMobilePlugin::registerTypes(const char *uri)
0054 {
0055     Q_ASSERT(uri == QLatin1String("org.kde.private.mycroftplasmoid"));
0056     qmlRegisterSingletonType<Notify>(uri, 1, 0, "Notify", notify_singleton);
0057     qmlRegisterSingletonType<LaunchApp>(uri, 1, 0, "LaunchApp", launchapp_singleton);
0058     qmlRegisterSingletonType<FileReader>(uri, 1, 0, "FileReader", filereader_singleton);    
0059     qmlRegisterType<MsmApp>(uri, 1, 0, "MsmApp");
0060 }
0061 
0062 void MycroftPlasmoidMobilePlugin::initializeEngine(QQmlEngine* engine, const char* uri)
0063 {
0064   QQmlExtensionPlugin::initializeEngine(engine, uri);
0065   auto mycroftDbusAdapterInterface = new MycroftDbusAdapterInterface(engine);
0066   engine->rootContext()->setContextProperty("main2", mycroftDbusAdapterInterface);
0067 }