File indexing completed on 2024-09-15 12:00:27
0001 /* 0002 SPDX-FileCopyrightText: 2003 Malte Starostik <malte@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPAC_PROXYSCOUT_H 0008 #define KPAC_PROXYSCOUT_H 0009 0010 #include <KDEDModule> 0011 0012 #include <QDBusMessage> 0013 #include <QMap> 0014 #include <QUrl> 0015 0016 class QFileSystemWatcher; 0017 0018 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 0019 #include <QNetworkInformation> 0020 #else 0021 class QNetworkConfiguration; 0022 class QNetworkConfigurationManager; 0023 #endif 0024 0025 namespace KPAC 0026 { 0027 class Downloader; 0028 class Script; 0029 0030 class ProxyScout : public KDEDModule 0031 { 0032 Q_OBJECT 0033 Q_CLASSINFO("D-Bus Interface", "org.kde.KPAC.ProxyScout") 0034 public: 0035 ProxyScout(QObject *parent, const QList<QVariant> &); 0036 ~ProxyScout() override; 0037 0038 public Q_SLOTS: 0039 Q_SCRIPTABLE QString proxyForUrl(const QString &checkUrl, const QDBusMessage &); 0040 Q_SCRIPTABLE QStringList proxiesForUrl(const QString &checkUrl, const QDBusMessage &); 0041 Q_SCRIPTABLE Q_NOREPLY void blackListProxy(const QString &proxy); 0042 Q_SCRIPTABLE Q_NOREPLY void reset(); 0043 0044 private Q_SLOTS: 0045 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 0046 void disconnectNetwork(QNetworkInformation::Reachability newReachability); 0047 #else 0048 void disconnectNetwork(const QNetworkConfiguration &config); 0049 #endif 0050 0051 void downloadResult(bool); 0052 void proxyScriptFileChanged(const QString &); 0053 0054 private: 0055 bool startDownload(); 0056 QStringList handleRequest(const QUrl &url); 0057 0058 QString m_componentName; 0059 Downloader *m_downloader; 0060 Script *m_script; 0061 0062 struct QueuedRequest { 0063 QueuedRequest() 0064 { 0065 } 0066 QueuedRequest(const QDBusMessage &, const QUrl &, bool sendall = false); 0067 0068 QDBusMessage transaction; 0069 QUrl url; 0070 bool sendAll; 0071 }; 0072 typedef QList<QueuedRequest> RequestQueue; 0073 RequestQueue m_requestQueue; 0074 0075 typedef QMap<QString, qint64> BlackList; 0076 BlackList m_blackList; 0077 qint64 m_suspendTime; 0078 QFileSystemWatcher *m_watcher; 0079 0080 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0081 QNetworkConfigurationManager *m_networkConfig; 0082 #endif 0083 }; 0084 } 0085 0086 #endif // KPAC_PROXYSCOUT_H