TInt CCoreSerialConverter::BearerToInterface(const TDesC8& aBearerData, TUid& aInterfaceUid, TUint& aOperationId, TRemConMessageType& aMsgType, TDes8& aData) const { TInt ret = KErrCorrupt; // We read KRemConSerialBearerMessageLength bytes at a time, so we should // get precisely one message. if ( aBearerData.Length() == KRemConSerialBearerMessageLength ) { TPtrC8 ptr; ptr.Set(aBearerData); TPtrC8 interfaceUid; interfaceUid.Set(ptr.Mid(2, 8)); TLex8 interfaceLex(interfaceUid); TUint uid = 0; ret = interfaceLex.Val(uid, EHex); if ( ret == KErrNone ) { aInterfaceUid = TUid::Uid(uid); TPtrC8 operationId; operationId.Set(ptr.Mid(13, 2)); TLex8 operationLex(operationId); TUint id = 0; ret = operationLex.Val(id, EHex); if ( ret == KErrNone ) { aOperationId = id; TPtrC8 data; data.Set(ptr.Mid(16, 3)); if ( data == KCmdText() ) { aMsgType = ERemConCommand; } else if ( data == KRspText() ) { aMsgType = ERemConResponse; } else { ret = KErrCorrupt; } if ( ret == KErrNone ) { TPtrC8 data; data.Set(ptr.Mid(20, 10)); aData.Copy(data); } } } } return ret; }
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData) { if (aLength <= aData.Length()) { // Can read it from this buffer TPtrC8 res(aData.Left(aLength)); aData.Set(aData.Mid(aLength)); return res; } else /*if (aLength > aData.Length())*/ { // Descriptor spans wrap point, so need to copy into temp buf aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated TInt overflowLen = aLength - aData.Length(); aData.Set(aOverflowData); // Wrap aData aOverflowData.Set(TPtrC8()); if (overflowLen > aData.Length()) { ASSERT(EFalse); // Shouldn't happen // in urel, return everything we've got return aData; } aTempBuf.Append(aData.Left(overflowLen)); aData.Set(aData.Mid(overflowLen)); return TPtrC8(aTempBuf); } }
void CWspHeaderReader::DecodeGenericNewStringValueL(RHeaderField& aHeader) const { TPtrC8 rawHeaderData; aHeader.RawDataL(rawHeaderData); TInt startPos = 0; TInt separatorPos = 0; TInt ii = 0; // Loop through all the parts separated by the header field name do { TPtrC8 rawData(rawHeaderData.Mid(startPos)); separatorPos = rawData.Locate((TUint8)(aHeader.Name().Index(WSP::Table) + KTopBitMask)); if(separatorPos!=KErrNotFound) rawData.Set(rawHeaderData.Mid(startPos, separatorPos)); CheckLengthL(rawData, 1); TWspPrimitiveDecoder wspDecoder(rawData); if( !(CheckNullDesPartL(aHeader, rawData, ii)) ) { AddNewDecoderStringPartL(aHeader, wspDecoder, ii); } ++ii; startPos += (separatorPos + 1); } while( separatorPos != KErrNotFound ); }
void CContentWindowContainer::DataReceived(class MBrCtlLinkContent* aLinkContent, const isab::DataGuiMess* aMess, const char *aUrl) { HBufC8* data = NULL; HBufC* contentType = NULL; HBufC* url = WFTextUtil::AllocLC(aUrl); TPtr8 ptr(const_cast<unsigned char*>(aMess->getData()), aMess->getSize(), aMess->getSize()); TInt neck = ptr.Find(KNeck()); if (neck == KErrNotFound) { data = HBufC8::NewLC( ptr.Length()); data->Des().Copy(ptr); contentType = WFTextUtil::AllocLC("text/html"); } else { TPtrC8 header = ptr.Left(neck); TPtrC8 body = ptr.Mid(neck+4); data = HBufC8::NewLC( body.Length()); data->Des().Copy(body); TInt pos = header.Find(KLineEnd); TPtrC8 rest = header; while (pos != KErrNotFound) { TPtrC8 tmp = rest.Left(pos); rest.Set(rest.Mid(pos+2)); pos = rest.Find(KLineEnd); TInt ctpos = tmp.FindF(KContentTypeMarker); if (ctpos != KErrNotFound) { TPtrC8 tmp2 = tmp.Mid(ctpos+KContentTypeMarker().Length()); TInt scpos = tmp2.Find(KSemiColon); if (scpos == KErrNotFound) { contentType = HBufC::NewLC(tmp2.Length()); contentType->Des().Copy(tmp2); } else { contentType = HBufC::NewLC(tmp2.Left(scpos).Length()); contentType->Des().Copy(tmp2.Left(scpos)); } break; } } if (!contentType) { contentType = WFTextUtil::AllocLC("text/html"); } } /* contentType = RecognizeLC(*url, ptr); */ /* contentType = WFTextUtil::AllocLC("text/html"); */ aLinkContent->HandleResolveComplete(*contentType, KCharSet, data); CleanupStack::PopAndDestroy(contentType); CleanupStack::PopAndDestroy(data); CleanupStack::PopAndDestroy(url); }
EXPORT_C CPushMessage* CMultipartBinIterator::PartL() /** Gets the message part currently referenced by the iterator. @return Message part @leave KErrCorrupt The message is too short @leave KErrNotFound Will leave if message body is empty @leave TDesC8::AllocLC @leave CPushMessage::NewL */ { __ASSERT_DEBUG( iCurrentPart < iMultiNumEntries.iValue, User::Panic(KPushPartIndexOutOfRange,0)); TPtrC8 msgBody; if (!iPushMessage.GetMessageBody(msgBody)) User::Leave(KErrNotFound); // iCurrentPartStart is pointing to beginning of the message // index will be used to get past the message headers TUint index = iCurrentPartStart; // Move over the headers TWapBinCodex::TUintvar hdrSize, bodySize; TWapBinCodex::ExtractUIntvarL(msgBody, index, hdrSize); index += hdrSize.iOctetSize; TWapBinCodex::ExtractUIntvarL(msgBody, index, bodySize); index += bodySize.iOctetSize; // Now get the data TUint len = msgBody.Length(); // validate that we have as much data as HEADER indicates if ( hdrSize.iValue < 0 || // No negative indices (len < (index + hdrSize.iValue))) User::Leave(KErrCorrupt); // Get the Header HBufC8* header = msgBody.Mid(index, hdrSize.iValue).AllocLC(); index += hdrSize.iValue; // validate that we have as much data as BODY indicates if ( bodySize.iValue < 0 || // No negative indices (len < (index + bodySize.iValue))) User::Leave(KErrCorrupt); // Get the Body HBufC8* body = msgBody.Mid(index, bodySize.iValue).AllocLC(); CPushMessage* pm = CPushMessage::NewL( header, body); CleanupStack::Pop(2, header); // body, header return pm; }
void CWspHeaderReader::DecodeContentEncodingL(RHeaderField& aHeader) const { TPtrC8 rawHeaderData; aHeader.RawDataL(rawHeaderData); TInt startPos = 0; TInt separatorPos = 0; TInt ii = 0; // Loop through all the parts separated by the header field token name do { TPtrC8 rawData(rawHeaderData.Mid(startPos)); separatorPos = rawData.Locate((TUint8)(WSP::EContentEncoding + KTopBitMask)); if(separatorPos!=KErrNotFound) rawData.Set(rawHeaderData.Mid(startPos, separatorPos)); CheckLengthL(rawData, 1); TInt contentEncodingIndex = KErrNotFound; switch( rawData[0] ) { case 128: // This is the token for 'GZip' { contentEncodingIndex = WSPStdConstants::EGzip; } break; case 129: // This is the token for 'Compress' { contentEncodingIndex = WSPStdConstants::ECompress; } break; case 130: // This is the token for 'Deflate' { contentEncodingIndex = WSPStdConstants::EDeflate; } break; default: // Must be token text { TWspPrimitiveDecoder wspDecoder(rawData); // Check that the data is of string type if( wspDecoder.VarType() == TWspPrimitiveDecoder::EString ) { // Extract and add the string as a part AddNewDecoderStringPartL(aHeader, wspDecoder, ii); } else User::Leave(KErrCorrupt); } break; } if(contentEncodingIndex!=KErrNotFound) SetFStringPartL(aHeader, ii, iStrPool.StringF(contentEncodingIndex, WSPStdConstants::Table)); ++ii; startPos += (separatorPos + 1); } while( separatorPos != KErrNotFound ); }
void CWspHeaderReader::DecodeContentLanguageL(RHeaderField& aHeader) const { TPtrC8 rawHeaderData; aHeader.RawDataL(rawHeaderData); TInt startPos = 0; TInt separatorPos = 0; TInt ii = 0; // Loop through all the parts separated by the header field name do { TPtrC8 rawData(rawHeaderData.Mid(startPos)); separatorPos = rawData.Locate((TUint8)(WSP::EContentLanguage + KTopBitMask)); if(separatorPos!=KErrNotFound) rawData.Set(rawHeaderData.Mid(startPos, separatorPos)); CheckLengthL(rawData, 1); // First check for any language ('*') encoded as octet 128 if( rawData[0] == 128 ) SetFStringPartL(aHeader, ii, iStrPool.StringF(WSPLanguages::EAnyLanguage, WSPLanguages::Table)); else { // Otherwise the language is encoded as a short int, long int or token text TWspPrimitiveDecoder wspDecoder(rawData); switch( wspDecoder.VarType() ) { case TWspPrimitiveDecoder::E7BitVal: // short int case TWspPrimitiveDecoder::ELengthVal: // long int { TUint32 languageToken = 0; User::LeaveIfError(wspDecoder.Integer(languageToken)); // Check if the language token is short or long int as long requires an offset if( languageToken >= 128 ) // Language token is long int so apply the offset --languageToken; SetFStringPartL(aHeader, ii, iStrPool.StringF(languageToken, WSPLanguages::Table)); } break; case TWspPrimitiveDecoder::EString: // token text { // Extract the token text and set the part AddNewDecoderStringPartL(aHeader, wspDecoder, ii); } break; default: User::Leave(KErrCorrupt); break; } } ++ii; startPos += (separatorPos + 1); } while( separatorPos != KErrNotFound ); }
void CWspDefaultHdrReader::DecodeHeaderL(RHeaderField& aHeader) { // Get and store the header field name TPtrC8 headerField(aHeader.Name().DesC()); // Decode the header as a text-string TPtrC8 rawHeaderData; aHeader.RawDataL(rawHeaderData); TInt startPos = 0; TInt separatorPos = 0; TInt ii = 0; // Loop through all the parts separated by the header field name do { TPtrC8 rawData(rawHeaderData.Mid(startPos)); separatorPos = rawData.FindF(headerField); if(separatorPos!=KErrNotFound) rawData.Set(rawHeaderData.Mid(startPos, separatorPos)); // Check that the length of the data is at least 1 if( rawData.Length() < 1 ) User::Leave(KErrCorrupt); // Check if the data is an empty string which should only have a NULL terminator // otherwise extract the text-string from the primitive decoder TUint8 firstByte = rawData[0]; TWspPrimitiveDecoder wspDecoder(rawData); TPtrC8 buffer; if( firstByte == 0 ) buffer.Set(KNullDesC8()); else User::LeaveIfError(wspDecoder.String(buffer)); // Create a header part from the decoded buffer and add the part to the header field RStringF partStr = iStrPool.OpenFStringL(buffer); CleanupClosePushL(partStr); THTTPHdrVal partVal(partStr); CHeaderFieldPart* part = CHeaderFieldPart::NewL(partVal); CleanupStack::PushL(part); aHeader.SetPartL(part, ii); CleanupStack::Pop(part); CleanupStack::PopAndDestroy(&partStr); ++ii; startPos += (separatorPos + headerField.Length() + 1); } while( separatorPos != KErrNotFound ); }
EXPORT_C TBool CHTTPResponse::ExtractCacheControlTime(TCacheControlFieldValue aField, TTime& aTime) const { __LOG_ENTER(_L("CHTTPResponse::ExtractCacheControlTime")); __ASSERT_DEBUG(aField == ECacheCtrlMaxAge || aField == ECacheCtrlMaxStale || aField == ECacheCtrlMinFresh, User::Invariant()); TBool result = EFalse; TPtrC8 cacheControl; aTime = 0; TInt index = FindCacheControlFieldValue(aField, cacheControl); if(index != KErrNotFound) { // Have the cache control and the field position // Now we need to extract the field's delta-secs value index++; TInt time = 0; TPtrC8 integerSource = cacheControl.Mid(index); if(integerSource[0] >= 0x80) // Short integer value time = integerSource[0] & 0x7F; else // Otherwise its multi octet ExtractMultiOctetInteger(time, integerSource); TTimeIntervalSeconds timeSeconds(time); aTime += timeSeconds; // Store the seconds in the time field result = ETrue; } __LOG_RETURN; return result; }
void CWspHeaderReader::DecodePragmaL(RHeaderField& aHeader) const { TPtrC8 rawData; aHeader.RawDataL(rawData); CheckLengthL(rawData, 1); // Check for <Octet 128> which indicates "No-Cache" string if( rawData[0] == 128 ) { SetFStringPartL(aHeader, 0, iStrPool.StringF(WSPStdConstants::ENoCache, WSPStdConstants::Table)); } else { TWspPrimitiveDecoder wspDecoder(rawData); if( wspDecoder.VarType() == TWspPrimitiveDecoder::ELengthVal ) { TInt dataLength = 0; TInt bytesProcessed = wspDecoder.LengthVal(dataLength); User::LeaveIfError(bytesProcessed); TPtrC8 rawParamBlock(rawData.Mid(bytesProcessed)); // Check that there is only one parameter block if( dataLength != rawParamBlock.Length() ) User::Leave(KErrCorrupt); CHeaderFieldPart& fieldPart = SetNewFStringPartL(aHeader, 0, KNullDesC8()); bytesProcessed += DecodeGenericSingleParameterL(rawParamBlock, fieldPart); if( bytesProcessed != rawData.Length() ) User::Leave(KErrCorrupt); } } }
TPtrC8 CSocketEngine::GetHttpHeaderInfo(const TDesC8 &aHeaderData,const TDesC8 &aHeaderInfo){ _LIT8(KEnter,"\r\n"); TBuf8<256> bufInfo(aHeaderInfo); bufInfo.Append(_L8(": ")); TPtrC8 ret; TPtrC8 ptr; ptr.Set(aHeaderData); TInt pos=ptr.FindF(bufInfo); if(pos>0){ TInt start=pos+bufInfo.Length(); ptr.Set(ptr.Mid(start)); pos=ptr.FindF(KEnter); if(pos>0){ ptr.Set(ptr.Left(pos)); ret.Set(ptr); }else if(-1==pos){ pos=ptr.FindF(_L8("\n")); if(pos>0){ ptr.Set(ptr.Left(pos)); ret.Set(ptr); } } } return ret; }
void CUPnPHeaderReader::DecodeCallbackL(RHeaderField& aHeader) const { //Callback: <token1><token2><token3>...<tokenN> TPtrC8 rawData; aHeader.RawDataL(rawData); TInt remaining = rawData.Length(); TPtrC8 token; TInt tokensFound = 0; TInt consumed; while (remaining) { // Locate and remove the '<' character from the token consumed = rawData.Locate(KOpenAngleBracket); if(consumed == KErrNotFound) { // No more tokens. break; } // '<' character has now been removed. rawData.Set(rawData.Mid(consumed+1)); // Now extract the value before '>' character. // This will be the actual value of the token. remaining -= InetProtTextUtils::ExtractNextTokenFromList(rawData, token, KCloseAngleBracket); // No parameters. Just store the field value InetProtTextUtils::RemoveWhiteSpace(token, InetProtTextUtils::ERemoveBoth); SetNewFStringPartL(aHeader, tokensFound, token); ++tokensFound; } }
/** * Retrieve contact point details from within SIA content body. This * method looks up the owned CPushMessage message body and gets a * pointer to it which it then parses to obtain the contact Points * string only which it sets the iContactList pointer to. * @leave KErrNotFound Will leave if the contacts list can not be obtained * @leave KErrCorrupt Will leave if the message body contains corrupted data */ void CSIAContentHandler::ObtainContactPointsListL() { __LOG_PTR_DEBUG("CSIAContentHandler::ObtainContactPointsListL Called"); TPtrC8 rFieldValue; TBool gotList = EFalse; if (iMessage->GetMessageBody(rFieldValue)) { TPtrC8 messageBodyPtr = rFieldValue; TWapBinCodex::TUintvar rMultiByte; TUint startpos = 1; TWapBinCodex::ExtractUIntvarL(messageBodyPtr, startpos, rMultiByte); TUint fieldSize = rMultiByte.iOctetSize; TUint appIdFieldLength = rMultiByte.iValue; TUint contactPointOffset = fieldSize + appIdFieldLength + startpos; // now get Uintvar of ContactPointLen TWapBinCodex::ExtractUIntvarL(messageBodyPtr, contactPointOffset, rMultiByte); //actual Contact Points field starts after ContactPointLen uintvar TUint contactPointLenSize = rMultiByte.iOctetSize; TUint contactPointLen = rMultiByte.iValue; TUint index = contactPointOffset + contactPointLenSize; iContactList.Set(messageBodyPtr.Mid(index, contactPointLen)); if (iContactList.Length()) gotList = ETrue; } // failed to parse the contact points list if (!gotList) { __LOG_PTR_DEBUG("CSIAContentHandler: Invalid Message Body - unable to parse."); User::Leave(KErrNotFound); } }
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 } }
void CVBookmarkConverter::IgnoreSpaces( TPtrC8& aData ) { TInt last = aData.Length() - 1; TInt begin; for ( begin = 0; begin <= last; begin++ ) { if ( !TChar( aData[begin] ).IsSpace() ) { break; } } TInt end; for ( end = last; end >= 0; end-- ) { if ( !TChar( aData[end] ).IsSpace() ) { break; } } TInt length = end - begin + 1; if ( ( begin != 0 || end != last ) && length > 0 ) { TPtrC8 newData = aData.Mid( begin, length ); aData.Set( newData ); } }
TInt CVBookmarkConverter::ReadAssignment( const TDesC8& aBuffer, TInt& aPosition, TPtrC8& aTag, TPtrC8& aValue ) { LOGGER_ENTERFN( "CVBookmarkConverter::ReadAssignment" ); TPtrC8 start = aBuffer.Mid( aPosition ); TInt assignment = start.Find( KVBMKAssignment ); TInt linefeed = start.Find( KVBMKLinefeed ); // Did we find the delimeter and the linefeed if ( ( assignment == KErrNotFound) || ( linefeed == KErrNotFound ) ) { return KErrNotFound; } // Linefeed must reside behind the delimeter if ( linefeed <= assignment ) { return KErrNotFound; } // Extract tag aTag.Set( start.Left( assignment ) ); IgnoreSpaces( aTag ); // Extract value aValue.Set( start.Mid( assignment + 1, ( linefeed - 1 ) - assignment ) ); IgnoreSpaces( aValue ); // update position aPosition += ( linefeed + KVBMKLinefeed().Length() ); LOGGER_LEAVEFN( "CVBookmarkConverter::ReadAssignment" ); return KErrNone; }
void CATSmsMessagingRead::PopulateScaFieldsAndRemove(TPtrC8& aPdu, RMobilePhone::TMobileAddress& aGsmServiceCentre) // // Populate the SCA field in the MM ETel structure from the SCA prepended in a received PDU. // { const TUint8 KTONBitMask =0x70; const TUint8 KNPIBitMask=0x0f; const TUint8 KTONBitShift=4; const TUint8 KNPIBitShift=0; _LIT(KInternationalPrefix,"+"); __ASSERT_ALWAYS(aPdu.Length()>0,Panic(ECMTHandlerDesPassedWithZeroLength)); aGsmServiceCentre.iTypeOfNumber=(RMobilePhone::TMobileTON)0; aGsmServiceCentre.iNumberPlan=(RMobilePhone::TMobileNPI)0; aGsmServiceCentre.iTelNumber.Zero(); TUint8 len=aPdu[0]; if(len==0) { // A zero length SCA has been prepended - just strip this first byte off aPdu.Set(aPdu.Mid(len+1)); return; } TUint8 numDes=aPdu[1]; aGsmServiceCentre.iTypeOfNumber=(RMobilePhone::TMobileTON)((numDes&KTONBitMask)>>KTONBitShift); aGsmServiceCentre.iNumberPlan=(RMobilePhone::TMobileNPI)((numDes&KNPIBitMask)>>KNPIBitShift); if(aGsmServiceCentre.iTypeOfNumber==RMobilePhone::EInternationalNumber) aGsmServiceCentre.iTelNumber.Append(KInternationalPrefix); TInt i; TUint16 digit; for(i=2;i<(len+1);i++) { digit=(TUint16)((aPdu[i]&0x0f)+0x30); aGsmServiceCentre.iTelNumber.Append(digit); digit=(TUint16)(((aPdu[i]&0xf0)>>4)+0x30); if(digit==0x003f) // 'F' is the padding digit at the end of a number break; aGsmServiceCentre.iTelNumber.Append(digit); } aPdu.Set(aPdu.Mid(len+1)); }
// ----------------------------------------------------------------------------- // CUpnpDevice::DescriptionUrlPort // Retrun description URL port. // ----------------------------------------------------------------------------- // EXPORT_C TInt CUpnpDevice::DescriptionUrlPort() const { if ( iAddress != TInetAddr( INET_ADDR( 0,0,0,0 ), 0) ) { return iAddress.Port(); } const TDesC8& url = DescriptionUrl(); if ( url.Length()> KHttp().Length() ) { TPtrC8 addrAndPath = url.Right( url.Length() - KHttp().Length() ); TInt separIndex = addrAndPath.Find( KSepar() ); if ( separIndex == KErrNotFound ) { return KDefaultDescriptionUrlPort; } TInt slashIndex = addrAndPath.Find( KSlash8() ); if ( slashIndex != KErrNotFound ) { TPtrC8 port = addrAndPath.Mid( separIndex + 1, slashIndex - separIndex ); TLex8 lex( port ); TInt prt; TInt err = lex.Val( prt ); if( KErrNone != err ) { return KErrNotFound; } return prt; } else { TPtrC8 port = addrAndPath.Right( addrAndPath.Length() - ( separIndex + 1 ) ); TLex8 lex( port ); TInt prt; TInt err = lex.Val( prt ); if( KErrNone != err ) { return KErrNotFound; } return prt; } } return KDefaultDescriptionUrlPort; }
//--------------------------------------------------------------- // CNativeMmsUtility::resolvedByContentIdL // @see header //--------------------------------------------------------------- TBool CNativeMmsUtility::resolvedByContentIdL(const TPtrC8& contentidptr, const CUri16& targeturi) { #ifdef _DEBUG_TRACES_ qDebug() << " Enter CNativeMmsUtility::resolvedByContentIdL"; #endif TBool result = EFalse; TUriParser8 parser; CUri16* contIdUri = NULL; HBufC8* contentId = NULL; //get content-id uri if (contentidptr.Length()) { //Copy string to 8-bit descriptor contentId = HBufC8::NewLC(contentidptr.Length()); if (contentId->Find(KCidLeftAngle) == 0 && contentId->Find(KCidRightAngle) == contentId->Length() - 1) { // When comparing against cid, remove "<" and ">" contentId->Des().Copy(contentidptr.Mid(1, contentidptr.Length() - 2)); } else { contentId->Des().Copy(contentidptr); } parser.Parse(*contentId); contIdUri = UriUtils::ConvertToDisplayFormL(parser); CleanupStack::PushL(contIdUri); } //compare content-id against the target uri if ( (contentidptr.Length()) && (targeturi.Uri().UriDes().CompareF(contIdUri->Uri().UriDes()) == 0)) { #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentIdL"; #endif result = ETrue; } //do some cleanup if (contentId) { CleanupStack::PopAndDestroy(2, contentId); // contentId, contIdUri } #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::resolvedByContentIdL"; #endif return result; }
TBool CExampleResolver::Match(const TDesC8& aImplementationType, const TDesC8& aMatchType, TBool aUseWildcards) const { TInt matchPos = KErrNotFound; _LIT8(dataSeparator, "||"); const TInt separatorLength = dataSeparator().Length(); // Look for the section separator marker '||' TInt separatorPos = aImplementationType.Find(dataSeparator); if(separatorPos == KErrNotFound) { // Match against the whole string if(aUseWildcards) matchPos = aImplementationType.Match(aMatchType); else matchPos = aImplementationType.Compare(aMatchType); } else { // Find the first section, up to the separator TPtrC8 dataSection = aImplementationType.Left(separatorPos); TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength); // Match against each section in turn while(separatorPos != KErrNotFound) { // Search this section if(aUseWildcards) matchPos = dataSection.Match(aMatchType); else matchPos = dataSection.Compare(aMatchType); // If we found it then no need to continue, so return if(matchPos != KErrNotFound) return ETrue; // Move on to the next section separatorPos = remainingData.Find(dataSeparator); if(separatorPos != KErrNotFound) { dataSection.Set(remainingData.Left(separatorPos)); remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); } else dataSection.Set(remainingData); } // Check the final part if(aUseWildcards) matchPos = dataSection.Match(aMatchType); else matchPos = dataSection.Compare(aMatchType); } return matchPos != KErrNotFound; }
void CWspHeaderReader::DecodeSetCookieL(RHeaderField& aHeader) const { TPtrC8 rawData; aHeader.RawDataL(rawData); CheckLengthL(rawData, 2); TWspPrimitiveDecoder wspDecoder(rawData); if( wspDecoder.VarType() != TWspPrimitiveDecoder::ELengthVal ) User::Leave(KErrCorrupt); TInt valueLength = 0; TInt bytesProcessed = wspDecoder.LengthVal(valueLength); User::LeaveIfError(bytesProcessed); // Get the first part which is the cookie-version TInt err = 0; if( CheckForNullStringL(rawData, bytesProcessed, wspDecoder) ) { SetNewFStringPartL(aHeader, 0, KNullDesC8()); } else { RStringF version; err = wspDecoder.VersionL(iStrPool, version); User::LeaveIfError(err); bytesProcessed += err; CleanupClosePushL(version); SetFStringPartL(aHeader, 0, version); CleanupStack::PopAndDestroy(&version); } // Loop through the next two // Get the second part which is the cookie-name // Get the third part which is the cookie-value CHeaderFieldPart* fieldPart = NULL; for(TInt ii=1; ii<3; ++ii) { TPtrC8 cookiePart(KNullDesC8()); if( !(CheckForNullStringL(rawData, bytesProcessed, wspDecoder)) ) { err = wspDecoder.String(cookiePart); User::LeaveIfError(err); bytesProcessed += err; } fieldPart = &(SetNewFStringPartL(aHeader, ii, cookiePart)); } // Check if there are any parameters. if so add them to the 3rd part if( fieldPart != NULL ) { while( bytesProcessed < rawData.Length() ) { TPtrC8 parameterBlock(rawData.Mid(bytesProcessed)); bytesProcessed += DecodeGenericSingleParameterL(parameterBlock, *fieldPart); } } }
void RElementIdArray::SetListL( const TDesC8& aChilds) { TInt index = 0; TPtrC8 ptr = aChilds; while ( 0 <= ( index = ptr.Locate( KMessageDelimiterChar))) { AppendL( ptr.Left( index).AllocL()); ptr.Set( ptr.Mid(index + 1)); } }
// Return descriptor, without any enclosing brackets < > TPtrC8 CImapAtom::AtomNoAngleBrackets() { TPtrC8 atom = iAtom; TInt len = atom.Length(); if (len>2 && atom[0]==KImcvLeftChevron && atom[len-1]==KImcvRightChevron) { atom.Set(atom.Mid(1,len-2)); } return(atom); }
void CWspHeaderReader::DecodeGenericFieldNameL(RHeaderField& aHeader) const { TPtrC8 rawHeaderData; aHeader.RawDataL(rawHeaderData); TInt startPos = 0; TInt separatorPos = 0; TInt ii = 0; // Loop through all the parts separated by the header field name do { TPtrC8 rawData(rawHeaderData.Mid(startPos)); separatorPos = rawData.Locate((TUint8)(aHeader.Name().Index(WSP::Table) + KTopBitMask)); if(separatorPos!=KErrNotFound) rawData.Set(rawHeaderData.Mid(startPos, separatorPos)); CheckLengthL(rawData, 1); TWspPrimitiveDecoder wspDecoder(rawData); switch( wspDecoder.VarType() ) { case TWspPrimitiveDecoder::EString: { AddNewDecoderStringPartL(aHeader, wspDecoder, ii); } break; case TWspPrimitiveDecoder::E7BitVal: { TUint8 fieldNameToken = 0; User::LeaveIfError(wspDecoder.Val7Bit(fieldNameToken)); RStringF fieldNameStr = iStrPool.StringF(fieldNameToken, iStrTable); SetFStringPartL(aHeader, ii, fieldNameStr); } break; default: User::Leave(KErrCorrupt); break; } ++ii; startPos += (separatorPos + 1); } while( separatorPos != KErrNotFound ); }
/** Loads a drawsection from externalized data. @param aData The parser for the externalized data. @param aIndex The index of the drawsection in CCommandBuffer::iDrawSections to load from the externalized data. */ TInt CDrawSection::LoadL(const TWsGraphicMsgBufParser& aData, TInt aIndex) { if(aData.Uid(aIndex).iUid != KDrawSection.iUid) { return KErrArgument; } const TPtrC8 pckg = aData.Data(aIndex); const TPtrC8 drawRectPtr = pckg.Left(sizeof(TRect)); const TPtrC8 boundingRectPtr = pckg.Mid(sizeof(TRect), sizeof(TRect)); const TPtrC8 segBufPtr = pckg.Mid(sizeof(TRect)*2); Mem::Copy(&iDrawRect, drawRectPtr.Ptr(), sizeof(TRect)); Mem::Copy(&iBoundingRect, boundingRectPtr.Ptr(), sizeof(TRect)); if(iSectionSegBuf) delete iSectionSegBuf; iSectionSegBuf = CBufSeg::NewL(KBufferSize); iSectionSegBuf->InsertL(0, segBufPtr); return KErrNone; }
TBool CAiwResolver::MatchServiceCmd(const TDesC8& aOpaqueData, const TDesC8& aServiceCmd) const { _LIT8(dataSeparator, "||"); const TInt separatorLength = dataSeparator().Length(); // Look for the section separator marker '||' TInt separatorPos = aOpaqueData.Find(dataSeparator); if (separatorPos == KErrNotFound) { if (aServiceCmd.Compare(aOpaqueData) == 0) { return ETrue; } } else { // Find the first section, up to the separator TPtrC8 dataSection = aOpaqueData.Left(separatorPos); TPtrC8 remainingData = aOpaqueData.Mid(separatorPos + separatorLength); // Match against each section in turn while (separatorPos != KErrNotFound) { if (dataSection.Compare(aServiceCmd) == 0) { return ETrue; } // Move on to the next section separatorPos = remainingData.Find(dataSeparator); if (separatorPos != KErrNotFound) { dataSection.Set(remainingData.Left(separatorPos)); remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); } else { dataSection.Set(remainingData); } } if (dataSection.Compare(aServiceCmd) == 0) { return ETrue; } } return EFalse; }
/** Checks that a path is in a valid form @return ETrue if the path is valid otherwise EFalse */ TBool TValidatorTel::IsValidPath() const { const TDesC8& path = iUri.Extract(EUriPath); //empty path is invalid if(!path.Length()) { return EFalse; } //Implementation of all the steps specified in section 2.5.2.2 //Validation of the path components of tel uri TDelimitedPathSegmentParser8 parser; parser.Parse(path); // tel parameters should start with a '+' or 'digit' TChar ch( path[0] ); if(! (ch == '+' || ch.IsDigit()) ) { return EFalse; } TPtrC8 name; TPtrC8 value; TPtrC8 segment; //First segemnt must be telephone number if (parser.GetNext(segment) == KErrNone) { GetNameValuePair(segment, name, value); //contains only digits if(!IsValidCharacters(name.Mid(1), KCharSetNumber)) { return EFalse; } } //Remainig all the segments while( parser.GetNext(segment) == KErrNone ) { GetNameValuePair(segment, name, value); if(IsEmpty(segment)) { return ETrue; } if ( IsEmpty(value) || IsDuplicated(name, parser) || !IsValidParamSegment(name, value) ) { return EFalse; } } return ETrue; }
TInt CSenPropertiesElement::ValueTokensL(const TDesC8& aDelimiter, RPointerArray<TPtrC8>& aTokens) { TPtrC8 content = this->Content(); TInt delim = content.Find(aDelimiter); while ( delim != KErrNotFound ) { TPtrC8* piece = new (ELeave) TPtrC8(); piece->Set(content.Mid(0,delim)); aTokens.Append(piece); content.Set(content.Mid(delim+aDelimiter.Length(), content.Length()-(delim+aDelimiter.Length()))); delim = content.Find(aDelimiter); } if(!(this->Content()!=KNullDesC8 && content==KNullDesC8)) { // If this property does NOT zero-length content // and the "last" (or first) token is KNullDesC8 // it means that the string ends with delimiter; // Therefore, KNullDesC8 must NOT be added as a // result of "tailing delimiter". // Add all other tokens here; even KNullDesC8 // gets added, if it is eiher first or TPtrC8* token = new (ELeave) TPtrC8(); token->Set(content); aTokens.Append(token); } if (aTokens.Count() == 0) { return KErrNotFound; } return KErrNone; }
void CWspHeaderReader::DecodeUntypedParamL(TWspPrimitiveDecoder& aDecoder, TInt& aBytesRead, TPtrC8& aRawParamBlock, CHeaderFieldPart& aHeaderFieldPart) const { TPtrC8 paramName; aBytesRead = aDecoder.String(paramName); User::LeaveIfError(aBytesRead); TWspPrimitiveDecoder paramValueDecoder(aRawParamBlock.Mid(aBytesRead)); TWspPrimitiveDecoder::TWspHeaderType type = paramValueDecoder.VarType(); // Check if the first octet is NULL, if it is then the value is a <no-value> string if( aRawParamBlock[aBytesRead] == 0 ) type = TWspPrimitiveDecoder::EString; switch( type ) { case TWspPrimitiveDecoder::ELengthVal: case TWspPrimitiveDecoder::E7BitVal: { TUint32 paramIntValue = 0; aBytesRead += paramValueDecoder.Integer(paramIntValue); SetNewParamL(aHeaderFieldPart, paramName, paramIntValue); } break; case TWspPrimitiveDecoder::EString: case TWspPrimitiveDecoder::EQuotedString: { RStringF paramValueStr; CleanupClosePushL(paramValueStr); // Check if the parameter has a value if( aRawParamBlock[aBytesRead] == 0 ) { paramValueStr = iStrPool.OpenFStringL(KNullDesC8()); ++aBytesRead; } else { TPtrC8 paramStrValue; TInt err = paramValueDecoder.String(paramStrValue); paramValueStr = iStrPool.OpenFStringL(paramStrValue); User::LeaveIfError(err); aBytesRead += err; } SetNewParamL(aHeaderFieldPart, paramName, paramValueStr); CleanupStack::PopAndDestroy(¶mValueStr); } break; default: User::Leave(KErrCorrupt); break; } }
// ----------------------------------------------------------------------------- // CUpnpSoapMessage::ActionName // // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C const TPtrC8 CUpnpSoapMessage::ActionName() { const TPtrC8 soap = SoapAction(); if (soap.Length() > 0) { TInt crossIndex = soap.Find( KCross() ); if ( 0 <= crossIndex ) { return soap.Mid(crossIndex + 1, soap.Length() - (crossIndex + 2)); } } // If soap is zero or KCross is not found, return KNullDesC8 return KNullDesC8(); }