File indexing completed on 2024-04-14 15:49:37

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #include "kupdaemon.h"
0006 #include "kupdaemon_debug.h"
0007 
0008 #include <KAboutData>
0009 #include <KDBusService>
0010 #include <KLocalizedString>
0011 
0012 #include <QApplication>
0013 #include <QCommandLineParser>
0014 
0015 int main(int argc, char *argv[]) {
0016     QApplication lApp(argc, argv);
0017     QApplication::setQuitOnLastWindowClosed(false);
0018     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0019 
0020     KLocalizedString::setApplicationDomain("kup");
0021 
0022     qCDebug(KUPDAEMON) << "Running Kup daemon...";
0023 
0024     auto *lDaemon = new KupDaemon();
0025     if(!lDaemon->shouldStart()) {
0026         qCCritical(KUPDAEMON) << xi18nc("@info:shell Error message at startup",
0027                                         "Kup is not enabled, enable it from the "
0028                                         "system settings module. You can do that by running "
0029                                         "<command>kcmshell5 kup</command>");
0030         return 0;
0031     }
0032 
0033     KAboutData lAbout(QStringLiteral("kupdaemon"), xi18nc("@title", "Kup Daemon"), QStringLiteral("0.9.1"),
0034                       i18n("Kup is a flexible backup solution using the backup storage system 'bup'. "
0035                            "This allows it to quickly perform incremental backups, only saving the "
0036                            "parts of files that has actually changed since last backup was saved."),
0037                       KAboutLicense::GPL, i18n("Copyright (C) 2011-2020 Simon Persson"));
0038     lAbout.addAuthor(i18n("Simon Persson"), i18n("Maintainer"), "simon.persson@mykolab.com");
0039     lAbout.setTranslator(xi18nc("NAME OF TRANSLATORS", "Your names"), xi18nc("EMAIL OF TRANSLATORS", "Your emails"));
0040     KAboutData::setApplicationData(lAbout);
0041 
0042     QCommandLineParser lParser;
0043     lAbout.setupCommandLine(&lParser);
0044     lParser.process(lApp);
0045     lAbout.processCommandLine(&lParser);
0046 
0047     // This call will exit() if an instance is already running
0048     KDBusService lService(KDBusService::Unique);
0049 
0050     lDaemon->setupGuiStuff();
0051     KupDaemon::connect(&lApp, &QApplication::commitDataRequest, lDaemon, [lDaemon](QSessionManager &pManager) {
0052         lDaemon->slotShutdownRequest(pManager);
0053     });
0054 
0055     return QApplication::exec();
0056 }