00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifndef __UPNP_H__
00014 #define __UPNP_H__
00015
00016 #include "configuration.h"
00017
00019
00021
00022 #include "upnpdevice.h"
00023 #include "taskqueue.h"
00024 #include "httpserver.h"
00025 #include "ssdp.h"
00026
00028
00030
00031 typedef enum
00032 {
00033 UPnPResult_Success = 0,
00034
00035 UPnPResult_InvalidAction = 401,
00036 UPnPResult_InvalidArgs = 402,
00037 UPnPResult_ActionFailed = 501,
00038 UPnPResult_ArgumentValueInvalid = 600,
00039 UPnPResult_ArgumentValueOutOfRange = 601,
00040 UPnPResult_OptionalActionNotImplemented = 602,
00041 UPnPResult_OutOfMemory = 603,
00042 UPnPResult_HumanInterventionRequired = 604,
00043 UPnPResult_StringArgumentTooLong = 605,
00044 UPnPResult_ActionNotAuthorized = 606,
00045 UPnPResult_SignatureFailure = 607,
00046 UPnPResult_SignatureMissing = 608,
00047 UPnPResult_NotEncrypted = 609,
00048 UPnPResult_InvalidSequence = 610,
00049 UPnPResult_InvalidControlURL = 611,
00050 UPnPResult_NoSuchSession = 612,
00051
00052 UPnPResult_CDS_NoSuchObject = 701,
00053 UPnPResult_CDS_InvalidCurrentTagValue = 702,
00054 UPnPResult_CDS_InvalidNewTagValue = 703,
00055 UPnPResult_CDS_RequiredTag = 704,
00056 UPnPResult_CDS_ReadOnlyTag = 705,
00057 UPnPResult_CDS_ParameterMismatch = 706,
00058 UPnPResult_CDS_InvalidSearchCriteria = 708,
00059 UPnPResult_CDS_InvalidSortCriteria = 709,
00060 UPnPResult_CDS_NoSuchContainer = 710,
00061 UPnPResult_CDS_RestrictedObject = 711,
00062 UPnPResult_CDS_BadMetadata = 712,
00063 UPnPResult_CDS_ResrtictedParentObject = 713,
00064 UPnPResult_CDS_NoSuchSourceResource = 714,
00065 UPnPResult_CDS_ResourceAccessDenied = 715,
00066 UPnPResult_CDS_TransferBusy = 716,
00067 UPnPResult_CDS_NoSuchFileTransfer = 717,
00068 UPnPResult_CDS_NoSuchDestRes = 718,
00069 UPnPResult_CDS_DestResAccessDenied = 719,
00070 UPnPResult_CDS_CannotProcessRequest = 720,
00071
00072 UPnPResult_CMGR_IncompatibleProtocol = 701,
00073 UPnPResult_CMGR_IncompatibleDirections = 702,
00074 UPnPResult_CMGR_InsufficientNetResources = 703,
00075 UPnPResult_CMGR_LocalRestrictions = 704,
00076 UPnPResult_CMGR_AccessDenied = 705,
00077 UPnPResult_CMGR_InvalidConnectionRef = 706,
00078 UPnPResult_CMGR_NotInNetwork = 707,
00079
00080 UPnPResult_MS_AccessDenied = 801,
00081
00082 UPnPResult_MythTV_NoNamespaceGiven = 32001,
00083
00084 } UPnPResultCode;
00085
00088
00089
00090
00093
00094 class UPNP_PUBLIC UPnp
00095 {
00096
00097 protected:
00098
00099 static Configuration *g_pConfig;
00100
00101 HttpServer *m_pHttpServer;
00102 int m_nServicePort;
00103
00104 public:
00105
00106 static UPnpDeviceDesc g_UPnpDeviceDesc;
00107 static QStringList g_IPAddrList;
00108
00109 public:
00110 UPnp();
00111 virtual ~UPnp();
00112
00113 static void SetConfiguration( Configuration *pConfig );
00114 static Configuration* GetConfiguration();
00115
00116 bool Initialize( int nServicePort, HttpServer *pHttpServer );
00117 bool Initialize( QStringList &sIPAddrList, int nServicePort, HttpServer *pHttpServer );
00118
00119 virtual void Start();
00120
00121 void CleanUp ();
00122
00123 UPnpDevice *RootDevice() { return &(g_UPnpDeviceDesc.m_rootDevice); }
00124
00125 HttpServer *GetHttpServer() { return m_pHttpServer; }
00126
00127 static UPnpDeviceDesc *GetDeviceDesc( QString &sURL, bool bInQtThread = true);
00128
00129 static QString GetResultDesc( UPnPResultCode eCode );
00130 static void FormatErrorResponse( HTTPRequest *pRequest,
00131 UPnPResultCode eCode,
00132 const QString &sMsg = "" );
00133
00134 static void FormatRedirectResponse( HTTPRequest *pRequest,
00135 const QString &hostName );
00136
00137
00138 };
00139
00140 #endif