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