1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2015 by Mathieu Tarral <mathieu.tarral@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dbusinterface.h"
23 #include "dolphin_generalsettings.h"
24 #include "dolphin_version.h"
25 #include "dolphindebug.h"
26 #include "dolphinmainwindow.h"
31 #include <KDBusService>
32 #include <KLocalizedString>
33 #include <Kdelibs4ConfigMigrator>
35 #include <QApplication>
36 #include <QCommandLineParser>
43 extern "C" Q_DECL_EXPORT
int kdemain(int argc
, char **argv
)
46 // Prohibit using sudo or kdesu (but allow using the root user directly)
48 if (!qEnvironmentVariableIsEmpty("SUDO_USER")) {
49 std::cout
<< "Executing Dolphin with sudo is not possible due to unfixable security vulnerabilities." << std::endl
;
51 } else if (!qEnvironmentVariableIsEmpty("KDESU_USER")) {
52 std::cout
<< "Executing Dolphin with kdesu is not possible due to unfixable security vulnerabilities." << std::endl
;
58 QApplication
app(argc
, argv
);
59 app
.setAttribute(Qt::AA_UseHighDpiPixmaps
, true);
60 app
.setWindowIcon(QIcon::fromTheme(QStringLiteral("system-file-manager"), app
.windowIcon()));
64 Kdelibs4ConfigMigrator
migrate(QStringLiteral("dolphin"));
65 migrate
.setConfigFiles(QStringList() << QStringLiteral("dolphinrc"));
66 migrate
.setUiFiles(QStringList() << QStringLiteral("dolphinpart.rc") << QStringLiteral("dolphinui.rc"));
69 KLocalizedString::setApplicationDomain("dolphin");
71 KAboutData
aboutData(QStringLiteral("dolphin"), i18n("Dolphin"), QStringLiteral(DOLPHIN_VERSION_STRING
),
72 i18nc("@title", "File Manager"),
74 i18nc("@info:credit", "(C) 2006-2018 Peter Penz, Frank Reininghaus, Emmanuel Pescosta and Elvis Angelaccio"));
75 aboutData
.setHomepage(QStringLiteral("http://dolphin.kde.org"));
76 aboutData
.addAuthor(i18nc("@info:credit", "Elvis Angelaccio"),
77 i18nc("@info:credit", "Maintainer (since 2018) and developer"),
78 QStringLiteral("elvis.angelaccio@kde.org"));
79 aboutData
.addAuthor(i18nc("@info:credit", "Emmanuel Pescosta"),
80 i18nc("@info:credit", "Maintainer (2014-2018) and developer"),
81 QStringLiteral("emmanuelpescosta099@gmail.com"));
82 aboutData
.addAuthor(i18nc("@info:credit", "Frank Reininghaus"),
83 i18nc("@info:credit", "Maintainer (2012-2014) and developer"),
84 QStringLiteral("frank78ac@googlemail.com"));
85 aboutData
.addAuthor(i18nc("@info:credit", "Peter Penz"),
86 i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
87 QStringLiteral("peter.penz19@gmail.com"));
88 aboutData
.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
89 i18nc("@info:credit", "Developer"),
90 QStringLiteral("trueg@kde.org"));
91 aboutData
.addAuthor(i18nc("@info:credit", "David Faure"),
92 i18nc("@info:credit", "Developer"),
93 QStringLiteral("faure@kde.org"));
94 aboutData
.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
95 i18nc("@info:credit", "Developer"),
96 QStringLiteral("aseigo@kde.org"));
97 aboutData
.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
98 i18nc("@info:credit", "Developer"),
99 QStringLiteral("ereslibre@kde.org"));
100 aboutData
.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
101 i18nc("@info:credit", "Developer"),
102 QStringLiteral("ervin@kde.org"));
103 aboutData
.addAuthor(i18nc("@info:credit", "Holger Freyther"),
104 i18nc("@info:credit", "Developer"),
105 QStringLiteral("freyther@gmx.net"));
106 aboutData
.addAuthor(i18nc("@info:credit", "Max Blazejak"),
107 i18nc("@info:credit", "Developer"),
108 QStringLiteral("m43ksrocks@gmail.com"));
109 aboutData
.addAuthor(i18nc("@info:credit", "Michael Austin"),
110 i18nc("@info:credit", "Documentation"),
111 QStringLiteral("tuxedup@users.sourceforge.net"));
113 KAboutData::setApplicationData(aboutData
);
115 KDBusService dolphinDBusService
;
116 DBusInterface interface
;
118 QCommandLineParser parser
;
119 aboutData
.setupCommandLine(&parser
);
121 // command line options
122 parser
.addOption(QCommandLineOption(QStringList() << QStringLiteral("select"), i18nc("@info:shell", "The files and folders passed as arguments "
123 "will be selected.")));
124 parser
.addOption(QCommandLineOption(QStringList() << QStringLiteral("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
125 parser
.addOption(QCommandLineOption(QStringList() << QStringLiteral("daemon"), i18nc("@info:shell", "Start Dolphin Daemon (only required for DBus Interface)")));
126 parser
.addPositionalArgument(QStringLiteral("+[Url]"), i18nc("@info:shell", "Document to open"));
129 aboutData
.processCommandLine(&parser
);
131 if (parser
.isSet(QStringLiteral("daemon"))) {
135 const QStringList args
= parser
.positionalArguments();
136 QList
<QUrl
> urls
= Dolphin::validateUris(args
);
138 if (urls
.isEmpty()) {
139 // We need at least one URL to open Dolphin
140 urls
.append(Dolphin::homeUrl());
143 const bool splitView
= parser
.isSet(QStringLiteral("split")) || GeneralSettings::splitView();
144 if (splitView
&& urls
.size() < 2) {
145 // Split view does only make sense if we have at least 2 URLs
146 urls
.append(urls
.last());
149 DolphinMainWindow
* mainWindow
= new DolphinMainWindow();
151 if (parser
.isSet(QStringLiteral("select"))) {
152 mainWindow
->openFiles(urls
, splitView
);
154 mainWindow
->openDirectories(urls
, splitView
);
159 if (app
.isSessionRestored()) {
160 const QString className
= KXmlGuiWindow::classNameOfToplevel(1);
161 if (className
== QLatin1String("DolphinMainWindow")) {
162 mainWindow
->restore(1);
164 qCWarning(DolphinDebug
) << "Unknown class " << className
<< " in session saved data!";
168 return app
.exec(); // krazy:exclude=crash;