void CLocationEngine::XmppStanzaAcknowledgedL(const TDesC8& aStanza, const TDesC8& /*aId*/) { CXmlParser* aXmlParser = CXmlParser::NewLC(aStanza); TPtrC8 aAttributeType = aXmlParser->GetStringAttribute(_L8("type")); if(aXmlParser->MoveToElement(_L8("location"))) { if(aAttributeType.Compare(_L8("result")) == 0) { // Beacon log result iPatternQuality = aXmlParser->GetIntAttribute(_L8("cellpatternquality")); iPlaceId = aXmlParser->GetIntAttribute(_L8("placeid")); TPtrC8 aAttributeState = aXmlParser->GetStringAttribute(_L8("state")); if(aAttributeState.Compare(_L8("stationary")) == 0) { iMotionState = EMotionStationary; } else if(aAttributeState.Compare(_L8("restless")) == 0) { iMotionState = EMotionRestless; } else { iMotionState = EMotionMoving; } iEngineObserver->HandleLocationServerResult(iMotionState, iPatternQuality, iPlaceId); } } CleanupStack::PopAndDestroy(); // aXmlParser }
CSenElement* CPolicyNormalizer::ProcessAssertionBranchingL(CSenElement* aPolicy) { RPointerArray<CSenElement>& children = aPolicy->ElementsL(); TInt childCount = children.Count(); if(childCount == 0) return aPolicy; TInt i = 0; while (i < childCount) { CSenElement* pChild = children[i]; TPtrC8 childName = pChild->LocalName(); if( childName.Compare(WSPolicy::KWsPolicy) == 0 || childName.Compare(WSPolicy::KAndCompositeAssertion) == 0 || childName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { ProcessAssertionBranchingL(pChild); } else //Assertion { DuplicateAssertionBranchL(aPolicy , pChild); } i++; } return aPolicy; }
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; }
// ----------------------------------------------------------------------------- // TSdpTypedTime::DecodeL // Decodes typed time from TDesC // ----------------------------------------------------------------------------- // TSdpTypedTime TSdpTypedTime::DecodeL(const TDesC8& aText) { TLex8 typedTimeLex(aText); TSdpTypedTime typedTime; User::LeaveIfError(typedTimeLex.Val(typedTime.iValue, EDecimal)); if (typedTimeLex.Peek() != 0) { TPtrC8 unitString = typedTimeLex.NextToken(); RStringPool pool = SdpCodecStringPool::StringPoolL(); const TDesC8& timeDays = pool.StringF( SdpCodecStringConstants::ETimeUnitDays, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeHours = pool.StringF( SdpCodecStringConstants::ETimeUnitHours, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeMinutes = pool.StringF( SdpCodecStringConstants::ETimeUnitMinutes, SdpCodecStringConstants::Table).DesC(); const TDesC8& timeSeconds = pool.StringF( SdpCodecStringConstants::ETimeUnitSeconds, SdpCodecStringConstants::Table).DesC(); if (unitString.Compare(timeDays) == 0) { typedTime.iUnit = ETimeUnitDays; } else if (unitString.Compare(timeHours) == 0) { typedTime.iUnit = ETimeUnitHours; } else if (unitString.Compare(timeMinutes) == 0) { typedTime.iUnit = ETimeUnitMinutes; } else if (unitString.Compare(timeSeconds) == 0) { typedTime.iUnit = ETimeUnitSeconds; } else { User::Leave(KErrSdpCodecTypedTime); } } else { typedTime.iUnit = ETimeUnitNone; } return typedTime; }
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; }
CSenElement* CPolicyNormalizer::ProcessXORTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion) { CSenElement* pNormChild = AddXorElementL(aNormalAssertion); RPointerArray<CSenElement>& children = aAssertion->ElementsL(); TInt childCount = children.Count(); TInt i = 0; while (i < childCount) { CSenElement* pChild = children[i]; CSenElement* pNewChild = NULL; // CSenElement* newChild = NULL; TPtrC8 childName = pChild->LocalName(); if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { //If AND element then take child of AND // CSenElement* newChild = ProcessANDTermL(pChild, pNormChild); } else if (childName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { } else if(childName.Compare(WSPolicy::KWsPolicy) == 0) { pNewChild = AddAndElementL(pNormChild); if(HasChildL(pChild) > 0) ProcessPolicyTermL(pChild,pNewChild); } else { pNewChild = AddAndElementL(pNormChild); // newChild = ProcessAssertionTermL(pChild, pNewChild); //if Assertion then first we haveto add AND and then add Assertion //(assertion will be done by AND too) } i++; } return pNormChild; }
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 } }
//util to check any key within that section holds that value //if not found simply return the number of keys within that section TInt CConfigImpl::CheckValueExist(const TDesC8& aSectionName,const TDesC8& aValue,TInt& aKeyCount) { CIniSecIter8* iter=NULL; TRAPD(err,iter=CIniSecIter8::NewL(aSectionName,iIniFileDocument)); //if section not found it might be the first time we are creating //the document so it is fine to return KErrNone if (err==KErrNotFound) { return KErrNone; } //return the error code if else than KErrNotFound e.g. KErrNoMemory; if (err!=KErrNone) { return err; } TPtrC8 key; TPtrC8 value; TInt keyCount=0; while (iter->Next(key,value)) { if (value.Compare(aValue)==0) { delete iter; keyCount=0; return KErrAlreadyExists; } keyCount++; } aKeyCount=keyCount; delete iter; return KErrNone; }
HBufC8* CVBookmarkConverter::DecodeQuotedPrintableLC( const TDesC8& aEncodedData ) { TInt encodedLength = aEncodedData.Length(); HBufC8* decodeBuffer = HBufC8::NewLC( encodedLength ); TPtr8 ptrDecodeBuffer = decodeBuffer->Des(); TInt i(0); while ( i < encodedLength ) { TChar nextChar = aEncodedData[i++]; if ( nextChar == '=' ) { if ( i + 2 > encodedLength ) { ptrDecodeBuffer.Append( '=' ); if ( i + 1 == encodedLength ) { ptrDecodeBuffer.Append( aEncodedData[i++] ); } } else { TPtrC8 data = aEncodedData.Mid( i, 2 ); i += 2; if ( data.Compare(KVBMKLinefeed) == 0 ) { // Do nothing // '=' at the end of line is soft line break, not to be decoded } else { TLex8 hexChar( data ); TUint8 value( 0 ); if ( hexChar.Val( value, EHex ) == KErrNone ) { ptrDecodeBuffer.Append( TChar( value ) ); } else { // Decoding failed, put the data at itself ptrDecodeBuffer.Append( '=' ); ptrDecodeBuffer.Append( data ); } } } } else { ptrDecodeBuffer.Append( nextChar ); } } return decodeBuffer; }
TInt CTlsEncrypt::DecryptAndVerifyL(const TDesC8& aInput,HBufC8*& aOutput, TInt64& aSeqNumber, TRecordProtocol& aType) { if(!aInput.Length()) return KErrBadDescriptor; TLSPROV_LOG2(_L("Before Decryption...RecordType: %d"),(TInt)aType) TLSPROV_LOG_HEX(aInput.Ptr(),aInput.Size() ) TInt nAlloc = iCryptos.iDecryptor->MaxFinalOutputLength(aInput.Size()) + 24; if ( !aOutput || aOutput->Des().MaxLength() < nAlloc ) { delete aOutput; aOutput = NULL; aOutput = HBufC8::NewL( nAlloc ); } TPtr8 DecOutput = aOutput->Des(); DecOutput.Zero(); TRAP_IGNORE(iCryptos.iDecryptor->ProcessFinalL(aInput,DecOutput)); TUint HashSize = KSetOfTLSCipherSuites[iCipherIndex].iHashSize; if(DecOutput.Length() < HashSize) { return KErrSSLAlertDecryptError; } //set ptr to MAC TPtrC8 ReceivedMac = DecOutput.Mid(DecOutput.Length()-HashSize,HashSize); //& set length to trim MAC DecOutput.SetLength( DecOutput.Length()-HashSize ); TBuf8<64> CalculatedMac; ComputeMacL(CalculatedMac,DecOutput,ETrue,aSeqNumber,aType); TInt err = KErrBadMAC; if(ReceivedMac.Compare(CalculatedMac) == 0) { err = KErrNone; } else { TLSPROV_LOG(_L("Decryption: Received MAC error")) err = KErrSSLAlertBadRecordMac; } TLSPROV_LOG(_L("After Decryption , no mac")) TLSPROV_LOG_HEX(aOutput->Ptr(),aOutput->Size() ) return err; }
//----------------------------------------------------------------------------- //Function Name : void* SearchName(const TE32ExpSymInfoHdr* aSymInfoHeader, // const char* aName) //Description : To search symbol name in symbol table of the dll. //Return Value : Valid address if name found otherwise NULL //----------------------------------------------------------------------------- void* SearchName(const TE32ExpSymInfoHdr* aSymInfoHeader, const char* aName) { //Size of Offset used by Symbol Table, it depends upon iFlags of E32EpocExpSymInfoHdr TInt sizeOfStringTableOffset = KTwoByteOffset; // Check size of symbol table offset if ( aSymInfoHeader->iFlags ) { sizeOfStringTableOffset = KFourByteOffset; } //Total no of Symbol in a Symbol table TInt noOfSymbols = aSymInfoHeader->iSymCount; TInt start = 0; TInt mid; TInt end = noOfSymbols-1; TInt temp = 0 ; TInt offsetToString = 0; TPtrC8 tempName; TPtrC8 pName; pName.Set((unsigned char*)aName, strlen(aName)); TUint8* tempSymbolOffset = (TUint8*) aSymInfoHeader+ aSymInfoHeader->iSymbolTblOffset + noOfSymbols * sizeof(TInt); TUint8* tempStringTableOffset = (TUint8*) aSymInfoHeader + aSymInfoHeader->iStringTableOffset; //Binary Search for searching name in symbol table while (start <= end) { mid = (start + end) / 2; if ( sizeOfStringTableOffset == KTwoByteOffset ) { offsetToString = *(unsigned short int*)(tempSymbolOffset + (sizeOfStringTableOffset * mid)); } else { offsetToString = *(unsigned int*)(tempSymbolOffset + (sizeOfStringTableOffset * mid)); } //need to shift 2 bit to left for alignment reasons offsetToString <<= 2; tempName.Set((unsigned char*)(tempStringTableOffset + offsetToString), strlen((char*)tempStringTableOffset + offsetToString)); temp = pName.Compare(tempName); //if found return address of symbol if( !temp ) { return *( (void**)( (TUint8*)aSymInfoHeader+ aSymInfoHeader->iSymbolTblOffset + mid * sizeof(TInt))); } //update start/end if ( temp < 0 ) { end = mid -1; } else { start = mid +1; } } return NULL; }
TBool CMulScreensTestAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine) { TPtrC8 tailEnd = aCommandLine.TailEnd(); if(tailEnd.Compare(KScreenDevice) == 0) { RDebug::Print(_L("**** MultipleScreensAppTest - ScreenDevice: This should panic with ECoePanicInvalidScreenNumber")); CCoeEnv::Static()->ScreenDevice(KInvalidScreenNumber); } else if(tailEnd.Compare(KWindowGroup) == 0) { RDebug::Print(_L("**** MultipleScreensAppTest - WindowGroup: This should panic with ECoePanicInvalidScreenNumber")); CCoeEnv::Static()->RootWin(KInvalidScreenNumber); } else { RDebug::Print(_L("MultipleScreensAppTest - Bad arguments, failing test....")); RProcess().Terminate(KMulScreensAppTestFailed); } return ETrue; }
CSenElement* CPolicyNormalizer::ProcessANDTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion) { CSenElement* pNormChild = AddAndElementL(aNormalAssertion); RPointerArray<CSenElement>& children = aAssertion->ElementsL(); TInt childCount = children.Count(); // CSenElement* normalizedFinalChild = NULL; TInt i=0; while (i < childCount) { CSenElement* pChild = children[i]; // CSenElement* newChild = NULL; TPtrC8 childName = pChild->LocalName(); if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { } else if (childName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { //will be solved during collapsing } else if (childName.Compare(WSPolicy::KWsPolicy) == 0) { ProcessPolicyTermL(pChild,pNormChild); } else { // normalizedFinalChild = ProcessAssertionTermL(pChild, pNormChild); } i++; } return aNormalAssertion; }
/** * Processes the command line parameters * @param aCommandLine - command to be passed based on the menu item * selected by the user * * This function leaks intentionally some memory and examines the value of the trailing data * in aCommandLine (expected to be either ETrue or EFalse). According to this value CCoeEnv::DisableExitChecks() * is triggered in order to disable or not the exit checks at kernel resources. * */ TBool CExampleAppUi::ProcessCommandParametersL(CApaCommandLine& aCommandLine) { CEikAppUi* aAppUI = new(ELeave) CExampleAppUi; //intentionally caused memory leak TPtrC8 tailEnd = aCommandLine.TailEnd(); if(tailEnd.Compare(KETrue) == 0) { RDebug::Print(_L("Disable shutdown checks")); iEikonEnv->DisableExitChecks(ETrue); } else if(tailEnd.Compare(KEFalse) == 0) { RDebug::Print(_L("Enable shutdown checks")); iEikonEnv->DisableExitChecks(EFalse); } else { RDebug::Print(_L("Bad arguments, failing test....")); RProcess().Terminate(KTestFailed); } Exit(); return ETrue; }
CSenElement* CPolicyNormalizer::DeleteAsertionIndexL(CSenElement* aAssertion, CSenElement* anewAssertion, TInt aIndx) { TPtrC8 name = aAssertion->LocalName(); TPtrC8 nsUri = aAssertion->NamespaceURI(); TInt i = 0; RPointerArray<CSenElement>& assertionChildren = anewAssertion->ElementsL(); TInt newAssertionChildCount = assertionChildren.Count(); if(newAssertionChildCount == 0) return anewAssertion; TPtrC8 namee = anewAssertion->LocalName(); if (name.Compare(anewAssertion->LocalName())== 0) { //delete children from this assertion except index child CSenXmlElement* PolicyElement = (CSenXmlElement*)anewAssertion->Child(0); CSenXmlElement* XORElement = (CSenXmlElement*)PolicyElement->Child(0); RPointerArray<CSenElement>& XorChildren = XORElement->ElementsL(); TInt XORChildrenCount = XorChildren.Count(); for (TInt k = 0; k <XORChildrenCount; k++) { if(k == aIndx) { } else { CSenElement* newElement = XORElement->RemoveElement(*XorChildren[XORChildrenCount-1-k]); if(newElement) { delete newElement; // break; } } } return anewAssertion; } while (i < newAssertionChildCount) { DeleteAsertionIndexL(aAssertion, assertionChildren[i], aIndx); i++; } return anewAssertion; }
EXPORT_C TBool CDecPkcs12MacData::VerifyIntegrityL(const TDesC& aPassword) const { __UHEAP_MARK; HBufC8* encryptKey = HBufC8::NewMaxLC(KSha1HmacKeyLength); TPtr8 encryptedKey(encryptKey->Des()); // Convert the supplied string to a byte string. Each character is converted to a big // endian two-byte value, and a terminating NULL character is appended to the end. HBufC8* password = PKCS12KDF::GeneratePasswordLC(aPassword); PKCS12KDF::DeriveKeyL(encryptedKey, PKCS12KDF::EIDByteMACKey, *password ,MacSalt(), IterationCount()); CMessageDigest* digest1 = NULL; TAlgorithmId algorithmId = DigestInfo().Algorithm(); if (algorithmId != ESHA1) { User::Leave(KErrNotSupported); } digest1 = CSHA1::NewL(); CleanupStack::PushL( digest1 ); CHMAC* hmac1 = CHMAC::NewL( encryptedKey, digest1); CleanupStack::PushL( hmac1 ); TPtrC8 tmpHash = hmac1->Final(iAuthSafeDataPtr); TInt ret = tmpHash.Compare(DigestInfo().Digest()); TBool result; if(ret) { result = EFalse; } else { result = ETrue; } CleanupStack::PopAndDestroy(hmac1); CleanupStack::Pop(digest1); CleanupStack::PopAndDestroy(2,encryptKey); // encryptKey, password __UHEAP_MARKEND; return result; }
CSenElement* CPolicyNormalizer::NormalizeL(CPolicyRegistry* aRegistry) { CSenElement& element = AsElement(); TPtrC8 name = element.LocalName(); if (name.Compare(KWsPolicy) == 0) { iNewPolicy->CopyFromL(element); RPointerArray<CSenElement>& children = iNewPolicy->ElementsL(); CleanupClosePushL(children); TInt childCount = children.Count(); if(childCount > 0) { CSenElement* pNextChild; TInt i = 0; while (i < childCount) { pNextChild = children[childCount-1]; CSenElement* newElement = iNewPolicy->RemoveElement(*pNextChild); delete newElement; childCount--; } } CleanupStack::PopAndDestroy(); //children ProcessPolicyReferenceL(&element, aRegistry); ProcessPolicyTermL(&element, iNewPolicy); ProcessLogicL(iNewPolicy); ProcessAssertionBranchingL(iNewPolicy); //#ifdef _SENDEBUG WriteL(iNewPolicy); //#endif return iNewPolicy; } return NULL; //&element; }
CAtomEntryData* CXmppAtomEntryParser::XmlToAtomEntryLC(const TDesC8& aStanza, TDes8& aReferenceId, TBool aExtended) { CAtomEntryData* aAtomEntry = CAtomEntryData::NewLC(); CXmlParser* aXmlParser = CXmlParser::NewLC(aStanza); CTextUtilities* aTextUtilities = CTextUtilities::NewLC(); TEntryContentType aEntryType = EEntryContentPost; aReferenceId.Zero(); do { TPtrC8 aElementName = aXmlParser->GetElementName(); if(aElementName.Compare(_L8("updated")) == 0) { aAtomEntry->SetPublishTime(CTimeUtilities::DecodeL(aXmlParser->GetStringData())); } else if(aElementName.Compare(_L8("thr:in-reply-to")) == 0) { aReferenceId.Copy(aXmlParser->GetStringAttribute(_L8("ref")).Left(aReferenceId.MaxLength())); } else if(aElementName.Compare(_L8("author")) == 0) { CXmlParser* aAuthorXmlParser = CXmlParser::NewLC(aXmlParser->GetStringData()); do { aElementName.Set(aAuthorXmlParser->GetElementName()); if(aElementName.Compare(_L8("name")) == 0) { aAtomEntry->SetAuthorNameL(aTextUtilities->Utf8ToUnicodeL(aAuthorXmlParser->GetStringData())); } else if(aElementName.Compare(_L8("jid")) == 0) { aAtomEntry->SetAuthorJidL(aTextUtilities->Utf8ToUnicodeL(aAuthorXmlParser->GetStringData())); } else if(aElementName.Compare(_L8("affiliation")) == 0) { aAtomEntry->SetAuthorAffiliation(CXmppEnumerationConverter::PubsubAffiliation(aAuthorXmlParser->GetStringData())); } } while(aAuthorXmlParser->MoveToNextElement()); CleanupStack::PopAndDestroy(); // aAuthorXmlParser if(aAtomEntry->GetAuthorJid().Length() == 0) { aAtomEntry->SetAuthorJidL(aTextUtilities->Utf8ToUnicodeL(aXmlParser->GetStringData())); } } else if(aElementName.Compare(_L8("content")) == 0) { aAtomEntry->SetContentL(aTextUtilities->Utf8ToUnicodeL(aXmlParser->GetStringData()), aEntryType); } else if(aElementName.Compare(_L8("geoloc")) == 0) { CXmppGeolocParser* aGeolocParser = CXmppGeolocParser::NewLC(); CGeolocData* aGeoloc = aGeolocParser->XmlToGeolocLC(aXmlParser->GetStringData()); aAtomEntry->GetLocation()->SetStringL(EGeolocText, aGeoloc->GetString(EGeolocText)); aAtomEntry->GetLocation()->SetStringL(EGeolocLocality, aGeoloc->GetString(EGeolocLocality)); aAtomEntry->GetLocation()->SetStringL(EGeolocCountry, aGeoloc->GetString(EGeolocCountry)); if(aGeoloc->GetString(EGeolocText).Length() == 0) { HBufC* aLocation = HBufC::NewLC(aGeoloc->GetString(EGeolocLocality).Length() + 2 + aGeoloc->GetString(EGeolocCountry).Length()); TPtr pLocation(aLocation->Des()); aTextUtilities->AppendToString(pLocation, aGeoloc->GetString(EGeolocLocality), KNullDesC); aTextUtilities->AppendToString(pLocation, aGeoloc->GetString(EGeolocCountry), _L(", ")); aAtomEntry->GetLocation()->SetStringL(EGeolocText, pLocation); CleanupStack::PopAndDestroy(); // aLocation } CleanupStack::PopAndDestroy(2); // aGeoloc, aGeolocParser } else if(aElementName.Compare(_L8("star")) == 0) { aAtomEntry->SetHighlighted(aXmlParser->GetBoolData()); } else if(aExtended && aElementName.Compare(_L8("x")) == 0) { aAtomEntry->SetIdL(aXmlParser->GetStringAttribute(_L8("id"))); aAtomEntry->SetRead(aXmlParser->GetBoolAttribute(_L8("read"))); aAtomEntry->SetHighlighted(aXmlParser->GetBoolAttribute(_L8("star"))); aAtomEntry->SetPrivate(aXmlParser->GetBoolAttribute(_L8("private"))); aAtomEntry->SetDirectReply(aXmlParser->GetBoolAttribute(_L8("reply"))); aAtomEntry->SetIconId(aXmlParser->GetIntAttribute(_L8("icon"))); aAtomEntry->SetAuthorAffiliation((TXmppPubsubAffiliation)aXmlParser->GetIntAttribute(_L8("affiliation"))); aEntryType = (TEntryContentType)aXmlParser->GetIntAttribute(_L8("type")); } } while(aXmlParser->MoveToNextElement()); CleanupStack::PopAndDestroy(2); // aElementData, aXmlParser return aAtomEntry; }
CGeolocData* CXmppGeolocParser::XmlToGeolocLC(const TDesC8& aStanza) { CGeolocData* aGeoloc = CGeolocData::NewLC(); CXmlParser* aXmlParser = CXmlParser::NewLC(aStanza); CTextUtilities* aTextUtilities = CTextUtilities::NewLC(); do { TPtrC8 aElementName = aXmlParser->GetElementName(); TPtrC aElementData = aTextUtilities->Utf8ToUnicodeL(aXmlParser->GetStringData()); if(aElementName.Compare(_L8("uri")) == 0 || aElementName.Compare(_L8("id")) == 0) { aGeoloc->SetStringL(EGeolocUri, aElementData); } else if(aElementName.Compare(_L8("text")) == 0 || aElementName.Compare(_L8("name")) == 0) { aGeoloc->SetStringL(EGeolocText, aElementData); } else if(aElementName.Compare(_L8("street")) == 0) { aGeoloc->SetStringL(EGeolocStreet, aElementData); } else if(aElementName.Compare(_L8("area")) == 0) { aGeoloc->SetStringL(EGeolocArea, aElementData); } else if(aElementName.Compare(_L8("locality")) == 0 || aElementName.Compare(_L8("city")) == 0) { aGeoloc->SetStringL(EGeolocLocality, aElementData); } else if(aElementName.Compare(_L8("postalcode")) == 0) { aGeoloc->SetStringL(EGeolocPostalcode, aElementData); } else if(aElementName.Compare(_L8("region")) == 0) { aGeoloc->SetStringL(EGeolocRegion, aElementData); } else if(aElementName.Compare(_L8("country")) == 0) { aGeoloc->SetStringL(EGeolocCountry, aElementData); } else if(aElementName.Compare(_L8("lat")) == 0) { aGeoloc->SetRealL(EGeolocLatitude, aXmlParser->GetRealData()); } else if(aElementName.Compare(_L8("lon")) == 0) { aGeoloc->SetRealL(EGeolocLongitude, aXmlParser->GetRealData()); } else if(aElementName.Compare(_L8("accuracy")) == 0) { aGeoloc->SetRealL(EGeolocAccuracy, aXmlParser->GetRealData()); } } while(aXmlParser->MoveToNextElement()); CleanupStack::PopAndDestroy(2); // aElementData, aXmlParser return aGeoloc; }
void TCmdSendStreamDtmf::ExecuteL() { // ---------- Setup -------------------------------------------------------- // DTMF out-of-band means DTMF tones are sent as the numerical value in a packet // (RTP type telephone-event, refer RFC2833). const TInt KDefaultDuration = 0; // Get session CMceSession* session = reinterpret_cast<CMceSession*>(GetObjectForIdL(KSessionId, ETrue)); TPtrC8 dtmfTones = ExtractTextL( KParamDtmfTones, EFalse ); TInt dtmfDuration = ExtractIntegerL( KParamDtmfDuration, KDefaultDuration, EFalse ); TBool isSingleTone = ExtractBooleanL( KParamDtmfIsSingleTone, EFalse ); const RPointerArray<CMceMediaStream>& streams = session->Streams(); for ( TInt i = 0; i < streams.Count(); ++i ) { CMceMediaStream* mediaStream; mediaStream = streams[i]; if ( mediaStream->Type() == KMceAudio && mediaStream->Source()->Type() == KMceRTPSource ) { CMceAudioStream* audioStream = dynamic_cast<CMceAudioStream*>(mediaStream); const RPointerArray<CMceAudioCodec>& codecsMain = audioStream->Codecs(); TBool dtmfFound = EFalse; for (TInt i = codecsMain.Count()-1; dtmfFound == EFalse && i >= 0; i --) { if ( codecsMain[i]->SdpName().Compare(KValueCodecDtmf())) { //TODO modify dtmf codec codecsMain[i]->SetMMFPriorityL( KDtmfAudioPriority ); codecsMain[i]->SetMMFPriorityPreferenceL( KDtmfAudioPref ); codecsMain[i]->SetPreferenceL(0); dtmfFound = ETrue; } } //getting the media source pointer from the audio stream; CMceMediaSource* dtmfSource = audioStream->Source(); //checking if dtmf is available if(dtmfSource->DtmfAvailable() && (!dtmfSource->DtmfActive()) ) { //sending dtmf tones if( dtmfTones.Compare( KNullDesC8 ) != 0 ) { HBufC* buf = HBufC::NewLC(dtmfTones.Length()); buf->Des().Copy(dtmfTones); if( isSingleTone && dtmfDuration > 0) { TLex lexer( *buf ); TChar tone = lexer.Get(); //starts sending the tone dtmfSource->StartDtmfToneL( tone ); iDtmfTimer = NULL; //create instance of timer to stop sending the tone after given duration iDtmfTimer = CDelayedProcess::NewL(dtmfSource); if(iDtmfTimer) { TTimeIntervalMicroSeconds32 delay = dtmfDuration * 1000; iDtmfTimer->StartProcess(delay); } } else if( !isSingleTone ) { iDtmfTimer = NULL; dtmfSource->SendDtmfToneSequenceL(*buf); } iaudioStream = audioStream; CleanupStack::PopAndDestroy(buf); buf = NULL; } else { //send default sequence if not present in the params dtmfSource->SendDtmfToneSequenceL(KTestSequence); iaudioStream = audioStream; } } //stop sending dtmf if( dtmfSource->DtmfActive() && ( !isSingleTone ) ) { dtmfSource->CancelDtmfToneSequenceL(); } } } // ---------- Response creation -------------------------------------------- if(iaudioStream) { AddIdResponseL( KStreamId, *iaudioStream ); AddTextResponseL( KParamDtmfTones, dtmfTones ); AddIntegerResponseL( KResponseLocalMediaPort, iaudioStream->LocalMediaPort() ); } else { AddIntegerResponseL(KResponseActionReturnCode, KErrArgument); } }
/** Set the Device Name in the EIR buffer from a TPtrC8. This may be a complete or partial name. @param aName is the Device Name converted into Unicode format @param aIsComplete is marking if the name is complete or partial @return TInt an error code @internalTechnology */ EXPORT_C TInt TExtendedInquiryResponseDataCodec::SetDeviceName(const TPtrC8& aName, TBool aIsComplete) { TPtrC8 name; TInt error = KErrNotFound; TInt offset = NextDataType(0); TInt nameTag = (aIsComplete ? EEirLocalNameComplete : EEirLocalNamePartial); TBool replaceCurrentName = ETrue; while(offset >= KErrNone) { if(iEir[offset] == EEirLocalNameComplete || iEir[offset] == EEirLocalNamePartial) { name.Set(iEir.Mid(offset + KEIRTagToDataOffset, iEir[offset-KEIRLengthToTagOffset] - KEIRLengthToTagOffset)); if(iEir[offset] == EEirLocalNameComplete && name.Compare(aName) == 0) { // The only scenario we don't want to replace the existing name is when // it's complete and same as the new one (aName) replaceCurrentName = EFalse; LOG(_L("We won't replace the current name")); } error = KErrNone; break; } else { offset = NextDataType(offset); } } if(error == KErrNotFound) // no device name present, we will add the name to the end of the eir data { if(iEir.MaxLength() < (iEir.Length() + KEIRTagToDataOffset + KEIRLengthToTagOffset + aName.Length())) { // Not enough space to store this name and its length & tag return KErrNoMemory; } // Add length iEir.Append(aName.Length() + KEIRTagToDataOffset); // Append Tag iEir.Append(nameTag); // Append value iEir.Append(aName); LOG1(_L("EIR data with name appended: %d bytes of data"), iEir.Size()); LOGHEXDESC(iEir); error = KErrNone; } else if(replaceCurrentName) // device name exists in current eir and it's either partial or different from aName, we'll update it with aName { // move all the data on the right of device name to the left and then append new name after it TPtr8 rightPtr = iEir.RightTPtr(iEir.Length() - offset - name.Length() - KEIRLengthToTagOffset); iEir.Replace(offset-KEIRLengthToTagOffset, iEir.Length() - offset + KEIRLengthToTagOffset, rightPtr); iEir.SetLength(offset + rightPtr.Length() - KEIRTagToDataOffset); // Check if the new name is too big for iEir if(iEir.MaxLength() < (iEir.Length() + KEIRTagToDataOffset + KEIRLengthToTagOffset + aName.Length())) { // Not enough space to store this name and its length & tag return KErrNoMemory; } // Add length iEir.Append(aName.Length() + KEIRTagToDataOffset); // Append Tag iEir.Append(nameTag); // Append value iEir.Append(aName); LOG(_L("Reshuffled EIR data:")); LOGHEXDESC(iEir); error = KErrNone; } // otherwise we do nothing, as this is the case of an identical complete name is already present. if(iNameRecord) { if(iEir.Length() > 0) { iNameRecord->iName.SetLength(((iEir.Length() + iEir.Length()%2)/2)); } else { iNameRecord->iName.SetLength(0); } } return error; }
// ----------------------------------------------------------------------------- // 3GPExtParser::MapID3v1GenreToString() // ----------------------------------------------------------------------------- // void C3GPExtParser::ParseIlstBoxesL() { #ifdef _DEBUG RDebug::Print(_L("C3GPExtParser::ParseIlstBoxesL")); #endif TUint32 sizeIlst = ilst.Length(); TUint32 offset = 8; // first tag while (offset < sizeIlst) { TUint32 tagSize = 0; TPtrC8 tagSizeDes = ilst.Mid(offset, 4); for(TInt i = 0 ; i <= 3; i++) { tagSize <<= 8; tagSize |= tagSizeDes[i]; } TPtrC8 tagName = ilst.Mid(offset + 4, 4); TUint32 dataSize = 0; TPtrC8 dataSizeDesc = ilst.Mid(offset + 8, 4); for(TInt i = 0 ; i <= 3; i++) { dataSize <<= 8; dataSize |= dataSizeDesc[i]; } if(dataSize > 16) { if(!tagName.Compare(K3GPExtMetaTitle)) { iTitleOffset = offset + 8 + 16; iTitleSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaArtist)) { iArtistOffset = offset + 8 + 16; iArtistSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaComposer)) { iComposerOffset = offset + 8 + 16; iComposerSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaAlbum)) { iAlbumOffset = offset + 8 + 16; iAlbumSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaComment)) { iCommentOffset = offset + 8 + 16; iCommentSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaYear)) { iYearOffset = offset + 8 + 16; iYearSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaCustomGenre)) { iCustomGenreOffset = offset + 8 + 16; iCustomGenreSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaGenre)) { iGenreOffset = offset + 8 + 16; iGenreSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaTrack)) { iTrackNumberOffset = offset + 8 + 16; iTrackNumberSize = dataSize - 16; } else if(!tagName.Compare(K3GPExtMetaJpeg)) { iCoverOffset = offset + 8 + 16; iCoverSize = dataSize - 16; } else // default { // unwanted tag, ignore } } if (tagSize <= 0) { #ifdef _DEBUG RDebug::Print(_L("C3GPExtParser::ParseIlstBoxesL - break")); #endif break; } else { offset += tagSize; } } }
// ----------------------------------------------------------------------------- // CWimCertHandler::GetExtrasFromWimRefL // Fetches extra information (e.g. certs trusted usage) from the WIM card. // ----------------------------------------------------------------------------- // WIMI_STAT CWimCertHandler::GetExtrasFromWimRefL( WIMI_Ref_t* aTmpWimRef, TInt8 aUsage, TDesC8& aKeyHash, const RMessage2& aMessage ) { _WIMTRACE(_L("WIM | WIMServer | CWimCertHandler::GetExtrasFromWimRefL | Begin")); TUint8 tempCertCount = 0; WIMI_RefList_t certRefList = NULL; WIMI_STAT callStatus = WIMI_Ok; TInt certIndex = 0; TPtrC8 keyHash; if ( aTmpWimRef ) { // List all certificates (by WIM and usage) callStatus = WIMI_GetCertificateListByWIM( aTmpWimRef, aUsage, &tempCertCount, &certRefList ); } else { callStatus = WIMI_ERR_BadReference; } if ( callStatus == WIMI_Ok ) { CleanupPushWimRefListL( certRefList ); WIMI_Ref_t* tempRef = NULL; WIMI_BinData_t ptLabel; WIMI_BinData_t ptKeyID; WIMI_BinData_t ptCAID; WIMI_BinData_t ptIssuerHash; WIMI_BinData_t ptTrustedUsage; TUint8 uiCDFRefs; TUint8 usage; TUint8 certType; TUint16 certLen; TUint8 modifiable = 0; for ( TInt i = 0; i < tempCertCount; i++ ) { // Get info for each certificate until we find valid cert callStatus = WIMI_GetCertificateInfo( certRefList[i], &tempRef, &ptLabel, &ptKeyID, &ptCAID, &ptIssuerHash, &ptTrustedUsage, &uiCDFRefs, &usage, &certType, &certLen, &modifiable ); if ( callStatus == WIMI_Ok ) { free_WIMI_Ref_t( tempRef ); // Code MAY NOT leave before ptLabel.pb_buf, ptKeyID.pb_buf, // ptCAID.pb_buf, ptIssuerHash.pt_buf, and ptTrustedUsage.pb_buf // are deallocated. keyHash.Set( ptKeyID.pb_buf, ptKeyID.ui_buf_length ); // Compare given and fetched key hash if ( keyHash.Compare( aKeyHash ) == 0 && certType == WIMI_CT_X509 ) //Match { certIndex = i; // Found one i = tempCertCount; // Stop looping callStatus = WIMI_Ok; } else // Cert not supported { callStatus = WIMI_ERR_UnsupportedCertificate; } WSL_OS_Free( ptLabel.pb_buf ); WSL_OS_Free( ptKeyID.pb_buf ); WSL_OS_Free( ptCAID.pb_buf ); WSL_OS_Free( ptIssuerHash.pb_buf ); WSL_OS_Free( ptTrustedUsage.pb_buf ); // Code can leave after this point. } } if ( callStatus == WIMI_Ok ) { CopyCertExtrasInfoL( certRefList[certIndex], aMessage ); } CleanupStack::PopAndDestroy( certRefList ); } return callStatus; }
CSenElement* CPolicyNormalizer::ProcessAssertionTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion) { TPtrC8 assertionName = aAssertion->LocalName(); TPtrC8 assertionNsUri = aAssertion->NamespaceURI(); TPtrC8 nsPrefix = aAssertion->NsPrefix(); TBuf8<255> qname(nsPrefix); qname.Append(':'); qname.Append(assertionName); CSenElement& newNormalForm = aNormalAssertion->AddElementL(assertionNsUri,assertionName, qname); if(IsOptionalL(aAssertion)) { if (CopySenElementWithoutOptionL(aAssertion, &newNormalForm)) { CSenElement* parent = aNormalAssertion->Parent(); AddAndElementL(parent); } } else { CopySenElementL(aAssertion, &newNormalForm); } RPointerArray<CSenElement>& children = aAssertion->ElementsL(); TInt childCount = children.Count(); if (childCount > 0) { CSenElement* pNextChild; TInt i =0; while (i < childCount) { pNextChild = children[i]; TPtrC8 localName = pNextChild->LocalName(); if(localName.Compare(KXorCompositeAssertion) == 0) { } else if (localName.Compare(KAndCompositeAssertion) == 0) { } else if (localName.Compare(KWsPolicy) == 0 ) { CSenElement* aNewElement = AddPolicyElementL(&newNormalForm); aNewElement = ProcessPolicyTermL(pNextChild,aNewElement); } else {//if asserion is not well defined and dont have apolicy object here //then it should add one and then add XOR and AND // CSenElement* aNewElement = AddPolicyElementL(&newNormalForm); // CSenElement* pChildXor = AddXorElementL(aNewElement); // CSenElement* pChildAnd = AddAndElementL(pChildXor); aNormalAssertion = ProcessAssertionTermL(pNextChild, &newNormalForm); } i++; } } return aNormalAssertion; }
CSenElement* CPolicyNormalizer::ProcessLogicL(CSenElement* aTerm) { //if sibling names are same as <ExactlyOne> RPointerArray<CSenElement> matchingSiblings; TInt matchingSiblingCount = 0; if(aTerm->ElementsL(matchingSiblings, WSPolicy::KXorCompositeAssertion) == KErrNone) matchingSiblingCount= matchingSiblings.Count(); if(matchingSiblingCount>1) { //XOR elements should have AND elements in them else normalization error //Find elements CSenElement* firstSibling = matchingSiblings[0]; TInt i = 1; while ( i < matchingSiblingCount) { CSenElement* nextSibling = matchingSiblings[i]; firstSibling = ProcessAndAndLogicL(firstSibling, nextSibling); i++; } TInt j = 0; while ( j < matchingSiblingCount) { CSenElement* removed = aTerm->RemoveElement(*matchingSiblings[j]); if(removed) delete removed; j++; } /**** aTerm->AddElementL(*firstSibling); */ } RPointerArray<CSenElement>& children = aTerm->ElementsL(); TInt childCount = children.Count(); TInt i=0; while (i < childCount) { CSenElement* pChild = children[i]; if(childCount == 1) ProcessLogicL(pChild); TPtrC8 childName = pChild->LocalName(); TPtrC8 parentName = aTerm->LocalName(); //if parent name and child name are same if(childName.Compare(parentName) == 0) { if(childName.Compare(WSPolicy::KWsPolicy) == 0) { } else if(childName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { } else if(childName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { ProcessXorCollapseLogicL(aTerm,pChild); continue; } } i++; } matchingSiblings.Close(); return aTerm; }
// Convert the WWW-Authenticate header field from OTA to generic form. void CHttpClientHeaderReader::DecodeWWWAuthenticateL( RHeaderField& aHeader ) const { // RFC2616, section 14.47 WWW-Authenticate // RFC2617, 'HTTP Authentication: Basic and Digest Access Authentication' // // WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge // challenge = auth-scheme 1*SP 1#auth-param // auth-scheme = token // auth-param = token "=" ( token | quoted-string ) // There may be one or more challenge, in a comma-separated list. TPtrC8 buffer; aHeader.RawDataL( buffer ); TInt totalBytesConsumed = 0; TInt numChallenges = 0; CHeaderFieldPart* part = NULL; TBool done = EFalse; while ( !done ) { _LIT8( commaSpaceNewline, ", \n" ); TPtrC8 token; TInt bytesConsumed = InetProtTextUtils::ExtractNextTokenFromList( buffer, token, commaSpaceNewline ); done = (bytesConsumed == 0); if ( done && ( numChallenges == 0 ) ) // if we didn't find _anything_ at all... { User::Leave( KErrHttpDecodeWWWAuthenticate ); } if ( !done && ( token.Length() > 0 ) ) { totalBytesConsumed += bytesConsumed; TBool equalsPresent = ( token.Locate( '=' ) != KErrNotFound ); if ( ( totalBytesConsumed == bytesConsumed ) && equalsPresent ) { // The first token has an equals sign in it. That // can't be as it has to be an authentication scheme User::Leave( KErrHttpDecodeWWWAuthenticate ); } if ( !equalsPresent ) { // Got a new part. Add it. ++numChallenges; part = SetNewFStringPartL( aHeader, numChallenges - 1, token ); if( token.Compare( iStrPool.StringF(HTTP::ENTLM, iStringTable).DesC() ) == 0 ) { TInt consumed = InetProtTextUtils::ExtractNextTokenFromList( buffer, token, commaSpaceNewline ); if( consumed > 0 ) { ++numChallenges; part = SetNewFStringPartL( aHeader, numChallenges -1, token ); } } } else { // Got a param & parameter value. TPtrC8 paramName; TInt paramBytesConsumed = InetProtTextUtils::ExtractNextTokenFromList( token, paramName, '=' ); if ( paramBytesConsumed == 0 ) { User::Leave( KErrHttpDecodeBasicAuth ); } // Obtain the parameter value. It is a string which // may or may not be quoted. TPtrC8 paramVal; if ( token.Length() > 0 && token[0] == '"' ) { bytesConsumed += InetProtTextUtils::ExtractQuotedStringL( token, paramVal ); } else { paramVal.Set( token ); } SetNewStringParamL( *part, paramName, paramVal ); } } } }
// --------------------------------------------------------------------------- // CNSmlDmACLParser::ParseL() // Parses ACL data and keeps data until Reset() is called or instance // is destructed // --------------------------------------------------------------------------- TInt CNSmlDmACLParser::ParseL(const TDesC8& aACL) { Reset(); for(TInt i=EAclExecute;i>=EAclAdd;i--) { TInt aclStart = 0; TBool found=EFalse; switch(i) { case EAclAdd: aclStart = aACL.Find(KNSmlDmAclAddEqual); found = aclStart>=0; aclStart=aclStart+KNSmlDmAclAddEqual().Length(); break; case EAclReplace: aclStart = aACL.Find(KNSmlDmAclReplaceEqual); found = aclStart>=0; aclStart=aclStart+KNSmlDmAclReplaceEqual().Length(); break; case EAclDelete: aclStart = aACL.Find(KNSmlDmAclDeleteEqual); found = aclStart>=0; aclStart=aclStart+KNSmlDmAclDeleteEqual().Length(); break; case EAclGet: aclStart = aACL.Find(KNSmlDmAclGetEqual); found = aclStart>=0; aclStart=aclStart+KNSmlDmAclGetEqual().Length(); break; case EAclExecute: aclStart = aACL.Find(KNSmlDmAclExecEqual); found = aclStart>=0; aclStart=aclStart+KNSmlDmAclExecEqual().Length(); break; default: User::Panic(KSmlDmTreeDbHandlerPanic,KErrArgument); break; } if(found) { TInt aclStop = aACL.Right(aACL.Length()-aclStart). Locate(KNSmlDMAclCommandSeparator); if(aclStop<0) { aclStop = aACL.Length()-aclStart; } TPtrC8 commandAcl = aACL.Mid(aclStart,aclStop); CNSmlAclElement* aclElement = new(ELeave) CNSmlAclElement(); aclElement->iCommandType = (TNSmlDmCmdType)i; aclElement->iNext = iCommandAcls; iCommandAcls=aclElement; if(commandAcl.Compare(KNSmlDmAclAll)==0) { aclElement->iAllServers=ETrue; } else { TBool end = EFalse; TInt serverIdStart=0; while(!end) { TPtrC8 serverIdPtr = commandAcl.Right(commandAcl.Length()-serverIdStart); TInt serverIdStop = serverIdPtr.Locate(KNSmlDMAclSeparator); if(serverIdStop == KErrNotFound) { serverIdStop=commandAcl.Length(); end=ETrue; } HBufC8* serverId = serverIdPtr.Left(serverIdStop).AllocL(); aclElement->iServerIds.AppendL(serverId); serverIdStart=serverIdStart+serverIdStop+1; } } } } return KErrNone; }
// ------------------------------------------------------------------------------------------------ // CNSmlDataModBase::StripAllNotOnPartnerListL // Strips all data from entity that is not supported by remote server. // ------------------------------------------------------------------------------------------------ void CNSmlDataModBase::StripAllNotOnPartnerListL( CVersitParser* aEntity, TBool& aModified, TBool aParamLevelCheck ) const { _DBG_FILE("CNSmlDataModBase::StripAllNotOnPartnerListL(): begin"); TInt remotepropertycount = iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); if( iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount() ) { // Check correct Data Sync protocol TInt value( EDataSyncNotRunning ); TSmlProtocolVersion usedSyncProtocol( ESmlVersion1_2 ); TInt error = RProperty::Get( KPSUidDataSynchronizationInternalKeys, KDataSyncStatus, value ); if ( error == KErrNone && value == EDataSyncRunning ) { usedSyncProtocol = ESmlVersion1_1_2; } TBool wasModified( EFalse ); CArrayPtr<CParserProperty>* allProps = aEntity->ArrayOfProperties( EFalse ); for( TInt i = 0; i < allProps->Count(); ) // Variable i is not increased here because size of count might be changes during loop { const CParserProperty& ownProperty = *allProps->At( i ); TBool removeMe( ETrue ); for( TInt i2 = 0; i2 < iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).PropertyCount(); i2++ ) { const CSmlDataProperty& remoteProperty = iRemoteStoreFormat->MimeFormat( iUsedRemoteMimeType ).Property( i2 ); TPtrC8 remotename = remoteProperty.Field().Name().DesC(); if( !ownProperty.Name().Compare( remoteProperty.Field().Name().DesC() ) ) { TInt remoteparamcount = remoteProperty.ParamCount(); if( remoteProperty.ParamCount() > 0 && aParamLevelCheck ) { if ( usedSyncProtocol == ESmlVersion1_1_2 ) { const CParserProperty* p = allProps->At( i ); TInt entityParamCount = (( CNSmlProperty* )p)->ParamCount(); if( entityParamCount > 0) { for( TInt i3 = 0; i3 < remoteProperty.ParamCount(); i3++ ) { TPtrC8 remoteparamname = remoteProperty.Param( i3 ).Field().Name().DesC(); if( ownProperty.Param( remoteProperty.Param( i3 ).Field().Name().DesC() ) ) { removeMe = EFalse; } } } else { removeMe = EFalse; } } else // ESmlVersion1_2 { CArrayPtr<CParserParam>* ownerparamarray = ownProperty.ParamArray(); if(ownerparamarray != NULL) { for(TInt ownerparam = 0; ownerparam < ownerparamarray->Count(); ownerparam++) { removeMe = ETrue; const CParserParam& ownParam = *ownerparamarray->At( ownerparam ); TPtrC8 ownparamname = ownParam.Name(); TPtrC8 ownparamvalue = ownParam.Value(); if(ownparamvalue == _L8("")) { for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++) { TDesC8 remoteparamname = remoteProperty.Param( remoteparam ).Field().Name().DesC(); const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field(); if( field.EnumValueCount() > 0) { for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ ) { TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC(); if( rmtenumvalue.Compare(ownparamname)== 0 ) { removeMe = EFalse; break; } } } else { removeMe = EFalse; break; } } } else { //Handling when the device supports VersitTokenType as "Encoding" if(ownparamname == KVersitTokenENCODING) { removeMe = EFalse; } else { for(TInt remoteparam = 0; remoteparam < remoteProperty.ParamCount(); remoteparam++) { TDesC8 remoteparamname = remoteProperty.Param( remoteparam ).Field().Name().DesC(); if(ownparamname.Compare(remoteProperty.Param( remoteparam ).Field().Name().DesC()) == 0) { const CSmlDataField& field = remoteProperty.Param( remoteparam ).Field(); if( field.EnumValueCount() > 0) { for( TInt rmtenumcount = 0; rmtenumcount < field.EnumValueCount(); rmtenumcount++ ) { TPtrC8 rmtenumvalue = field.EnumValue( rmtenumcount ).DesC(); if( rmtenumvalue.Compare(ownparamvalue)== 0 ) { removeMe = EFalse; break; } } } else { removeMe = EFalse; break; } } } } } if( removeMe ) { break; } } } else { removeMe = EFalse; } } } else { removeMe = EFalse; } if( !removeMe ) { break; } } } if( removeMe ) { #ifdef __NSML_DEBUG__ TPtrC8 pn( ownProperty.Name() ); DBG_ARGS8(_S8("CNSmlDataModBase::StripAllNotOnPartnerListL(): Dropping %S"), &pn); #endif // __NSML_DEBUG__ delete allProps->At( i ); allProps->Delete( i ); wasModified = ETrue; aModified = ETrue; } else { #ifdef __NSML_DEBUG__ TPtrC8 pn( ownProperty.Name() ); DBG_ARGS8(_S8("CNSmlDataModBase::StripAllNotOnPartnerListL(): NOT dropping %S"), &pn); #endif // __NSML_DEBUG__ i++; } } // can't use aModified as that may have been set earlier! if( wasModified ) { allProps->Compress(); } } _DBG_FILE("CNSmlDataModBase::StripAllNotOnPartnerListL(): end"); }
CSenElement* CPolicyNormalizer::DuplicateAssertionBranchL(CSenElement* /*aParent*/, CSenElement* aDuplicatingPolicy) { //aDuplicatingPolicy is always an assertion //check if aDuplicatingPolicy have two assertions, if yes then divide the assertion in // T W O separate assertions //first check that if any of the two assertion themselve have // if XOR have multiple ANDs then check if XOR parent is an Assertion. // if yes then divide them in Two assertions. TPtrC8 asseryName = aDuplicatingPolicy->LocalName(); TInt childCount = HasChildL(aDuplicatingPolicy); if( childCount== 0) //There is NO CHILD NESTING in assertion return aDuplicatingPolicy; else if (childCount == 1) ////Assertion should always have only one <wsp:policy> element. { TBool deleted = EFalse; CSenElement* assertionPolicyElement = aDuplicatingPolicy->Child(0); //policy element TPtrC8 policyName = assertionPolicyElement->LocalName(); if(policyName.Compare(WSPolicy::KWsPolicy)== 0) { //now we should have XOR and AND elements CSenElement* assertionXORElement = assertionPolicyElement->Child(0); //XOR element //there should be only one XOR element (in normalize mode) TPtrC8 name1 = assertionXORElement->LocalName(); TInt AndElementCount = HasChildL(assertionXORElement); //If it has only one AND child element then nuthing to do here but if more then one element // then it means that assertion have nesting and should have a different branch. if(AndElementCount == 0) return aDuplicatingPolicy; else if(AndElementCount == 1) { ProcessAssertionBranchingL(assertionXORElement->Child(0)); } else if(AndElementCount > 1) { RPointerArray<CSenElement>& assertionXorChildren = assertionXORElement->ElementsL(); //AND elements TInt i = 0; while (i < AndElementCount) { //copy the root assertion to new tag // Take out the replacing tag // create two separate tag and replace them in the original and root copy tag CSenXmlElement* AND = (CSenXmlElement*)assertionXorChildren[i]; // ProcessAssertionBranchingL(AND); CSenXmlElement* rootAssertion = (CSenXmlElement*)FindRootAssertionL(AND); if (!IsChildOfElement(rootAssertion, AND)) { i++; continue; } //create a duplicate tag, //duplicating assertion TPtrC8 assertionCopyName = rootAssertion->LocalName(); TPtrC8 assertionCopyNsUri = rootAssertion->NamespaceURI(); CSenXmlElement* XORParent = (CSenXmlElement*)rootAssertion->Parent(); CSenElement* parentsBrandNewRootAssertion =AddAndElementL(XORParent->Parent()); CSenElement& newDuplicateAssertion = parentsBrandNewRootAssertion->AddElementL(assertionCopyNsUri,assertionCopyName); //cut and paste the second AND to duplicate newDuplicateAssertion.CopyFromL(*rootAssertion); DeleteAsertionIndexL(aDuplicatingPolicy, &newDuplicateAssertion, i); deleted = ETrue; // newDuplicateAssertion.SetParent(parentsBrandNewRootAssertion); //parentsBrandNewRootAssertion->ReplaceElementL(newDuplicateAssertion); //find from this new element the required assertion and then delete // all of the optins from it except the current i+1 ALL element i++; } if(deleted) { CSenElement* rootAssertion = FindRootAssertionL(aDuplicatingPolicy); CSenElement* AND = rootAssertion->Parent(); CSenElement* XOR = AND->Parent(); CSenElement* thisOne = XOR->RemoveElement(*AND); if(thisOne) iOrphanElements.Append(thisOne); // delete thisOne; //P DuplicateAssertionBranch A T H E T I C H A C K //now we have solved the first level nesting //our original policy is changed so now use the original policy and solve it again CSenElement* documentRoot = (CSenElement*)&XOR->Root(); ProcessAssertionBranchingL(documentRoot); } } } } else if(childCount > 1) { //this count is always one because its a child wsp:policy element, policy element //could have multiple XOR elements . If it comes here something is W R O N G } //here is the nesting problem. the assertion policy should have only one // Alternative = <XOR><AND>< --assertion-- ></AND></XOR> // NO TWO XORs are allowed here return aDuplicatingPolicy; }
CSenElement* CPolicyNormalizer::ProcessPolicyTermL(CSenElement* aAssertion, CSenElement* aNormalAssertion) { RPointerArray<CSenElement>& children = aAssertion->ElementsL(); TInt childCount = children.Count(); CSenElement* pNextChild; if(childCount == 0) { CSenElement* pXor = AddXorElementL(aNormalAssertion); CSenElement* pAnd = AddAndElementL(pXor); return aNormalAssertion; } TInt i=0; CSenElement* assertionParent = aNormalAssertion; while (i < childCount) { pNextChild = children[i]; TPtrC8 localName = pNextChild->LocalName(); if(localName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { TPtrC8 nt = aNormalAssertion->LocalName(); if(nt.Compare(WSPolicy::KWsPolicy)== 0) //PERFECT we need it { // aNormalAssertion = ProcessXORTermL(pNextChild,aNormalAssertion); } else if(nt.Compare(WSPolicy::KXorCompositeAssertion)== 0) { CSenElement* NewXorParent = aNormalAssertion->Parent(); ProcessXORTermL(pNextChild,NewXorParent); } else if(nt.Compare(WSPolicy::KAndCompositeAssertion)== 0) { CSenElement* NewXorParent = aNormalAssertion->Parent()->Parent(); ProcessXORTermL(pNextChild,NewXorParent); } else { //SHOULDNT BE A CASE CAZ then we have XOR in some assertion //It should always be in a POLICY tag } } else if (localName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { CSenElement* pNormChild = AddXorElementL(aNormalAssertion); // aNormalAssertion = ProcessANDTermL(pNextChild, pNormChild); } else if (localName.Compare(WSPolicy::KWsPolicy) == 0 ) { TPtrC8 parentName = aNormalAssertion->LocalName(); if(parentName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { CSenElement* pChildXor = AddXorElementL(aNormalAssertion); CSenElement* pChildAnd = AddAndElementL(pChildXor); } else if(parentName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { } else if(parentName.Compare(WSPolicy::KWsPolicy) == 0) { CSenElement* pChildXor = AddXorElementL(aNormalAssertion); CSenElement* pChildAnd = AddAndElementL(pChildXor); } else { CSenElement* pChildXor = AddXorElementL(aNormalAssertion); CSenElement* pChildAnd = AddAndElementL(pChildXor); } } else //its an Assertion { TPtrC8 parentName = assertionParent->LocalName(); //if parent is Policy -> add XOR and AND and then process //assertion- >new parent for same level is AND //if parent is XOR -> Add AND and then process assertion. at this level the parent will be AND //if parent is AND just process assertion if(IsOptionalL(pNextChild)) { if(parentName.Compare(WSPolicy::KWsPolicy) == 0) { CSenElement* pXor = AddXorElementL(assertionParent); CSenElement* pAnd = AddAndElementL(pXor); // aNormalAssertion = ProcessAssertionTermL(pNextChild, pAnd); } else if(parentName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { CSenElement* parentNow = assertionParent; assertionParent = assertionParent->Parent(); CSenElement* policyParent= assertionParent->Parent(); CSenElement* pXor = AddXorElementL(policyParent); CSenElement* pAnd = AddAndElementL(pXor); // aNormalAssertion = ProcessAssertionTermL(pNextChild, pAnd); assertionParent = parentNow; } else if(parentName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { } else { //probably error } } else { if(parentName.Compare(WSPolicy::KWsPolicy) == 0) { CSenElement* pXor = AddXorElementL(assertionParent); CSenElement* pAnd = AddAndElementL(pXor); assertionParent = pAnd; // assertionParent = ProcessAssertionTermL(pNextChild, pAnd); } else if(parentName.Compare(WSPolicy::KXorCompositeAssertion) == 0) { CSenElement* pXor = AddXorElementL(assertionParent); CSenElement* pAnd = AddAndElementL(pXor); // aNormalAssertion = ProcessAssertionTermL(pNextChild, pAnd); } else if(parentName.Compare(WSPolicy::KAndCompositeAssertion) == 0) { // aNormalAssertion = ProcessAssertionTermL(pNextChild, assertionParent); } else { CSenElement* pXor = AddXorElementL(assertionParent); CSenElement* pAnd = AddAndElementL(pXor); assertionParent = pAnd; // aNormalAssertion = ProcessAssertionTermL(pNextChild, pAnd); } ProcessAssertionTermL(pNextChild, assertionParent); } } i++; } return assertionParent; }