2011-02-21 16:30:31 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2014-05-14 13:08:46 +02:00
|
|
|
** Copyright (C) 2012-2014 Digia Plc and/or its subsidiary(-ies).
|
2012-12-21 10:31:17 +01:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2012-12-21 10:31:17 +01:00
|
|
|
** This file is part of the Qt Installer Framework.
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2012-12-21 10:31:17 +01:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-12-21 10:31:17 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-11-28 17:03:44 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2012-12-21 10:31:17 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
2011-11-28 17:03:44 +01:00
|
|
|
**
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2012-12-21 10:31:17 +01:00
|
|
|
** $QT_END_LICENSE$
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
|
|
|
**************************************************************************/
|
2011-09-30 12:17:38 +02:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
#include "console.h"
|
2011-03-03 16:03:57 +01:00
|
|
|
#include "installerbasecommons.h"
|
2014-01-07 14:19:44 +01:00
|
|
|
#include "sdkapp.h"
|
2011-03-03 16:03:57 +01:00
|
|
|
#include "tabcontroller.h"
|
2014-07-14 12:10:06 +02:00
|
|
|
#include "updatechecker.h"
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-11 15:15:26 +02:00
|
|
|
#include <binarycontent.h>
|
2012-03-13 16:38:56 +01:00
|
|
|
#include <errors.h>
|
2011-09-30 12:17:38 +02:00
|
|
|
#include <init.h>
|
2014-07-09 13:23:33 +02:00
|
|
|
#include <messageboxhandler.h>
|
|
|
|
#include <productkeycheck.h>
|
|
|
|
#include <remoteserver.h>
|
2011-06-20 22:00:34 +02:00
|
|
|
#include <settings.h>
|
2012-03-13 16:38:56 +01:00
|
|
|
#include <utils.h>
|
2011-03-10 15:50:33 +01:00
|
|
|
|
2011-11-19 00:00:52 +01:00
|
|
|
#include <kdselfrestarter.h>
|
|
|
|
#include <kdrunoncechecker.h>
|
2012-03-13 16:38:56 +01:00
|
|
|
#include <kdupdaterfiledownloaderfactory.h>
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
#include <QCommandLineParser>
|
2013-10-16 12:48:21 +02:00
|
|
|
#include <QDirIterator>
|
2014-07-09 13:23:33 +02:00
|
|
|
#include <QNetworkProxyFactory>
|
|
|
|
#include <QTranslator>
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-11-23 15:26:28 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
2011-09-30 12:24:57 +02:00
|
|
|
#define QUOTE_(x) #x
|
|
|
|
#define QUOTE(x) QUOTE_(x)
|
2014-07-09 13:23:33 +02:00
|
|
|
#define VERSION "IFW Version: \"" QUOTE(IFW_VERSION) "\""
|
|
|
|
#define BUILDDATE "Build date: " QUOTE(__DATE__)
|
|
|
|
#define SHA "Installer Framework SHA1: \"" QUOTE(_GIT_SHA1_) "\""
|
|
|
|
static const char PLACEHOLDER[32] = "MY_InstallerCreateDateTime_MY";
|
2011-07-04 22:47:25 +02:00
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
using namespace QInstaller;
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
static QStringList repositories(const QString &list)
|
2011-05-10 11:53:36 +02:00
|
|
|
{
|
2014-07-09 13:23:33 +02:00
|
|
|
const QStringList items = list.split(QLatin1Char(','), QString::SkipEmptyParts);
|
|
|
|
foreach (const QString &item, items)
|
|
|
|
qDebug() << "Adding custom repository:" << item;
|
|
|
|
return items;
|
2011-05-10 11:53:36 +02:00
|
|
|
}
|
|
|
|
|
2011-11-22 17:52:59 +01:00
|
|
|
// -- main
|
2011-11-21 17:32:29 +01:00
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-05-14 13:08:46 +02:00
|
|
|
// increase maximum numbers of file descriptors
|
2014-07-03 10:57:09 +02:00
|
|
|
#if defined (Q_OS_OSX)
|
2014-05-14 13:08:46 +02:00
|
|
|
struct rlimit rl;
|
|
|
|
getrlimit(RLIMIT_NOFILE, &rl);
|
|
|
|
rl.rlim_cur = qMin((rlim_t)OPEN_MAX, rl.rlim_max);
|
|
|
|
setrlimit(RLIMIT_NOFILE, &rl);
|
|
|
|
#endif
|
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
QCommandLineParser parser;
|
|
|
|
QCommandLineOption help = parser.addHelpOption();
|
|
|
|
|
|
|
|
QCommandLineOption version(QLatin1String("version"),
|
|
|
|
QLatin1String("Displays version information."));
|
|
|
|
parser.addOption(version);
|
|
|
|
|
|
|
|
QCommandLineOption verbose(QStringList() << QLatin1String("v") << QLatin1String("verbose"),
|
|
|
|
QLatin1String("Verbose mode. Prints out more information."));
|
|
|
|
parser.addOption(verbose);
|
|
|
|
|
|
|
|
QCommandLineOption proxy(QLatin1String("proxy"),
|
|
|
|
QLatin1String("Use system proxy on Windows and OS X. This option has no effect on Linux."));
|
|
|
|
parser.addOption(proxy);
|
|
|
|
|
|
|
|
QCommandLineOption script(QLatin1String("script"),
|
|
|
|
QLatin1String("Execute the script given as argument."), QLatin1String("file"));
|
|
|
|
parser.addOption(script);
|
|
|
|
|
|
|
|
QCommandLineOption checkUpdates(QLatin1String("checkupdates"),
|
|
|
|
QLatin1String("Check for updates and return an XML description."));
|
|
|
|
parser.addOption(checkUpdates);
|
|
|
|
|
|
|
|
QCommandLineOption updater(QLatin1String("updater"),
|
|
|
|
QLatin1String("Start application in updater mode."));
|
|
|
|
parser.addOption(updater);
|
|
|
|
|
|
|
|
QCommandLineOption pkgManager(QLatin1String("manage-packages"),
|
|
|
|
QLatin1String("Start application in package manager mode."));
|
|
|
|
parser.addOption(pkgManager);
|
|
|
|
|
|
|
|
QCommandLineOption noForce(QLatin1String("no-force-installations"),
|
|
|
|
QLatin1String("Allow deselection of components that are marked as forced."));
|
|
|
|
parser.addOption(noForce);
|
|
|
|
|
|
|
|
QCommandLineOption showVirtuals(QLatin1String("show-virtual-components"),
|
|
|
|
QLatin1String("Show virtual components in installer and package manager."));
|
|
|
|
parser.addOption(showVirtuals);
|
|
|
|
|
|
|
|
QCommandLineOption offlineRepo(QLatin1String("create-offline-repository"), QLatin1String(
|
|
|
|
"Create a local repository inside the installation directory. This option has no effect "
|
|
|
|
"on online installer's"));
|
|
|
|
parser.addOption(offlineRepo);
|
|
|
|
|
|
|
|
QCommandLineOption addRepo(QLatin1String("addRepository"),
|
|
|
|
QLatin1String("Add a local or remote repository to the list of user defined repositories."),
|
|
|
|
QLatin1String("URI,..."));
|
|
|
|
parser.addOption(addRepo);
|
|
|
|
|
|
|
|
QCommandLineOption addTmpRepo(QLatin1String("addTempRepository"), QLatin1String(
|
|
|
|
"Add a local or remote repository to the list of temporary available repositories."),
|
|
|
|
QLatin1String("URI,..."));
|
|
|
|
parser.addOption(addTmpRepo);
|
|
|
|
|
|
|
|
QCommandLineOption setTmpRepo(QLatin1String("setTempRepository"),
|
|
|
|
QLatin1String("Set a local or remote repository as temporary repository, it is the only "
|
|
|
|
"one used during fetch.\nNote: URI must be prefixed with the protocol, i.e. file:///, "
|
|
|
|
"https://, http:// or ftp://."), QLatin1String("URI,..."));
|
|
|
|
parser.addOption(setTmpRepo);
|
|
|
|
|
|
|
|
QCommandLineOption startServer(QLatin1String("startserver"), QLatin1String("Starts the "
|
|
|
|
"application as headless process waiting for commands to execute."),
|
|
|
|
QLatin1String("port,key"));
|
|
|
|
parser.addOption(startServer);
|
|
|
|
|
|
|
|
parser.addPositionalArgument(QLatin1String("Key=Value"),
|
|
|
|
QLatin1String("Key Value pair to be set."));
|
|
|
|
|
2014-07-14 12:10:33 +02:00
|
|
|
// We need to start either a command line application or a GUI application. Since we
|
|
|
|
// fail doing so at least on Linux while parsing the argument using a core application
|
|
|
|
// object and later starting the GUI application, we now parse the arguments first.
|
|
|
|
parser.parse(QInstaller::parseCommandLineArgs(argc, argv));
|
2014-07-09 13:23:33 +02:00
|
|
|
|
|
|
|
QStringList mutually;
|
|
|
|
if (parser.isSet(checkUpdates))
|
|
|
|
mutually << checkUpdates.names();
|
|
|
|
if (parser.isSet(updater))
|
|
|
|
mutually << updater.names();
|
|
|
|
if (parser.isSet(pkgManager))
|
|
|
|
mutually << pkgManager.names();
|
|
|
|
|
|
|
|
if (parser.isSet(help) || parser.isSet(version) || (mutually.count() > 1)) {
|
|
|
|
Console c;
|
|
|
|
QCoreApplication app(argc, argv);
|
|
|
|
|
|
|
|
if (parser.isSet(version)) {
|
|
|
|
std::cout << VERSION << std::endl << BUILDDATE << std::endl << SHA << std::endl;
|
|
|
|
const QDateTime dateTime = QDateTime::fromString(QLatin1String(PLACEHOLDER),
|
|
|
|
QLatin1String("yyyy-MM-dd - HH:mm:ss"));
|
|
|
|
if (dateTime.isValid())
|
|
|
|
std::cout << "Installer creation time: " << PLACEHOLDER << std::endl;
|
|
|
|
return EXIT_SUCCESS;
|
2012-11-13 09:34:39 +01:00
|
|
|
}
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
if (mutually.count() > 1) {
|
|
|
|
std::cerr << qPrintable(QString::fromLatin1("The following options are mutually "
|
|
|
|
"exclusive: %1.").arg(mutually.join(QLatin1String(", ")))) << std::endl;
|
2011-09-30 12:24:57 +02:00
|
|
|
}
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
std::cout << qPrintable(parser.helpText()) << std::endl;
|
|
|
|
return parser.isSet(help) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
if (parser.isSet(startServer)) {
|
|
|
|
const QString argument = parser.value(startServer);
|
|
|
|
const QString port = argument.section(QLatin1Char(','), 0, 0);
|
|
|
|
const QString key = argument.section(QLatin1Char(','), 1, 1);
|
|
|
|
|
|
|
|
QStringList missing;
|
|
|
|
if (port.isEmpty())
|
|
|
|
missing << QLatin1String("Port");
|
|
|
|
if (key.isEmpty())
|
|
|
|
missing << QLatin1String("Key");
|
|
|
|
|
|
|
|
SDKApp<QCoreApplication> app(argc, argv);
|
|
|
|
if (missing.count()) {
|
|
|
|
Console c;
|
|
|
|
std::cerr << qPrintable(QString::fromLatin1("Missing argument(s) for option "
|
|
|
|
"'startserver': %2").arg(missing.join(QLatin1String(", ")))) << std::endl;
|
|
|
|
std::cout << qPrintable(parser.helpText()) << std::endl;
|
|
|
|
return EXIT_FAILURE;
|
2011-05-18 13:24:28 +02:00
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
RemoteServer *server = new RemoteServer;
|
|
|
|
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()));
|
|
|
|
server->init(port.toInt(), QHostAddress::LocalHost, Protocol::Mode::Release);
|
|
|
|
server->setAuthorizationKey(key);
|
|
|
|
server->start();
|
|
|
|
return app.exec();
|
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
try {
|
|
|
|
QScopedPointer<Console> console;
|
|
|
|
if (parser.isSet(verbose)) {
|
|
|
|
console.reset(new Console);
|
|
|
|
QInstaller::setVerbose(parser.isSet(verbose));
|
2011-09-06 16:12:18 +02:00
|
|
|
}
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
// On Windows we need the console window from above, we are a GUI application.
|
|
|
|
const QStringList unknownOptionNames = parser.unknownOptionNames();
|
|
|
|
if (!unknownOptionNames.isEmpty()) {
|
|
|
|
const QString options = unknownOptionNames.join(QLatin1String(", "));
|
|
|
|
std::cerr << "Unknown option: " << qPrintable(options) << std::endl;
|
2011-10-04 12:46:04 +02:00
|
|
|
}
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
if (parser.isSet(proxy)) {
|
|
|
|
// Make sure we honor the system's proxy settings
|
|
|
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
|
|
|
|
QUrl proxyUrl(QString::fromLatin1(qgetenv("http_proxy")));
|
|
|
|
if (proxyUrl.isValid()) {
|
|
|
|
QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(),
|
|
|
|
proxyUrl.userName(), proxyUrl.password());
|
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
2012-11-13 12:24:49 +01:00
|
|
|
}
|
2014-07-09 13:23:33 +02:00
|
|
|
#else
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
|
|
#endif
|
|
|
|
}
|
2012-11-13 12:24:49 +01:00
|
|
|
|
2014-07-14 12:10:06 +02:00
|
|
|
if (parser.isSet(checkUpdates))
|
|
|
|
return UpdateChecker().check(argc, argv);
|
2012-11-13 12:24:49 +01:00
|
|
|
|
2014-01-07 14:19:44 +01:00
|
|
|
SDKApp<QApplication> app(argc, argv);
|
2014-07-14 12:10:06 +02:00
|
|
|
KDRunOnceChecker runCheck(QLatin1String("lockmyApp1234865.lock"));
|
2014-07-09 13:23:33 +02:00
|
|
|
|
|
|
|
if (runCheck.isRunning(KDRunOnceChecker::ProcessList)
|
|
|
|
|| runCheck.isRunning(KDRunOnceChecker::Lockfile)) {
|
|
|
|
QInstaller::MessageBoxHandler::information(0, QLatin1String("AlreadyRunning"),
|
2014-07-17 15:26:04 +02:00
|
|
|
QString::fromLatin1("Waiting for %1").arg(qAppName()),
|
2014-07-09 13:23:33 +02:00
|
|
|
QString::fromLatin1("Another %1 instance is already running. Wait "
|
|
|
|
"until it finishes, close it, or restart your system.").arg(qAppName()));
|
|
|
|
return EXIT_FAILURE;
|
2011-11-22 17:52:59 +01:00
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-14 12:10:06 +02:00
|
|
|
const KDSelfRestarter restarter(argc, argv);
|
|
|
|
QInstaller::init(); // register custom operations
|
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
if (QInstaller::isVerbose()) {
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << VERSION;
|
2014-07-14 12:10:33 +02:00
|
|
|
qDebug() << "Arguments:" << app.arguments();
|
2014-07-09 13:23:33 +02:00
|
|
|
qDebug() << "Language: " << QLocale().uiLanguages().value(0,
|
|
|
|
QLatin1String("No UI language set"));
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
|
2014-07-14 12:10:06 +02:00
|
|
|
BinaryContent content = BinaryContent::readAndRegisterFromBinary(app.binaryFile());
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
// instantiate the installer we are actually going to use
|
2014-07-09 13:23:33 +02:00
|
|
|
PackageManagerCore core(content.magicMarker(), content.performedOperations());
|
2013-11-25 16:53:04 +01:00
|
|
|
ProductKeyCheck::instance()->init(&core);
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
QString controlScript;
|
2014-07-09 13:23:33 +02:00
|
|
|
if (parser.isSet(script)) {
|
|
|
|
controlScript = parser.value(script);
|
|
|
|
if (!QFileInfo(controlScript).exists())
|
|
|
|
throw Error(QLatin1String("Script file does not exist."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(proxy)) {
|
|
|
|
core.settings().setProxyType(QInstaller::Settings::SystemProxy);
|
|
|
|
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(core.proxyFactory());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(showVirtuals)) {
|
|
|
|
QFont f;
|
|
|
|
f.setItalic(true);
|
|
|
|
PackageManagerCore::setVirtualComponentsFont(f);
|
|
|
|
PackageManagerCore::setVirtualComponentsVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(updater)) {
|
|
|
|
if (core.isInstaller())
|
|
|
|
throw Error(QLatin1String("Cannot start installer binary as updater."));
|
|
|
|
core.setUpdater();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(pkgManager)) {
|
|
|
|
if (core.isInstaller())
|
|
|
|
throw Error(QLatin1String("Cannot start installer binary as package manager."));
|
|
|
|
core.setPackageManager();
|
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
if (parser.isSet(addRepo)) {
|
|
|
|
const QStringList repoList = repositories(parser.value(addRepo));
|
|
|
|
if (repoList.isEmpty())
|
|
|
|
throw Error(QLatin1String("Empty repository list for option 'addRepository'."));
|
|
|
|
core.addUserRepositories(repoList);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(addTmpRepo)) {
|
|
|
|
const QStringList repoList = repositories(parser.value(addTmpRepo));
|
|
|
|
if (repoList.isEmpty())
|
|
|
|
throw Error(QLatin1String("Empty repository list for option 'addTempRepository'."));
|
|
|
|
core.setTemporaryRepositories(repoList, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parser.isSet(setTmpRepo)) {
|
|
|
|
const QStringList repoList = repositories(parser.value(setTmpRepo));
|
|
|
|
if (repoList.isEmpty())
|
|
|
|
throw Error(QLatin1String("Empty repository list for option 'setTempRepository'."));
|
|
|
|
core.setTemporaryRepositories(repoList, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
PackageManagerCore::setNoForceInstallation(parser.isSet(noForce));
|
|
|
|
PackageManagerCore::setCreateLocalRepositoryFromBinary(parser.isSet(offlineRepo));
|
|
|
|
|
|
|
|
QHash<QString, QString> params;
|
|
|
|
const QStringList positionalArguments = parser.positionalArguments();
|
|
|
|
foreach (const QString &argument, positionalArguments) {
|
2011-02-21 16:30:31 +01:00
|
|
|
if (argument.contains(QLatin1Char('='))) {
|
|
|
|
const QString name = argument.section(QLatin1Char('='), 0, 0);
|
|
|
|
const QString value = argument.section(QLatin1Char('='), 1, 1);
|
|
|
|
params.insert(name, value);
|
2011-06-14 16:24:50 +02:00
|
|
|
core.setValue(name, value);
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-16 15:04:28 +02:00
|
|
|
// this needs to happen after we parse the arguments, but before we use the actual resources
|
|
|
|
const QString newDefaultResource = core.value(QString::fromLatin1("DefaultResourceReplacement"));
|
|
|
|
if (!newDefaultResource.isEmpty())
|
|
|
|
content.registerAsDefaultQResource(newDefaultResource);
|
|
|
|
|
2013-10-14 19:26:18 +02:00
|
|
|
if (QInstaller::isVerbose()) {
|
2014-08-25 14:31:13 +02:00
|
|
|
qDebug() << "Resource tree:";
|
2013-10-16 12:48:21 +02:00
|
|
|
QDirIterator it(QLatin1String(":/"), QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden,
|
|
|
|
QDirIterator::Subdirectories);
|
2014-08-25 14:31:13 +02:00
|
|
|
while (it.hasNext()) {
|
|
|
|
const QString path = it.next();
|
|
|
|
if (path.startsWith(QLatin1String(":/trolltech"))
|
|
|
|
|| path.startsWith(QLatin1String(":/qt-project.org"))) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-08-27 12:01:48 +02:00
|
|
|
qDebug() << " " << path.toUtf8().constData();
|
2014-08-25 14:31:13 +02:00
|
|
|
}
|
2013-10-14 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString directory = QLatin1String(":/translations");
|
|
|
|
const QStringList translations = core.settings().translations();
|
|
|
|
|
|
|
|
// install the default Qt translator
|
|
|
|
QScopedPointer<QTranslator> translator(new QTranslator(&app));
|
|
|
|
foreach (const QLocale locale, QLocale().uiLanguages()) {
|
|
|
|
// As there is no qt_en.qm, we simply end the search when the next
|
|
|
|
// preferred language is English.
|
|
|
|
if (locale.language() == QLocale::English)
|
|
|
|
break;
|
|
|
|
if (translator->load(locale, QLatin1String("qt"), QString::fromLatin1("_"), directory)) {
|
|
|
|
app.installTranslator(translator.take());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
translator.reset(new QTranslator(&app));
|
|
|
|
// install English translation as fallback so that correct license button text is used
|
|
|
|
if (translator->load(QLatin1String("en_us"), directory))
|
|
|
|
app.installTranslator(translator.take());
|
|
|
|
|
|
|
|
if (translations.isEmpty()) {
|
|
|
|
translator.reset(new QTranslator(&app));
|
|
|
|
foreach (const QLocale locale, QLocale().uiLanguages()) {
|
|
|
|
if (translator->load(locale, QLatin1String(""), QLatin1String(""), directory)) {
|
|
|
|
app.installTranslator(translator.take());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (const QString &translation, translations) {
|
|
|
|
translator.reset(new QTranslator(&app));
|
|
|
|
if (translator->load(translation, QLatin1String(":/translations")))
|
|
|
|
app.installTranslator(translator.take());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-09 13:23:33 +02:00
|
|
|
//create the wizard GUI
|
2011-02-21 16:30:31 +01:00
|
|
|
TabController controller(0);
|
2011-06-14 16:24:50 +02:00
|
|
|
controller.setManager(&core);
|
|
|
|
controller.setManagerParams(params);
|
2011-02-21 16:30:31 +01:00
|
|
|
controller.setControlScript(controlScript);
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
if (core.isInstaller()) {
|
|
|
|
controller.setGui(new InstallerGui(&core));
|
2011-02-21 16:30:31 +01:00
|
|
|
} else {
|
2011-06-14 16:24:50 +02:00
|
|
|
controller.setGui(new MaintenanceGui(&core));
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
PackageManagerCore::Status status = PackageManagerCore::Status(controller.init());
|
|
|
|
if (status != PackageManagerCore::Success)
|
2011-03-14 17:42:15 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
const int result = app.exec();
|
|
|
|
if (result != 0)
|
|
|
|
return result;
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
if (core.finishedWithSuccess())
|
|
|
|
return PackageManagerCore::Success;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
status = core.status();
|
2011-02-21 16:30:31 +01:00
|
|
|
switch (status) {
|
2011-06-14 16:24:50 +02:00
|
|
|
case PackageManagerCore::Success:
|
2011-03-10 15:50:33 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
case PackageManagerCore::Canceled:
|
2011-03-10 15:50:33 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
} catch(const Error &e) {
|
|
|
|
std::cerr << qPrintable(e.message()) << std::endl;
|
|
|
|
} catch (const std::exception &e) {
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
} catch(...) {
|
|
|
|
std::cerr << "Unknown error, aborting." << std::endl;
|
|
|
|
}
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|