MythTV master
servicehost.h
Go to the documentation of this file.
1
2// 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#include <QString>
20#include <QVariant>
21
23
26
29//
30//
31//
34
36{
37 public:
38
40 QString m_sName;
41 QMetaMethod m_oMethod;
45
46 public:
47 MethodInfo() = default;
48
49 QVariant Invoke( Service *pService, const QStringMap &reqParams ) const;
50};
51
52using MetaInfoMap = QMap< QString, MethodInfo >;
53
56//
57// ServiceHost is used for Standard Web Services Only
58//
59// (It does NOT expose anything as upnp devices/services)
60//
63
65{
66 protected:
67
68 QString m_sBaseUrl;
69
70 QMetaObject m_oMetaObject {};
72
73 protected:
74
75 virtual bool FormatResponse( HTTPRequest *pRequest, QObject *pResults );
76 virtual bool FormatResponse( HTTPRequest *pRequest, const QFileInfo& oInfo );
77 virtual bool FormatResponse( HTTPRequest *pRequest, const QVariant& vValue );
78
79 public:
80
81 ServiceHost( const QMetaObject &metaObject,
82 const QString &sExtensionName,
83 QString sBaseUrl,
84 const QString &sSharePath );
85 ~ServiceHost() override = default;
86
87 QStringList GetBasePaths() override; // HttpServerExtension
88
89 bool ProcessRequest( HTTPRequest *pRequest ) override; // HttpServerExtension
90
91 virtual QString GetServiceControlURL() { return m_sBaseUrl.mid( 1 ); }
92
93 const QMetaObject& GetServiceMetaObject() { return m_oMetaObject; }
94 const MetaInfoMap& GetMethods () { return m_methods; }
95
96};
97
98#endif
HttpRequestType m_eRequestType
Definition: servicehost.h:42
MethodInfo()=default
int m_nMethodIndex
Definition: servicehost.h:39
QString m_sName
Definition: servicehost.h:40
QVariant Invoke(Service *pService, const QStringMap &reqParams) const
Definition: servicehost.cpp:26
QMetaMethod m_oMethod
Definition: servicehost.h:41
MetaInfoMap m_methods
Definition: servicehost.h:71
virtual bool FormatResponse(HTTPRequest *pRequest, QObject *pResults)
bool ProcessRequest(HTTPRequest *pRequest) override
const MetaInfoMap & GetMethods()
Definition: servicehost.h:94
QString m_sBaseUrl
Definition: servicehost.h:68
QStringList GetBasePaths() override
const QMetaObject & GetServiceMetaObject()
Definition: servicehost.h:93
ServiceHost(const QMetaObject &metaObject, const QString &sExtensionName, QString sBaseUrl, const QString &sSharePath)
~ServiceHost() override=default
virtual QString GetServiceControlURL()
Definition: servicehost.h:91
QMetaObject m_oMetaObject
Definition: servicehost.h:70
HttpRequestType
Definition: httprequest.h:46
@ RequestTypePost
Definition: httprequest.h:51
@ RequestTypeGet
Definition: httprequest.h:49
@ RequestTypeHead
Definition: httprequest.h:50
QMap< QString, MethodInfo > MetaInfoMap
Definition: servicehost.h:52
QMap< QString, QString > QStringMap
Definition: upnputil.h:28