コード例 #1
0
TBool CRefTestAgentManager::RecognizeFileL(const TDesC& aFileName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType) const
	{
	TBool result = EFalse;
	
	// Check filename extension
	TPtrC extension(aFileName.Right(KRtaExtensionContent().Length()));
	if(extension.CompareF(KRtaExtensionContent) == 0)
		{
		// It's a content file ready for applications to read
		aFileMimeType.Copy(KRtaMimeContent());
		CRefTestAgentArchive::GetDefaultMimeTypeFromHeaderL(aBuffer, aContentMimeType);
		result = ETrue;	
		}
	else
		{
		extension.Set(aFileName.Right(KRtaExtensionContentRights().Length()));
		if(extension.CompareF(KRtaExtensionContentRights) == 0)
			{
			// It's a content and rights file ready for the supplier API
			aFileMimeType.Copy(KRtaMimeContentRights());
			result = ETrue;
			}
		else
			{
			extension.Set(aFileName.Right(KRtaExtensionRights().Length()));
			if(extension.CompareF(KRtaExtensionRights) == 0)
				{
				// It's a content and rights file ready for the supplier API
				aFileMimeType.Copy(KXmlRORights());
				result = ETrue;
				}
			}
		}
	return result;
	}
コード例 #2
0
ファイル: AgentPosition.cpp プロジェクト: BwRy/core-symbian
/**
 * Function that retrieves SSID of current scanned network
 * 
 * The SSID is the Information Element with ID = 0
 * The SSID can be at most 32 bytes, so the aSSID should have the capacity for 32 bytes
 * 
 * Returns KErrNone if successful or the type of error ocurred
 */
TInt CAgentPosition::GetSSID(CWlanScanInfo *scanInfo, TDes8 &aSSID)
{
	TInt error;
	TUint8 ie;
	TUint8 length;
	TUint8 vdata[40];
	const TUint8 *data = &vdata[0];
 
	if((error = scanInfo->FirstIE(ie, length, &data)) == KErrNone)
	{
		if(ie == 0)
		{
			aSSID.Copy(data, length);
			return KErrNone;
		}
	}
	else
		return error;
 
	while((error = scanInfo->NextIE(ie, length, &data)) == KErrNone)
	{
		if(ie == 0)
		{
			aSSID.Copy(data, length);
			return KErrNone;
		}
	}
 
	return error;
}
// ---------------------------------------------------------------------------
// CSensorDataCompensatorAxisDataHandler::Compensate
// ---------------------------------------------------------------------------
//
TInt CSensorDataCompensatorAxisDataHandler::Compensate( TDes8& aData )
    {
	FUNC_LOG;
	TInt err( KErrNone );
    TInt x( 0 );
    TInt y( 0 );
    TInt z( 0 );

    TRACE_MATRIX( "Axis data compensation matrix", iMatrix );

    if ( KSensrvChannelTypeIdMagnetometerXYZAxisData == iDataType )
        {
        INFO( "Compensating magnetometer data" );
        TPckgBuf<TSensrvMagnetometerAxisData> pckg;
        if ( aData.MaxSize() == pckg.MaxSize() )
            {
            pckg.Copy( aData );
            iMatrix.Transform( x, y, z, pckg().iAxisXRaw, pckg().iAxisYRaw,  pckg().iAxisZRaw );
            INFO_3( "Compensated data Magnetometer raw [X: %d], [Y: %d], [Z: %d]", x, y, z );

            pckg().iAxisXRaw = x;
            pckg().iAxisYRaw = y;
            pckg().iAxisZRaw = z;                
            iMatrix.Transform( x, y, z, pckg().iAxisXCalibrated, pckg().iAxisYCalibrated, pckg().iAxisZCalibrated );
            INFO_3( "Compensated data Magnetometer calib [X: %d], [Y: %d], [Z: %d]", x, y, z );

            pckg().iAxisXCalibrated = x;
            pckg().iAxisYCalibrated = y;
            pckg().iAxisZCalibrated = z;
            aData.Copy( pckg );    
            }
        else
            {
            err = KErrArgument;
            }
        }
    else
        {        
        INFO( "Compensating accelerometer data" );
        TPckgBuf<TSensrvAccelerometerAxisData> pckg;
        if ( aData.MaxSize() == pckg.MaxSize() )
            {
            pckg.Copy( aData );
            iMatrix.Transform( x, y, z, pckg().iAxisX, pckg().iAxisY, pckg().iAxisZ );
            INFO_3( "Compensated data accelerometer[X: %d], [Y: %d], [Z: %d]", x, y, z  );
            pckg().iAxisX = x;
            pckg().iAxisY = y;
            pckg().iAxisZ = z;
            aData.Copy( pckg );
            }
        else
            {
            err = KErrArgument;
            }
        }

    ERROR( err, "Axis data compensation error" );
    return err;
    }
コード例 #4
0
LOCAL_C void ExtractEnumeratorComponentsL(
    const TDesC8& aMessageBuffer,
    TDes8& aStore,
    TDes8& aNamespace,
    TDes8& aHashKey )
    {
    TInt len;
    TInt offset;
    TInt total = aMessageBuffer.Length();

	offset = 0;
	len = aMessageBuffer[offset];
	if ( len <= 0 || len > KMaxWmDrmStoreNameSize || offset + len + 1> total )
	    {
	    User::Leave( KErrArgument );
	    }
    aStore.Copy( aMessageBuffer.Mid( offset + 1, len ) );
    
    offset += len + 1;
    if ( offset >= total )
        {
        User::Leave( KErrArgument );
        }
	len = aMessageBuffer[offset];
	if ( len <= 0 || len > KMaxWmDrmNamespaceNameSize || offset + len + 1 > total )
	    {
	    User::Leave( KErrArgument );
	    }
	aNamespace.Copy( aMessageBuffer.Mid( offset + 1, len ) );
	    
    offset += len + 1;
	len = aMessageBuffer[offset];
    if ( offset >= total )
        {
        User::Leave( KErrArgument );
        }
	if ( ( len > 0 && len != KWmDrmIdSize ) || offset + len + 1 > total )
	    {
	    User::Leave( KErrArgument );
	    }
	else if ( len > 0 )
	    {
	    aHashKey.Copy( aMessageBuffer.Mid( offset + 1, len ) );
	    }
	else
	    {
	    aHashKey.SetLength( 0 );
	    }
    }
コード例 #5
0
TInt CImConvertCharconv::StraightCopy( const TDesC& aBufIn, TDes8& rBufOut)
	{
	TInt inLen=aBufIn.Length();
	TInt outMaxLen=rBufOut.MaxLength();

	if (inLen >= outMaxLen)
		{
		TPtrC16 in = aBufIn.Left(outMaxLen);
		rBufOut.Copy(in);
		return (inLen-outMaxLen);
		}
	else
		rBufOut.Copy(aBufIn);
	return 0;
	}
コード例 #6
0
ファイル: t_modem1.cpp プロジェクト: kuailexs/symbiandump-os1
LOCAL_C TInt TranslateCrLf(TDes8 &aDes)
//
// Search for CR/LF characters in a string and replace them with
// '\r' '\n' format. Also replaces unprintable characters with "?"
//
{

    TText8 buf[KBlockSize];
    TText8 *pS=(TText8*)aDes.Ptr();
    TText8 *pSE=pS+aDes.Size();
    TText8 *pT=&buf[0];
    TText8 *pTMax=pT+(KBlockSize-1);
    for (; pS<pSE; pS++,pT++)
    {
        if (pT>=pTMax)
            return(KErrTooBig);
        if (*pS=='\xD'||*pS=='\xA')
        {
            *pT++='\\';
            *pT=(*pS=='\xD')?'r':'n';
        }
        else if (((TChar)*pS).IsPrint())
            *pT=*pS;
        else
            *pT='\?';
    }
    *pT=0;
    if ((pT-&buf[0])>aDes.MaxLength())
        return(KErrTooBig);
    aDes.Copy(&buf[0]);
    return(KErrNone);
}
コード例 #7
0
TInt CCoreSerialConverter::BearerToInterface(const TDesC8& aBearerData,
		TUid& aInterfaceUid,
		TUint& aOperationId,
		TRemConMessageType& aMsgType,
		TDes8& aData) const
	{
	TInt ret = KErrCorrupt;

	// We read KRemConSerialBearerMessageLength bytes at a time, so we should
	// get precisely one message.
	if ( aBearerData.Length() == KRemConSerialBearerMessageLength )
		{
		TPtrC8 ptr;
		ptr.Set(aBearerData);

		TPtrC8 interfaceUid;
		interfaceUid.Set(ptr.Mid(2, 8));
		TLex8 interfaceLex(interfaceUid);
		TUint uid = 0;
		ret = interfaceLex.Val(uid, EHex);
		if ( ret == KErrNone )
			{
			aInterfaceUid = TUid::Uid(uid);

			TPtrC8 operationId;
			operationId.Set(ptr.Mid(13, 2));
			TLex8 operationLex(operationId);
			TUint id = 0;
			ret = operationLex.Val(id, EHex);
			if ( ret == KErrNone )
				{
				aOperationId = id;

				TPtrC8 data;
				data.Set(ptr.Mid(16, 3));
				if ( data == KCmdText() )
					{
					aMsgType = ERemConCommand;
					}
				else if ( data == KRspText() )
					{
					aMsgType = ERemConResponse;
					}
				else
					{
					ret = KErrCorrupt;
					}

				if ( ret == KErrNone )
					{
					TPtrC8 data;
					data.Set(ptr.Mid(20, 10));
					aData.Copy(data);
					}
				}
			}
		}

	return ret;
	}
コード例 #8
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"));
	}
コード例 #9
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;
	}
コード例 #10
0
void CSmtpClientMtm::InvokeSyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter)
/** Invokes a synchronous SMTP-specific operation.

@param aFunctionId Specifies which operation to perform. The only valid ID is KSMTPMTMIsConnected.
@param aSelection A selection of messages for the operation.
@param aParameter Not used
*/
	{
	__ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ESmtcMTMNoCMsvEntrySet));

	TInt error = KErrNone;
	switch (aFunctionId)
		{
		case KSMTPMTMIsConnected:
			{
			TPckgBuf<TImSmtpProgress> progress;
			Session().TransferCommandL(aSelection, KSMTPMTMIsConnected, aParameter, progress);
			aParameter.Copy(progress);
			return;
			}
		default:
			error=KErrNotSupported;
			__ASSERT_DEBUG(EFalse,gPanic(ESmtcUnknownSyncFunction));
		}

	User::LeaveIfError(error);
	}
コード例 #11
0
ファイル: FotaDB.cpp プロジェクト: kuailexs/symbiandump-mw3
// ---------------------------------------------------------------------------
// CFotaDB::GetStateL
// Gets pkg state from db
// ---------------------------------------------------------------------------
TPackageState CFotaDB::GetStateL(const TInt aPkgId, TDes8& aPkgURL)
    {
    RDbView view;
    TPackageState s;
    CleanupClosePushL(view);

    s.iState = RFotaEngineSession::EIdle; // default state is idle

    HBufC* select = HBufC::NewLC(KSelect_where_packageid().Length() + 10);
    select->Des().Format(KSelect_where_packageid, aPkgId);

    TInt err = view.Prepare(iStateDB, TDbQuery(*select));
    __LEAVE_IF_ERROR(err);
    view.EvaluateAll();
    view.FirstL();

    while (view.AtRow())
        {
        view.GetL();
        HBufC8* url;
        s = RowToStateL(url, view);
        CleanupStack::PushL(url);
        aPkgURL.Copy(url->Des());
        CleanupStack::PopAndDestroy(); // url
        view.NextL();
        }
    CleanupStack::PopAndDestroy(); //select
    CleanupStack::PopAndDestroy(); //view
    return s;
    }
コード例 #12
0
TInt CT_DataRGavdp::GAVDP_SecurityControlIndication(TSEID /*aSEID*/, TDes8& aSecurityDataInOut)
{
    INFO_PRINTF1(KLogInfoSecurityControlIndication);

    //verify
    CheckEvent(EGAVDP_SecurityControlIndication);

    HBufC16* securityDataInOut = HBufC16::NewL(aSecurityDataInOut.Length());
    securityDataInOut->Des().Copy(aSecurityDataInOut);
    if (KLogDataFixed().Compare(*securityDataInOut)==0)
    {
        INFO_PRINTF1(KLogInfoSecurityDataUnchanged);
    }
    else if(KLogDataChange().Compare(*securityDataInOut)==0)
    {
        aSecurityDataInOut.Copy(KLogDataChanged());
        INFO_PRINTF2(KLogInfoSecurityDataChanged, &KLogDataChanged());
    }
    else
    {
        ERR_PRINTF1(KLogErrReceivedSecurityData);
        SetAsyncError(iCmdIndex, KErrGeneral);
    }
    delete securityDataInOut;

    DecOutstanding();
    return KErrNone;
}
コード例 #13
0
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
	{
	if (aLength <= aData.Length())
		{
		// Can read it from this buffer
		TPtrC8 res(aData.Left(aLength));
		aData.Set(aData.Mid(aLength));
		return res;
		}
	else /*if (aLength > aData.Length())*/
		{
		// Descriptor spans wrap point, so need to copy into temp buf
		aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
		TInt overflowLen = aLength - aData.Length();
		aData.Set(aOverflowData); // Wrap aData
		aOverflowData.Set(TPtrC8());
		if (overflowLen > aData.Length())
			{
			ASSERT(EFalse); // Shouldn't happen
			// in urel, return everything we've got
			return aData;
			}
		aTempBuf.Append(aData.Left(overflowLen));
		aData.Set(aData.Mid(overflowLen));
		return TPtrC8(aTempBuf);
		}
	}
コード例 #14
0
// ---------------------------------------------------------------------------
// CSensrvDataHandler::GetData
// ---------------------------------------------------------------------------
//
TInt CSensrvDataHandler::GetData( TDes8& aDataPtr )
    {
    COMPONENT_TRACE( ( _L( "Sensrv Client - CSensrvDataHandler::GetData - Start" ) ) );
    TInt err( KErrNone );
    
    if( aDataPtr.Length() < iChannelInfo.iDataItemSize )
        {
        // aDataPtr is too small
        err = KErrOverflow;
        }
    else if( iGetDataCount >= iReadBufferCount || !iReadBuffer )
        {
        // data not found.
        err = KErrNotFound;
        }
    else
        {
        // set data
        TUint8* ptr = const_cast<TUint8*>( iReadBuffer->Des().Ptr() );
        ptr += ( iGetDataCount * iChannelInfo.iDataItemSize ); 
        
        aDataPtr.Copy( ptr, iChannelInfo.iDataItemSize );
        ++iGetDataCount;
        }
    
    COMPONENT_TRACE( ( _L( "Sensrv Client - CSensrvDataHandler::GetData - Return %d" ), err ) );
    return err;
    }
コード例 #15
0
// ==========================================================================
// FUNCTION: ReadNextBlockL
// ==========================================================================
TBool CContainerStoreContentManager::ReadNextBlockL( CBufferedReader& aReader,
                                                     TDes8&           aPlaintextBlock,
                                                     TBool            aIsContentEncrypted )
    {    
    TPtrC8 nextBlock = aReader.NextBlockL();
    
    if ( aIsContentEncrypted )
        {
        iEncryption.DecryptL( nextBlock, aPlaintextBlock );    
        }
    else
        {
        aPlaintextBlock.Copy( nextBlock );
        }
        
    // If this is the last block in the file then remove the pad bytes
    TBool done = aReader.AtEofL();
    if( done && aIsContentEncrypted )   
        {
        iEncryption.RemovePaddingL( aPlaintextBlock );
        } // end if
        
    return done;        
          
    } // end ReadNextBlockL
コード例 #16
0
ファイル: TSYCONFG.CPP プロジェクト: cdaffara/symbiandump-os1
TInt CTsyConfig::ConfigModemStringL(const TDesC& aStringTag, TDes8& aString)
	{
	TInt r=KErrNone;
	for (TInt i=0;i<10;i++)
		{
		TRAP(r, GetCurrentTableViewsL()); // Place a cursor on the default modem record in comms database server
		if (r==KErrAccessDenied) // if we get access denied from DBMS, which is a timing thing, just re-post
			{
			User::After(1000000);
			continue;
			}
		else
			break;
		}
	if (r)
		{
		LOGTEXT(_L8("CommDB values seem to be corrupt"));
		ResetCurrentTableViews(); // clean up everything
		return (KErrEtelModemSettingsCorrupt);
		}

	CCDModemBearerRecord* modemRecord = static_cast<CCDModemBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdModemBearerRecord));
	CleanupStack::PushL(modemRecord);
	modemRecord->SetRecordId(iModemBearer);
	modemRecord->LoadL(*iDbSession);
	
	TInt ret;
	TInt type(0);
	CMDBElement* baseField = NULL;
	TRAP(ret, baseField = modemRecord->GetFieldByNameL(aStringTag, type));
	if (ret == KErrNone)
		{
		// check for type
		switch(type)
			{
			case EMedText:
			case EText:
				{
				CMDBField<TDesC>* field16 = static_cast<CMDBField<TDesC>*>(baseField);
				const TDesC& refField = *field16;
				aString.Copy(refField);
				ret = KErrNone;
				}
				break;
			case EDesC8:
				{
				CMDBField<TDesC8>* field = static_cast<CMDBField<TDesC8>*>(baseField);
				aString = *field;
				ret = KErrNone;
				}
				break;
			default:
				ret = KErrNotFound;
			}
    	}
	CleanupStack::PopAndDestroy(modemRecord);

	ResetCurrentTableViews(); // Clear location and modem table views and close handle to CCommsDatabase
	return ret;
	}
コード例 #17
0
ファイル: shautils.cpp プロジェクト: BwRy/core-symbian
void ShaUtils::CreateSha(const TDesC8& aBuffer, TDes8& aSha)
	{
	CSHA1* payloadSha1 = CSHA1::NewL();
	CleanupStack::PushL(payloadSha1);
	payloadSha1->Update(aBuffer);
	aSha.Copy(payloadSha1->Final());
	CleanupStack::PopAndDestroy(payloadSha1);
	}
コード例 #18
0
TInt CTestAgentContent::AgentSpecificCommand(TInt aCommand, const TDesC8&, TDes8& aOutputBuffer)
	{
	if(aCommand == 1)
		{
		aOutputBuffer.Copy(KAgentSpecificCommandResponse());
		return KErrNone;
		}
	return KErrCANotSupported;
	}
コード例 #19
0
void RMobilePhoneStore::GetInfo(
    TRequestStatus& aReqStatus, TDes8& aInfo) const
{
    RMobilePhoneBookStore::TMobilePhoneBookInfoV1 info;
    info.iCaps = 0x10000000;
    RMobilePhoneBookStore::TMobilePhoneBookInfoV1Pckg pckgInfo( info );
    aInfo.Copy( pckgInfo ); 
    TRequestStatus* tmp = &aReqStatus;
    User::RequestComplete(tmp, KErrNone);
    qDebug("RMobilePhoneStore::GetInfo mock");
}
コード例 #20
0
void RMobilePhoneBookStore::Read(
    TRequestStatus& aReqStatus, TInt /*aIndex*/, 
    TInt /*aNumSlots*/, TDes8& aPBData) const
{ 
    TRequestStatus* tmp = &aReqStatus;
// data ?
    TBuf<5> pbdata(_L("data5"));
    aPBData.Copy(pbdata);
    
    User::RequestComplete(tmp, KErrNone);
}
コード例 #21
0
/**
Read data from a single page. If the page is not found or not valid anymore, read media onto iActive page
first.
@param  aPos    the starting position of the media address to be read.
@param  aLength the length of the content to be read.
@param  aDes    the descriptor to contain the content.
@pre    aLength should be no more than page size.
*/
void CDynamicDirCache::ReadDataFromSinglePageL(TInt64 aPos, TInt aLength, TDes8& aDes)
    {
    //-- the data section is in the cache page entirely, take data directly from the cache
    TDynamicDirCachePage* pPage = FindPageByPos(aPos);
    if (pPage)
        {
        // lock page before reading,
        if (LockPage(pPage) != NULL)
            {
            // read data
            aDes.Copy(pPage->PtrInPage(aPos), aLength);

            // if page is from unlocked queue, insert it onto the last page of the locked
            //  queue. this is to avoid excessive locking and unlocking operations that is
            //  highly likely to happen for following reads.
            if (pPage->PageType() == TDynamicDirCachePage::EUnlocked)
                {
                DeQueue(pPage);
                MakePageLastLocked(pPage);
                }
            }
        else    // page locking failed
            {
            ASSERT(pPage->PageType() == TDynamicDirCachePage::EUnlocked);
            DeQueue(pPage);
            LookupTblRemove(pPage->StartPos());
            DecommitPage(pPage);
            delete pPage;
            pPage = NULL;
            }
        }

    if (!pPage)
        {
        // if page not found or page data not valid anymore, use active page to read data in
        pPage = UpdateActivePageL(aPos);
        // read data
        aDes.Copy(pPage->PtrInPage(aPos), aLength);
        }

    }
コード例 #22
0
static void FormatSqlStmt(TDes8& aSqlBuf, const char aSql[], TInt aRecIds[], TInt aRecCnt)
	{
	aSqlBuf.Copy(TPtrC8((const TUint8*)aSql));
	aSqlBuf.Append(_L8("("));
	for(TInt i=0;i<aRecCnt;++i)
		{
		aSqlBuf.AppendNum((TInt64)aRecIds[i]);
		aSqlBuf.Append(_L8(","));
		}
	aSqlBuf.SetLength(aSqlBuf.Length() - 1);
	aSqlBuf.Append(_L8(")"));
	}
コード例 #23
0
void RMobilePhone::GetMailboxNumbers(
    TRequestStatus& aReqStatus, 
    TDes8& aMailBox) const
{
    RMobilePhone::TMobilePhoneVoicemailIdsV3 info;
    RMobilePhone::TMobilePhoneVoicemailIdsV3Pckg infoPckg(info);
    info.iVoice = 1;
    aMailBox.Copy(infoPckg);
    TRequestStatus* tmp = &aReqStatus;
    User::RequestComplete(tmp, KErrNone);
    qDebug("RMobilePhoneStore::GetMailboxNumbers mock");
}
コード例 #24
0
ファイル: pccenrep.cpp プロジェクト: cdaffara/symbiandump-os2
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
	{
	TBuf8<KMaxBinaryLength> val;
	TInt ret = iImpl->Get(aKey, val);	
	if (ret==KErrNone)
		{
		TInt settingValueLength=val.Length();
		//now check whether any string overflow
		if (settingValueLength > aValue.MaxLength())
			{
			aActualLength=settingValueLength;
			aValue.Copy(val.Left(aValue.MaxLength()));
			return KErrOverflow;
			}
		else
			{
			aValue.Copy(val);
			}
		}	
	return ret;	
	}
コード例 #25
0
/**
 * Obtain the key exchange suite for WTLS, for an anonymous session (ie.
 * on in which no server-certificate is obtained)
 *
 * Out:
 *  aSuite	- the key exchange suite desired for WTLS
 *  aIdType	- the ID type desired for WTLS
 *  aKeyId	- the key ID desired for WTLS
 *
 * Rtn: ETrue if the default is to be overridden
 */
TBool CGTPushSecurityPolicy::GetKeyExchangeSuiteAnon(
								RWTLS::TKeyExchangeSuite& aSuite,
								RWTLS::TIdType& aIdType,
								TDes8& aKeyId
								)
	{
	//
	// NB DISCLAIMER - THIS IS A DUMMY POLICY FOR TESTING PURPOSES ONLY.   //
	//                 IN REALITY, DELIVERABLE SOFTWARE SHOULD REFLECT     //
	//                 ACTUAL LICENSEE/NETWORK PROVIDER POLICY.            //
	//
	//__LOG_ENTER(_L("CGTPushSecurityPolicy::GetKeyExchangeSuiteAnon"));
	TBool retVal = EFalse;
	switch (iKeyExchangeSuitesSet)
		{
		case 0:
			{
			aSuite = RWTLS::ERsaAnon512;
			aIdType = RWTLS::EIdNull;
			aKeyId.Copy(KNullDesC8);
			retVal = ETrue;
			iKeyExchangeSuitesSet++;
			} break;
		case 1:
			{
			aSuite = RWTLS::ERsaAnon768;
			aIdType = RWTLS::EIdNull;
			aKeyId.Copy(KNullDesC8);
			retVal = ETrue;
			iKeyExchangeSuitesSet++;
			} break;
		case 2:
			{
			// No more key exchange suites to be set...
			retVal = EFalse;
			}
		}
	//__LOG_RETURN;
	return retVal;
	}
コード例 #26
0
ファイル: SocketEngine.cpp プロジェクト: rusteer/symbian
//////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////
void ReplaceUrl(TDes8& aUrl,const TDesC8& aIsRepeatedKStr,const TDesC8& aStr){
  HBufC8* tmp=HBufC8::NewL(aUrl.Length()+aStr.Length()+128);
  int iPos=aUrl.FindF(aIsRepeatedKStr);
  if(iPos>=0){
    tmp->Des().Copy(aUrl.Left(iPos)); //加上前面有用的字符
    tmp->Des().Append(aStr);
    int iStart=iPos+aIsRepeatedKStr.Length(); //要被替换的字符,加上要被替换的字符长度
    int iLen2=aUrl.Length()-iStart;
    tmp->Des().Append(aUrl.Mid(iStart,iLen2)); //加上后面有用的字符
    aUrl.Copy(tmp->Des());
  }
  delete tmp;
}
コード例 #27
0
ファイル: EcmtMMCEvent.cpp プロジェクト: fedor4ever/packaging
// -----------------------------------------------------------------------------
// CEcmtMMCEvent::GetEmulatedMMCPathL
// Public method to get MMC disk status from Fileserver
// -----------------------------------------------------------------------------
//
void CEcmtMMCEvent::GetMMCStatus( TDes8& aStatus ) const
	{
	TInt status = 0;
	status = iFs.CheckDisk( KMMCDrive16 );
	switch(status)
		{
			case KErrNone:
				{
				aStatus.Copy( KMMCInsert );
				break;
				}
			case KErrNotReady:
				{
				aStatus.Copy( KMMCRemove );
				break;
				}
			default:
				{
				aStatus.Copy( KMMCCorrupted );
				}
		}
	}
コード例 #28
0
ファイル: netImpl.cpp プロジェクト: Felard/MoSync
void CHttpConnection::RecvOneOrMoreL(TDes8& aDes, CPublicActive& op) {
	MYASSERT(mState == FINISHED, ERR_HTTP_NOT_FINISHED);
	if(mPos < mBufPtr.Length()) {	//there's still some data left in the buffer
		int len = MIN(mBufPtr.Length() - mPos, aDes.MaxLength());
		aDes.Copy(mBufPtr.Ptr() + mPos, len);
		mPos += len;
		op.SetActive();
		TRequestStatus* temp = &op.iStatus;
		User::RequestComplete(temp, len);
	} else {	//we gotta read from outside
		mTransport->RecvOneOrMoreL(aDes, op);
	}
}
コード例 #29
0
void CEnumerator::GetUniqueKey( TDes8& aKey )
    {
    LOGFN( "CEnumerator::GetUniqueKey" );
    aKey.SetLength( 0 );
    if ( iUniqueKey.CompareC( KZeroID ) == 0 )
        {
        aKey.Fill( '\0', KWmDrmIdSize );
        }
    else
        {
        aKey.Copy( iUniqueKey );
        }
    }
コード例 #30
0
ファイル: mschap2.cpp プロジェクト: kuailexs/symbiandump-os2
void CPppMsChap2::ChallengeHashL(const TDesC8& aPeerChallenge,
                                 const TDesC8& aAuthenticatorChallenge,
                                 const TDesC8& aUserName,
                                 TDes8& aChallengeHash)
/**
   Computes the hash of the Peer Challenge, Authenticator Challenge
   and username using SHA-1.
   @param aPeerChallenge [in] The Peer Challenge (16 octets).
   @param aAuthenticatorChallenge [in] The Authenticator Challenge (16
   octets).
   @param aUserName [in] The Microsoft Windows NT username (0 to 256
   char).
   @param aChallengeHash [out] The hash of the peer challenge,
   authenticator challenge and username, computed using SHA-1 (8
   octets).
   @note This function implements the ChallengeHash routine specified
   in RFC 2759.
   @internalComponent
*/
{
    ASSERT(aPeerChallenge.Length() ==
           KPppMsChap2PeerChallengeSize);
    ASSERT(aAuthenticatorChallenge.Length() ==
           KPppMsChap2AuthenticatorChallengeSize);
    ASSERT(aUserName.Length() <= KPppMsChapMaxNTUserNameLength);
    ASSERT(aChallengeHash.Length()==KPppMsChap2ChallengeHashSize);

    CSHA1* sha1 = CSHA1::NewL();
    CleanupStack::PushL(sha1);

// RFC 2759: "Only the user name (as presented by the peer and
// excluding any prepended domain name)"
    TPtrC8 userName(aUserName);
    TInt i = aUserName.Locate('\\');
    if (i >= 0 && i < userName.Length() - 1)
        userName.Set(aUserName.Mid(i + 1));
    else if (i >= userName.Length() - 1)
        User::Leave(KErrGeneral);


    sha1->Update(aPeerChallenge);
    sha1->Update(aAuthenticatorChallenge);

    aChallengeHash.Copy(sha1->Final(userName).Ptr(),
                        KPppMsChap2ChallengeHashSize);


    CleanupStack::PopAndDestroy(sha1);

    ASSERT(aChallengeHash.Length()==KPppMsChap2ChallengeHashSize);
}