File indexing completed on 2024-04-21 03:55:14

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2012 Dawit Alemayehu <adawit@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #ifndef USERNOTIFICATIONHANDLER_P_H
0009 #define USERNOTIFICATIONHANDLER_P_H
0010 
0011 #include <QCache>
0012 #include <QHash>
0013 #include <QObject>
0014 #include <QPointer>
0015 #include <QVariant>
0016 
0017 namespace KIO
0018 {
0019 class Worker;
0020 class WorkerInterface;
0021 
0022 class UserNotificationHandler : public QObject
0023 {
0024     Q_OBJECT
0025 public:
0026     enum MessageBoxDataType {
0027         MSG_TEXT,
0028         MSG_TITLE,
0029         MSG_PRIMARYACTION_TEXT,
0030         MSG_SECONDARYACTION_TEXT,
0031         MSG_PRIMARYACTION_ICON,
0032         MSG_SECONDARYACTION_ICON,
0033         MSG_DONT_ASK_AGAIN,
0034         MSG_DETAILS,
0035         MSG_META_DATA,
0036     };
0037 
0038     class Request
0039     {
0040     public:
0041         QString key() const;
0042 
0043         int type;
0044         QPointer<Worker> worker;
0045         QHash<MessageBoxDataType, QVariant> data;
0046     };
0047 
0048     explicit UserNotificationHandler(QObject *parent = nullptr);
0049     ~UserNotificationHandler() override;
0050 
0051     void requestMessageBox(WorkerInterface *iface, int type, const QHash<MessageBoxDataType, QVariant> &data);
0052 
0053     void sslError(WorkerInterface *iface, const QVariantMap &sslErrorData);
0054 
0055 private Q_SLOTS:
0056     void processRequest();
0057     void slotProcessRequest(int result);
0058 
0059 private:
0060     QCache<QString, int> m_cachedResults;
0061     QList<Request *> m_pendingRequests;
0062 };
0063 }
0064 
0065 #endif