File indexing completed on 2025-01-19 03:56:07
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2022-08-31 0007 * Description : digiKam global static QNetworkAccessManager 0008 * 0009 * SPDX-FileCopyrightText: 2022 by Maik Qualmann <metzpinguin at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_NETWORK_MANAGER_H 0016 #define DIGIKAM_NETWORK_MANAGER_H 0017 0018 // Qt includes 0019 0020 #include <QObject> 0021 #include <QNetworkAccessManager> 0022 0023 // Local includes 0024 0025 #include "digikam_export.h" 0026 0027 namespace Digikam 0028 { 0029 0030 class DIGIKAM_EXPORT NetworkManager : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 0036 /** 0037 * Global instance of internal network manager. 0038 * All accessor methods are thread-safe. 0039 */ 0040 static NetworkManager* instance(); 0041 0042 /** 0043 * Get the current QNetworkAccessManager or create 0044 * a new QNetworkAccessManager if the passed 0045 * QObject runs on a different thread. 0046 */ 0047 QNetworkAccessManager* getNetworkManager(QObject* const object) const; 0048 0049 private: 0050 0051 // Disable 0052 0053 NetworkManager(); 0054 explicit NetworkManager(QObject*) = delete; 0055 0056 ~NetworkManager() override; 0057 0058 private: 0059 0060 class Private; 0061 Private* const d; 0062 0063 friend class NetworkManagerCreator; 0064 }; 0065 0066 } // namespace Digikam 0067 0068 #endif // DIGIKAM_NETWORK_MANAGER_H