Beispiel #1
0
/** 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);
	}
// ==========================================================================
// METHOD:  Write
//
// DESIGN:  Write the given buffer.  Chunk the string if it is longer than
//          KMaxTextPerLine. 
// ==========================================================================
void CLogFileHandler::Write( const TDesC8&  aClassName,
                             const TDesC8&  aFuncName,
                             const TDesC16& aDes )
    {
    TRAP_IGNORE( AddTimestampToOutputBufferL() );
        
    TInt prefixLength = iOutputBuffer.Length();
        
    TRAP_IGNORE( AddClassAndFunctionToOutputBufferL( aClassName, aFuncName ) );
            
    TInt curPos = 0;
    
	while( curPos < aDes.Length() )
	    {
        TInt lengthToWrite = Min( KMaxTextPerLine - iOutputBuffer.Length(), aDes.Length() - curPos );
        
		TRAP_IGNORE( WriteLineL( aDes.Mid( curPos, lengthToWrite ) ) );
		    
		iOutputBuffer.SetLength( prefixLength );
				    
		curPos += lengthToWrite;

    	} // end while
    
    } // END Write
void CCatalogsBaseMessageImpl::CompleteAndReleaseL(
    const TDesC16& aOutputData,
    TInt aStatus ) 
    {
    DLTRACEIN(("TDesC16, TInt, handle: %d, this: %x", Handle(), this));
    if ( iSenderLost )
        {
        DLINFO(("Sender was lost, deleting message"));
        delete this;
        DLTRACEOUT((""));
        return;
        }

    TInt clientDescLength( iMessage.GetDesMaxLengthL( 3 ) );

    if ( clientDescLength < aOutputData.Length() )
        {
        if( iMessage.Function() == ECatalogsExternalAllocMessage )
            {
            TInt incompMsgHandle( iSession.WriteToLargerDesL( aOutputData,
                                                              aStatus ) );
                                                              
            TBuf16<KCatalogsMinimumAllocSize> internalMsg(
                                               KCatalogsMinimumAllocLength );
            
            internalMsg.Num( incompMsgHandle );
            internalMsg.Append( KCatalogsTooSmallDescMsgElementDivider );
            internalMsg.AppendNum( aOutputData.Length() );

            TRAPD( error, iMessage.WriteL( KOutputSlot, internalMsg ) );
            if ( error != KErrNone )
                {
                iSession.RemoveIncompleteMessage( incompMsgHandle );
                User::Leave( error );
                }
            }

        iMessage.Complete( KCatalogsErrorTooSmallDescriptor );
        }
    else
        {
        iMessage.WriteL( KOutputSlot, aOutputData );
        iMessage.Complete( aStatus );
        }
        
    delete this;
    DLTRACEOUT((""));
    }
// -----------------------------------------------------------------------------
// CSatNotifySendSs::CreateTerminalRespL
// Constructs SendSs specific part of terminal response and calls 
// DOS to send the actual message.
// -----------------------------------------------------------------------------
//
TInt CSatNotifySendSs::CreateTerminalRespL
        ( 
        TUint8 aPCmdNumber,        
        TUint8 aGeneralResult,      
        const TDesC16& aAdditionalInfo
		)
    {
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CREATETERMINALRESPL_1, "CSAT:: CSatNotifySendSs::CreateTerminalRespL");
    // Create and append response data
    TTlv tlvSpecificData;
    tlvSpecificData.AddTag( KTlvResultTag );    
	// Append general result
    tlvSpecificData.AddByte( aGeneralResult );
	for (TInt i = 0; i < aAdditionalInfo.Length(); i++ )
		{
		tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[i] ) );
		}
		
    // Prepare data
    iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
    TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
    // Pack data
    CSatDataPackage dataPackage;
	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
    // Forward request to the DOS
    return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
		ESatTerminalRsp, &dataPackage );
    }
// -----------------------------------------------------------------------------
// Sets poly points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPointsL( const TDesC16& aPointString )
    {
    TInt coordCount = aPointString.Length();

    if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
        {
        RDebug::Printf("%s, line %d, ERROR: Illegal coordinate count", __FILE__, __LINE__);
        User::Leave(KErrArgument);
        }

    iPointCount = coordCount >> 1;
    iPoints = new (ELeave) TPolyPoint[iPointCount];

    iPoints[0].iX = aPointString[0];
    iPoints[0].iY = aPointString[1];

    TUint16 oldX = iPoints[0].iX;
    TUint16 oldY = iPoints[0].iY;

    // parse numbers from the descriptor
    for (TInt i = 1; i < iPointCount; i++) // first point already set
        {
        iPoints[i].iX = aPointString[i*2];
        iPoints[i].iY = aPointString[i*2+1];

        if (oldX == iPoints[i].iX && oldY == iPoints[i].iY)
            {
            RDebug::Printf("%s, line %d, ERROR: subsequent coordinates cannot be equal", __FILE__, __LINE__);
            User::Leave(KErrArgument);
            }

        oldX = iPoints[i].iX;
        oldY = iPoints[i].iY;
        }
    }
// -----------------------------------------------------------------------------
// Sets poly1D points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPoints1DL( const TDesC16& aPointString )
    {
    TInt coordCount = aPointString.Length();

    if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
        User::Leave(KErrArgument);

    iPointCount = coordCount >> 1;
    iPoints = new (ELeave) TPolyPoint[iPointCount];

    iPoints[0].iX = aPointString[0];
    iPoints[0].iY = aPointString[1];

    TUint16 oldX = iPoints[0].iX;

    // parse numbers from the descriptor
    for (TInt i = 1; i < iPointCount; i++) // first point already set
        {
        iPoints[i].iX = aPointString[i*2];
        iPoints[i].iY = aPointString[i*2+1];

        if (iPoints[i].iX < oldX) // points must be in ascending order
            User::Leave(KErrArgument);

        oldX = iPoints[i].iX;
        }
    }
Beispiel #7
0
inline void CPppMsChap::NTChallengeResponseL(const TDesC8& aChallenge,
					     const TDesC16& aPassword,
					     TDes8& aResponse)
/**
   Computes a MS-CHAP Windows NT compatible Challenge Response.
   @param aChallenge [in] A MS-CHAP Challenge (8 octets).
   @param aPassword [in] The Microsoft Windows NT password (0 to 256
   Unicode char).
   @param aResponse [out] The MS-CHAP Windows NT compatible Challenge
   Response (24 octets).
   @note This function implements the NTChallengeResponse routine
   specified in RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aChallenge.Length() == KPppMsChapChallengeSize);
	ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);

	HBufC8* paddedPasswordHashBuf =
			HBufC8::NewLC(KPppMsChapPaddedHashSize);
	TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des());

	paddablePasswordHash.SetLength(KPppMsChapHashSize);
	NtPasswordHashL(aPassword, paddablePasswordHash);

	ChallengeResponseL(aChallenge, 
			paddablePasswordHash,
			aResponse);

	CleanupStack::PopAndDestroy(paddedPasswordHashBuf);
	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);
	}
EXPORT_C  void CPTPIPInitCmdAck::SetDeviceFriendlyName(TDesC16& aName)
{
	OstTraceFunctionEntry0( CPTPIPINITCMDACK_SETDEVICEFRIENDLYNAME_ENTRY );
	if(KErrNone == iBuffer.Create(aName,aName.Length()+KMTPNullCharLen))
		{
		iBuffer.Append(KMTPNullChar);
		}
}    
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullHiragnaToFullKatakana
// Converts Full-width Hiragana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the
// resulting text into aUnicodeTarget.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullHiragnaToFullKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    const TInt maxLength( aUnicodeTarget.MaxLength() );
    if( length > maxLength )
        {
        return KErrTooBig;
        }

    const TUint comp = KFullWidthKatakanaSmallA - KFullWidthHiraganaSmallA;

    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        TText uniChar2(0);
        if (i + 1 < length)
            {
            uniChar2 = aUnicodeSource[i+1];
            }
        // First check if this is this Full Width Katakana
        if (KFullWidthHiraganaSmallA <= uniChar && uniChar <= KFullWidthHiraganaVU)
            {
            if (uniChar == KFullWidthHiraganaU
             && uniChar2 == KFullWidthHiraganaVoicedSound)
                {
                aUnicodeTarget.Append(KFullWidthKatakanaSmallVU);
                totalConverted++;
                i++;
                }
            else
                {
                TUint katakana = uniChar + comp;
                if (IsKatakana(katakana))
                    {
                    aUnicodeTarget.Append(katakana);
                    totalConverted++;
                    }
                }
            }
        else
            {
            aUnicodeTarget.Append(uniChar);
            totalConverted++;
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another loop over
    // the text
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }
//---------------------------------------------------------------------
//
//---------------------------------------------------------------------	
CLogEntry::CLogEntry(const TDesC16& aMsg, TInt aNbrArg, TInt aArg1, TInt aArg2, TInt aArg3, TInt aArg4) :  iNbrArgs(aNbrArg), 
					iArg1(aArg1), iArg2(aArg2), iArg3(aArg3), iArg4(aArg4) 
	{
	iMsg = HBufC16::New(aMsg.Length());
	if(iMsg)
	    {
    	(*iMsg) = aMsg;
	    }
	}	  
Beispiel #11
0
/** 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 CNcdConfigurationParser::ParseL( const TDesC16& aData )
    {
    DLTRACEIN(("16-bit parse, length=%d",aData.Length()));
    HBufC8* utf8 = NcdProtocolUtils::ConvertUnicodeToUtf8L( aData );
    CleanupStack::PushL( utf8 );
    ParseL( *utf8 );
    CleanupStack::PopAndDestroy( utf8 );
    
    }
Beispiel #13
0
	void ExternalizeDesL(const TDesC16& aDes, RWriteStream& aStream)
		{
		TInt length = aDes.Length();
		aStream.WriteInt32L(length);

		if (length > 0)
			{
			aStream << aDes;
			}
		}
EXPORT_C void CSenLogger::WriteAll(TInt aChannel, TInt aLevel, const TDesC16& aText)
    {
    RFileLogger* pLogger = Logger(aChannel, aLevel);
    if ( pLogger )
        {
        TInt i = 0;
        TInt lineAmount(KColumnWidth);
        TInt length = aText.Length();
        while(i<aText.Length())
            {
            if ( length - i < KColumnWidth )
                {
                lineAmount = length - i;    
                }
            pLogger->Write(aText.Mid(i, lineAmount));
            i += KColumnWidth;
            }
        }
    }
Beispiel #15
0
inline void CPppMsChap2::GenerateNTResponseL(
    const TDesC8& aAuthenticatorChallenge,
    const TDesC8& aPeerChallenge,
    const TDesC8& aUserName,
    const TDesC16& aPassword,
    TDes8& aResponse)
/**
   Generates a MS-CHAP-V2 NT-Response.
   @param aAuthenticatorChallenge [in] The MS-CHAP-V2 authenticator
   challenge (16 octets).
   @param aPeerChallenge [in] The MS-CHAP-V2 peer challenge (16
   octets).
   @param aUserName [in] The Microsoft Windows NT username (0 to 256
   char).
   @param aPassword [in] The Microsoft Windows NT password (0 to 256
   unicode char).
   @param aResponse [out] The MS-CHAP-V2 Challenge Response,
   NT-Response (24 octets).
   @note This function implements the GenerateNTResponse routine
   specified in RFC 2759.
   @internalComponent
*/
{
    ASSERT(aAuthenticatorChallenge.Length() ==
           KPppMsChap2AuthenticatorChallengeSize);
    ASSERT(aPeerChallenge.Length() ==
           KPppMsChap2PeerChallengeSize);
    ASSERT(aUserName.Length() <= KPppMsChapMaxNTUserNameLength);
    ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
    ASSERT(aResponse.Length() == KPppMsChap2NTResponseSize);

    HBufC8* challengeHashBuf =
        HBufC8::NewMaxLC(KPppMsChap2ChallengeHashSize);
    TPtr8 challengeHash(challengeHashBuf->Des());
    ChallengeHashL(aPeerChallenge,
                   aAuthenticatorChallenge,
                   aUserName,
                   challengeHash);

    HBufC8* paddedPasswordHashBuf =
        HBufC8::NewLC(KPppMsChap2PaddedHashSize);
    TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des());

    paddablePasswordHash.SetLength(KPppMsChap2HashSize);
    NtPasswordHashL(aPassword, paddablePasswordHash);

    ChallengeResponseL(challengeHash,
                       paddablePasswordHash,
                       aResponse);

    CleanupStack::PopAndDestroy(paddedPasswordHashBuf);
    CleanupStack::PopAndDestroy(challengeHashBuf);

    ASSERT(aResponse.Length()==KPppMsChap2NTResponseSize);
}
/** Tests whether the input has a path.

@param aUri descriptor to URI
@return ETrue if it has a path
*/
TBool TUriShortcutParser16::HasPath( const TDesC16& aUri )
{

    for ( TInt i = aUri.Length() - 1; i >= 0; --i )
    {
        if ( aUri[i] == KUriComponentSeparator || aUri[i] == KUriQueryDelimiter || aUri[i] == KUriFragmentDelimiter )
        {
            return ETrue;
        }
    }
    return EFalse;
}
Beispiel #17
0
void CPppMsChap2::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 2759.
   @internalComponent
*/
{
    ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
    ASSERT(aPasswordHash.Length()==KPppMsChap2HashSize);

// 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.Length()*2));
    md4->Output(aPasswordHash);

    CleanupStack::PopAndDestroy(md4);

    ASSERT(aPasswordHash.Length()==KPppMsChap2HashSize);
}
Beispiel #18
0
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;
		}
}
// -----------------------------------------------------------------------------
// CSyncMLFilterProperty::AddDefaultValueText16L
// Adds default value for text16 property.
// This is useful only if data type is text16.
// -----------------------------------------------------------------------------
EXPORT_C void CSyncMLFilterProperty::AddDefaultValueText16L( 
                TDesC16& aNewDefaultValue, const TBool aSelected )
	{
	if ( iDataTypeForDefaultValues != ESyncMLDataTypeText16 )
		{
		User::Leave( KErrNotSupported );
		}
	if ( aNewDefaultValue.Length() > iMaxTextLength )
		{
		User::Leave( KErrArgument );
		}
	iDefaultValueText16List.AppendL( aNewDefaultValue.AllocLC() );
	CleanupStack::Pop(); // aNewDefaultValue.AllocLC()
	iDefaultValueSelected.AppendL( aSelected );
	}
/** Gets the number of components in the host name.

@param aUri descriptor to URI
@return Number of components
@panic KErrBadName URI should not start with a '.'
*/
TInt TUriShortcutParser16::ComponentCount( const TDesC16& aUri )
{
    //make sure first character is not '.'
    __ASSERT_ALWAYS( aUri[0] != '.', User::Panic( KPanicDescriptor,KErrBadName ) );

    TInt nComponentCount = 1;

    for ( TInt i = aUri.Length() - 1; i > 0; i-- )
    {
        if ( aUri[i] == KSeparatorDot )
        {
            nComponentCount++;
        }
    }

    return nComponentCount;
}
// -----------------------------------------------------------------------------
// CSyncMLFilterProperty::SetQueryValueText16L
// Sets query value for text16 property.
// This is useful only if data type is text16 and if query value can be used.
// This method also selects query value.
// -----------------------------------------------------------------------------
EXPORT_C void
            CSyncMLFilterProperty::SetQueryValueText16L( const TDesC16& aValue )
	{
	if ( iDataTypeForQueryValue != ESyncMLDataTypeText16 || !iCanUseQueryValue )
		{
		User::Leave( KErrNotSupported );
		}
	if ( aValue.Length() > iMaxTextLength )
		{
		User::Leave( KErrArgument );
		}

	delete iQueryValueText16;
	iQueryValueText16 = NULL;
	iQueryValueText16 = aValue.AllocL();
	iQueryValueSelected = ETrue;
	}
/**
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0535
@SYMTestCaseDesc        Tests for truncated conversion from Unicode to EucJpPacked
@SYMTestPriority        Medium
@SYMTestActions         Tests for truncated conversion from Unicode to EucJpPacked and back to Unicode
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void CT_EUCJP_PACKED_2::TestTruncatedConversionFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0535 "));
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
		{
		TBuf8<KBufferLength> generatedEucJpPacked;
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedEucJpPacked, aOriginalUnicode.Left(i));
		test(returnValue>=0);
		TBuf8<KBufferLength> generatedsecondPartOfEucJpPacked;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfEucJpPacked, aOriginalUnicode.Mid(i-returnValue))==0);
		generatedEucJpPacked.Append(generatedsecondPartOfEucJpPacked);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedEucJpPacked, state)==0);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
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;
}
void CT_ISO2022JP1_2::TestTruncatedConversionFromUnicodeToIso2022Jp(
                CCnvCharacterSetConverter& aCharacterSetConverter,
                const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp "));
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
		{
		TBuf8<KBufferLength> generatedIso2022Jp;
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode.Left(i));
		test(returnValue>=0);
		TBuf8<KBufferLength> generatedsecondPartOfIso2022Jp;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfIso2022Jp, aOriginalUnicode.Mid(i-returnValue))==0);
		generatedIso2022Jp.Append(generatedsecondPartOfIso2022Jp);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state)==0);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
// -----------------------------------------------------------------------------
// CUpnpHttpFileAccess::ConstructL
// Two-phased constructor, called when serving file
// -----------------------------------------------------------------------------
//
void CUpnpHttpFileAccess::ConstructL( CUpnpHttpSession* aSession,
                                      const TDesC8& aHeaderBuffer, const TDesC16& aFilename )
{
    LOGS1H(
        iHandle,
        "%i, CUpnpHttpFileAccess::ConstructL(CUpnpHttpSession*, TDesC8&, TDesC16&)",
        this );
    iHeaderBuffer = HBufC8::NewL( aHeaderBuffer.Length( ) );
    iHeaderBuffer->Des().Zero( );
    iHeaderBuffer->Des().Append( aHeaderBuffer );

    iFileToServe = HBufC16::NewL( aFilename.Length( ) );
    iFileToServe->Des().Zero( );
    iFileToServe->Des().Append( aFilename );

    iHeaderLength = aHeaderBuffer.Length( );
    User::LeaveIfError( iFsSession.Connect( ) );
    iSession = aSession;
    iOpenedFile = KNullDesC().AllocL( );
}
// -----------------------------------------------------------------------------
// CSatNotifyCloseChannel::CreateTerminalRespL
// Constructs Close channel specific part of terminal response and calls 
// DOS to send the actual message.
// -----------------------------------------------------------------------------
//
TInt CSatNotifyCloseChannel::CreateTerminalRespL
        ( 
        TUint8 aPCmdNumber,         
        TUint8 aGeneralResult,     
        const TDesC16& aAdditionalInfo	
		)
    {
    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_CREATETERMINALRESPL_1, "CSAT: CSatNotifyCloseChannel::CreateTerminalRespL");
    TTlv tlvSpecificData;
    // Append general result tag
    tlvSpecificData.AddTag( KTlvResultTag );
    // Append general result
    tlvSpecificData.AddByte( aGeneralResult );

    if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
        || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult ) 
        || ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
        || ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
        || ( RSat::KBearerIndepProtocolError == aGeneralResult )
        || ( RSat::KFramesError == aGeneralResult ))
        {
        // Unsuccessful result requires an additional info byte
        for ( TInt i = 0; i < aAdditionalInfo.Length(); i++ )
        	{
        	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_CREATETERMINALRESPL_2, "CSAT: CSatNotifyCloseChannel::CreateTerminalRespL, Unsuccessful result");
        	tlvSpecificData.AddByte( static_cast<TUint8>( 
        	    aAdditionalInfo[i] ) );
        	}
        }
    
    // Prepare data
    iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
    TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
    // Pack data
    CSatDataPackage dataPackage;
	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
    // Forward request to the DOS
    return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
		ESatTerminalRsp, &dataPackage );      
	}
Beispiel #27
0
// ------------------------------------------------
// LogLit
// ------------------------------------------------
//
void CMdSLogger::LogLit( const TDesC16& aText )
    {
    if (!iValid)
    	{
    	return;
    	}

    TInt offset = 0;
    TInt linecount = 0;
    TInt length = aText.Length();
    while( offset < length )
        {
        TInt partLength = Min( length-offset, KLineLength );
#ifdef MDE_FILE_LOGGING
        iLog.Write( aText.Mid( offset, partLength ) );
#else
        RDebug::Print( aText.Mid( offset, partLength ) );
#endif
        ++linecount;
        offset += partLength;
        }
    CheckSize( linecount );
    }
 /**
   * 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;
}
Beispiel #29
0
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullToHalfWidthKatakana
// Converts Full-width Katakana and Special Character text found in
// aUnicodeSource to their Half-width counterparts and places the resulting text
// into aUnicodeTarget. There will be a 2-for-1 conversion for each Full-width
// Voiced and Semi-voiced Katakana character.
// (detailed information about the parameters and return values can be found in
// the header file)
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullToHalfWidthKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    const TInt maxLength( aUnicodeTarget.MaxLength() );
    if( length > maxLength )
        {
        return KErrTooBig;
        }
    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        // First check if this is this Full Width Katakana
        if( ( uniChar >= KFullWidthKatakanaLowerBound &&
              uniChar <= KFullWidthKatakanaUpperBound ) ||
            ( uniChar == KFullWidthKatakanaVoicedSoundMark ||
              uniChar == KFullWidthKatakanaSemiVoicedSoundMark ) )
            {
            // Then check if it is (Semi-)Voiced and convert it properly
            const TBool isVoiced(
                UnicodeTextUtil::IsFullWidthVoicedKatakana( uniChar )
            );
            const TBool isSemiVoiced(
                UnicodeTextUtil::IsFullWidthVoicedKatakana( uniChar, ETrue )
            );
            if( isVoiced || isSemiVoiced )
                {
                if( aUnicodeTarget.Length() + 2 > maxLength )
                    {
                    // This descriptor can't hold the new data
                    aUnicodeTarget.Zero();
                    return KErrTooBig;
                    }
                UnicodeTextUtil::ConvertVoicedKatakanaCharAndAppendToTarget(
                    EFullToHalfWidth,
                    uniChar,
                    aUnicodeTarget,
                    isSemiVoiced
                );
                totalConverted++;
                }
            else
                {
                if( aUnicodeTarget.Length() + 1 > maxLength )
                    {
                    // This descriptor can't hold the new data
                    aUnicodeTarget.Zero();
                    return KErrTooBig;
                    }
                aUnicodeTarget.Append(
                    UnicodeTextUtil::ConvertKatakanaChar(
                        EFullToHalfWidth,
                        uniChar
                    )
                );
                totalConverted++;
                }
            }
        // This is not Full Width Katakana, so copy directly...
        else
            {
            if( aUnicodeTarget.Length() + 1 > maxLength )
                {
                // This descriptor can't hold the new data
                aUnicodeTarget.Zero();
                return KErrTooBig;
                }
            const TChar uniCharacter( uniChar );
            aUnicodeTarget.Append( uniCharacter );
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another loop over
    // the text
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }
Beispiel #30
0
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertHalfToFullWidthKatakana
// Converts Half-width Katakana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the resulting text
// into aUnicodeTarget.
// (detailed information about the parameters and return values can be found in
// the header file)
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertHalfToFullWidthKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    if( length > aUnicodeTarget.MaxLength() )
        {
        return KErrTooBig;
        }
    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        // Check if the next character is a Half Width Katakana (Semi-)Voiced
        // Sound Mark and if the current character + the voiced sound mark have
        // a Full Width counterpart
        if( i + 1 < length )
            {
            const TBool isVoiced(
            ( UnicodeTextUtil::IsFullWidthVoicedConvertableHalfWidthBaseKatakana
                  ( uniChar ) &&
              ( aUnicodeSource[i + 1] == KHalfWidthKatakanaVoicedSoundMark )
            ) );

            const TBool isSemiVoiced(
            ( UnicodeTextUtil::IsFullWidthVoicedConvertableHalfWidthBaseKatakana
                  ( uniChar, ETrue ) &&
              ( aUnicodeSource[i + 1] == KHalfWidthKatakanaSemiVoicedSoundMark )
            ) );

            if( isVoiced || isSemiVoiced )
                {
                UnicodeTextUtil::ConvertVoicedKatakanaCharAndAppendToTarget(
                    EHalfToFullWidth,
                    uniChar,
                    aUnicodeTarget,
                    isSemiVoiced
                );
                i++; // Skip the (semi-)voice marker
                totalConverted++;
                continue;
                }
            }
        // If not, then just convert directly if in range
        if( uniChar >= KHalfWidthKatakanaLowerBound &&
            uniChar <= KHalfWidthKatakanaUpperBound )
            {
            aUnicodeTarget.Append(
                UnicodeTextUtil::ConvertKatakanaChar( EHalfToFullWidth,
                                                      uniChar )
            );
            totalConverted++;
            }
        // Else this is not Half Width Katakana, so copy directly...
        else
            {
            const TChar uniCharacter( uniChar );
            aUnicodeTarget.Append( uniCharacter );
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another
    // loop over the text.
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EHalfToFullWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }