2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2.1.
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 Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
19
#include "ubuntuplugin.h"
20
#include "ubuntuconstants.h"
21
#include "ubuntuprojectapplicationwizard.h"
23
#include <coreplugin/modemanager.h>
25
#include <QJsonDocument>
27
#include <QJsonObject>
30
#include <QGuiApplication>
32
using namespace Ubuntu::Internal;
34
UbuntuPlugin::UbuntuPlugin()
39
UbuntuPlugin::~UbuntuPlugin()
44
bool UbuntuPlugin::initialize(const QStringList &arguments, QString *errorString)
49
Core::MimeDatabase *mimeDB = Core::ICore::mimeDatabase();
51
const QLatin1String mimetypesXml(":/ubuntu/UbuntuProject.mimetypes.xml");
53
if (!mimeDB->addMimeTypes(mimetypesXml, errorString))
56
QJsonDocument jsonDoc = QJsonDocument::fromJson(Internal::UbuntuProjectApplicationWizard::getProjectTypesJSON());
57
if (jsonDoc.isArray()) {
58
QJsonArray array = jsonDoc.array();
59
for (int idx = 0; idx < array.size(); idx++) {
60
if (array.at(idx).isObject()) {
61
QJsonObject obj = array.at(idx).toObject();
63
QJsonValue tmp_folder = obj.value(QLatin1String(Constants::UBUNTU_PROJECTJSON_FOLDER));
64
if (tmp_folder.isUndefined() == false) {
65
folder = tmp_folder.toString();
66
if (QFileInfo(UbuntuProjectApplicationWizard::templatesPath(folder)).exists()) {
67
addAutoReleasedObject(new Internal::UbuntuProjectApplicationWizard(obj));
73
qWarning() << __PRETTY_FUNCTION__ << "failed to read from JSON.";
76
m_ubuntuWelcomeMode = new UbuntuWelcomeMode;
77
m_ubuntuDeviceMode = new UbuntuDeviceMode;
78
m_ubuntuMenu = new UbuntuMenu;
79
m_ubuntuIRCMode = new UbuntuIRCMode;
80
m_ubuntuAPIMode = new UbuntuAPIMode;
81
m_ubuntuCoreAppsMode = new UbuntuCoreAppsMode;
82
m_ubuntuWikiMode = new UbuntuWikiMode;
83
m_ubuntuPackagingMode = new UbuntuPackagingMode;
84
m_ubuntuPastebinMode = new UbuntuPastebinMode;
86
addAutoReleasedObject(m_ubuntuWelcomeMode);
87
addAutoReleasedObject(m_ubuntuDeviceMode);
88
addAutoReleasedObject(m_ubuntuMenu);
89
addAutoReleasedObject(m_ubuntuIRCMode);
90
addAutoReleasedObject(m_ubuntuAPIMode);
91
addAutoReleasedObject(m_ubuntuCoreAppsMode);
92
addAutoReleasedObject(m_ubuntuWikiMode);
93
addAutoReleasedObject(m_ubuntuPackagingMode);
94
addAutoReleasedObject(m_ubuntuPastebinMode);
96
addAutoReleasedObject(new UbuntuVersionManager);
97
addAutoReleasedObject(new UbuntuFeatureProvider);
99
//addAutoReleasedObject(new UbuntuProjectManager);
100
//addAutoReleasedObject(new UbuntuRunConfigurationFactory);
101
//addAutoReleasedObject(new UbuntuRunControlFactory);
106
void UbuntuPlugin::extensionsInitialized()
108
m_ubuntuMenu->initialize();
109
m_ubuntuWelcomeMode->initialize();
110
m_ubuntuDeviceMode->initialize();
111
m_ubuntuIRCMode->initialize();
112
m_ubuntuAPIMode->initialize();
113
m_ubuntuCoreAppsMode->initialize();
114
m_ubuntuWikiMode->initialize();
115
m_ubuntuPackagingMode->initialize();
116
Core::ModeManager::activateMode(m_ubuntuWelcomeMode->id());
119
Q_EXPORT_PLUGIN2(Ubuntu, UbuntuPlugin)