MythTV  master
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 COPYING 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 "upnpexp.h"
21 #include "upnp.h"
22 #include "eventing.h"
23 #include "service.h"
24 
27 //
28 //
29 //
32 
34 {
35  public:
36 
37  int m_nMethodIndex {0};
38  QString m_sName;
39  QMetaMethod m_oMethod;
43 
44  public:
45  MethodInfo() = default;
46 
47  QVariant Invoke( Service *pService, const QStringMap &reqParams );
48 };
49 
50 typedef QMap< QString, MethodInfo > MetaInfoMap;
51 
54 //
55 // ServiceHost is used for Standard Web Services Only
56 //
57 // (It does NOT expose anything as upnp devices/services)
58 //
61 
63 {
64  protected:
65 
66  QString m_sBaseUrl;
67 
68  QMetaObject m_oMetaObject;
70 
71  protected:
72 
73  virtual bool FormatResponse( HTTPRequest *pRequest, QObject *pResults );
74  virtual bool FormatResponse( HTTPRequest *pRequest, QFileInfo oInfo );
75  virtual bool FormatResponse( HTTPRequest *pRequest, QVariant vValue );
76 
77  public:
78 
79  ServiceHost( const QMetaObject &metaObject,
80  const QString &sExtensionName,
81  const QString &sBaseUrl,
82  const QString &sSharePath );
83  virtual ~ServiceHost() = default;
84 
85  QStringList GetBasePaths() override; // HttpServerExtension
86 
87  bool ProcessRequest( HTTPRequest *pRequest ) override; // HttpServerExtension
88 
89  virtual QString GetServiceControlURL() { return m_sBaseUrl.mid( 1 ); }
90 
91  const QMetaObject& GetServiceMetaObject() { return m_oMetaObject; }
92  const MetaInfoMap& GetMethods () { return m_Methods; }
93 
94 };
95 
96 #endif
HttpRequestType
Definition: httprequest.h:39
QMetaMethod m_oMethod
Definition: servicehost.h:39
const MetaInfoMap & GetMethods()
Definition: servicehost.h:92
QMap< QString, MethodInfo > MetaInfoMap
Definition: servicehost.h:50
virtual QString GetServiceControlURL()
Definition: servicehost.h:89
QString m_sName
Definition: servicehost.h:38
virtual bool ProcessRequest(HTTPRequest *pRequest)=0
QMap< QString, QString > QStringMap
Definition: upnputil.h:40
QString m_sBaseUrl
Definition: servicehost.h:66
#define UPNP_PUBLIC
Definition: upnpexp.h:9
QMetaObject m_oMetaObject
Definition: servicehost.h:68
virtual QStringList GetBasePaths()=0
const QMetaObject & GetServiceMetaObject()
Definition: servicehost.h:91
MetaInfoMap m_Methods
Definition: servicehost.h:69