コード例 #1
0
ファイル: UriUtils.cpp プロジェクト: cdaffara/symbiandump-os2
/**
	Validates and Converts the valid Percent encoded triplets to Uppercase for specified 
	sub component of URI. For eg: Converts %3a to %3A
	
	@param aData A reference to a string to be validated and converted to upper case.
	@param aCaseNormalizedData A reference to a descriptor that is converted to 
	uppercase that is to be returned.
	@return returns a bool whether it is a valid Percent encoded triplet
*/
TBool ValidateAndConvertPercentEncodedTriple(TDesC8& aData , TDes8& aCaseNormalizedData )	
	{
	// See if the descriptor is actually long enough and
	// Check that the three characters form an escape triple - first char is '%'
	if( aData.Length() < KEscapeTripleLength || aData[KEscDelimiterPos] != KEscapeIndicator )
		{
		return EFalse;//do nothing
		}
	
	// Check that next two characters are valid
	TInt mostSignificantDigitValue = KHexDigit().LocateF(aData[KMostSignificantNibblePos] );
	TInt leastSignificantDigitValue = KHexDigit().LocateF(aData[KLeastSignificantNibblePos] );

	if( mostSignificantDigitValue== KErrNotFound || leastSignificantDigitValue == KErrNotFound )
		{
		// Either of the characters were not a valid hex character
		return EFalse;
		}
	aCaseNormalizedData.Zero();
	aCaseNormalizedData.Append(KEscapeIndicator); 
	
	//Coverts most significant hex character to uppercase
	(mostSignificantDigitValue >= 0 && mostSignificantDigitValue <= 0xF) ? 
		aCaseNormalizedData.Append(KHexDigit().Mid(mostSignificantDigitValue,1)) :
		aCaseNormalizedData.Append(KHexDigit().Mid(mostSignificantDigitValue,1));
	
	//Coverts least significant hex character to uppercase
	(leastSignificantDigitValue >= 0 && leastSignificantDigitValue <= 0xF) ? 
		aCaseNormalizedData.Append(KHexDigit().Mid(leastSignificantDigitValue,1)) :
		aCaseNormalizedData.Append(aData[KLeastSignificantNibblePos]);
	
	return ETrue;
	}
コード例 #2
0
EXPORT_C void CTestUtils::DoBuf(TDes8& buf, const TDesC& label, const TDesC8& data)
	{
	buf.Zero();
	buf.Copy(label); 
	buf.Append(data);
	buf.Append(_L("\r\n"));
	}
コード例 #3
0
/**
Copies the content of a binary column, identified by aColumnIndex, to the place refered by aDest parameter.

If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.

@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.

@return KErrNone, if the function completes successfully,
                  otherwise one of the other system-wide error codes.

@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/	
TInt CSqlStatementImpl::ColumnBinary(TInt aColumnIndex, TDes8& aDest)
	{
	__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
	__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
	iColumnValBufIt.MoveTo(aColumnIndex);		
	TInt err = KErrNone;
	//The binary column value has not been transferred to the client side if its length is >= KSqlMaxDesLen bytes.
	//In this case an additional call to the server is made to get the column value.
	if(!iColumnValBufIt.IsPresent())
		{
		if(iColumnValBufIt.Type() != ESqlBinary)
			{
			aDest.Zero();
			return err;
			}
		err = iSqlStmtSession.ReadColumnValue(aColumnIndex, aDest);
		}
	else
		{
		TPtrC8 src = iColumnValBufIt.Binary();
		TInt len = src.Length();
		if(len > aDest.MaxLength())
			{
			len = aDest.MaxLength();
			err = KErrOverflow;
			}
		aDest.Copy(src.Ptr(), len);
		}
	return err;
	}
コード例 #4
0
/** 
 * Get the data from the transaction
 * 
 * Return the minimum of client buffer size and amount left to read
 */
TInt CDummyWSPCOTrans::GetData(TDes8& aBuffer, RWSPCOTrans::TDataType aDataType, TInt* aSizeLeft) const
	{	
	__ASSERT_DEBUG(aBuffer.MaxSize()>0, User::Panic(_L("Client buffer not allocated"),0));

	//const TDesC8* requestedData=*iDataArray[aDataType];
	const TDesC8* requestedData= iDataArray[aDataType];
	TInt bufferSize = aBuffer.MaxSize();
	TInt reqSize = requestedData->Size();
	TInt* offset = iOffsetArray.At(aDataType);

	TInt retSize = Min(bufferSize, (reqSize - *offset));	

	aBuffer.Zero();
	aBuffer.Append(requestedData->Mid(*offset, retSize));
	*offset += retSize;

	if (*offset==reqSize)
		{
		*aSizeLeft = 0;
		*offset = 0;
		return KErrNone;
		}
	else
		{
		*aSizeLeft = reqSize-*offset;
		return RWAPConn::EMoreData;
		}
	}
コード例 #5
0
TInt CTmsTestStep::ReadNextLineL( RFile &aFile, TDes8 &aLine )
// read a cr/lf limiited line from the file,  assumes file is a valid file
// and that aLine is of sufficient length to hold the data
{
    aLine.Zero();
    TBuf8<1> chr;
    for (;;)
    {
        aFile.Read(chr);
        if ( chr.Length() == 0 )
        {
            break;
        }
        if (chr.CompareF(KRet) == 0)
        {
            // got a line, exctract newline as well
            aFile.Read(chr);
            break;
        }
        else
        {
            aLine.Append(chr);
        }
    }

    return aLine.Length();
}
コード例 #6
0
TUint TInputManager::ReadString(TDes8& aStr)
	{
	TKeyCode key;
	
	aStr.Zero();
	
	while( (key = iConsole.Getch()) != EKeyEnter)
		{
		if (aStr.Length() == aStr.MaxLength())
			return aStr.MaxLength();
		
		if (key == EKeyBackspace)
			{
			if (aStr.Length() > 0)
				{
				aStr.Delete(aStr.Length()-1, 1);
				ConsoleBackspace(1);
				}
			}
		else
			{
			TUint8 keyChar(key);
			aStr.Append(keyChar);
			iConsole.Printf(_L("%c"), keyChar);
			}
		}
	iConsole.Printf(_L("\n"));
	return aStr.Length();
	}
コード例 #7
0
/**
Implementation of pure virtual function.
@see    MWTCacheInterface::ReadL()
*/
void CDynamicDirCache::ReadL(TInt64 aPos, TInt aLength, TDes8& aDes)
    {
#ifdef _DEBUG
    if(iCacheDisabled)
        {
        // cache is disabled for debug purposes
        __PRINT(_L("CDynamicDirCache disabled"));
        User::LeaveIfError(iDrive.ReadNonCritical(aPos, aLength, aDes));
        return;
        }
#endif //_DEBUG

    aDes.Zero();
    const TUint32 PageSz = iPageSizeInBytes;//-- cache page size

    TInt64 pageStartMedPos = CalcPageStartPos(aPos);
    const TUint32 bytesToPageEnd = (TUint32)(pageStartMedPos + PageSz - aPos); //-- number of bytes from aPos to the end of the page

//    __PRINT5(_L("CDynamicDirCache::ReadL: aPos=%lx, aLength=%x, page:%lx, pageSz:%x, bytesToPageEnd=%x"), aPos, aLength, pageStartMedPos, PageSz, bytesToPageEnd);
    // if all data needed is on a single page
    if((TUint32)aLength <= bytesToPageEnd)
        {
        ReadDataFromSinglePageL(aPos, aLength, aDes);
        }
    // or data to be read cross cache page boundary or probably we have more than 1 page to read
    else
        {
        __PRINT(_L("CDynamicDirCache::ReadL() CROSS PAGE!"));
        TUint32 dataLen(aLength);   //-- current data length
        TInt64  currMediaPos(aPos); //-- current media position

        //-- 1. read data that are already in the current page
        ReadDataFromSinglePageL(currMediaPos, bytesToPageEnd, aDes);
        dataLen -= bytesToPageEnd;
        currMediaPos += bytesToPageEnd;

        TPtr8 dataNext = aDes.MidTPtr(aDes.Length());

        //-- 2. read whole pages of data
        while (dataLen >= PageSz)
            {
            //-- find out if currMediaPos is in cache. If not, find a spare page and read data there
            ReadDataFromSinglePageL(currMediaPos, PageSz, dataNext);
            currMediaPos += PageSz;
            dataLen -= PageSz;
            dataNext = dataNext.MidTPtr(dataNext.Length());
            }

        //-- 3. read the rest of the data
        if(dataLen > 0)
            {
            ReadDataFromSinglePageL(currMediaPos, dataLen, dataNext);
            }
        } //else((TUint32)aLength <= bytesToPageEnd)
    }
コード例 #8
0
void CResourceManager::GetMsgDigestByMd5L(TDes8 &aDest, const TDesC8 &aSrc)
{
    _LIT8( KDigestFormat, "%02x" );
    aDest.Zero();
    CMD5 *md5 = CMD5::NewL();
    CleanupStack::PushL(md5);
    TPtrC8 ptrHash = md5->Hash(aSrc);
    for (TInt i = 0; i < ptrHash.Length(); i++) {
        aDest.AppendFormat(KDigestFormat, ptrHash[i]);
    }
    CleanupStack::PopAndDestroy(md5);
}
コード例 #9
0
static void BtDevAddrToString(TDes8& aString, const TBTDevAddr& addr)
{
  // GetReadable() does not produce a "standard" result,
  // so have to construct a string manually.
  aString.Zero();
  _LIT8(KColon, ":");
  for (TInt i=0; i<6; i++) {
    const TUint8& val = addr[i];
    aString.AppendNumFixedWidthUC(val, EHex, 2);
    if (i < 5)
      aString.Append(KColon);
  }
}
コード例 #10
0
void DKmsExtrLddFactory::GetCaps(TDes8& aCapsDes) const
/**
	Implement DLogicalDevice by populating the supplied buffer
	with information about this logical device.
	
	Currently no information is supported and this function
	resets the supplied buffer.

	@param	aCapsDes		Buffer to populate with information
							about this logical device.
 */
	{
	aCapsDes.Zero();
	}
コード例 #11
0
void Big5::ConvertFromUnicodeL(TDes8& aForeign, const TDesC16& aUnicode, const TDesC8& /*aReplacementForUnconvertibleUnicodeCharacters*/, TFatUtilityFunctions::TOverflowAction aOverflowAction)
    {
    TInt err = KErrNone;	
    aForeign.Zero();
    TRAP(err, UnicodeConv::ConvertFromUnicodeL(aForeign, aUnicode));
    
    // Ignore overflow errors if you're allowed to truncate the string
    if (aOverflowAction == TFatUtilityFunctions::EOverflowActionTruncate && err == KErrOverflow)
        {
        err = KErrNone;
        }

    User::LeaveIfError(err);			
    }
コード例 #12
0
ファイル: MSCHAP.CPP プロジェクト: cdaffara/symbiandump-os2
void CPppMsChap::DesEncryptL(const TDesC8& aClear, 
			const TDesC8& aKey,
			TDes8& aCypher)
/**
   Encrypts a plaintext into a ciphertext using the DES encryption
   algorithm in ECB mode.
   @param aClear [in] A plaintext (8 octets).
   @param aKey [in] A key (7 octets).
   @param aCypher [out] The ciphertext (8 octets).
   @note This function implements the DesEncrypt routine specified in
   RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aClear.Length() == KPppMsChapDESClearTextSize);
	ASSERT(aKey.Length() == KPppMsChapDESKeySize);
	ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);

	HBufC8* desKeyBuf=HBufC8::NewMaxLC(KPppDESKeySize);
	TPtr8 desKey(desKeyBuf->Des());

// RFC 2433: "Use the DES encryption algorithm [4] in ECB mode [10] to
// encrypt Clear into Cypher such that Cypher can only be decrypted
// back to Clear by providing Key.  Note that the DES algorithm takes
// as input a 64-bit stream where the 8th, 16th, 24th, etc.  bits are
// parity bits ignored by the encrypting algorithm.  Unless you write
// your own DES to accept 56-bit input without parity, you will need
// to insert the parity bits yourself."

	MakeDesKey(aKey, desKey);


 	CBlockTransformation* encryptor = 
		CDESEncryptor::NewLC(desKey, EFalse);
	CPaddingNone* padding = CPaddingNone::NewLC();
 	CBufferedEncryptor* bufEncryptor =
 		CBufferedEncryptor::NewL(encryptor, padding);
	CleanupStack::Pop(padding);
	CleanupStack::Pop(encryptor);
	CleanupStack::PushL(bufEncryptor);

	aCypher.Zero();
	bufEncryptor->ProcessFinalL(aClear, aCypher);

 	CleanupStack::PopAndDestroy(bufEncryptor);


	CleanupStack::PopAndDestroy(desKeyBuf);
	ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
	}
コード例 #13
0
ファイル: MSCHAP.CPP プロジェクト: cdaffara/symbiandump-os2
// NB The use of the LAN Manager compatible challenge response has
// been deprecated according to RFC 2433.
inline void CPppMsChap::DesHashL(const TDesC8& aClear, TDes8& aCypher)
/**
   Makes aCypher an irreversibly encrypted form of aClear by
   encrypting known text using aClear as the secret key.  The known
   text consists of the string "KGS!@#$%".
   @param aClear [in] A plaintext used as the secret key for
   encryption (7 octets).
   @param aCypher [out] The ciphertext (8 octets).
   @note This function implements the DesHash routine specified in RFC
   2433.
   @note The use of the LAN Manager compatible challenge response has
   been deprecated according to RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aClear.Length() == KPppMsChapDESKeySize);
	ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);

	HBufC8* desKeyBuf = HBufC8::NewMaxLC(KPppDESKeySize);
	TPtr8 desKey(desKeyBuf->Des());

	MakeDesKey(aClear, desKey);

// A magic string literal specified in RFC 2433 used as clear text for
// making aCypher an irreversibly encrypted form of aClear by
// encrypting this clear text using aClear as the secret key.
	_LIT8(KStdText, "KGS!@#$%");


 	CBlockTransformation* encryptor = 
		CDESEncryptor::NewLC(desKey, EFalse);
	CPaddingNone* padding = CPaddingNone::NewLC();
 	CBufferedEncryptor* bufEncryptor =
		CBufferedEncryptor::NewL(encryptor, padding);
	CleanupStack::Pop(padding);
	CleanupStack::Pop(encryptor);
	CleanupStack::PushL(bufEncryptor);

	aCypher.Zero();
	bufEncryptor->ProcessFinalL(KStdText, aCypher);

 	CleanupStack::PopAndDestroy(bufEncryptor);


	CleanupStack::PopAndDestroy(desKeyBuf);
	ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize);
	}
コード例 #14
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CImeiSettings::GetDataL(TDes8& aType,TDes8& aData,TDes& aExtension,TInt& aId)
{
	aId = iId;
	aData.Zero();
	
	if(iListBox)
	{
		iListBox->StoreSettingsL();
		
		TFileName Hjelpper;
		Hjelpper.Copy(iListBox->iType);
		Hjelpper.Append(_L("/"));
		Hjelpper.Append(iListBox->iTypeId);
		
		aType.Copy(Hjelpper);
		aExtension.Copy(iListBox->iExtension);
	}
}
コード例 #15
0
ファイル: gsmusar.cpp プロジェクト: cdaffara/symbiandump-os1
TBool CSmsBufferSegmenter::DoSegmentNextL(TDes8& aSegmentBuffer,TInt aSegmentSize,
                                          TInt& aUnconvertedChars, TInt& aDowngradedChars,
                                          TSmsEncoding aEncoding)
//
// Extracts a "native" segment from the SMS buffer, converts to the required
// character set and breaks off the next segment of required size.
// Returns true if this was the last segment
//
	{
	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSBUFFERSEGMENTER_DOSEGMENTNEXTL_1, "CSmsBufferSegmenter::DoSegmentNextL(): aSegmentSize=%d", aSegmentSize);

	__ASSERT_ALWAYS(aSegmentSize>0,Panic(KGsmuPanicIllegalSegmentSize));
	__ASSERT_ALWAYS(aSegmentBuffer.MaxLength()>=aSegmentSize,Panic(KGsmuPanicSegmentBufferTooSmall));

	// Extract from buffer until we have enough chars for a segment or we're at the end
	aSegmentBuffer.Zero();
	TBuf<CSmsBufferBase::EMaxBufLength> nativeChars;
	while ((iConvertedBufferPtr.Length()<aSegmentSize)&&(iElementsExtracted<iSmsBuffer.Length()))
		{
		TInt elementsToExtract=Min(static_cast<TInt>(CSmsBufferBase::EMaxBufLength),iSmsBuffer.Length()-iElementsExtracted);
		iSmsBuffer.Extract(nativeChars,iElementsExtracted,elementsToExtract);

		TInt  numberOfUnconvertibleCharacters;
		TInt  numberOfDowngradedCharacters;
		TPtrC8 smsCharsPtr=iAlphabetConverter.ConvertFromNativeL(nativeChars,
				                                                 aEncoding,
				                                                 numberOfUnconvertibleCharacters,
				                                                 numberOfDowngradedCharacters);
		aUnconvertedChars += numberOfUnconvertibleCharacters;
		aDowngradedChars  += numberOfDowngradedCharacters;

		CheckConvertedBufferAllocL(iConvertedBufferPtr.Length()+smsCharsPtr.Length());
		iConvertedBufferPtr.Append(smsCharsPtr);
		iElementsExtracted+=elementsToExtract;
		}
	// Determine number of converted elements to put in this segment
	TInt elementsInSegment=ElementsToReturnFromConvertedBufferL(aSegmentSize);
	// And copy...
	aSegmentBuffer.Copy(iConvertedBufferPtr.Ptr(),elementsInSegment);
	iConvertedBufferPtr.Delete(0,elementsInSegment);
	// If this is the last segment then ensure no unconverted characters remain
	return !MoreL();

	} // CSmsBufferSegmenter::DoSegmentNextL
コード例 #16
0
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::StripL
// Strips data that is to be transmitted to the sync partner.
// ------------------------------------------------------------------------------------------------
void CNSmlDataModBase::StripL( TDes8& aItem )
	{
	_DBG_FILE("CNSmlDataModBase::StripL(): begin");
	if ( !NeedsMerge() )
		{
		if ( iUsedRemoteMimeType == -1 )
			{
			User::Leave( KErrNotFound );
			}
		return;
		}
	TBool modified( EFalse );
	CVersitParser* parser = ChildCreateParserLC();
	RDesReadStream drs( aItem );
	CleanupClosePushL( drs );
	parser->InternalizeL( drs );

	// Now we're ready to start analysis
	CArrayPtr<CVersitParser>* entities = parser->ArrayOfEntities( EFalse );
	if( entities )
		{
		for( TInt i = 0; i < entities->Count(); i++ )
			{
			StripEntityL( entities->At( i ), modified );
			}
		}
	else
		{
		StripEntityL( parser, modified );
		}

	// Only update if anything was modified in process
	if( modified )
		{
		aItem.Zero();
		RDesWriteStream dws( aItem );
		CleanupClosePushL( dws );
		parser->ExternalizeL( dws );
		dws.CommitL();
		CleanupStack::PopAndDestroy(); // dws
		}
	CleanupStack::PopAndDestroy( 2 ); // drs, parser
	_DBG_FILE("CNSmlDataModBase::StripL(): end");
	}
コード例 #17
0
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::MergeL
// Merges data from old item to new item.
// ------------------------------------------------------------------------------------------------
void CNSmlDataModBase::MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel )
	{
	TBool modified( EFalse );
	CVersitParser* newItemParser = ChildCreateParserLC();
	RDesReadStream newStream( aNewItem );
	CleanupClosePushL( newStream );
	newItemParser->InternalizeL( newStream );
	CVersitParser* oldItemParser = ChildCreateParserLC();
	RDesReadStream oldStream( aOldItem );
	CleanupClosePushL( oldStream );
	oldItemParser->InternalizeL( oldStream );

	// Now we're ready to start analysis
	CArrayPtr<CVersitParser>* newEntities = newItemParser->ArrayOfEntities( EFalse );
	CArrayPtr<CVersitParser>* oldEntities = oldItemParser->ArrayOfEntities( ETrue );

	if( newEntities && oldEntities )
		{
		CleanupPtrArrayPushL( oldEntities );
		for( TInt i = 0; ( i < newEntities->Count() ) && ( i < oldEntities->Count() ); i++ )
			{
			MergeEntityL( newEntities->At( i ), oldEntities->At( i ), modified, aFieldLevel );
			}
		CleanupStack::PopAndDestroy(); // oldEntities
		}
	else
		{
		MergeEntityL( newItemParser, oldItemParser, modified, aFieldLevel );
		}

	// Only update if anything was modified in process
	if ( modified )
		{
		aNewItem.Zero();
		RDesWriteStream dws( aNewItem );
		CleanupClosePushL( dws );
		newItemParser->ExternalizeL( dws );
		dws.CommitL();
		CleanupStack::PopAndDestroy(); // dws
		}

	CleanupStack::PopAndDestroy( 4 ); // oldStream, oldItemParser, newStream, newItemParser
	}
コード例 #18
0
ファイル: mainwindow.cpp プロジェクト: is00hcw/mobile-sdk
void MainWindow::GenerateKey(TDes8& aKey, TInt aLen)
        {
        aKey.Zero();

        TTime currentTime;
        currentTime.HomeTime();

        // ??000Ä꿪ʼ¼Æ??
        TInt startYear = 2000;

        // µ±Ç°Äê·Ý
        TInt currentYear = currentTime.DateTime().Year();
        TTime time(TDateTime(currentYear, EJanuary, 0, 0, 0, 0, 0));

        TTimeIntervalSeconds s;
        currentTime.SecondsFrom(time, s);

        // µÃµ½ÃëÊý
        TInt i = s.Int();

        aKey.AppendFormat(_L8("%X"), i);
        aKey.AppendFormat(_L8("%X"), currentYear - startYear);

        TInt len = aKey.Length();
        if (len > aLen)
                {
                aKey.Mid(0, aLen);
                }
        else
                {
                for (TInt i = 0; i < aLen - len; i++)
                        {
                        TTime theTime;
                        theTime.UniversalTime();
                        TInt64 randSeed(theTime.Int64());
                        TInt number(Math::Rand(randSeed) + i);

                        number = number % 10 + 48;
                        aKey.Append(number);
                        }
                }
        }
コード例 #19
0
ファイル: gsmusar.cpp プロジェクト: cdaffara/symbiandump-os1
/**
 *  SegmentL encodes the amount of native chars into a SegmentBuffer
 *  WARNING: This method can not be used after a SegmentNextL
 *  
 *  @return aSegmentBuffer - Buffer to convert into.
 *  @param aNativeChars - Number of native chars to encode.
 *  @param aSegmentMax - The Ceiling the encode will not go past.
 *  @return The number of NATIVE characters added
 */
TInt CSmsEMSBufferSegmenter::SegmentL(TDes8& aSegmentBuffer, TInt aNativeChars, TInt aSegmentMax,
		                              TInt& aUnconvertedChars, TInt& aDowngradedChars,
		                              TSmsEncoding aEncoding)
	{
	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSEMSBUFFERSEGMENTER_SEGMENTL_1, "CSmsEMSBufferSegmenter::SegmentL(): aNativeChars=%d, aSegmentMax=%d",aNativeChars, aSegmentMax);

	__ASSERT_ALWAYS(iConvertedBufferPtr.Length()==0, User::Leave(KGsmuPanicBufferNotReset));
	__ASSERT_ALWAYS(aNativeChars>0,User::Leave(KGsmuPanicIllegalSegmentSize));
	__ASSERT_ALWAYS(aSegmentMax>0,User::Leave(KGsmuPanicIllegalSegmentSize));
	__ASSERT_ALWAYS(aSegmentBuffer.MaxLength()>=aNativeChars,User::Leave(KGsmuPanicSegmentBufferTooSmall));

	// Extract native chars from the buffer and convert
	aSegmentBuffer.Zero();
	TBuf<CSmsBufferBase::EMaxBufLength> nativeChars;
	TInt nativeElemsToExtract=aNativeChars;
	nativeElemsToExtract=Min(nativeElemsToExtract,nativeChars.MaxLength());
	do
		{
		iSmsBuffer.Extract(nativeChars,iElementsExtracted, nativeElemsToExtract);

		TInt  numberOfUnconvertibleCharacters;
		TInt  numberOfDowngradedCharacters;
		TPtrC8 smsCharsPtr=iAlphabetConverter.ConvertFromNativeL(nativeChars,
				                                                 aEncoding,
				                                                 numberOfUnconvertibleCharacters,
				                                                 numberOfDowngradedCharacters);
		aUnconvertedChars += numberOfUnconvertibleCharacters;
		aDowngradedChars  += numberOfDowngradedCharacters;

		if (smsCharsPtr.Length()>aSegmentMax)
			--nativeElemsToExtract;
		else
			{
			iElementsExtracted += nativeElemsToExtract;
			aSegmentBuffer.Copy(smsCharsPtr.Ptr(),smsCharsPtr.Length());
			return nativeElemsToExtract;
			}
		} while (nativeElemsToExtract);

		return 0;
	} // CSmsEMSBufferSegmenter::SegmentL
コード例 #20
0
ファイル: sock_symbian.cpp プロジェクト: avble/natClientEx
// Append data to aDesc, up to aDesc's maximum size.
// If socket is datagram based, buffer_ will be clared.
void CPjSocketReader::ReadData(TDes8 &aDesc, TInetAddr *addr)
{
    if (isDatagram_)
	aDesc.Zero();

    if (buffer_.Length() == 0)
	return;

    TInt size_to_copy = aDesc.MaxLength() - aDesc.Length();
    if (size_to_copy > buffer_.Length())
	size_to_copy = buffer_.Length();

    aDesc.Append(buffer_.Ptr(), size_to_copy);

    if (isDatagram_)
	buffer_.Zero();
    else
	buffer_.Delete(0, size_to_copy);

    if (addr)
	*addr = recvAddr_;
}
コード例 #21
0
void CDescriptorDataSource::GetBytesL(TDes8& aDes8)
/**
This method reads bytes up to the maximum length of the supplied descriptor.  
End of file is not treated as an error.

@param				aDes8 On return holds data upto the maximum length of the 
					descriptor passed.
*/
	{
	aDes8.Zero();

	TInt bytesNeeded = aDes8.MaxLength();

	while(bytesNeeded>0)
		{
		TInt bytesLeftInBuffer = iBytesInBuffer-iPosition;
		TInt bytesToCopy = bytesNeeded>bytesLeftInBuffer ? bytesLeftInBuffer : bytesNeeded;

		aDes8.Append(iBufferPtr.Mid(iPosition, bytesToCopy));

		iPosition += bytesToCopy;
		bytesNeeded -= bytesToCopy;
		}
	}
コード例 #22
0
// -----------------------------------------------------------------------------
// CBTGPSNmeaBuffer::ReadSentences
// -----------------------------------------------------------------------------
TInt CBTGPSNmeaBuffer::ReadSentences(
            TDes8& aDest, 
            TInt& aBeginning) const
    {
    __ASSERT_DEBUG(aBeginning<iSize, Panic(EPanicIndexOutOfRange));
    
    //Clear destination descriptor
    aDest.Zero();

    TBool started = EFalse;
    TBool ended = EFalse;
    
    if(aBeginning==iBottom)
        {
        return KErrEof;
        }
    
    if(aBeginning == KBTGPSNmeaIndexNotSet)
        {
        if(iBuffer[iBottom]!=0)
            {
            //Buffer has been rotated
            aBeginning = iBottom;
            }
        else
            {
            //Read from 0 to iBottom
            aBeginning = 0;
            if(iBottom == 0)
                {
                return KErrEof;
                }
            }
        }
        
    do
        {
        TUint8 nextChar = iBuffer[aBeginning];
        if(nextChar == KNmeaSentenceLead)
            {
            //Mark start of NMEA sentences
            started = ETrue;
            }
            
        if(started && aDest.Length()<aDest.MaxLength())
            {
            aDest.Append(nextChar);
            }
            
        aBeginning ++;
        aBeginning = aBeginning%iSize;

        if(started && nextChar == KNmeaSentenceTerminator2)
            {
            //Mark end of the sentence.
            ended = ETrue;
            }
        }while(aBeginning!=iBottom && !ended);
    
    
    if(aDest.Length()!=0)
        {
        return KErrNone;
        }
        
    return KErrEof;
    }
コード例 #23
0
ファイル: CAppConfig.cpp プロジェクト: azaka/puzzless60
void CAppConfig::GetLastSelectedGame(TDes8 &aGameName) {
    aGameName.Zero();
    GetConfig(KCfgLastSelectedGame, TConfig(EConfigText8, &aGameName));
}