Example #1
0
/**
 *  Parses a string of hex characters representing a number
 *  
 *  @param aInValue descriptor containing the number
 *  @param aBigEndian true if number is big endian
 *  @param aRadix Radixbase; 16, 10 etc
 *  @return TInt the parsed number
 *  @leave Panics with KPanicInvalidParseNumber error code, if not a
 *  number. Maximum width of the hex value can be 4.
 *  
 *  TODO use TLex instead
 */
TInt TWapTextMessage::ParseNumber(const TDesC8& aInValue,
                                  TBool   aBigEndian,
                                  TInt    aRadix)
    {
    OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, TWAPTEXTMESSAGE_PARSENUMBER_1, "TWapTextMessage::ParseNumber [%s]", aInValue);
    // least significant byte first
    TInt Values[4] = {0,0,0,0};
    TInt Temp = 0;
    TInt length = aInValue.Length();
    TInt i = 0;
    TInt Value = 0;

    __ASSERT_DEBUG(length<5,Panic(KPanicInvalidParseNumber));
    if( length >= 5 )
        return KErrNotFound;
    for(i=0; i<length; i++)
        {
        Temp = aInValue[i];
        if (Temp>='0' && Temp<='9')
            Temp-='0';
        else if (Temp>='A' && Temp<='Z')
            Temp = Temp - 'A'+10;
        else if (Temp>='a' && Temp<='z')
            Temp = Temp - 'a'+10;
        else
            return KErrNotFound;
        if (aBigEndian)
            Values[(length-1)-i]=Temp;
        else
            Values[i]=Temp;
        }

    // build the value
    Value=Values[0];
    TInt Base=1;
    for(i=1; i<length; i++)
        {
        Base*=aRadix;
        Value+=(Base)*Values[i];
        }

    return Value;
    } // TWapTextMessage::ParseNumber
// ---------------------------------------------------------------------------
// NetworkIdL
// Utility function to translate the 5 digit ASCII network identification 
// returned by the ME into Mobile Country Code (aCountryCode) and a Mobile 
// Network Code (aNetworkIdentity) strings. Tbe format returned by the ME is 
// XXXYY, where XXX represents the Mobile Country Code and YY represents the 
// Mobile Network Code.
// ---------------------------------------------------------------------------
static TInt NetworkIdL(const TDesC8& aCode,
					   RMobilePhone::TMobilePhoneNetworkCountryCode& aCountryCode, 
					   RMobilePhone::TMobilePhoneNetworkIdentity& aNetworkIdentity)
	{
	if (aCode.Length()!=5)
		{
		return KErrGeneral;
		}
	
	aCountryCode.SetLength(3);
	aCountryCode[0] = aCode[0];
	aCountryCode[1] = aCode[1];
	aCountryCode[2] = aCode[2];

	aNetworkIdentity.SetLength(2);
	aNetworkIdentity[0] = aCode[3];
	aNetworkIdentity[1] = aCode[4];
	return KErrNone;
	}
Example #3
0
// ------------------------------------------------------------------------------------------------
// TPtrC8 Cdmatest::RemoveLastURISeg(const TDesC8& aURI)
// returns parent uri, i.e. removes last uri segment
// ------------------------------------------------------------------------------------------------
TPtrC8 Cdmatest::RemoveLastURISeg( const TDesC8& aURI )
	{
	TInt i;
	for ( i = aURI.Length() - 1; i >= 0 ; i-- )
		{
		if( aURI[i] == '/' )
			{
			break;
			}
		}
	if ( i > -1 )
		{
		return aURI.Left( i );	
		}
	else
		{
		return KNullDesC8();
		}
	}	
Example #4
0
TBool CPKCS12Handler::VerifyType(const TDesC8& aData) const
    {
    ASSERT(iPkcsHandler);

    LOG_("-> CPKCS12Handler::VerifyType()");

    TBool isPKCS12(EFalse);

    // Need to check the data length before IsPKCS12Data call,
    // otherwise an assert (instead of a more suitable) 
    // might occur
    if (aData.Length() >= KPKCS12DataMinLength) 
        {
        isPKCS12 = iPkcsHandler->IsPKCS12Data(aData);
        }

    LOG_1("<- CPKCS12Handler::VerifyType() RET: %d", isPKCS12);
    return isPKCS12;
    }
// ------------------------------------------------------------------------------------------------
// TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
// Returns only the last uri segemnt
// ------------------------------------------------------------------------------------------------
TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
	{
	TInt i;
	for(i=aURI.Length()-1;i>=0;i--)
		{
		if(aURI[i]==KNSmlDMUriSeparator)
			{
			break;
			}
		}
	if(i==0)
		{
		return aURI;
		}
	else
		{
		return aURI.Mid(i+1);
		}
	}
Example #6
0
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 CSymbianUnitTestResult::AddFailureL(
    const TDesC8& aFailureText,
    TInt aAllocFailureRate )
    {
    CSymbianUnitTestFailure* failure = NULL;
    if ( aAllocFailureRate > 0 )
        {
        const TInt KLength = 
            aFailureText.Length() + 
            KSymbianUnitTestAllocFailureRateFormat().Length() + 
            KMax64BitUintLengthAsDescriptor;
        HBufC8* failureMsg = HBufC8::NewLC( KLength );
        failureMsg->Des() = aFailureText;
        failureMsg->Des().AppendFormat(
            KSymbianUnitTestAllocFailureRateFormat, aAllocFailureRate );
        failure = CSymbianUnitTestFailure::NewL( 
            *iCurrentTestName, *failureMsg, KErrNotFound, KNullDesC8 );
        CleanupStack::PopAndDestroy( failureMsg );
        CleanupStack::PushL( failure );
        }
    else
        {
        failure = CSymbianUnitTestFailure::NewLC( 
            *iCurrentTestName, aFailureText, KErrNotFound, KNullDesC8 );
        }
        
    TBuf8<KMaxLength> strLine;
    strLine.Format( KSymbianUnitTestFailed, &aFailureText );
    while(strLine.Length() > 120) 
        {
        TBuf8<KMaxLength> line = strLine.MidTPtr( 0, 120 );
        line.Append( '-' );
        SUT_LOG_FORMAT(_L8("%S"), &line );
        line = strLine.Mid( 120 );
        strLine = line;
        }
    SUT_LOG_FORMAT(_L8("%S"), &strLine );
    //SUT_LOG_FORMAT(KSymbianUnitTestFailed, &aFailureText);
    iCurrentResult = EFalse;
    iFailures.AppendL( failure );
    CleanupStack::Pop( failure ); 
    }
Example #8
0
/**
Protected second phase constructor.

The view is sorted according to the sort order and view preferences specified, 
using a low priority idle time active object. The specified view observer 
is notified when the view is sorted and ready for use.

Called by NewL().

@param aObserver An observer that receives notifications when this view is 
ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady 
event when the view is ready. Any attempt to use the view before this notification will Leave with KErrNotReady.
@param aSortOrder Specifies the fields to use to sort the items in the view. 
@param aUseNamedPlugin A flag indicates whether the aSortPluginName parameter is valid.
@param aSortPluginName Specifies a plug-in that will be used to compare view contacts
when the the view is sorted. This name is used by ECOM to select the plugin, and is matched
with the "default_data" of all ECOM plugins that support the required interface.
*/
void CContactLocalView::ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder, TBool aUseNamedPlugin, const TDesC8& aSortPluginName)
	{
	CContactViewBase::ConstructL();
	if(iFactory == NULL)
		{
		iFactory = const_cast<CContactDatabase&>(iDb).FactoryL();
		}
    
	OpenL(aObserver);
	if (aUseNamedPlugin)
		{
		// find and load Sort plug-in
		if (aSortPluginName.Length())
			{
			TUid sortPluginUid = FindSortPluginImplL (aSortPluginName);
			LoadViewSortPluginL(sortPluginUid, iViewPreferences);
			}
		}
	else
		{
		// find and load default Sort plug-in (if any)
		TUid sortPluginUid = FindDefaultViewSortPluginImplL();
		if (sortPluginUid != KNullUid)
			{
			LoadViewSortPluginL(sortPluginUid, iViewPreferences);
			}
		}
	
	//Initialise sort order and textdef.
	SetSortOrderL(aSortOrder);
	
	//Create view contact manager to handle sorting
    iViewCntMgr = CViewContactManager::NewL(*this, *iFactory, *iTextDef, iViewPreferences, SortPluginImpl());
	
	if (&iDb != NULL)
		{
        const_cast<CContactDatabase&>(iDb).AddObserverL(*this);
		}
	
	//Doing the sort.
	SortL();
	}
Example #9
0
// -----------------------------------------------------------------------------
// CGbaServer::WriteOptionL()
// -----------------------------------------------------------------------------
//
void CGbaServer::WriteOptionL(const TUid& aOptionID, const TDesC8& aValue) const
{
    GBA_TRACE_DEBUG(("WriteOptionL"));
    TInt pushCount = 0;
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL( fs );
    pushCount++;
    TFindFile folder( fs );

    TFileName fullPath;
    MakePrivateFilenameL(fs, KGbaIniFileName, fullPath);
    EnsurePathL(fs, fullPath );

    GBA_TRACE_DEBUG(fullPath);

    TInt err = folder.FindByDir( fullPath, KNullDesC);

    if (  err == KErrNotFound || err == KErrNone )
    {
        CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC( fs, fullPath, KGbaIniUid );
        pushCount++;

        RDictionaryWriteStream wrs;
        CleanupClosePushL( wrs );
        wrs.AssignL(*pStore,aOptionID);

        wrs.WriteInt32L(aValue.Length());
        wrs.WriteL(aValue);
        wrs.CommitL();

        pStore->CommitL();
        CleanupStack::PopAndDestroy( &wrs );
        CleanupStack::PopAndDestroy( pushCount );
        GBA_TRACE_DEBUG(aValue);
    }
    else
    {
        CleanupStack::PopAndDestroy( pushCount );
        User::LeaveIfError( err );
    }
}
// -----------------------------------------------------------------------------
// RDRMRightsClient::AddRecord
// Add a new entry to the rights database.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RDRMRightsClient::AddRecord( const TDesC8& aCEK, // Content encryption key
                                  // The rights object which is to be added
                                  const CDRMPermission& aRightsObject,
                                  const TDesC8& aCID, // Content-ID
                                  TDRMUniqueID& aID ) // Unique ID, out-parameter
    {
    DRMLOG( _L( "RDRMRightsClient::AddRecord" ) );
    TInt error = KErrArgument;

    // Check the parameters.
    if ( aCEK.Length() )
        {

        HBufC8* rightsData = NULL;
        TRAP( error, rightsData = aRightsObject.ExportL() );
        TInt size = aRightsObject.Size();

        if ( rightsData && size > 0 )
            {
            // For C/S communications.
            TPtr8 rightsObject( NULL, 0 );
            TPtr8 uid( reinterpret_cast< TUint8* >( &aID ),
                       0,
                       sizeof( TDRMUniqueID ) );

            rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ),
                              size,
                              size );


            // Send the message.
            error = SendReceive( DRMEngine::EAddRecord,
                             TIpcArgs( &aCID, &rightsObject, &aCEK, &uid ) );

            delete rightsData;
            rightsData = NULL;
            }
        }

    DRMLOG2( _L( "RDRMRightsClient::AddRecord: %d" ), error );
    return error;
    }
Example #11
0
// buf to array
EXPORT_C TInt CRpsMsg::InternalizeL(const TDesC8& aBufIn)
	{
	TInt length(aBufIn.Length());
	if(length <= 0)
		{
		return KErrCorrupt;
		}
		
	if(iMsgDataArray != NULL)
		iMsgDataArray->Reset();
	
	TBuf8<KMaxElementSize> buf;
	
	// Dismantle msg into data elements first 
	TBool stop(EFalse);
	while (stop == EFalse)
		{
		TPtrC8 ptr = aBufIn.Right(length);
		
		TInt offset = ptr.Find(KComma);
		
		if(offset == KErrNotFound)
			{
			if(length > 0)
				{
				buf.Copy(ptr);
				iMsgDataArray->AppendL(buf);
				break;
				}	
			}

		buf.Copy(ptr.Left(offset));
		iMsgDataArray->AppendL(buf);
		length -= ++offset;
		if(length <= 0)
			{
			stop = ETrue;
			}
		}
	
	return KErrNone;
	}
void CAknGlobalListQuerySubject::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, 
    const RMessagePtr2& aMessage)
    {
    if (iPending)
        {
        aMessage.Complete(KErrInUse);
        return;
        }

    RDesReadStream readStream(aBuffer);
    if (aBuffer.Length() < KCharsInTInt || readStream.ReadInt32L() != KAKNNOTIFIERSIGNATURE)
        {
        User::Leave(KErrArgument);
        }

    iMessage = aMessage;
    iSelectFirst = readStream.ReadInt16L();
    TInt count = readStream.ReadInt16L();

    // Create array
    delete iArray;
    iArray = 0;
    iArray = new (ELeave) CDesCArrayFlat(KArrayGranularity);
    
    TBuf<KListQueryItemLength> arrayItem;

    for (TInt ii = 0; ii < count; ii++)
        {
        readStream >> arrayItem;
        iArray->AppendL(arrayItem);
        }
        
    TInt headingLength = readStream.ReadInt16L();
    delete iHeading;
    iHeading = 0;
    
    if (headingLength != KErrNotFound)
        {
        iHeading = HBufC::NewL(headingLength);
        TPtr ptr = iHeading->Des();
        readStream >> ptr;
        }
Example #13
0
void CSocketsWriter::IssueWriteL(const TDesC8& aData)
    {
    if (((iWriteStatus != EWaiting) && (iWriteStatus != ESending)) || (!fileBuffer))
	{   
		iAppUi->LogInfo(_L("Write Exit"));
		if (!fileBuffer)
			iAppUi->LogInfo(_L("NULL File pointer"));
		User::Leave(KErrNotReady);
	}
    //iGlobalEngine->LogInfo(_L("fileBuffer->Write:%d"),aData.Length());
    TRAPD(iErr, fileBuffer->Write(m_iSizeFile+1, aData));
	if (iErr==KErrNone){
	    m_iSizeFile+=aData.Length();
	    if (!IsActive())
	        SendNextPacket();
	    
		}
	else
		iAppUi->LogInfo(_L("ERROR fileBuffer->Write"));
    }
// --------------------------------------------------------------------------
// CNSmlDmAOAdapter::LastURISeg
// Returns the last uri segemnt of a uri. 
// --------------------------------------------------------------------------
TPtrC8 CNSmlDmAOAdapter::LastURISeg( const TDesC8& aURI ) const
    {
    TInt i;
    for ( i=aURI.Length()-1; i >= 0; i-- )
        {
        if ( aURI[i]=='/' )
            {
            break;
            }
        }
        
    if ( i==0 )
        {
        return aURI;
        }
    else
        {
        return aURI.Mid( i + 1 );
        }
    }
// -----------------------------------------------------------------------------
// RDRMRightsClient::DeleteDbEntry
// Delete a single rights object identified by given parameters.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID,
                                               const TDRMUniqueID& aUniqueID )
    {
    DRMLOG( _L( "RDRMRightsClient::DeleteDbEntry with CID & UID" ) );

    if ( aContentID.Length() )
        {
        // Something to do.
        // Put aUniqueID inside a descriptor.
        // Works even if its typedef is changed.
        TPtrC8 uid( reinterpret_cast< TUint8* >(
                        const_cast< TDRMUniqueID* >( &aUniqueID ) ),
                    sizeof( TDRMUniqueID ) );

        return SendReceive( DRMEngine::EDeleteRO,
                            TIpcArgs( &uid, NULL, NULL, &aContentID ) );
        }

    return KErrArgument;
    }
Example #16
0
/** @prototype */
EXPORT_C TInt CFsPlugin::ClientWrite(TFsPluginRequest& aRequest, const TDesC8& aDes, TInt aOffset)
	{
	CFsMessageRequest& msgRequest = * (CFsMessageRequest*) aRequest.Request();
	TMsgOperation& currentOperation = msgRequest.CurrentOperation();
	
	TInt r = KErrNone;
	if (currentOperation.iClientRequest)
		{
		r = msgRequest.Write(0, aDes, aOffset);
		}
	else
		{
		TInt len = aDes.Length();
		if (len > (currentOperation.iReadWriteArgs.iTotalLength - aOffset))
			return KErrArgument;
		memcpy(((TUint8*) currentOperation.iReadWriteArgs.iData) + aOffset, aDes.Ptr(), len);
		currentOperation.iReadWriteArgs.iOffset = aOffset + len;
		}
	return r;
	}
Example #17
0
/**
	Checks whether valid parameter names and values exist in the 
	whole path of the tel-uri.
								
	@param		aName	The descriptor for parameter name to be checked as per RFC3966.
	@param		aValue	The descriptor for value to be checked as per RFC3966.
	@return		A boolean value of ETrue if uri contains valid parameters and values,
				EFalse if it does not.
 */
TBool TValidatorTel::IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const
	{
	//Validation of the Name
	if (!aName.Length() || !IsValidCharacters(aName, KCharSetParamAll) )
		{
		return EFalse;	
		}
	//Validation of the Value based on ISDN, EXTN, Phone-context or any.
	if( ( KIsdnSubAddress().CompareF(aName) == 0 && !IsValidCharacters(aValue, KCharSetParamAll, ETrue) ) ||
		( KExtension().CompareF(aName) == 0 && !IsValidCharacters(aValue, KCharSetNumber) ) ||
		( KContext().CompareF(aName) == 0 && !IsValidCharacters(aValue, KCharSetParamAll) ) ||
		( KIsdnSubAddress().CompareF(aName) != 0 && 
		KExtension().CompareF(aName) != 0	&&
		KContext().CompareF(aName) != 0 &&
		!IsValidCharacters(aValue, KCharSetParamAll, ETrue) ) )
		{
		return EFalse;	
		}
	return ETrue;
	}
Example #18
0
TPtrC8 Cdmatest::RemoveLastSeg(const TDesC8& aURI)
	{
	TInt i;
	for(i=aURI.Length()-1;i>=0;i--)
		{
		if(aURI[i]==KNSmlDMUriSeparator)
			{
			break;
			}
		}

	if(i>0)
		{
		return aURI.Left(i);
		}
	else
		{
		return KNullDesC8();
		}
	}
// ---------------------------------------------------------------------------
// CNATFWTraversalAdapter::DeleteL
//
// ---------------------------------------------------------------------------
//
void CNATFWTraversalAdapter::DeleteL( const TDesC8& aSaveData )
    {
    DBG_PRINT( "CNATFWTraversalAdapter::DeleteL - begin" );
    // Central Repository for NAT-FW Traversal settings.
    CRepository* rep = CRepository::NewLC( KCRUidUNSAFProtocols );
    TInt step( 0 );

    // Delete all keys that are stored.
    while ( step < aSaveData.Length() )
        {
        TUint32 key = DesToTUint( aSaveData.Mid( step, KMaxCharsInTUint32 ) );
        key &= KUNSAFProtocolsTableMask;
        TUint32 errorKey;
        rep->Delete( key, KUNSAFProtocolsTableMask, errorKey );
        step += KMaxCharsInTUint32;
        }
    
    CleanupStack::PopAndDestroy( rep );
    DBG_PRINT( "CNATFWTraversalAdapter::DeleteL - end" );
    }
EXPORT_C TInt CSenWsSecurityHeader::TimestampL(const TDesC8& aCreated, HBufC8*& aToken)
    {
    TPtrC8 nsPrefix = KSecurityUtilityXmlNsPrefix();
    aToken = HBufC8::NewLC(KTimestampFormatString8().Length()
                            + aCreated.Length() 
                            + nsPrefix.Length()*5
                            + KSecurityUtilityXmlNs().Length());

    TPtr8 ptr = aToken->Des();
    ptr.Format(KTimestampFormatString8, 
               &nsPrefix, 
               &nsPrefix, 
               &KSecurityUtilityXmlNs(),
               &nsPrefix, 
               &aCreated,
               &nsPrefix, 
               &nsPrefix);
    CleanupStack::Pop(aToken);
    return KErrNone;
    }
Example #21
0
TPtrC8 Cdmatest::LastURISeg( const TDesC8& aURI )
	{
	TInt i;
	for( i = aURI.Length() - 1; i >= 0; i-- ) 
		{
		if( aURI[i] == '/' )
			{
			break;
			}
		}

	if( i == 0 )
		{
		return aURI;
		}
	else
		{
		return aURI.Mid( i+1 );
		}
	}
Example #22
0
// ---------------------------------------------------------------------------
// CFotaDB::StateToRowL
// Converts state object to database row (into view object)
// ---------------------------------------------------------------------------
void CFotaDB::StateToRowL(const TPackageState& aPkg, const TDesC8& aPkgURL,
        RDbView& aView)
    {
    HBufC* pkgname = HBufC::NewLC(aPkg.iPkgName.Length());
    HBufC* version = HBufC::NewLC(aPkg.iPkgVersion.Length());

    pkgname->Des().Copy(aPkg.iPkgName);
    version->Des().Copy(aPkg.iPkgVersion);

    aView.SetColL(iColSet->ColNo(KColPkgId), aPkg.iPkgId);
    aView.SetColL(iColSet->ColNo(KColResult), aPkg.iResult);
    aView.SetColL(iColSet->ColNo(KColState), aPkg.iState);
    aView.SetColL(iColSet->ColNo(KColProfileId), aPkg.iProfileId);
    aView.SetColL(iColSet->ColNo(KColPkgName), *pkgname);
    aView.SetColL(iColSet->ColNo(KColVersion), *version);
    aView.SetColL(iColSet->ColNo(KColSmlTryCount), aPkg.iSmlTryCount);
    aView.SetColL(iColSet->ColNo(KColSessionType), aPkg.iSessionType);
    aView.SetColL(iColSet->ColNo(KColIapId), aPkg.iIapId);
    aView.SetColL(iColSet->ColNo(KColPkgSize), aPkg.iPkgSize);
    aView.SetColL(iColSet->ColNo(KColUpdateLtr), aPkg.iUpdateLtr);

    RDbColWriteStream wstream;
    CleanupClosePushL(wstream);
    wstream.OpenL(aView, iColSet->ColNo(KColPkgUrl));
    // Cannot write 8 bit descriptors to databae
    HBufC* buf = HBufC::NewLC(aPkgURL.Length());
    buf->Des().Copy(aPkgURL);
    wstream.WriteL(buf->Des());

    FLOG(_L("CFotaDB::StateToRowL  id:%d result:%d state:%d profileid:%d \
    		name:%d chars version: %d chars url: %d chars sessiontype:%d iapid:%d pkgsize:%d updateltr = %d"),
            aPkg.iPkgId, aPkg.iResult, aPkg.iState, aPkg.iProfileId,
            pkgname->Des().Length(), version->Des().Length(),
            buf->Des().Length(), aPkg.iSessionType, aPkg.iIapId,
            aPkg.iPkgSize, aPkg.iUpdateLtr);

    CleanupStack::PopAndDestroy(buf);
    CleanupStack::PopAndDestroy(&wstream);
    CleanupStack::PopAndDestroy(version);
    CleanupStack::PopAndDestroy(pkgname);
    }
Example #23
0
inline void CPppMsChap::MakeDesKey(const TDesC8& aMsChapKey, 
				TDes8& aDesKey)
/**
   Creates a DES key by inserting the parity bits.  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.
   @param aMsChapKey [in] A key used by MS-CHAP for DES encryption. (7
   octets).
   @param aDesKey [out] A DES key (8 octets).
   @internalComponent
*/
	{
	ASSERT(aMsChapKey.Length() == KPppMsChapDESKeySize);
	ASSERT(aDesKey.Length() == KPppDESKeySize);

// RFC 2433, RFC 2759: "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."

	TUint8* pdk = const_cast<TUint8*>(aDesKey.Ptr());
	const TUint8* pmk = aMsChapKey.Ptr();
	TUint16 high, low;
	TUint8 i = 0;
    do
		{
		high = *(pmk + i/8);
		low = *(pmk + i/8 + 1);
		*(pdk + i/7) = static_cast<TUint8>(
			((high << 8 | low) >> (8 - i%8)) & 0xfe);
		i += 7;
		}
	while (i < 49);

	*(pdk + 7) = static_cast<TUint8>(*(pmk + 6) << 1 & 0xfe);

	ASSERT(aDesKey.Length() == KPppDESKeySize);
	}
// -----------------------------------------------------------------------------
// CSIPRequireHeader::BaseDecodeL
// -----------------------------------------------------------------------------
//
RPointerArray<CSIPHeaderBase> 
CSIPRequireHeader::BaseDecodeL (const TDesC8& aValue)
	{
	__ASSERT_ALWAYS (aValue.Length() > 0, 
                     User::Leave(KErrSipCodecRequireHeader));
                     	
	RPointerArray<CSIPHeaderBase> headers;
    CSIPHeaderBase::PushLC(&headers);
	CSIPTokenizer* tokenizer = CSIPTokenizer::NewLC(aValue, ',');
	for (TInt i=0; i < tokenizer->Tokens().Count(); i++)
		{
		CSIPRequireHeader* header = new(ELeave)CSIPRequireHeader;
		CleanupStack::PushL(header);
		header->ConstructL(tokenizer->Tokens()[i]);
		headers.AppendL(header);
		CleanupStack::Pop(header);
		}
	CleanupStack::PopAndDestroy(tokenizer);
	CleanupStack::Pop(); // headers 
	return headers;
	}
Example #25
0
DMAD_EXPORT_C TPtrC8 TDmAdUtil::FirstUriSeg(const TDesC8& aUri)
    {
    TInt i;
    TBool found = EFalse;
    for (i=0; i<aUri.Length(); i++)
        {
        if (aUri[i] == '/')
            {
            found = ETrue;
            break;
            }
        }
    if (found)
        {
        return aUri.Left(i);
        }
    else
        {
        return aUri;
        }
    }
// from MRemConInterfaceIf
void CRemConMediaInformationTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& aData )
	{
	LOG1(_L("\taOperationId = 0x%02x"), aOperationId);
	LOG1(_L("\taData.Length = %d"), aData.Length());

	(void) aOperationId; // ignore warning about this variable being unused
	
	if (!iInProgress && iMsgQueue.IsEmpty())
		{
		ProcessMessage(aData);
		}
	else
		{
		CRemConMediaInformationQueuedMessage* msg = NULL;
		TRAPD(err, msg = CRemConMediaInformationQueuedMessage::NewL(aData));
		if (err == KErrNone)
			{
			iMsgQueue.AddLast(*msg);
			}
		}
	}
Example #27
0
// Send a string, specifying the transport-idle timeout to be used
TInt CImapIO::SendWithTimeout(TRequestStatus& aStatus, TInt aTimeout, const TDesC8& aLine)
	{
	// Disconnected?
	if (iState==EIOStateDisconnected)
		return(KErrDisconnected);

	if (iState!=EIOStateConnected)
		{
		return(KErrNotReady);
		}
		
	// We're queuing a send
	iState=EIOStateWriteQueued;

	Queue(aStatus);
	iTXbytes+=aLine.Length();
	iSession->SendWithTimeout(iStatus, aTimeout, aLine);
	SetActive();

	return(KErrNone);
	}
// ------------------------------------------------------------------------------------------------
// TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
// returns parent uri, i.e. removes last uri segment
// ------------------------------------------------------------------------------------------------
TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
	{
	TBool onlyOneSeg = ETrue;
	TInt i;
	for(i=aURI.Length()-1;i>=0;i--)
		{
		if(aURI[i]==KNSmlDMUriSeparator)
			{
			onlyOneSeg = EFalse;
			break;
			}
		}
	if(onlyOneSeg)
		{
		return KNSmlDmRootUri();
		}
	else
		{
		return aURI.Left(i);
		}
	}
// ---------------------------------------------------------------------------
// Write the file to correct directory.
// ---------------------------------------------------------------------------
//
EXPORT_C void CXIMPTestFileTool::PluginStoreL( const TDesC8& aExternalizedObject )
    {
    HBufC* fileName = GetFileNameLC( 
            KFileToolPluginDirBase,
            iObjIndex );

    RFileWriteStream out;
    CleanupClosePushL( out );
    out.Create( iFs, *fileName, EFileWrite|EFileStream|EFileShareAny );

    // write the file
    TUint32 len = aExternalizedObject.Length();
    out.WriteUint32L( len );
    out.WriteL( aExternalizedObject );
    CleanupStack::PopAndDestroy(); // out

    CleanupStack::PopAndDestroy( fileName ); // fileName

    // next file will have a new index
    iObjIndex++;
    }
void CVBookmarkConverter::WriteL( const TDesC8 &aData )
    {
    if ( iBuffer )
        {
        TInt newPosition = iWriteBufPosition + aData.Length();

        if ( newPosition > iWriteBufSize )
            {
            TInt expandStep = newPosition - iWriteBufSize + 100;
            iBuffer->ExpandL( iWriteBufSize, expandStep );
            iWriteBufSize += expandStep;
            }

        iBuffer->Write( iWriteBufPosition, aData );
        iWriteBufPosition = newPosition;
        }
    else if( iDesc )
        {
        iDesc->Append( aData );       
        }
    }