00001
00002
00003
00004
00005
00007
00008 #include "upnp.h"
00009 #include "upnpmsrr.h"
00010
00011 #include <math.h>
00012 #include <qregexp.h>
00013
00015
00017
00018 UPnpMSRR::UPnpMSRR( UPnpDevice *pDevice,
00019 const QString &sSharePath )
00020 : Eventing( "UPnpMSRR", "MSRR_Event" )
00021 {
00022 AddVariable( new StateVariable< unsigned short >( "AuthorizationGrantedUpdateID", true ) );
00023 AddVariable( new StateVariable< unsigned short >( "AuthorizationDeniedUpdateID" , true ) );
00024 AddVariable( new StateVariable< unsigned short >( "ValidationSucceededUpdateID" , true ) );
00025 AddVariable( new StateVariable< unsigned short >( "ValidationRevokedUpdateID" , true ) );
00026
00027 SetValue< unsigned short >( "AuthorizationGrantedUpdateID", 0 );
00028 SetValue< unsigned short >( "AuthorizationDeniedUpdateID" , 0 );
00029 SetValue< unsigned short >( "ValidationSucceededUpdateID" , 0 );
00030 SetValue< unsigned short >( "ValidationRevokedUpdateID" , 0 );
00031
00032 QString sUPnpDescPath = UPnp::g_pConfig->GetValue( "UPnP/DescXmlPath", sSharePath );
00033
00034 m_sSharePath = sSharePath;
00035 m_sServiceDescFileName = sUPnpDescPath + "MSRR_scpd.xml";
00036 m_sControlUrl = "/MSRR_Control";
00037
00038
00039
00040 RegisterService( pDevice );
00041 }
00042
00044
00046
00047 UPnpMSRR::~UPnpMSRR()
00048 {
00049 }
00050
00052
00054
00055 UPnpMSRRMethod UPnpMSRR::GetMethod( const QString &sURI )
00056 {
00057 if (sURI == "GetServDesc" ) return MSRR_GetServiceDescription;
00058 if (sURI == "IsAuthorized" ) return MSRR_IsAuthorized ;
00059 if (sURI == "RegisterDevice" ) return MSRR_RegisterDevice ;
00060 if (sURI == "IsValidated" ) return MSRR_IsValidated ;
00061
00062 return( MSRR_Unknown );
00063 }
00064
00066
00068
00069 bool UPnpMSRR::ProcessRequest( HttpWorkerThread *pThread, HTTPRequest *pRequest )
00070 {
00071 if (pRequest)
00072 {
00073 if (Eventing::ProcessRequest( pThread, pRequest ))
00074 return true;
00075
00076 if ( pRequest->m_sBaseUrl != m_sControlUrl )
00077 return false;
00078
00079 VERBOSE(VB_UPNP, QString("UPnpMSRR::ProcessRequest : %1 : %2 :")
00080 .arg( pRequest->m_sBaseUrl )
00081 .arg( pRequest->m_sMethod ));
00082
00083 switch( GetMethod( pRequest->m_sMethod ) )
00084 {
00085 case MSRR_GetServiceDescription : pRequest->FormatFileResponse( m_sServiceDescFileName ); break;
00086 case MSRR_IsAuthorized : HandleIsAuthorized ( pRequest ); break;
00087 case MSRR_RegisterDevice : HandleRegisterDevice ( pRequest ); break;
00088 case MSRR_IsValidated : HandleIsValidated ( pRequest ); break;
00089
00090 default:
00091 UPnp::FormatErrorResponse( pRequest, UPnPResult_InvalidAction );
00092 break;
00093 }
00094 }
00095
00096 return( true );
00097
00098 }
00099
00101
00103
00104 void UPnpMSRR::HandleIsAuthorized( HTTPRequest *pRequest )
00105 {
00106
00107 VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleIsAuthorized"));
00108 NameValueList list;
00109
00110 NameValue *pResult = new NameValue( "Result", "1");
00111
00112 pResult->AddAttribute( "xmlns:dt", "urn:schemas-microsoft-com:datatypes" );
00113 pResult->AddAttribute( "dt:dt" , "int" );
00114
00115 list.append( pResult );
00116
00117 pRequest->FormatActionResponse( &list );
00118
00119 }
00120
00122
00124
00125 void UPnpMSRR::HandleRegisterDevice( HTTPRequest *pRequest )
00126 {
00127
00128 VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleRegisterDevice"));
00129 NameValueList list;
00130
00131 list.append( new NameValue( "Result", "1"));
00132
00133 pRequest->FormatActionResponse( &list );
00134
00135 }
00136
00137 void UPnpMSRR::HandleIsValidated( HTTPRequest *pRequest )
00138 {
00139
00140
00141 VERBOSE(VB_UPNP, QString("UPnpMSRR::HandleIsValidated"));
00142 NameValueList list;
00143
00144 NameValue *pResult = new NameValue( "Result", "1");
00145
00146 pResult->AddAttribute( "xmlns:dt", "urn:schemas-microsoft-com:datatypes" );
00147 pResult->AddAttribute( "dt:dt" , "int" );
00148
00149 list.append( pResult );
00150
00151 pRequest->FormatActionResponse( &list );
00152
00153 }
00154