File indexing completed on 2024-04-21 04:56:46

0001 /*
0002  * SPDX-FileCopyrightText: 2019 Weixuan XIAO <veyx.shaw@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef INDICATORHELPER_H
0008 #define INDICATORHELPER_H
0009 
0010 #include <QProcess>
0011 #include <QSplashScreen>
0012 
0013 #ifdef Q_OS_WIN
0014 #include <QSystemTrayIcon>
0015 #else
0016 #include <KStatusNotifierItem>
0017 #endif
0018 
0019 #ifdef Q_OS_WIN
0020 #include <QUrl>
0021 namespace processes
0022 {
0023 const QString dbus_daemon = QStringLiteral("dbus-daemon.exe");
0024 const QString kdeconnect_daemon = QStringLiteral("kdeconnectd.exe");
0025 const QString kdeconnect_app = QStringLiteral("kdeconnect-app.exe");
0026 const QString kdeconnect_handler = QStringLiteral("kdeconnect-handler.exe");
0027 const QString kdeconnect_settings = QStringLiteral("kdeconnect-settings.exe");
0028 const QString kdeconnect_sms = QStringLiteral("kdeconnect-sms.exe");
0029 };
0030 #endif
0031 
0032 class IndicatorHelper
0033 {
0034 public:
0035 #ifdef Q_OS_WIN
0036     IndicatorHelper(const QUrl &indicatorUrl);
0037 #else
0038     IndicatorHelper();
0039 #endif
0040     ~IndicatorHelper();
0041 
0042     void preInit();
0043     void postInit();
0044 
0045     void iconPathHook();
0046 
0047     int daemonHook(QProcess &kdeconnectd);
0048 
0049 #ifdef Q_OS_WIN
0050     void systrayIconHook(QSystemTrayIcon &systray);
0051 #else
0052     void systrayIconHook(KStatusNotifierItem &systray);
0053 #endif
0054 
0055 private:
0056 #ifdef Q_OS_MAC
0057     QSplashScreen *m_splashScreen;
0058 #endif
0059 
0060 #ifdef Q_OS_WIN
0061     /**
0062      * Terminate processes of KDE Connect like kdeconnectd.exe and dbus-daemon.exe
0063      *
0064      * @return True if termination was successful, false otherwise
0065      */
0066 
0067     bool terminateProcess(const QString &processName, const QUrl &indicatorUrl) const;
0068     QUrl m_indicatorUrl;
0069 #endif
0070 };
0071 
0072 #endif