File indexing completed on 2024-05-12 05:46:35
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2001-2003 Tim Jansen <tim@tjansen.de> 0004 ** Copyright (C) 2007 - 2012 Urs Wolfer <uwolfer @ kde.org> 0005 ** 0006 ** This file is part of KDE. 0007 ** 0008 ** This program is free software; you can redistribute it and/or modify 0009 ** it under the terms of the GNU General Public License as published by 0010 ** the Free Software Foundation; either version 2 of the License, or 0011 ** (at your option) any later version. 0012 ** 0013 ** This program is distributed in the hope that it will be useful, 0014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 ** GNU General Public License for more details. 0017 ** 0018 ** You should have received a copy of the GNU General Public License 0019 ** along with this program; see the file COPYING. If not, write to 0020 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 ** Boston, MA 02110-1301, USA. 0022 ** 0023 ****************************************************************************/ 0024 0025 #include "mainwindow.h" 0026 #include "krdc_debug.h" 0027 #include "krdc_version.h" 0028 #include "settings.h" 0029 0030 #include <KCoreAddons/KAboutData> 0031 #include <Kdelibs4ConfigMigrator> 0032 #include <Kdelibs4Migration> 0033 #include <KLocalizedString> 0034 #include <QDir> 0035 #include <QFile> 0036 #include <QElapsedTimer> 0037 #include <QCommandLineOption> 0038 #include <QCommandLineParser> 0039 #include <QPluginLoader> 0040 #include <QStandardPaths> 0041 0042 int main(int argc, char **argv) 0043 { 0044 const QString appName = QStringLiteral("krdc"); 0045 QApplication app(argc, argv); 0046 KLocalizedString::setApplicationDomain("krdc"); 0047 QElapsedTimer startupTimer; 0048 startupTimer.start(); 0049 0050 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0051 0052 Kdelibs4ConfigMigrator migrate(appName); 0053 migrate.setConfigFiles(QStringList() << QStringLiteral("krdcrc")); 0054 if (migrate.migrate()) { 0055 Kdelibs4Migration dataMigrator; 0056 const QString sourceBasePath = dataMigrator.saveLocation("data", QStringLiteral("krdc")); 0057 const QString targetBasePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/krdc/"); 0058 QString targetFilePath; 0059 QDir sourceDir(sourceBasePath); 0060 QDir targetDir(targetBasePath); 0061 if (sourceDir.exists()) { 0062 if (!targetDir.exists()) { 0063 QDir().mkpath(targetBasePath); 0064 } 0065 const QStringList fileNames = sourceDir.entryList(QDir::Files | 0066 QDir::NoDotAndDotDot | QDir::NoSymLinks); 0067 for (const QString &fileName : fileNames) { 0068 targetFilePath = targetBasePath + fileName; 0069 if (!QFile::exists(targetFilePath)) { 0070 QFile::copy(sourceBasePath + fileName, targetFilePath); 0071 } 0072 } 0073 } 0074 } 0075 0076 KAboutData aboutData(appName, i18n("KRDC"), QStringLiteral(KRDC_VERSION_STRING), 0077 i18n("KDE Remote Desktop Client"), KAboutLicense::LicenseKey::GPL); 0078 0079 aboutData.setCopyrightStatement(i18n("(c) 2007-2016, Urs Wolfer\n" 0080 "(c) 2001-2003, Tim Jansen\n" 0081 "(c) 2002-2003, Arend van Beelen jr.\n" 0082 "(c) 2000-2002, Const Kaplinsky\n" 0083 "(c) 2000, Tridia Corporation\n" 0084 "(c) 1999, AT&T Laboratories Boston\n" 0085 "(c) 1999-2003, Matthew Chapman\n" 0086 "(c) 2009, Collabora Ltd")); 0087 0088 aboutData.addAuthor(i18n("Urs Wolfer"), i18n("Developer, Maintainer"), QStringLiteral("uwolfer@kde.org")); 0089 aboutData.addAuthor(i18n("Tony Murray"), i18n("Developer"), QStringLiteral("murraytony@gmail.com")); 0090 aboutData.addAuthor(i18n("Tim Jansen"), i18n("Former Developer"), QStringLiteral("tim@tjansen.de")); 0091 aboutData.addAuthor(i18n("Arend van Beelen jr."), i18n("Initial RDP backend"), QStringLiteral("arend@auton.nl")); 0092 aboutData.addCredit(i18n("Brad Hards"), i18n("Google Summer of Code 2007 KRDC project mentor"), 0093 QStringLiteral("bradh@frogmouth.net")); 0094 aboutData.addCredit(i18n("LibVNCServer / LibVNCClient developers"), i18n("VNC client library"), 0095 QStringLiteral("libvncserver-common@lists.sf.net"), QStringLiteral("http://libvncserver.sourceforge.net/")); 0096 aboutData.addAuthor(i18n("Abner Silva"), i18n("Telepathy Tubes Integration"), QStringLiteral("abner.silva@kdemail.net")); 0097 aboutData.setOrganizationDomain("kde.org"); 0098 0099 KAboutData::setApplicationData(aboutData); 0100 app.setWindowIcon(QIcon::fromTheme(appName)); 0101 0102 QCommandLineParser parser; 0103 aboutData.setupCommandLine(&parser); 0104 0105 // command line options 0106 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("fullscreen"), 0107 i18n("Start KRDC with the provided URL in fullscreen mode (works only with one URL)"))); 0108 parser.addPositionalArgument(QStringLiteral("url"), i18n("URLs to connect after startup")); 0109 0110 parser.process(app); 0111 aboutData.processCommandLine(&parser); 0112 MainWindow *mainwindow = new MainWindow; 0113 mainwindow->show(); 0114 const QStringList args = parser.positionalArguments(); 0115 if (args.length() > 0) { 0116 for (int i = 0; i < args.length(); ++i) { 0117 QUrl url = QUrl(args.at(i)); 0118 // no URL scheme, assume argument is only a hostname 0119 if (url.scheme().isEmpty()) { 0120 QString defaultProto = Settings::defaultProtocol(); 0121 url.setScheme(defaultProto); 0122 url.setHost(args.at(i)); 0123 url.setPath(QString()); 0124 } 0125 if (!url.isValid()) { 0126 continue; 0127 } 0128 0129 mainwindow->newConnection(url, parser.isSet(QStringLiteral("fullscreen"))); 0130 } 0131 } 0132 qCDebug(KRDC) << "########## KRDC ready:" << startupTimer.elapsed() << "ms ##########"; 0133 0134 return app.exec(); 0135 }