MythTV  master
upnp.h
Go to the documentation of this file.
1 // Program Name: upnp.h
3 // Created : Oct. 24, 2005
4 //
5 // Purpose : UPnp Main Class
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 
13 #ifndef UPNP_H
14 #define UPNP_H
15 
16 // Qt
17 #include <QObject>
18 
19 // MythTV
20 #include "mythpower.h"
21 
23 //
25 
26 #include "upnpdevice.h"
27 #include "taskqueue.h"
28 #include "httpserver.h"
29 #include "ssdp.h"
30 
32 //
34 
36 {
38 
55 
75 
83 
85 
88 };
89 
92 //
93 //
94 //
97 
98 class UPNP_PUBLIC UPnp : public QObject
99 {
100  Q_OBJECT
101 
102  protected:
103 
104  HttpServer *m_pHttpServer {nullptr};
105  int m_nServicePort {0};
106 
107  public:
108 
110  static QList<QHostAddress> g_IPAddrList;
111 
112  public:
113  UPnp();
114  ~UPnp() override;
115 
116  bool Initialize( int nServicePort, HttpServer *pHttpServer );
117  bool Initialize( QList<QHostAddress> &sIPAddrList, int nServicePort,
118  HttpServer *pHttpServer );
119 
120  bool isInitialized() { return (m_pHttpServer != nullptr); }
121 
122  virtual void Start();
123 
124  static void CleanUp ();
125 
126  static UPnpDevice *RootDevice() { return &(g_UPnpDeviceDesc.m_rootDevice); }
127 
128  HttpServer *GetHttpServer() { return m_pHttpServer; }
129 
130  static UPnpDeviceDesc *GetDeviceDesc( QString &sURL );
131 
132  static QString GetResultDesc( UPnPResultCode eCode );
133  static void FormatErrorResponse( HTTPRequest *pRequest,
134  UPnPResultCode eCode,
135  const QString &sMsg = "" );
136 
137  static void FormatRedirectResponse( HTTPRequest *pRequest,
138  const QString &hostName );
139 
140  public slots:
141  static void DisableNotifications(std::chrono::milliseconds /*unused*/);
142  void EnableNotificatins(std::chrono::milliseconds /*unused*/) const;
143 
144  private:
146 };
147 
148 #endif // UPNP_H
UPnPResult_CDS_RequiredTag
@ UPnPResult_CDS_RequiredTag
Definition: upnp.h:59
UPnPResult_MythTV_NoNamespaceGiven
@ UPnPResult_MythTV_NoNamespaceGiven
Definition: upnp.h:86
UPnPResult_InvalidArgs
@ UPnPResult_InvalidArgs
Definition: upnp.h:40
UPnPResult_CMGR_NotInNetwork
@ UPnPResult_CMGR_NotInNetwork
Definition: upnp.h:82
HTTPRequest
Definition: httprequest.h:108
UPnPResult_CDS_InvalidSearchCriteria
@ UPnPResult_CDS_InvalidSearchCriteria
Definition: upnp.h:62
upnpdevice.h
MythPower
Definition: mythpower.h:23
UPnPResult_CDS_BadMetadata
@ UPnPResult_CDS_BadMetadata
Definition: upnp.h:66
ssdp.h
UPnPResult_CMGR_IncompatibleProtocol
@ UPnPResult_CMGR_IncompatibleProtocol
Definition: upnp.h:76
UPnPResult_ArgumentValueOutOfRange
@ UPnPResult_ArgumentValueOutOfRange
Definition: upnp.h:43
UPnpDeviceDesc
Definition: upnpdevice.h:150
UPnPResult_CDS_NoSuchDestRes
@ UPnPResult_CDS_NoSuchDestRes
Definition: upnp.h:72
UPnp::GetHttpServer
HttpServer * GetHttpServer()
Definition: upnp.h:128
UPnPResult_OutOfMemory
@ UPnPResult_OutOfMemory
Definition: upnp.h:45
UPnPResult_CMGR_InsufficientNetResources
@ UPnPResult_CMGR_InsufficientNetResources
Definition: upnp.h:78
UPnPResult_CDS_TransferBusy
@ UPnPResult_CDS_TransferBusy
Definition: upnp.h:70
UPnPResult_SignatureMissing
@ UPnPResult_SignatureMissing
Definition: upnp.h:50
UPnPResult_HumanInterventionRequired
@ UPnPResult_HumanInterventionRequired
Definition: upnp.h:46
UPnp::m_power
MythPower * m_power
Definition: upnp.h:145
UPnpDeviceDesc::m_rootDevice
UPnpDevice m_rootDevice
Definition: upnpdevice.h:154
UPnPResult_NoSuchSession
@ UPnPResult_NoSuchSession
Definition: upnp.h:54
UPnPResult_CDS_NoSuchFileTransfer
@ UPnPResult_CDS_NoSuchFileTransfer
Definition: upnp.h:71
UPnPResult_CDS_NoSuchSourceResource
@ UPnPResult_CDS_NoSuchSourceResource
Definition: upnp.h:68
UPnPResult_OptionalActionNotImplemented
@ UPnPResult_OptionalActionNotImplemented
Definition: upnp.h:44
UPnPResult_CMGR_IncompatibleDirections
@ UPnPResult_CMGR_IncompatibleDirections
Definition: upnp.h:77
UPnp::isInitialized
bool isInitialized()
Definition: upnp.h:120
UPnPResult_CDS_CannotProcessRequest
@ UPnPResult_CDS_CannotProcessRequest
Definition: upnp.h:74
UPnPResult_CDS_InvalidCurrentTagValue
@ UPnPResult_CDS_InvalidCurrentTagValue
Definition: upnp.h:57
UPnPResult_NotEncrypted
@ UPnPResult_NotEncrypted
Definition: upnp.h:51
UPnpDevice
Definition: upnpdevice.h:101
UPnPResult_SignatureFailure
@ UPnPResult_SignatureFailure
Definition: upnp.h:49
UPnPResult_MythTV_XmlParseError
@ UPnPResult_MythTV_XmlParseError
Definition: upnp.h:87
UPnPResult_CDS_InvalidNewTagValue
@ UPnPResult_CDS_InvalidNewTagValue
Definition: upnp.h:58
UPnPResult_ActionNotAuthorized
@ UPnPResult_ActionNotAuthorized
Definition: upnp.h:48
UPnPResult_CMGR_LocalRestrictions
@ UPnPResult_CMGR_LocalRestrictions
Definition: upnp.h:79
UPnPResult_CDS_NoSuchContainer
@ UPnPResult_CDS_NoSuchContainer
Definition: upnp.h:64
UPnPResult_ActionFailed
@ UPnPResult_ActionFailed
Definition: upnp.h:41
UPnPResult_CMGR_InvalidConnectionRef
@ UPnPResult_CMGR_InvalidConnectionRef
Definition: upnp.h:81
taskqueue.h
UPnPResult_InvalidAction
@ UPnPResult_InvalidAction
Definition: upnp.h:39
UPnPResult_CDS_ParameterMismatch
@ UPnPResult_CDS_ParameterMismatch
Definition: upnp.h:61
UPnp::RootDevice
static UPnpDevice * RootDevice()
Definition: upnp.h:126
UPnPResult_CDS_RestrictedObject
@ UPnPResult_CDS_RestrictedObject
Definition: upnp.h:65
UPnPResult_CMGR_AccessDenied
@ UPnPResult_CMGR_AccessDenied
Definition: upnp.h:80
UPnp
Definition: upnp.h:98
UPnPResult_CDS_InvalidSortCriteria
@ UPnPResult_CDS_InvalidSortCriteria
Definition: upnp.h:63
UPnPResult_CDS_ReadOnlyTag
@ UPnPResult_CDS_ReadOnlyTag
Definition: upnp.h:60
UPnPResult_CDS_ResrtictedParentObject
@ UPnPResult_CDS_ResrtictedParentObject
Definition: upnp.h:67
UPnPResult_CDS_NoSuchObject
@ UPnPResult_CDS_NoSuchObject
Definition: upnp.h:56
UPnPResult_StringArgumentTooLong
@ UPnPResult_StringArgumentTooLong
Definition: upnp.h:47
UPNP_PUBLIC
#define UPNP_PUBLIC
Definition: upnpexp.h:9
HttpServer
Definition: httpserver.h:109
UPnPResult_ArgumentValueInvalid
@ UPnPResult_ArgumentValueInvalid
Definition: upnp.h:42
UPnPResult_InvalidControlURL
@ UPnPResult_InvalidControlURL
Definition: upnp.h:53
UPnPResult_CDS_ResourceAccessDenied
@ UPnPResult_CDS_ResourceAccessDenied
Definition: upnp.h:69
UPnPResult_InvalidSequence
@ UPnPResult_InvalidSequence
Definition: upnp.h:52
httpserver.h
UPnPResult_Success
@ UPnPResult_Success
Definition: upnp.h:37
mythpower.h
UPnPResult_MS_AccessDenied
@ UPnPResult_MS_AccessDenied
Definition: upnp.h:84
UPnp::g_UPnpDeviceDesc
static UPnpDeviceDesc g_UPnpDeviceDesc
Definition: upnp.h:109
UPnp::g_IPAddrList
static QList< QHostAddress > g_IPAddrList
Definition: upnp.h:110
UPnPResult_CDS_DestResAccessDenied
@ UPnPResult_CDS_DestResAccessDenied
Definition: upnp.h:73
UPnPResultCode
UPnPResultCode
Definition: upnp.h:35