| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 2012 Dawit Alemayehu <adawit@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-only |
| 6 | */ |
| 7 | |
| 8 | #ifndef USERNOTIFICATIONHANDLER_P_H |
| 9 | #define USERNOTIFICATIONHANDLER_P_H |
| 10 | |
| 11 | #include <QCache> |
| 12 | #include <QHash> |
| 13 | #include <QObject> |
| 14 | #include <QPointer> |
| 15 | #include <QVariant> |
| 16 | |
| 17 | namespace KIO |
| 18 | { |
| 19 | class Worker; |
| 20 | class WorkerInterface; |
| 21 | |
| 22 | class UserNotificationHandler : public QObject |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | public: |
| 26 | enum MessageBoxDataType { |
| 27 | MSG_TEXT, |
| 28 | MSG_TITLE, |
| 29 | MSG_PRIMARYACTION_TEXT, |
| 30 | MSG_SECONDARYACTION_TEXT, |
| 31 | MSG_PRIMARYACTION_ICON, |
| 32 | MSG_SECONDARYACTION_ICON, |
| 33 | MSG_DONT_ASK_AGAIN, |
| 34 | MSG_DETAILS, |
| 35 | MSG_META_DATA, |
| 36 | }; |
| 37 | |
| 38 | class Request |
| 39 | { |
| 40 | public: |
| 41 | QString key() const; |
| 42 | |
| 43 | int type; |
| 44 | QPointer<Worker> worker; |
| 45 | QHash<MessageBoxDataType, QVariant> data; |
| 46 | }; |
| 47 | |
| 48 | explicit UserNotificationHandler(QObject *parent = nullptr); |
| 49 | ~UserNotificationHandler() override; |
| 50 | |
| 51 | void requestMessageBox(WorkerInterface *iface, int type, const QHash<MessageBoxDataType, QVariant> &data); |
| 52 | |
| 53 | void sslError(WorkerInterface *iface, const QVariantMap &sslErrorData); |
| 54 | |
| 55 | private Q_SLOTS: |
| 56 | void processRequest(); |
| 57 | void slotProcessRequest(int result); |
| 58 | |
| 59 | private: |
| 60 | QCache<QString, int> m_cachedResults; |
| 61 | QList<Request *> m_pendingRequests; |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | #endif |
| 66 | |