File indexing completed on 2024-04-28 04:44:21

0001 /*
0002    SPDX-FileCopyrightText: 2015 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
0003 
0004    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef UPNPCONTROLABSTRACTSERVICE_H
0008 #define UPNPCONTROLABSTRACTSERVICE_H
0009 
0010 #include "upnplibqt_export.h"
0011 
0012 #include "upnpabstractservice.h"
0013 #include "upnpcontrolabstractservicereply.h"
0014 
0015 #include <QObject>
0016 #include <QString>
0017 #include <QUrl>
0018 #include <QVariant>
0019 #include <QVariantList>
0020 
0021 #include <memory>
0022 
0023 class UpnpAbstractServiceDescriptionPrivate;
0024 class QNetworkReply;
0025 class QHostInfo;
0026 
0027 /**
0028  * @brief The UpnpControlAbstractService class is the base class with infrastructure needed to call actions on UPnP services (i.e. control of the service)
0029  */
0030 class UPNPLIBQT_EXPORT UpnpControlAbstractService : public UpnpAbstractService
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     explicit UpnpControlAbstractService(QObject *parent = nullptr);
0036 
0037     ~UpnpControlAbstractService() override;
0038 
0039     [[nodiscard]] UpnpControlAbstractServiceReply *callAction(const QString &action, const QMap<QString, QVariant> &arguments);
0040 
0041     void subscribeEvents(int duration);
0042 
0043     void handleEventNotification(const QByteArray &requestData, const QMap<QByteArray, QByteArray> &headers);
0044 
0045 Q_SIGNALS:
0046 
0047 public Q_SLOTS:
0048 
0049     void downloadServiceDescription(const QUrl &serviceUrl);
0050 
0051 private Q_SLOTS:
0052 
0053     void finishedDownload(QNetworkReply *reply);
0054 
0055     void eventSubscriptionTimeout();
0056 
0057 protected:
0058     virtual void parseServiceDescription(QIODevice *serviceDescriptionContent);
0059 
0060     virtual void parseEventNotification(const QString &eventName, const QString &eventValue);
0061 
0062 private:
0063     std::unique_ptr<UpnpAbstractServiceDescriptionPrivate> d;
0064 };
0065 
0066 #endif // UPNPSERVICECALLER_H