MythTV
master
libs
libmythupnp
servicehost.h
Go to the documentation of this file.
1
// Program Name: servicehost.h
3
// Created : Jan. 19, 2010
4
//
5
// Purpose : Service Host Abstract Class
6
//
7
// Copyright (c) 2010 David Blain <dblain@mythtv.org>
8
//
9
// Licensed under the GPL v2 or later, see LICENSE for details
10
//
12
13
#ifndef SERVICEHOST_H_
14
#define SERVICEHOST_H_
15
16
#include <QMetaObject>
17
#include <QMetaMethod>
18
#include <QMap>
19
20
#include "
libmythservicecontracts/service.h
"
21
22
#include "
libmythupnp/upnpexp.h
"
23
#include "
libmythupnp/upnp.h
"
24
#include "
libmythupnp/eventing.h
"
25
28
//
29
//
30
//
33
34
class
UPNP_PUBLIC
MethodInfo
35
{
36
public
:
37
38
int
m_nMethodIndex {0};
39
QString
m_sName
;
40
QMetaMethod
m_oMethod
;
41
HttpRequestType
m_eRequestType {(
HttpRequestType
)(
RequestTypeGet
|
42
RequestTypePost
|
43
RequestTypeHead
)};
44
45
public
:
46
MethodInfo
() =
default
;
47
48
QVariant Invoke(
Service
*pService,
const
QStringMap
&reqParams )
const
;
49
};
50
51
using
MetaInfoMap
= QMap< QString, MethodInfo >;
52
55
//
56
// ServiceHost is used for Standard Web Services Only
57
//
58
// (It does NOT expose anything as upnp devices/services)
59
//
62
63
class
UPNP_PUBLIC
ServiceHost
:
public
HttpServerExtension
64
{
65
protected
:
66
67
QString
m_sBaseUrl
;
68
69
QMetaObject m_oMetaObject {};
70
MetaInfoMap
m_methods
;
71
72
protected
:
73
74
virtual
bool
FormatResponse(
HTTPRequest
*pRequest, QObject *pResults );
75
virtual
bool
FormatResponse(
HTTPRequest
*pRequest,
const
QFileInfo& oInfo );
76
virtual
bool
FormatResponse(
HTTPRequest
*pRequest,
const
QVariant& vValue );
77
78
public
:
79
80
ServiceHost
(
const
QMetaObject &metaObject,
81
const
QString &sExtensionName,
82
QString sBaseUrl,
83
const
QString &sSharePath );
84
~
ServiceHost
()
override
=
default
;
85
86
QStringList
GetBasePaths
()
override
;
// HttpServerExtension
87
88
bool
ProcessRequest
(
HTTPRequest
*pRequest )
override
;
// HttpServerExtension
89
90
virtual
QString
GetServiceControlURL
() {
return
m_sBaseUrl.mid( 1 ); }
91
92
const
QMetaObject&
GetServiceMetaObject
() {
return
m_oMetaObject; }
93
const
MetaInfoMap
&
GetMethods
() {
return
m_methods; }
94
95
};
96
97
#endif
HTTPRequest
Definition:
httprequest.h:109
MetaInfoMap
QMap< QString, MethodInfo > MetaInfoMap
Definition:
servicehost.h:51
service.h
ServiceHost::m_methods
MetaInfoMap m_methods
Definition:
servicehost.h:70
RequestTypePost
@ RequestTypePost
Definition:
httprequest.h:50
ServiceHost::GetServiceControlURL
virtual QString GetServiceControlURL()
Definition:
servicehost.h:90
ServiceHost
Definition:
servicehost.h:63
eventing.h
upnp.h
Service
Definition:
service.h:42
QStringMap
QMap< QString, QString > QStringMap
Definition:
upnputil.h:32
RequestTypeHead
@ RequestTypeHead
Definition:
httprequest.h:49
ServiceHost::m_sBaseUrl
QString m_sBaseUrl
Definition:
servicehost.h:67
MethodInfo
Definition:
servicehost.h:34
HttpServerExtension::ProcessRequest
virtual bool ProcessRequest(HTTPRequest *pRequest)=0
HttpServerExtension::GetBasePaths
virtual QStringList GetBasePaths()=0
MethodInfo::m_oMethod
QMetaMethod m_oMethod
Definition:
servicehost.h:40
ServiceHost::GetServiceMetaObject
const QMetaObject & GetServiceMetaObject()
Definition:
servicehost.h:92
UPNP_PUBLIC
#define UPNP_PUBLIC
Definition:
upnpexp.h:9
ServiceHost::GetMethods
const MetaInfoMap & GetMethods()
Definition:
servicehost.h:93
RequestTypeGet
@ RequestTypeGet
Definition:
httprequest.h:48
HttpServerExtension
Definition:
httpserver.h:71
MethodInfo::m_sName
QString m_sName
Definition:
servicehost.h:39
HttpRequestType
HttpRequestType
Definition:
httprequest.h:44
upnpexp.h
Generated on Wed Sep 6 2023 03:18:35 for MythTV by
1.8.17