00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifndef SERVICEHOST_H_
00014 #define SERVICEHOST_H_
00015
00016 #include <QMetaObject>
00017 #include <QMetaMethod>
00018 #include <QMap>
00019
00020 #include "upnpexp.h"
00021 #include "upnp.h"
00022 #include "eventing.h"
00023 #include "service.h"
00024
00027
00028
00029
00032
00033 class UPNP_PUBLIC MethodInfo
00034 {
00035 public:
00036
00037 int m_nMethodIndex;
00038 QString m_sName;
00039 QMetaMethod m_oMethod;
00040 RequestType m_eRequestType;
00041
00042 public:
00043 MethodInfo();
00044
00045 QVariant Invoke( Service *pService, const QStringMap &reqParams );
00046 };
00047
00048 typedef QMap< QString, MethodInfo > MetaInfoMap;
00049
00052
00053
00054
00055
00056
00059
00060 class UPNP_PUBLIC ServiceHost : public HttpServerExtension
00061 {
00062 protected:
00063
00064 QString m_sBaseUrl;
00065
00066 QMetaObject m_oMetaObject;
00067 MetaInfoMap m_Methods;
00068
00069 protected:
00070
00071 virtual bool FormatResponse( HTTPRequest *pRequest, QObject *pResults );
00072 virtual bool FormatResponse( HTTPRequest *pRequest, QFileInfo oInfo );
00073 virtual bool FormatResponse( HTTPRequest *pRequest, QVariant vValue );
00074
00075 public:
00076
00077 ServiceHost( const QMetaObject &metaObject,
00078 const QString &sExtensionName,
00079 const QString &sBaseUrl,
00080 const QString &sSharePath );
00081 virtual ~ServiceHost();
00082
00083 virtual QStringList GetBasePaths();
00084
00085 virtual bool ProcessRequest( HTTPRequest *pRequest );
00086
00087 virtual QString GetServiceControlURL() { return m_sBaseUrl.mid( 1 ); }
00088
00089 const QMetaObject& GetServiceMetaObject() { return m_oMetaObject; }
00090 const MetaInfoMap& GetMethods () { return m_Methods; }
00091
00092 };
00093
00094 #endif