MythTV master
upnptasknotify.h
Go to the documentation of this file.
1
2// Program Name: upnptasknotify.h
3// Created : Oct. 24, 2005
4//
5// Purpose : UPnp Task to send Notification messages
6//
7// Copyright (c) 2005 David Blain <dblain@mythtv.org>
8//
9// Licensed under the GPL v2 or later, see LICENSE for details
10//
12#ifndef UPNPTASKNOTIFY_H
13#define UPNPTASKNOTIFY_H
14
15#include <chrono>
16#include <cstdint>
17
18// Qt headers
19#include <QString>
20#include <QMutex>
21#include <QUdpSocket>
22
23#include "taskqueue.h"
24#include "upnpdevice.h"
25
26enum UPnpNotifyNTS : std::uint8_t
27{
29 NTS_byebye = 1
30};
31
32class UPnpNotifyTask : public Task
33{
34 protected:
35 QMutex m_mutex;
36
37 QString m_sMasterIP;
39 std::chrono::seconds m_nMaxAge {1h};
40
42
43 // Destructor protected to force use of Release Method
44 ~UPnpNotifyTask() override = default;
45
46 void ProcessDevice(QUdpSocket& socket, const UPnpDevice& device);
47 void SendNotifyMsg(QUdpSocket& socket, const QString& sNT, const QString& sUDN);
48
49 public:
50 explicit UPnpNotifyTask( int nServicePort );
51
52 QString Name() override { return( "Notify" ); } // Task
53 void Execute( TaskQueue *pQueue ) override; // Task
54
55 QString GetNTSString()
56 {
57 m_mutex.lock();
59 m_mutex.unlock();
60
61 switch( nts )
62 {
63 case NTS_alive : return( "ssdp:alive" );
64 case NTS_byebye: return( "ssdp:byebye" );
65 }
66 return( "unknown" );
67 }
68
70 {
71 m_mutex.lock();
73 m_mutex.unlock();
74
75 return( nts );
76 }
77
79 {
80 m_mutex.lock();
81 m_eNTS = nts;
82 m_mutex.unlock();
83 }
84};
85
86#endif // UPNPTASKNOTIFY_H
Definition: taskqueue.h:48
~UPnpNotifyTask() override=default
QString GetNTSString()
std::chrono::seconds m_nMaxAge
UPnpNotifyNTS GetNTS()
UPnpNotifyTask(int nServicePort)
void ProcessDevice(QUdpSocket &socket, const UPnpDevice &device)
void SendNotifyMsg(QUdpSocket &socket, const QString &sNT, const QString &sUDN)
QString m_sMasterIP
void SetNTS(UPnpNotifyNTS nts)
void Execute(TaskQueue *pQueue) override
UPnpNotifyNTS m_eNTS
QString Name() override
UPnpNotifyNTS
@ NTS_alive
@ NTS_byebye