// ------------------------------------------------------------------------------------------------ // CNSmlDataModBase::SetUsedMimeType // Sets mime type that is used for sending and receiving. // This method can be called separately before every item. // ------------------------------------------------------------------------------------------------ EXPORT_C TInt CNSmlDataModBase::SetUsedMimeType( const RStringF aMimeType, const RStringF aMimeVersion ) { _DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL(): begin"); iUsedRemoteMimeType = -1; if ( !iRemoteStoreFormat ) { _DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end"); return KErrNotFound; } else { for ( TInt i = 0; i < iRemoteStoreFormat->MimeFormatCount(); i++ ) { if ( iRemoteStoreFormat->MimeFormat( i ).MimeType().DesC().Compare( aMimeType.DesC() ) == 0 ) { if ( iRemoteStoreFormat->MimeFormat( i ).MimeVersion().DesC().Compare( aMimeVersion.DesC() ) == 0 ) { iUsedRemoteMimeType = i; iMimeType = iRemoteStoreFormat->MimeFormat( i ).MimeType(); iMimeVersion = iRemoteStoreFormat->MimeFormat( i ).MimeVersion(); _DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Found: end"); return KErrNone; } } } } _DBG_FILE("CNSmlDataModBase::SetUsedMimeTypeL() - Not Found: end"); return KErrNotFound; }
// ----------------------------------------------------------------------------- // RSIPSecChallengeResolver::SelectQopL // Security-Server can have one qop value. If it has, use it. Challenge can have // a list of qop values ("auth,auth-int"). Qop is not case-sensitive. // ----------------------------------------------------------------------------- // CSIPSecRequestData::TQop RSIPSecChallengeResolver::SelectQopL( CSIPAuthenticateHeaderBase& aHeader, RStringF aQopInSecurityServer ) const { if ( aQopInSecurityServer != SIPStrings::StringF( SipStrConsts::EEmpty ) ) { if ( aQopInSecurityServer.DesC().CompareF( KSIPSecAuthInt ) == 0 ) { return CSIPSecRequestData::EAuthInt; } if ( aQopInSecurityServer.DesC().CompareF( KSIPSecAuth ) == 0 ) { return CSIPSecRequestData::EAuth; } } if ( !aHeader.HasParam( SIPStrings::StringF( SipStrConsts::EQop ) ) ) { // No qop => accept, but "auth" is used later on. return CSIPSecRequestData::EDoesNotExist; } // If many values ("auth,auth-int"), use strongest ("auth-int") if ( aHeader.HasQopValueL( KSIPSecAuthInt ) ) { return CSIPSecRequestData::EAuthInt; } if ( aHeader.HasQopValueL( KSIPSecAuth ) ) { return CSIPSecRequestData::EAuth; } return CSIPSecRequestData::EUnknown; }
// --------------------------------------------------------------------------- // CSdpCodecParseUtil::ParseMediaLevelL // --------------------------------------------------------------------------- // RPointerArray<CSdpMediaField>* CSdpCodecParseUtil::ParseMediaLevelL() { RStringF headername = iPool.StringF( SdpCodecStringConstants::EMedia, SdpCodecStringConstants::Table ); TInt linestartPosition = 0; TInt lineEndPosition = 0; CSdpMediaField* mediafield = NULL; TBool endloop = EFalse; while(iData.Length() > 0 && !endloop) { linestartPosition = iData.FindF(headername.DesC()); if(linestartPosition != KErrNotFound) { TPtrC8 firstline(iData.Mid(linestartPosition)); TPtrC8 templine(iData.Mid(linestartPosition + 1)); HBufC8* searchString = HBufC8::NewLC(KCRLFStr().Length() + headername.DesC().Length()); TPtr8 strPtr(searchString->Des()); strPtr.Append(KCRLFStr); strPtr.Append(headername.DesC()); lineEndPosition = templine.FindF(strPtr); CleanupStack::PopAndDestroy(searchString); if(lineEndPosition == KErrNotFound) { mediafield = CSdpMediaField::DecodeLC(iData.Mid(linestartPosition)); User::LeaveIfError(iMediaFields->Append(mediafield)); CleanupStack::Pop();//mediafield mediafield = 0; iElementArray.Reset(); iLineArray.Reset(); endloop = ETrue; } else { mediafield = CSdpMediaField::DecodeLC(firstline.Left( lineEndPosition+1+KCRLFStr().Length())); User::LeaveIfError(iMediaFields->Append(mediafield)); CleanupStack::Pop();//mediafield mediafield = 0; iData.Set(firstline.Mid(lineEndPosition+1)); } } else { endloop = ETrue; } } RPointerArray<CSdpMediaField>* array = iMediaFields; iMediaFields = 0; return array; }
// ----------------------------------------------------------------------------- // CSdpConnectionField::SetAddressL // Sets new address and types, leaves on error // ----------------------------------------------------------------------------- // EXPORT_C void CSdpConnectionField::SetAddressL( RStringF aNetType, RStringF aAddressType, const TDesC8& aAddress ) { __TEST_INVARIANT; TInt err( KErrNone ); RStringF netTypeBackup = iNetType.Copy(); RStringF addressTypeBackup = iAddressType.Copy(); CleanupClosePushL( netTypeBackup ); CleanupClosePushL( addressTypeBackup ); TRAP( err, CopyNetTypeL( aNetType.DesC() ) ); if ( !err ) { // Netowrk type changed successfully TRAP( err, CopyAddressTypeL( aAddressType.DesC() ) ); if ( !err ) { // Address type & network type changed successfully TRAP( err, CopyAddressL( aAddress, iAddressType.Pool() ) ); if ( err ) { // Place back old netType & address iNetType.Close(); iNetType = netTypeBackup.Copy(); iAddressType.Close(); iAddressType = addressTypeBackup.Copy(); User::LeaveIfError( err ); } // Everything changed succesfully } else { // Place back old netType iNetType.Close(); iNetType = netTypeBackup.Copy(); User::LeaveIfError( err ); } } else { User::LeaveIfError( err ); } CleanupStack::PopAndDestroy( 2 ); // netTypeBackup, addressTypeBackup }
void CHttpController::AddPersistentHeaderL( TInt aHeaderId, const TDesC8& aValue ) { RStringF string = iSession.StringPool().StringF( aHeaderId, RHTTPSession::GetTable() ); CleanupClosePushL( string ); iPersistentHeaders->AddL( string.DesC(), aValue ); CleanupStack::PopAndDestroy( &string ); }
void CUPnPHeaderReader::DecodeTimeoutHeaderL(RHeaderField& aHeader) const { TPtrC8 buffer; aHeader.RawDataL(buffer); // Search for '\n' separator. In the case when a duplicate header has been received, // only use the fist instance of the valid data. TInt newLinePos = buffer.Locate('\n'); if (newLinePos != KErrNotFound) { buffer.Set(buffer.Left(newLinePos)); } RStringF infinite = iStringPool.StringF(UPnP::EInfinite, TUPnPTable::Table()); if(buffer.Compare(infinite.DesC()) == 0) { SetNewIntegerPartL(aHeader, 0, -(KMaxTInt)); } else { TPtrC8 token; InetProtTextUtils::ExtractNextTokenFromList(buffer, token, KSemiSpaceSep); TInt consumed = token.Locate('-'); token.Set(token.Mid(consumed+1)); TInt intVal; InetProtTextUtils::ConvertDescriptorToInt(token, intVal); SetNewIntegerPartL(aHeader, 0, intVal); // part 0, i.e. the first (and only) part } }
// ----------------------------------------------------------------------------- // CSdpConnectionField::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CSdpConnectionField::ConstructL( RStringF aNetType, RStringF aAddressType, const TDesC8& aAddress ) { iPool = SdpCodecStringPool::StringPoolL(); // Network type CopyNetTypeL( aNetType.DesC() ); // Address type CopyAddressTypeL( aAddressType.DesC() ); // Address + TTL + numOfAddress CopyAddressL( aAddress, aNetType.Pool() ); }
// ----------------------------------------------------------------------------- // CSIPRequestElements::SetMethodL // ----------------------------------------------------------------------------- // EXPORT_C void CSIPRequestElements::SetMethodL(RStringF aMethod) { __ASSERT_ALWAYS (aMethod.DesC().Length() > 0, User::Leave(KErrArgument)); iMethod.Close(); iMethod = aMethod.Copy(); }
// ---------------------------------------------------------------------------- // CSdpMediaField::SetMedia // ---------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::SetMediaL(RStringF aMedia) { __ASSERT_ALWAYS(SdpUtil::IsTokenChar(aMedia.DesC()), User::Leave(KErrSdpCodecMediaField)); iMedia.Close(); iMedia = aMedia.Copy(); }
// ----------------------------------------------------------------------------- // CSdpConnectionField::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CSdpConnectionField::ConstructL( const TDesC8& aText ) { // aText should be in format // c=<network type> <address type> <connection address> iPool = SdpCodecStringPool::StringPoolL(); RArray<TPtrC8> array = SdpUtil::GetElementsFromLineL( aText, KErrSdpCodecConnectionField ); CleanupClosePushL( array ); if ( array.Count() != KTokenCount ) { User::Leave( KErrSdpCodecConnectionField ); } RStringF origHeader = iPool.StringF( SdpCodecStringConstants::EConnection, SdpCodecStringConstants::Table ); if ( origHeader.DesC().CompareF( array[KHeaderIndex] ) != 0 ) { // Header didn't match User::Leave( KErrSdpCodecConnectionField ); } // <network type> CopyNetTypeL( array[KNetworkTypeIndex] ); // <address type> CopyAddressTypeL( array[KAddressTypeIndex] ); // <address> CopyAddressL( array[KAddressIndex], iPool ); CleanupStack::PopAndDestroy(); // array }
// ---------------------------------------------------------------------------- // CSdpMediaField::ConstructL // ---------------------------------------------------------------------------- // void CSdpMediaField::ConstructL(RStringF aMedia, TUint aPort, RStringF aProtocol, const TDesC8& aFormatList) { __ASSERT_ALWAYS(SdpUtil::IsTokenChar(aMedia.DesC()) && (aPort== 0 || (aPort >= 1024 && aPort <= 65535)) && SdpUtil::IsTokenCharWithOptionalSlash(aProtocol.DesC()) && SdpUtil::IsTokenCharWithSpacesL(aFormatList), User::Leave(KErrArgument)); ConstructL(); iMedia = aMedia.Copy(); iProtocol = aProtocol.Copy(); SetPortL(aPort); delete iFormatList; iFormatList = 0; iFormatList = aFormatList.AllocL(); }
HBufC8* CHttpController::HeaderNameLC( TInt aId ) { RStringF string = iSession.StringPool().StringF( aId, RHTTPSession::GetTable() ); CleanupClosePushL( string ); HBufC8* buffer = string.DesC().AllocL(); CleanupStack::PopAndDestroy( &string ); CleanupDeletePushL( buffer ); return buffer; }
/** Get the credentials from the user. @param aURI [in] The URI being requested @param aRealm [out] The realm being requested @param aAuthenticationType [out] The type of authentication. @param aUsername [out] User name @param aPassword [out] Pass word @return TBool ETrue if credentials being returned else EFalse */ TBool CTestWebBrowser::GetCredentialsL( const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword ) { // Convert to 16 bit to display HBufC* uriDesBuf = HBufC::NewLC( aURI.UriDes().Length() ); TPtr uriDesPtr( uriDesBuf->Des() ); uriDesPtr.Copy( aURI.UriDes() ); HBufC* uriRealmBuf = HBufC::NewLC( aRealm.DesC().Length() ); TPtr uriRealmPtr( uriRealmBuf->Des() ); uriRealmPtr.Copy( aRealm.DesC() ); HBufC* uriAuthenticationType = HBufC::NewLC ( aAuthenticationType.DesC().Length() ); TPtr uriAuthenticationPtr( uriAuthenticationType->Des() ); uriAuthenticationPtr.Copy ( aAuthenticationType.DesC() ); // Prompt user for input iTestUtils.Test().Printf ( _L( "Enter credentials for URL %S, realm %S\n"), &uriDesPtr, &uriRealmPtr ); iTestUtils.Test().Printf ( _L("Using %S authentication\n"), &uriAuthenticationPtr ); CleanupStack::PopAndDestroy ( 3 ); // Pop and destroy uriDesBuf, uriRealmBuf and uriAuthenticationType HBufC* userDetails16 = HBufC::NewLC ( KMaxUserEntrySize ); HBufC8* userDetails8 = HBufC8::NewLC ( KMaxUserEntrySize ); TPtr userDetailsPtr16( userDetails16->Des() ); TPtr8 userDetailsPtr8( userDetails8->Des() ); iTestUtils.GetAnEntry ( _L( "Username (or QUIT to give up): " ), userDetailsPtr16 ); TBool set = EFalse; if ( userDetailsPtr16.CompareF ( KQuit ) ) { userDetailsPtr8.Copy ( userDetailsPtr16 ); aUsername = aRealm.Pool().OpenStringL ( userDetailsPtr8 ); iTestUtils.GetAnEntry( _L( "Password: " ), userDetailsPtr16 ); userDetailsPtr8.Copy ( userDetailsPtr16 ); aPassword = aRealm.Pool().OpenStringL ( userDetailsPtr8 ); set = ETrue; } CleanupStack::PopAndDestroy ( 2 ); // Pop and destroy userDetails16 & userDetails8 return set; }
// ----------------------------------------------------------------------------- // CSdpOriginField::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CSdpOriginField::ConstructL( const TDesC8& aUserName, TInt64 aSessionId, TInt64 aSessionVersion, RStringF aNetType, RStringF aAddressType, const TDesC8& aAddress ) { iPool = SdpCodecStringPool::StringPoolL(); __ASSERT_ALWAYS( IsValidUserName( aUserName ) && IsValidAddress( aAddress ) && TypeMatchesWithFormat( aAddress, aAddressType.DesC(), iPool ) && ( SdpUtil::IsToken( aNetType.DesC() ) ) && ( SdpUtil::IsToken( aAddressType.DesC() ) ) && aSessionId >= 0 && aSessionVersion >= 0, User::Leave( KErrSdpCodecOriginField ) ); iUserName = reinterpret_cast< HBufC8* > ( CSdpOriginFieldPtrs::NewL( aSessionId, aSessionVersion ) ); OriginFieldPtrs().SetUserNameL( aUserName ); iNetType = aNetType.Copy(); TInetAddr addr; TBuf<KMaxAddressLength> address; address.Copy(aAddress); TInt err = addr.Input(address); if ( err == KErrNone ) { // Valid IP address TBuf< KMaxIPDesLength > buf; addr.Output( buf ); iAddress.Copy( buf ); SetIPAddressType( addr ); } else { iAddress = aAddress; iAddressType = aAddressType.Copy(); } __TEST_INVARIANT; }
// ---------------------------------------------------------------------------- // CSdpMediaField::EncodeL // ---------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::EncodeL(RWriteStream& aStream, TBool aRecurse) const { RStringF headername = iPool.StringF( SdpCodecStringConstants::EMedia, SdpCodecStringConstants::Table ); aStream.WriteL(headername.DesC()); aStream.WriteL(iMedia.DesC()); aStream.WriteL(KSPStr); TBuf8<80> text; text.Format(_L8("%u"), iPort); aStream.WriteL(text); if(iPortCount>0) { aStream.WriteL(_L8("/")); text.Format(_L8("%u"), iPortCount); aStream.WriteL(text); } aStream.WriteL(KSPStr); aStream.WriteL(iProtocol.DesC()); aStream.WriteL(KSPStr); aStream.WriteL(*iFormatList); aStream.WriteL(KCRLFStr); if(aRecurse) { SdpUtil::EncodeBufferL(*iInfo, SdpCodecStringConstants::EInfo, aStream); SdpCodecTemplate<CSdpConnectionField>::EncodeArrayL(*iConnectionFields, aStream); SdpCodecTemplate<CSdpBandwidthField>::EncodeArrayL(*iBandwidthFields, aStream); SdpCodecTemplate<CSdpKeyField>::EncodeL(Key(), aStream); for (TInt i = 0; i < iAttributeFields->Count(); i++) { if (!(((*iAttributeFields)[i])->IsFmtAttribute())) { ((*iAttributeFields)[i])->EncodeL(aStream); } } for (TInt i = 0; i < iFmtAttrFields->Count(); i++) { ((*iFmtAttrFields)[i])->EncodeL(aStream); for (TInt j=0; j<iAttributeFields->Count(); j++) { if ((((*iAttributeFields)[j])->IsFmtAttribute()) && ((*iAttributeFields)[j])->BelongsTo(*(*iFmtAttrFields)[i])) { ((*iAttributeFields)[j])->EncodeL(aStream); } } } } }
// ----------------------------------------------------------------------------- // CSdpOriginField::SetAddressL // Sets address from the buffer // ----------------------------------------------------------------------------- // EXPORT_C void CSdpOriginField::SetAddressL( const TDesC8& aAddress, RStringF aNetType, RStringF aAddressType ) { __TEST_INVARIANT; __ASSERT_ALWAYS( SdpUtil::IsToken( aNetType.DesC() ) && SdpUtil::IsToken( aAddressType.DesC() ) && IsValidAddress( aAddress ) && TypeMatchesWithFormat( aAddress, aAddressType.DesC(), iPool ), User::Leave( KErrSdpCodecOriginField ) ); iAddress = aAddress; iAddressType.Close(); iAddressType = aAddressType.Copy(); __TEST_INVARIANT; }
TBool CHttpTestCaseGet12::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { iEngine->Utils().LogIt(_L("Supplying credentials")); iEngine->Utils().DumpData(aURI.UriDes()); iEngine->Utils().DumpData(aRealm.DesC()); iEngine->Utils().DumpData(aAuthenticationType.DesC()); _LIT8(KScooby, "scooby"); _LIT8(KDoo, "doo"); RStringPool p = aRealm.Pool(); aUsername = p.OpenStringL(KScooby); aPassword = p.OpenStringL(KDoo); return ETrue; }
// ---------------------------------------------------------------------------- // CSdpMediaField::SetProtocol // ---------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::SetProtocolL(RStringF aProtocol) { __ASSERT_ALWAYS(SdpUtil::IsTokenCharWithOptionalSlash(aProtocol.DesC()), User::Leave(KErrSdpCodecMediaField)); if (aProtocol == iPool.StringF( SdpCodecStringConstants::EProtocolUdp, SdpCodecStringConstants::Table )) { __ASSERT_ALWAYS((iPort == 0 || (iPort >= 1024 && iPort <= 65535)), User::Leave(KErrSdpCodecMediaField)); } iProtocol.Close(); iProtocol = aProtocol.Copy(); }
// --------------------------------------------------------------------------- // TIRXMLElementFormat :: GetElementIdL // The ElementId of the element from the StringPool // --------------------------------------------------------------------------- // TIRXMLElement TIRXMLElementFormat::GetElementIdL( const TDesC8& aElement, const RStringPool& aStringPool ) { IRLOG_DEBUG( "TIRXMLElementFormat::GetElementIdL" ); TBool validElement = EFalse; TInt tableEntries; TInt pos(0); tableEntries = IRPoolTable.iCount; while( pos < tableEntries && validElement == EFalse ) { RStringF tableEntry; tableEntry = aStringPool.StringF( pos, IRPoolTable ); HBufC8* ElementName = HBufC8::NewLC( tableEntry.DesC().Length() ); ElementName->Des().Copy( tableEntry.DesC() ); TLex8 string( *ElementName ); TPtrC8 token = string.NextToken(); TInt CompareResult = aElement.Compare( token ); if ( CompareResult == 0 ) { validElement = ETrue; } if ( validElement == EFalse ) { pos++; } tableEntry.Close(); CleanupStack::PopAndDestroy( ElementName ); } if ( validElement ) { IRLOG_DEBUG( "CIRXMLContentHandler::GetElementIdL - Exiting (1)." ); return static_cast<TIRXMLElement>( pos ); } IRLOG_DEBUG( "CIRXMLContentHandler::GetElementIdL - Exiting (2)." ); return(EElementIDUnknown); }
// --------------------------------------------------------------------------- // SdpUtil::EncodeBufferL // Encodes headername and a value to the stream // --------------------------------------------------------------------------- // void SdpUtil::EncodeBufferL( const TDesC8& aValue, TInt aIndex, RWriteStream& aStream ) { if( aValue.Length() != 0 ) { RStringPool pool = SdpCodecStringPool::StringPoolL(); RStringF headername = pool.StringF( aIndex, SdpCodecStringPool::StringTableL() ); aStream.WriteL( headername.DesC() ); aStream.WriteL( aValue ); aStream.WriteL( KCRLFStr ); } }
TBool CHttpEventHandler::GetHdrVal( THTTPHdrVal& hdrVal, RStringPool& pool) { TBool retval = ETrue; TPtrC8 auth_token((const TUint8*)"auth_token"); switch (hdrVal.Type()) { case THTTPHdrVal::KStrFVal: { RStringF fieldNameStr = pool.StringF(hdrVal.StrF()); const TDesC8& fieldNameDesC = fieldNameStr.DesC(); if (iVerbose) { TBuf<CHttpConstants::KMaxHeaderValueLen> value; value.Copy(fieldNameDesC.Left(CHttpConstants::KMaxHeaderValueLen)); iTest->Console()->Printf(_L("%S:\n"), &value); } if ( fieldNameDesC.Length() > 0 && fieldNameDesC.Compare(auth_token) ) iCookies.Append(fieldNameDesC); else retval = EFalse; } break; case THTTPHdrVal::KStrVal: { RString fieldNameStr = pool.String(hdrVal.Str()); const TDesC8& fieldNameDesC = fieldNameStr.DesC(); if (iVerbose) { TBuf<CHttpConstants::KMaxHeaderValueLen> value; value.Copy(fieldNameDesC.Left(CHttpConstants::KMaxHeaderValueLen)); iTest->Console()->Printf(_L("%S:\n"), &value); } if ( fieldNameDesC.Length() > 0 && fieldNameDesC.Compare(auth_token) ) iCookies.Append(fieldNameDesC); else retval = EFalse; } break; } return retval; }
void CTestMessageComposer::StartLineL(TPtrC8& aMethod, TPtrC8& aRequestUri, TPtrC8& aVersion) { // The RFC2616 defines the Request-Line as follows - // // Request-Line = Method SP Request-URI SP HTTPVersion CRLF // // Get Method... iRequest = iTransaction.Request(); RStringF method = iStringPool.StringF(iRequest.Method()); aMethod.Set(method.DesC()); // Get the Request-URI... aRequestUri.Set(KUri); // Assume HTTP/1.1 aVersion.Set(iStringPool.StringF(HTTP::EHttp11, RHTTPSession::GetTable()).DesC()); }
// ---------------------------------------------------------------------------- // CClientEngine::GetCredentialsL() // // Inherited from MHTTPAuthenticationCallback // Called by framework when we requested authenticated page and framework // needs to know username and password. // ---------------------------------------------------------------------------- TBool CClientEngine::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { // aURI, aReal and aAuthenticationType are informational only. We only need // to set aUsername and aPassword and return ETrue, if aUsername and // aPassword are provided by user. // Informational only TBuf<KURIBufferSize> authType; TBuf<KURIBufferSize> uri; TBuf<KDefaultBufferSize> authText; authType.Copy(aAuthenticationType.DesC()); uri.Copy(aURI.UriDes()); _LIT(KAuthRequired, "%S requires %S authentication."); authText.Format(KAuthRequired, &uri, &authType); _LIT(KAuthNote, "Authentication required."); CEikonEnv::Static()->InfoWinL(KAuthNote, authText); // Query user name and password TBuf<KDefaultBufferSize> userName; TBuf<KDefaultBufferSize> password; //CAknMultiLineDataQueryDialog* dlg = // CAknMultiLineDataQueryDialog::NewL(userName, password); //if (!dlg->ExecuteLD(R_DIALOG_USER_PASSWORD_QUERY)) // return EFalse; // No credentials given; must return EFalse // Set aUsername and aPassword TBuf8<KDefaultBufferSize> temp; temp.Copy(userName); TRAPD(err, aUsername = aRealm.Pool().OpenStringL(temp)); if (!err) { temp.Copy(password); TRAP(err, aPassword = aRealm.Pool().OpenStringL(temp)); if (!err) return ETrue; } // Return ETrue if user has given credentials (username and password), // otherwise EFlase return EFalse; }
// ----------------------------------------------------------------------------- // CSIPParamContainerBase::CheckGenericParamL // ----------------------------------------------------------------------------- // void CSIPParamContainerBase::CheckGenericParamL(RStringF aName, TBool aHasValue, const TDesC8& aValue, TInt aLeaveCode) const { if (!SIPSyntaxCheck::Token(aName.DesC())) { User::Leave(aLeaveCode); } if (!aHasValue) { return; } if (!SIPSyntaxCheck::GenericParamValue(aValue)) { User::Leave(aLeaveCode); } }
TBool CHttpTestCaseGet14::GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword) { if(iCallsNum++) { iTestFail=1; iEngine->Utils().LogIt(_L("The test will fail: the credential haven't been kept(the GetCredential function has been called again)")); return EFalse; } iEngine->Utils().LogIt(_L("Supplying credentials")); iEngine->Utils().DumpData(aURI.UriDes()); iEngine->Utils().DumpData(aRealm.DesC()); iEngine->Utils().DumpData(aAuthenticationType.DesC()); _LIT8(KScooby, "scooby"); _LIT8(KDoo, "doo"); RStringPool p = aRealm.Pool(); aUsername = p.OpenStringL(KScooby); aPassword = p.OpenStringL(KDoo); return ETrue; }
// ----------------------------------------------------------------------------- // CCancelUAS::Send200L // If the canceled transaction has a To-tag, it's put in the response to CANCEL // ----------------------------------------------------------------------------- // void CCancelUAS::Send200L(const CUserAgentState& aFinalRespSent, RStringF aToTag) { CSIPResponse* resp = CSIPResponse::NewLC(200, SIPStrings::StringF(SipStrConsts::EPhraseOk)); FillResponseL(*resp); if (aToTag.DesC().Length() > 0) { CSIPToHeader* to = resp->To(); __SIP_ASSERT_LEAVE(to != NULL, KErrSIPMalformedMessage); to->SetParamL(SIPStrings::StringF(SipStrConsts::ETag), aToTag); } ChangeState(aFinalRespSent); SendResponseToTransactionL(resp); CleanupStack::Pop(resp); }
// ----------------------------------------------------------------------------- // CSdpConnectionField::EncodeL // Writes attributes in proper format to the stream // ----------------------------------------------------------------------------- // EXPORT_C void CSdpConnectionField::EncodeL( RWriteStream& aStream ) const { __TEST_INVARIANT; TBuf8<20> number; // Is enough for addr as well // c=<network type> <address type> <connection address> RStringF header = iPool.StringF( SdpCodecStringConstants::EConnection, SdpCodecStringConstants::Table ); aStream.WriteL( header.DesC() ); // Network type aStream.WriteL( iNetType.DesC() ); aStream.WriteL( KSPStr ); // Address type aStream.WriteL( iAddressType.DesC() ); aStream.WriteL( KSPStr ); // Connection address aStream.WriteL( *iAddress ); if ( iTTL != KErrNotFound ) { number.Zero(); number.Append( KSlashStr ); number.AppendFormat( _L8("%d"), iTTL ); aStream.WriteL( number ); } if ( iNumOfAddress > 1 ) { number.Zero(); number.Append( KSlashStr ); number.AppendFormat( _L8("%u"), iNumOfAddress ); aStream.WriteL( number ); } // End-of-Line mark aStream.WriteL( KCRLFStr ); }
// ----------------------------------------------------------------------------- // CSdpOriginField::EncodeL // Writes attributes in proper format to the stream // ----------------------------------------------------------------------------- // EXPORT_C void CSdpOriginField::EncodeL( RWriteStream& aStream ) const { __TEST_INVARIANT; // o=<username> <session id> <version> <network type> <address type> // <address> // "o=" RStringF header = iPool.StringF( SdpCodecStringConstants::EOrigin, SdpCodecStringConstants::Table ); aStream.WriteL( header.DesC() ); // <username> aStream.WriteL( OriginFieldPtrs().UserName() ); aStream.WriteL( KSPStr ); // <session id> aStream.WriteL( OriginFieldPtrs().SessionId() ); aStream.WriteL( KSPStr ); // <version> aStream.WriteL( OriginFieldPtrs().SessionVersion() ); aStream.WriteL( KSPStr ); // <network type> aStream.WriteL( iNetType.DesC() ); aStream.WriteL( KSPStr ); // <address type> aStream.WriteL( iAddressType.DesC() ); aStream.WriteL( KSPStr ); // <address> aStream.WriteL( iAddress ); // End-of-Line mark aStream.WriteL( KCRLFStr ); }
TInt CTestMessageComposer::NextHeaderL(TPtrC8& aHeaderName, TPtrC8& aHeaderValue) { if(iFlag) { THTTPHdrFieldIter it = iHTTPHeaders.Fields(); iFlag = EFalse; while(!it.AtEnd()) { // Get field current field. RStringF name = iStringPool.StringF(it()); CleanupClosePushL(name); // Get the OTA version of the field value TPtrC8 value; iRequest.GetHeaderCollection().GetRawField(name, value); User::LeaveIfError(iHeaders.Append(THeaderField(name.DesC(), value))); // Move onto next header field... ++it; CleanupStack::PopAndDestroy(&name); } } TInt error = ( iHeaderIndex < iHeaders.Count() ) ? KErrNone : KErrNotFound; if( iHeaderIndex < iHeaders.Count() ) { // Give the current header info... THeaderField header = iHeaders[iHeaderIndex]; aHeaderName.Set(header.iName); aHeaderValue.Set(header.iValue); // Loop to next header... ++iHeaderIndex; } else { // No more headers - change state iState = EPendingHasBody; } return error; }
void CWspHeaderReader::DecodeWellKnownParamTokenL(TWspPrimitiveDecoder& aDecoder, TInt& aBytesRead, TPtrC8& aRawParamBlock, CHeaderFieldPart& aHeaderFieldPart) const { TInt err = 0; TUint32 parameterToken = 0; aBytesRead = aDecoder.Integer(parameterToken); THTTPHdrVal paramValue; RStringF paramDesValue; CleanupClosePushL(paramDesValue); RStringF paramName = iStrPool.StringF(parameterToken, WSPParam::Table); switch( parameterToken ) { case WSPParam::EQ: { // Decode Q value TUint32 qIntValue = 0; err = aDecoder.UintVar(qIntValue); User::LeaveIfError(err); aBytesRead += err; TReal q; TInt numDecimals = 0; TBuf8<KMaxNumQDigits> qDesC; if( qIntValue > 100 ) { // Value is -100 and then divide by 1000 qIntValue -= 100; q = ((TReal)(qIntValue/1000.)); numDecimals = 3; } else { // Value is -1 and then divide by 100 --qIntValue; if( qIntValue%10 ==0 ) numDecimals = 1; else numDecimals = 2; q = ((TReal)(qIntValue/100.)); } TRealFormat realFt(KMaxNumQDigits,numDecimals); // set max width and 3 decimal places // always use a decimal separator rather than the one supplied // by the current locale realFt.iPoint = TChar('.'); qDesC.Num(q, realFt); paramDesValue = iStrPool.OpenFStringL(qDesC); paramValue.SetStrF(paramDesValue); } break; case WSPParam::ECharset: { if( aRawParamBlock[aBytesRead] == 128 ) { paramDesValue = iStrPool.StringF(WSPStdConstants::EAny, WSPStdConstants::Table); paramValue.SetStrF(paramDesValue); // Need to call Integer to update offset in WSP Decoder TUint8 updateDecoder = 0; err = aDecoder.Val7Bit(updateDecoder); User::LeaveIfError(err); aBytesRead += err; } else { switch( aDecoder.VarType() ) { case TWspPrimitiveDecoder::E7BitVal: case TWspPrimitiveDecoder::ELengthVal: { TUint32 value = 0; err = aDecoder.Integer(value); User::LeaveIfError(err); aBytesRead += err; GetCharacterSetFromValueL(value, paramDesValue); paramValue.SetStrF(paramDesValue); } break; default: User::Leave(KErrCorrupt); break; } } } break; case WSPParam::ELevel: { // This is a version value err = aDecoder.VersionL(iStrPool,paramDesValue); User::LeaveIfError(err); aBytesRead += err; paramValue.SetStrF(paramDesValue); } break; case WSPParam::EType: case WSPParam::ESize: case WSPParam::EPadding: case WSPParam::ESEC: case WSPParam::EMaxAge: { TUint32 integerValue = 0; err = aDecoder.Integer(integerValue); User::LeaveIfError(err); aBytesRead += err; paramValue.SetInt(integerValue); } break; case WSPParam::ECreationDate: case WSPParam::EModificationDate: case WSPParam::EReadDate: { TDateTime dateTime(1970, EJanuary, 0, 0, 0, 0, 0); err = aDecoder.Date(dateTime); User::LeaveIfError(err); aBytesRead += err; paramValue.SetDateTime(dateTime); } case WSPParam::ENameDep: case WSPParam::EFilenameDep: case WSPParam::EStartDep: case WSPParam::EStartInfoDep: case WSPParam::ECommentDep: case WSPParam::EDomainDep: case WSPParam::EPathDep: { TPtrC8 textString; err = aDecoder.String(textString); User::LeaveIfError(err); aBytesRead += err; paramDesValue = iStrPool.OpenFStringL(textString); paramValue.SetStrF(paramDesValue); } break; case WSPParam::EMAC: case WSPParam::EName: case WSPParam::EFilename: case WSPParam::EStart: case WSPParam::EStartInfo: case WSPParam::EComment: case WSPParam::EDomain: case WSPParam::EPath: { // Check if the string has <no-value> ie <octet 0> if( aRawParamBlock[aBytesRead] == 0 ) { paramDesValue = iStrPool.OpenFStringL(KNullDesC8()); paramValue.SetStrF(paramDesValue); // Need to call Integer to update offset in WSP Decoder TUint32 updateDecoder = 0; err = aDecoder.Integer(updateDecoder); User::LeaveIfError(err); } else { TPtrC8 textString; err = aDecoder.String(textString); User::LeaveIfError(err); paramDesValue = iStrPool.OpenFStringL(textString); paramValue.SetStrF(paramDesValue); } aBytesRead += err; } break; case WSPParam::EDifferences: { aBytesRead += DecodeGenericParamTokenL(aDecoder, iStrTable, paramValue, paramDesValue); } break; case WSPParam::EContentTypeType: { aBytesRead += DecodeGenericParamTokenL(aDecoder, WSPContentTypes::Table, paramValue, paramDesValue); } break; case WSPParam::ESecure: { // <octet 0> no-value paramDesValue = iStrPool.OpenFStringL(KNullDesC8()); paramValue.SetStrF(paramDesValue); // Need to call Integer to update offset in WSP Decoder TUint32 updateDecoder = 0; err = aDecoder.Integer(updateDecoder); User::LeaveIfError(err); aBytesRead += err; } break; default: User::Leave(KErrCorrupt); break; } // Add the parameter name and value TPtrC8 paramDes(paramName.DesC()); SetNewParamL(aHeaderFieldPart, paramDes, paramValue); CleanupStack::PopAndDestroy(¶mDesValue); }