// ----------------------------------------------------------------------------- // CDownloadUtils::IsContentTypeSupportedL // ----------------------------------------------------------------------------- // TBool CDownloadUtils::IsContentTypeSupportedL( RHttpDownload& aDownload, const TDesC8& aContentType ) { if ( aContentType.Length() == 0 ) { return EFalse; } #ifdef BRDO_WML_DISABLED_FF else if ( !aContentType.Compare(KWmlType1()) || !aContentType.Compare(KWmlType2()) || !aContentType.Compare(KWmlType3()) || !aContentType.Compare(KWmlType4()) ) { return EFalse; } #endif else { TBool canOpen( EFalse ); CDocumentHandler* docHandler = CDocumentHandler::NewLC(); TRAPD( err, canOpen = docHandler->CanOpenL( TDataType( aContentType ) ) ); if ( err == KMimeNotSupported ) { TUint8* contentTypeString = NULL; FindContentTypeFromFileL(aDownload, contentTypeString); if (contentTypeString != NULL) { TRAPD( err1, canOpen = docHandler->CanOpenL( TDataType( TPtrC8(contentTypeString) ) ) ); if ( err1 == KMimeNotSupported ) { canOpen = EFalse; delete contentTypeString; } else if (err1 == KErrNone) { // Setting Download Content type to a recognized one aDownload.SetStringAttribute( EDlAttrContentType, TPtrC8(contentTypeString) ); delete contentTypeString; canOpen = ETrue; } else { delete contentTypeString; User::Leave( err ); } } } else { if (err != KErrNone ) { User::Leave( err ); } } CleanupStack::PopAndDestroy(docHandler ); // docHandler return canOpen; } }
TInt CHandleOutSearch::CheckTag(const TDesC8& aTagData) { iMainEngine.WriteLog8(aTagData); TInt rValue=0; if(aTagData.Compare(KXMLP)==0) rValue= 1; else if(aTagData.Compare(KXMLA)==0) rValue= 2; else if(aTagData.Compare(KXMLBR)==0) rValue= 4; else if(aTagData.Compare(KXMLEM)==0) rValue= 3; else if(aTagData.Compare(KXMLB)==0) rValue= 3; else if(aTagData.Compare(KXMLSTRONG)==0) rValue= 3; else if(aTagData.Compare(KXMLU)==0) rValue= 3; else if(aTagData.Compare(KXMLBIG)==0) rValue= 3; else if(aTagData.Compare(KXMLSMALL)==0) rValue= 3; return rValue; }
TInt CConfigImpl::GenerateInternalKey(const TDesC8& aSection,TBuf8<15>& aKeyName) { TPtrC8 lastKey; TInt ret=GetKeyCount(aSection,lastKey); if (ret<0) { return ret; } //either "mediaX" or "X" //TInt key=ret; if(aSection.Compare(KPrimaryFilterSection)== 0 ) { TInt lastKeyValue=0; if(lastKey.Length()) { TLex8 lex(lastKey); TInt err = lex.Val(lastKeyValue); if(err != KErrNone) return err; } aKeyName.Format(_L8("%03d"),++lastKeyValue); } else if(aSection.Compare(KSecondaryFilterSection) == 0) { TInt lastKeyValue=0; if(lastKey.Length()) { TLex8 lex(lastKey); TInt err = lex.Val(lastKeyValue); if(err != KErrNone) return err; } aKeyName.Format(_L8("%04d"),++lastKeyValue); } else { TInt lastKeyValue=0; if(lastKey.Length()) { TLex8 lex(lastKey); TInt err = lex.Val(lastKeyValue); if(err != KErrNone) return err; } aKeyName.Format(_L8("%d"),++lastKeyValue); } return KErrNone; }
TXmppPubsubSubscription CXmppEnumerationConverter::PubsubSubscription(const TDesC8& aPubsubSubscription) { TXmppPubsubSubscription aSubscription = EPubsubSubscriptionNone; if(aPubsubSubscription.Compare(KPubsubSubscriptionSubscribed) == 0) { aSubscription = EPubsubSubscriptionSubscribed; } else if(aPubsubSubscription.Compare(KPubsubSubscriptionPending) == 0) { aSubscription = EPubsubSubscriptionPending; } else if(aPubsubSubscription.Compare(KPubsubSubscriptionUnconfigured) == 0) { aSubscription = EPubsubSubscriptionUnconfigured; } return aSubscription; }
TBool CUPnPRootDeviceInfoContainer::DeleteServiceL ( const TDesC8& aScpdUrl, CUPnPDevice* aDevice ) { RStringPool& sp = iStringPoolMgr->StringPool( ); const CUPnPServiceInfo* serviceInfo = NULL; TPtrC8 urlPtr ( NULL, 0 ); for ( TInt i = 0; i < aDevice->CountOfServiceInfoTable( ); i++ ) { serviceInfo = aDevice->AtServiceInfoTable( i ); urlPtr.Set ( serviceInfo->Property( sp.String ( UPNPDESCRIPTIONXMLTAGS::EScpdUrl,iStringPoolMgr->GetUPnPTable() ) ).Mid (1) ); if ( aScpdUrl.Compare ( urlPtr ) == 0 ) { aDevice->DeleteServiceInfoAtIndexL( i ); return ETrue; } } for ( TInt i=0; i < aDevice->CountOfEmbeddedDeviceInfoTable( ); i++ ) { if ( DeleteServiceL ( aScpdUrl, aDevice->AtEmbeddedDeviceInfoTable( i ) ) == 1 ) return ETrue; } return EFalse; }
// --------------------------------------------------------------------------- // Add <KeyName> element to <KeyInfo> node and set the value of it. // --------------------------------------------------------------------------- // void XmlSecTemplate::SetKeyInfoL(RXmlEngDocument& aTemplate, const TDesC8& aKeyName) { if(!aKeyName.Compare(KNullDesC8)) { User::Leave(KErrWrongParameter); } if(aTemplate.IsNull()) { User::Leave(KErrTemplate); } xmlNodePtr keyInfo = NULL; TXmlEngNode tmpNode = aTemplate.DocumentElement(); xmlNodePtr root = INTERNAL_NODEPTR(tmpNode); keyInfo = xmlSecFindNode(root,xmlSecNodeKeyInfo, xmlSecDSigNs); if(!keyInfo) { User::Leave(KErrTemplate); } TXmlEngElement(keyInfo).RemoveChildren(); char* name = XmlEngXmlCharFromDes8L(aKeyName); root = xmlSecTmplKeyInfoAddKeyName(keyInfo,(unsigned char*)name); delete name; if(!root) { User::Leave(KErrNoMemory); } }
void CRtpSourceEntry::ConstructL(const TDesC8& aCNAME) { if(0 != aCNAME.Compare(KNullDesC8)) { iCNAME = aCNAME.AllocL(); } }
TVerdict RTestStepVideoResolverUtils::DoTestStepL() { INFO_PRINTF1(_L("Tests the video resolver utility ")); _LIT8(KText, "<m>Manufacturer<p>320,200<l>100,20,4000"); TBufC8<50> data(KText); TPtr8 ptrData = data.Des(); CCodecApiVideoOpaqueData* codecApiVideoOpaqueData = CCodecApiVideoOpaqueData::NewLC(ptrData); // verify the picture size TSize picSize = codecApiVideoOpaqueData->MaxPictureSize(); if (picSize.iWidth != KPicSizeX && picSize.iHeight != KPicSizeY) { INFO_PRINTF1(_L("Incorrect picture size")); return EFail; } RArray<TPictureRateAndSize> pictureRateAndSize = codecApiVideoOpaqueData->MaxPictureRates(); TUint arraySize = pictureRateAndSize.Count(); if (arraySize == 0) { INFO_PRINTF1(_L("No picture rate and size extracted from the opaque data")); CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EFail; } INFO_PRINTF2(_L("No picture rate and size extracted from the opaque data, %d"), pictureRateAndSize[0].iPictureRate); if (pictureRateAndSize[0].iPictureRate != KPicRate) { INFO_PRINTF1(_L("Incorrect picture rate")); CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EFail; } if (pictureRateAndSize[0].iPictureSize.iWidth != KPicWidth) { INFO_PRINTF1(_L("Incorrect picture width")); CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EFail; } if (pictureRateAndSize[0].iPictureSize.iHeight != KPicHeight) { INFO_PRINTF1(_L("Incorrect picture heigh")); CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EFail; } TDesC8 manufacturer = codecApiVideoOpaqueData->Manufacturer(); if(manufacturer.Compare(KTextManufactor) == 0) { INFO_PRINTF1(_L("Incorrect manufacturer")); CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EFail; } CleanupStack::PopAndDestroy(codecApiVideoOpaqueData); return EPass; }
TPresenceSubscription CXmppEnumerationConverter::PresenceSubscription(const TDesC8& aPresenceSubscription) { TPresenceSubscription aSubscription = EPresenceSubscriptionNone; if(aPresenceSubscription.Compare(KPresenceSubscriptionBoth) == 0) { aSubscription = EPresenceSubscriptionBoth; } else if(aPresenceSubscription.Compare(KPresenceSubscriptionFrom) == 0) { aSubscription = EPresenceSubscriptionFrom; } else if(aPresenceSubscription.Compare(KPresenceSubscriptionTo) == 0) { aSubscription = EPresenceSubscriptionTo; } else if(aPresenceSubscription.Compare(KPresenceSubscriptionRemove) == 0) { aSubscription = EPresenceSubscriptionRemove; } return aSubscription; }
TXmppPubsubAccessModel CXmppEnumerationConverter::PubsubAccessModel(const TDesC8& aPubsubAccessModel) { TXmppPubsubAccessModel aAccessModel = EPubsubAccessWhitelist; if(aPubsubAccessModel.Compare(KPubsubAccessModelOpen) == 0) { aAccessModel = EPubsubAccessOpen; } return aAccessModel; }
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; }
// ---------------------------------------------------------------------------- // CSdpMediaField::SetInfoL // ---------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::SetInfoL(const TDesC8& aValue) { __ASSERT_ALWAYS (aValue.Compare(KNullDesC8) == 0|| SdpUtil::IsByteString(aValue), User::Leave(KErrSdpCodecMediaInfoField)); HBufC8* tmp = aValue.AllocL(); tmp->Des().Trim(); delete iInfo; iInfo = tmp; }
TInt CAuthenticationMac::Compare(const TDesC8 &aDigest) /** * Finish the digets computation and compare with ICV. * * @param aDigest The ICV to match * @return comparison result (= 0, match, != 0, no match). */ { return aDigest.Compare(iTemp->Des()); }
/** * Compare Buffers * * @param aReferenceBuffer Reference buffer * @param aDataBuffer Buffer to compare * * @return ETrue if buffer contents match */ TBool CT_DataVerify::CompareBuffers( const TDesC8& aReferenceBuffer, const TDesC8& aDataBuffer ) { TBool res = EFalse; TInt result = aReferenceBuffer.Compare( aDataBuffer ); if( result == 0 ) { // Buffer contents match res = ETrue; } return res; }
// ------------------------------------------------------------------------ // CNSmlDmAOAdapter::ChildURIListL // Fetches child nodes of a node. these may be either all VENDORCONFIG // nodes or leaf nodes under a VENDORCONFIG node. // ------------------------------------------------------------------------ void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" ); LOGSTRING3( "\tChildURIListL URI: %S, LUID: %S ", &aURI, &aLUID ); CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen ); CleanupStack::PushL( resultList ); // get all leaf nodes below VENDORCONFIG node if ( !aURI.Compare( KNSmlDmAOAdapterAO ) ) { CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( EFalse, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetCmd, KNullDesC8, KNullDesC8 ); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); if( cmd->Status() == CSmlDmAdapter::EOk ) { resultList->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *resultList, KNullDesC8 ); } CleanupStack::PopAndDestroy( cmd ); } CleanupStack::PopAndDestroy( resultList ); LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" ); }
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; }
// Check equality of the contents of two 8-bit descriptors void CTestCase::AssertEqualsL (const TDesC8& anExpected, const TDesC8& anActual, TInt aLineNumber, const TDesC8& aFileName) { if (anExpected.Compare(anActual) != 0) { AllocFailureSimulation(EFalse); HBufC8* msg = NotEqualsMessageLC (anExpected, anActual); AssertFailureToTlsL(*msg,aLineNumber,aFileName); CleanupStack::PopAndDestroy(); // msg User::Leave (KErrCppUnitAssertionFailed); } }
EXPORT_C TInt DSymbianUnitTest::AssertEquals( const TDesC8& aExpectedValue, const TDesC8& aActualValue, TInt aLineNumber, const TDesC8& aFileName ) { if ( aExpectedValue.Compare( aActualValue ) != 0 ) { TBuf8<sizeof(KDesCsNotEqualFormat) + KMaxSizeOfTwoIntsAsText> msg; Printf(msg, KDesCsNotEqualFormat, &aExpectedValue, &aActualValue); return AssertionFailed( msg, aLineNumber, aFileName ); } return KErrNone; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // TInt CConfigurationHandler::FindActionIndex( const TDesC8& aValue ) { for( unsigned i=0; i<sizeof(ActionList)/MaxStrSize; i++ ) { TPtrC8 ptr = ActionList[i]; if( aValue.Compare(ptr)==KErrNone ) { return i; } } return KErrNotFound; }
/* Compare the corresponding lines of two files @param aLine1 Complete line of a file to compare @param aLine2 Corresponding line to compare in the second file */ TBool CTestCompareCntFiles::CompareLine(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(KREV,"REV:"); TBool ret = !aLine1.Compare(aLine2); if (!ret) { TBufC8<4> propertyRev(aLine1.Left(4)); if(!propertyRev.Compare(KREV())) { return ETrue; } } return ret; }
void CEditorAppView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& aCustomMessage) { if (iContainer == NULL) { // iContainer = CTestEditorAppContainer::NewL(ClientRect()); iContainer = CMsgEditorView::NewL(*this, 0); TInt res(R_UNIEDITOR_TO); iContainer->AddControlFromResourceL(res, EMsgAddressControl, 0, EMsgHeader); res = R_UNIEDITOR_DATETIME; iContainer->AddControlFromResourceL(res, EMsgDateTimeControl, EMsgAppendControl, EMsgHeader); iContainer->ExecuteL(ClientRect(), 0); if (aCustomMessage.Length() > 0) { if (aCustomMessage.Compare(KViewChangeFromLoadDraft) == 0) { LoadMessage(SHModel()->GetDraftMsg()); } else if (aCustomMessage.Compare(KViewChangeFromModify) == 0) { LoadMessage(); } } AppUi()->AddToStackL(*this, iContainer); iContainer->DrawNow(); //add your init code ... } }
TBool CAgentTest::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(Krev,"REV"); TBool ret=!aLine1.Compare(aLine2); if (!ret) { TBufC8<2> firstchar(aLine1.Left(2)); if(!firstchar.Compare(Krev())) { return ETrue; } } return ret; }
TBool TSimpleContentHandler::IsForbiddenTagL ( const TDesC8& aTag ) { for ( TInt i = HtmlTagsStringTable::EArea; i <= HtmlTagsStringTable::EParam; ++i ) { RString string = iStringPool->String( i, HtmlTagsStringTable::Table ); CleanupClosePushL ( string ); TInt result = aTag.Compare ( string.DesC() ); CleanupStack::PopAndDestroy ( 1 ); if ( !result ) { return ETrue; } } return EFalse; }
// ----------------------------------------------------------------------------- // CRoapParser::ConvertRoapStatus // ----------------------------------------------------------------------------- // TRoapStatus CRoapParser::ConvertRoapStatus( const TDesC8& aStatus) { TInt i; TRoapStatus r = EUnknownStatus; for (i = 0; r == EUnknownStatus && i < ELEMENT_COUNT(KStatusValues); i++) { if (aStatus.Compare(TPtrC8(KStatusValues[i].iString, aStatus.Size())) == 0) { r = static_cast<TRoapStatus>(KStatusValues[i].iNumber); } } return r; }
TBool CDiscussion::DeleteEntryById(const TDesC8& aEntryId) { if(aEntryId.Length() > 0) { ReadDiscussionToMemoryL(); for(TInt i = 0; i < iEntries.Count(); i++) { if(aEntryId.Compare(iEntries[i]->GetEntry()->GetId()) == 0) { return DeleteEntryByIndex(i); } else if(iEntries[i]->DeleteCommentById(aEntryId)) { return true; } } } return false; }
/** Compares each line, REV and UID are ignored as they can be different */ TBool CCntPBAPSupport::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2) { _LIT8(KPropREV,"REV:"); _LIT8(KPropUID,"UID:"); TBool ret = !aLine1.Compare(aLine2); if (!ret) { TBufC8<4> first4char(aLine1.Left(4)); if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID())) { return ETrue; } } return ret; }
void CLoopbackTestStepBase::TestErrorCodeAndDescriptorL(TInt aErrCode, TInt aExpectedErrCode, const TDesC8& aDesC, const TDesC8& aExpectedDesC, const TDesC& aMessage) { if ( (aExpectedErrCode == aErrCode) && (aDesC.Compare(aExpectedDesC) == 0) ) { INFO_PRINTF4(_L("[%S]. err[%d], and string [%S] as expected. OK."), &aMessage, aErrCode, &aExpectedDesC); } else if (aExpectedErrCode == aErrCode) { ERR_PRINTF5(_L("Failed: [%S]. err[%d], expected [%d]. Leaving with [%d])."), &aMessage, aErrCode, aExpectedErrCode, aErrCode); User::Leave(aErrCode); } else { ERR_PRINTF4(_L("Failed: [%S]. String [%S] received, expected [%S]. Leaving with KErrGeneral."), &aMessage, &aDesC, &aExpectedDesC); User::Leave(KErrGeneral); } }
// ----------------------------------------------------------------------------- // CUpnpDevice::GetProperty // Get information from device description. // ----------------------------------------------------------------------------- // EXPORT_C TPtrC8 CUpnpDevice::GetProperty(const TDesC8& aProperty) { TInt index = 0; while ( index < iProperties.Count() ) { CUpnpDescriptionProperty* var = iProperties[index]; if ( aProperty.Compare( var->Name() ) == KErrNone ) { return var->Value(); } index++; } return KNullDesC8(); //return Content( aProperty ); }
TInt CAuthenticationHmac::Compare(const TDesC8 &aDigest) /** * Finish the digets computation and compare with ICV. * * @param aDigest The ICV to match * @return comparison result (= 0, match, != 0, no match). */ { TPtr8 ptr = iTemp->Des(); ptr.SetLength(iDigestSize); // Ensure correct length! iDigest->Final(ptr); // Get Current Digest Value iDigest->Init(); // Initialize Digest Engine iDigest->Update(*iHmac_opad); // Feed in the precomputed output pad iDigest->Update(ptr); // Merge with digest from the first phase iDigest->Final(ptr); // and produce the final digest value. // The caller may want a tructated value ptr.SetLength(aDigest.Length()); return aDigest.Compare(ptr); }
void CThemeChangeAppView::DoActivateL(const TVwsViewId& aPrevViewId, TUid /*aCustomMessageId*/, const TDesC8& aCustomMessage) { if (iContainer == NULL) { iContainer = CThemeChangeAppContainer::NewL(ClientRect()); iContainer->SetMopParent(this); AppUi()->AddToStackL(*this, iContainer); //add your init code ... if (aCustomMessage.Length() > 0) { if (aCustomMessage.Compare(KMsgCfgChange)) { iContainer->RefreshServer(); } } } }