File indexing completed on 2024-04-14 05:38:07

0001 /* This file is part of Apper
0002  *
0003  * Copyright (C) 2012 Matthias Klumpp <matthias@tenstral.net>
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; see the file COPYING. If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #include <limba.h>
0022 #include <KAboutData>
0023 
0024 #include <KDebug>
0025 
0026 #include <KMessageBox>
0027 #include <QFileInfo>
0028 #include <QApplication>
0029 #include <KLocalizedString>
0030 #include <QCommandLineParser>
0031 #include <QCommandLineOption>
0032 #include "config.h"
0033 
0034 #include "SetupWizard.h"
0035 
0036 int main(int argc, char** argv)
0037 {
0038     KLocalizedString::setApplicationDomain("apper");
0039 
0040     KAboutData aboutData("apper-appsetup",
0041                 "apper",
0042                 APPER_VERSION,
0043                 i18n("KDE Application Installer"),
0044                 KAboutLicense::LicenseKey::GPL);
0045 
0046     aboutData.addAuthor(i18nc("@info:credit", "Daniel Nicoletti"), i18n("Developer"),
0047                         "dantti12@gmail.com");
0048     aboutData.addAuthor(i18nc("@info:credit", "Matthias Klumpp"), i18n("Developer"),
0049                         "matthias@tenstral.net");
0050     aboutData.setProductName("apper/limba");
0051 
0052     QApplication app(argc, argv);
0053     QCommandLineParser parser;
0054     KAboutData::setApplicationData(aboutData);
0055     parser.addVersionOption();
0056     parser.addHelpOption();
0057     aboutData.setupCommandLine(&parser);
0058     parser.process(app);
0059     aboutData.processCommandLine(&parser);
0060     // Add --verbose as commandline option
0061     parser.addOption(QCommandLineOption(QStringList() << QLatin1String("verbose"), i18n("Show verbose information")));
0062     parser.addPositionalArgument(QLatin1String("file"), i18n("IPK package filename"));
0063 
0064     // Set if we are in verbose mode
0065     li_set_verbose_mode(parser.isSet("verbose"));
0066 
0067     QString fname;
0068     for(int i = 0; i < parser.positionalArguments().count(); i++) {
0069         fname = parser.positionalArguments()[i];
0070         QFileInfo file(fname);
0071         if (!file.exists())
0072             fname = "";
0073         else
0074             break;
0075     }
0076     
0077     // Check if we have a package
0078     if (fname.isEmpty()) {
0079         KMessageBox::error (0, i18n("We did not receive a path to an IPK package as parameter."),
0080                             i18n("Package not found!"));
0081         return 1;
0082     }
0083 
0084     // Create & run the setup wizard
0085     SetupWizard *wizard = new SetupWizard();
0086     wizard->initialize(fname);
0087     wizard->show();
0088     return app.exec();
0089 }