/** Sets an existing descriptor setting to a new value or creates a new setting with a descriptor value if it doesn't exist. @param aKey Key of setting to be written to. @param aValue Value to be written. @return KErrNone if successful, KErrArgument if aValue is longer than KMaxUnicodeStringLength or the setting exists but is not a descriptor, plus other system-wide error codes. @post Transactions fail on all error conditions. Outside transactions: on success the new value is persistent, on failure the repository is unmodified. @capability Dependent Caller must satisfy the write access policy of that key in the repository. */ EXPORT_C TInt CRepository::Set(TUint32 aKey, const TDesC16& aValue) { if (aValue.Length()>KMaxUnicodeStringLength) return KErrArgument; TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2); return Set(aKey,pVal); }
void CTestVwAppUi::ActivateViewL(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC16& aCustomMessage) { HBufC8* narrowMessage=HBufC8::NewLC(aCustomMessage.Size()); TPtr8 ptr=narrowMessage->Des(); ptr.Copy((TUint8*)aCustomMessage.Ptr(),aCustomMessage.Size()); CCoeAppUi::ActivateViewL(aViewId,aCustomMessageId,*narrowMessage); CleanupStack::PopAndDestroy(); // narrowMessage. }
/** Finds all the settings that match the specification given by aPartialKey and aMask, but are either not string values or do not match the given string. @param aPartialKey Contains a bit pattern that all the keys returned must at least partially match. @param aMask Has bits set for all the bits in aPartialKey that must match the returned keys. @param aValue Settings for the keys found will be settings that either contain values that are not strings or strings with value other than aValue. @param aFoundKeys All the keys found. For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and the setting with key k is either not a string value or a string value not equal to aValue. @see FindL() @return KErrNone if successful, KErrNotFound if capability check passed but no non-matching items are found, plus other system-wide error codes. @post Transactions fail only on those "other system-wide error codes". @capability Dependent Caller must satisfy the read policies of all settings found in the source range. */ EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, const TDesC16& aValue, RArray<TUint32>& aFoundKeys) { TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2); TRAPD(ret,iImpl->FindSettingsComparisonL(aPartialKey,aMask,pVal,ENotEqual,aFoundKeys)); if (ret==KErrNoMemory) User::LeaveNoMemory(); return ret; }
void TDes8::Copy(const TDesC16 &aDes) { TInt len=aDes.Length(); SetLength(len); const TUint16 *pS=aDes.Ptr(); const TUint16 *pE=pS+len; TUint8 *pT=const_cast<TUint8 *>(Ptr()); while (pS<pE) { TUint c=(*pS++); if (c>=0x100) c=1; *pT++=(TUint8)c; } }
EXPORT_C int Tlitc16ToChar(const TDesC16& aSrc, char* aDes, int& n_size) { unsigned int ilen = 0; int retval = ESuccess; ilen = aSrc.Length(); wchar_t* temp16String = NULL; int minusone = -1; if (0 == ilen ) { return EDescriptorNoData; } else if ( !aDes ) { return EInvalidPointer; } else if (n_size < ilen*2 +1) { n_size = ilen*2 + 1; return EInvalidSize; } temp16String = new wchar_t [ilen+1]; if (!temp16String) { return EInsufficientSystemMemory; } wmemcpy(temp16String, (const wchar_t*)aSrc.Ptr(), ilen); temp16String[ilen] = L'\0'; if(minusone != wcstombs(aDes, temp16String, ilen*2)) { aDes[ilen*2] = '\0'; } else { retval = EInvalidWCSSequence; } delete []temp16String; return retval; }
inline void CPppMsChap::NtPasswordHashL(const TDesC16& aPassword, TDes8& aPasswordHash) /** Computes the hash of the Microsoft Windows NT password using MD4. @param aPassword [in] The Microsoft Windows NT password (0 to 256 Unicode char). @param aPasswordHash [out] The MD4 hash of the Microsoft Windows NT password (16 octets). @note This function implements the NtPasswordHash routine specified in RFC 2433. @internalComponent */ { ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength); ASSERT(aPasswordHash.Length() == KPppMsChapHashSize); // The following code does not use the Symbian Security subsystem // components, because they do not provide a MD4 implementation yet. // This is a provisional solution until the Symbian Security subsystem // components will provide a MD4 implementation. CMd4* md4 = CMd4::NewL(); CleanupStack::PushL(md4); // The following code assumes that the data in TDesC16 descriptors is // stored in little endian byte order, which is currently a // characteristic of Symbian OS, so the reinterpret_cast is assumed to // be safe here. md4->Input(TPtrC8(reinterpret_cast<const TUint8*>( aPassword.Ptr()), aPassword.Size())); md4->Output(aPasswordHash); CleanupStack::PopAndDestroy(md4); ASSERT(aPasswordHash.Length() == KPppMsChapHashSize); }
/** * Converts a descriptor of type TLitc16 to Wstring * * @param aSrc is the descriptor to be converted , aDes is the * reference to the Wstring array where the result of conversion * is stored * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, * -5 is EDescriptorNoData) */ EXPORT_C int Tlitc16ToWstring(TDesC16& aSrc, wstring& aDes) { unsigned int ilen = aSrc.Length(); if (0 == ilen) { return EDescriptorNoData; } wchar_t* wcharString = new wchar_t[ilen+1]; if (!wcharString) { return EInsufficientSystemMemory; } wmemcpy((wchar_t*)wcharString, (const wchar_t*)aSrc.Ptr(), ilen); wcharString[ilen] = L'\0'; aDes.assign(wcharString); delete []wcharString; return ESuccess; }
/** Outputs a trace packet containing variable length data. If the specified data is too big to fit into a single trace record a multipart trace is generated. @deprecated @param aContext Attributes of the trace point. @param aTraceId The trace point identifier as specified by @see TTraceId @param aData Additional data to add to trace packet. Must be word aligned, i.e. a multiple of 4. @return The trace packet was/was not logged. @See BTrace::TMultipart */ EXPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC16& aData) { if(IsTraceActive(aContext)) { GET_PC(pc); return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, aTraceId, aData.Ptr(), aData.Size()); } return EFalse; }
/** Prints a string by outputting a trace packet with the Trace ID KFormatPrintfUnicode If the specified string is too long to fit into a single trace packet a multipart trace is generated. @deprecated @param aContext The trace packet context. @see TTraceContext @param aDes The string. This must not be longer than 256 characters. @return The trace packet was/was not output. @See BTrace::TMultipart */ EXPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes) { if(IsTraceActive(aContext)) { GET_PC(pc); return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, KFormatPrintfUnicode, aDes.Ptr(), aDes.Size()); } return EFalse; }
EXPORT_C void TDbColumn::SetL(const TDesC16& aValue) { SetL(aValue.Ptr(),aValue.Length()<<1); }
// --------------------------------------------------------- // RUnicodeFile::Write // --------------------------------------------------------- // TInt RUnicodeFile::Write( const TDesC16& aDes ) { return iFile.Write ( TPtrC8( (const TUint8*)aDes.Ptr(), aDes.Size() ) ); }