TBool assert_equals_des8(CTestExecuteLogger& aLogger, const TText8* aFile, TInt aLine, TInt aSeverity, 
	const TDesC8& aRes, const TDesC8& aExp, const TDesC& aMsg)
	{
	if(aRes != aExp)
		{
		TBuf<20> tempRes;
		TBuf<20> tempExp;
		
		TPtrC8 exp;
		TPtrC8 res;
		
		exp.Set(aExp.Ptr(), aExp.Length());
		res.Set(aRes.Ptr(), aRes.Length());
		
		if(exp.Length() > KMaxLogCharLength)
			{
			exp.Set(exp.Ptr(), KMaxLogCharLength);
			}
		
		if(res.Length() > KMaxLogCharLength)
			{
			res.Set(res.Ptr(), KMaxLogCharLength);
			}

		//8-bit copy to unicode for logging
		tempRes.Copy(res);
		tempExp.Copy(exp);
	
		aLogger.LogExtra(aFile, aLine, aSeverity, KAssertErrorEqualsTextDes, &tempRes, &tempExp, &aMsg);
		return EFalse;
		}
	return ETrue;
	}
EXPORT_C void CMTPTypeObjectPropList::AppendObjectPropListL(const CMTPTypeObjectPropList& aSource)
    {
    TInt chunkStatus = 0;
    TBool copyFirstChunk = ETrue;
    TUint srcElemNum = aSource.NumberOfElements();
    
    while (chunkStatus != KMTPChunkSequenceCompletion)
        {
        TPtrC8 tmpPtrRawData;
        if (copyFirstChunk)
            {
            chunkStatus = aSource.FirstReadChunk(tmpPtrRawData);
            tmpPtrRawData.Set(tmpPtrRawData.Ptr() + sizeof(TUint32), tmpPtrRawData.Length() - sizeof(TUint32));
            copyFirstChunk = EFalse;
            }
        else
            {
            chunkStatus = aSource.NextReadChunk(tmpPtrRawData);
            }
        
        const TUint8* srcPtr = tmpPtrRawData.Ptr();
        MemoryCopyL(iRevPageEnd, iRevDataEnd, srcPtr, tmpPtrRawData.Length());
        IncreaseIndexL(iRevPageEnd, iRevDataEnd, tmpPtrRawData.Length(), ETrue);
        }
    
    iNumberOfElements += srcElemNum;
    memcpy(&(iIOPages[0][KReservedTransportHeaderSize]), &iNumberOfElements, sizeof(TUint32));
    }
EXPORT_C void CMTPTypeObjectPropListElement::SetArrayL(TInt aElementId, const CMTPTypeArray& aArray)
    {
    if(EValue != aElementId)
        {
        User::Leave(KErrArgument);
        }
    
    SetDataType(aArray.Type());
    TUint32 num = aArray.NumElements();
    
    
    TUint pageIndex = iPageIndex;
    TUint bufIndex = iBufIndex;
    
    // Set number of array elements
    iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue);
    iPropList->MemoryCopyL(pageIndex, bufIndex, &num, sizeof(TUint32));

    TPtrC8 srcPtr;
    aArray.FirstReadChunk(srcPtr);
    srcPtr.Set(srcPtr.Ptr() + sizeof(TUint32), srcPtr.Length() - sizeof(TUint32));
    
    iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue);
    TUint arrayWidth = iPropList->ArrayElemWidth(iDataType);
    iValueSize = sizeof(TUint32) + num * arrayWidth;
    iPropList->MemoryCopyL(pageIndex, bufIndex, srcPtr.Ptr(), num * arrayWidth);
    iArrayBuffered = EFalse;
    }
EXPORT_C int Tptrc8ToWcharp(TPtrC8& aSrc, wchar_t* aDes, int& n_size)
{
    int retval = ESuccess;
    unsigned int ilen = aSrc.Length();
    int minusone = -1;
    
    if (0 == ilen)
    {
    	return EDescriptorNoData;
    }
    else if(!aDes)
    {
    	return EInvalidPointer;
    }
	else if(n_size < ilen)
	{
		n_size = ilen;
		return EInvalidSize;
	}
	
	if(minusone != mbstowcs(aDes, (const char*)aSrc.Ptr(), ilen))
	{
	    aDes[ilen] = L'\0';
	}
	else 
	{
		retval = EInvalidMBSSequence;
	}
	
	return retval;	
}
/**
    Check if the buffer is filled with aFill character.
    @param  aBufPtr buffer descriptor
    @param  aFill filling character
    @return ETrue if the buffer is filled with aFill byte.
*/
static TBool CheckBufFill(const TPtrC8& aBufPtr, TUint8 aFill)
{
    const TUint32 bufSz = (TUint32)aBufPtr.Size();
    
    //-- optimised by using DWORD granularity
    if(bufSz % sizeof(TUint32) == 0)
    {
        TUint32 wordPattern = aFill;
        wordPattern <<= 8; wordPattern |= aFill;
        wordPattern <<= 8; wordPattern |= aFill;
        wordPattern <<= 8; wordPattern |= aFill;

        const TUint nWords = bufSz / sizeof(TUint32);
        const TUint32* pWords = (const TUint32*) aBufPtr.Ptr();

        for(TUint32 i=0; i<nWords; ++i)
        {
            if(pWords[i] != wordPattern)
                return EFalse;
        }

        return ETrue;
    }
    
    //-- dumb implementation
    for(TUint32 i=0; i<bufSz; ++i)
    {
        if(aBufPtr[i] != aFill)
            return EFalse;
    }

    return ETrue;
}
Esempio n. 6
0
TUint8 CNcmNtb16Parser::DataTUint8(TUint aOffset, const TUint8* aBuf, TInt aBufLen)
    {
    if (0 == iQueLen)
        {
        return aBuf[iDataOffset + aOffset];
        }
    else if (iDataLen <= aOffset)
        {
        return aBuf[aOffset - iDataLen];
        }
    else
        {
        TInt    i = 1;
        TPtrC8* pPtr = &iBufQueue[0];
        TUint   totalOffset = pPtr->Length() - iDataOffset;
        while(totalOffset <= aOffset)
            {
            pPtr = &iBufQueue[i];
            totalOffset += pPtr->Length();
            i++;
            __ASSERT_DEBUG(i<=iQueLen, User::Panic(KNTBParsePanic, __LINE__));
            }
        return pPtr->Ptr()[pPtr->Length() + aOffset - totalOffset];
        }
    }
/**
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;
	}
// -----------------------------------------------------------------------------
// TBTSUDataConverter::ConvertByteL
// -----------------------------------------------------------------------------
//
TUint8 TBTSUDataConverter::ConvertByteL( const TPtrC8& aData )
    {
    if ( aData.Length() != sizeof(TUint8) )
        {
        User::Leave( KErrArgument );
        }
    return *aData.Ptr();
    }
// -----------------------------------------------------------------------------
// TBTSUDataConverter::ConvertDataUnsignedL
// -----------------------------------------------------------------------------
//
TUint32 TBTSUDataConverter::ConvertDataUnsignedL( const TPtrC8& aData )
    {
    if ( aData.Size() != sizeof(TUint32) )
        {
        User::Leave( KErrArgument );
        }
    return BigEndian::Get32(aData.Ptr());
    }
Esempio n. 10
0
void CResourceManager::GetMd5(const TDesC8& aString, TUint8* aMd5)
{
    CMD5 *md5 = CMD5::NewL();
    CleanupStack::PushL(md5);
    TPtrC8 ptrHash = md5->Hash(aString);
    const TUint8* p = ptrHash.Ptr();
    Mem::Copy(aMd5, p, ptrHash.Length());
    CleanupStack::PopAndDestroy(md5);
}
TInt CBulkOnlyTransport::SendDataRxCmdL(const MClientCommandServiceReq* aCommand,
                                        TDes8& aCopyBuf,
                                        TInt& aLen)
{
    __MSFNLOG

    TInt r = KErrNone;
    SendCbwL(aCommand, TBotCbw::EDataIn, aLen);

    // store initial length as data is appended to the buffer
    TInt startPos = aCopyBuf.Length();

    TInt len = aLen;

    while (len)
    {
        if(len > KResponsePacketSize)
            iBulkDataTd.SaveData(KResponsePacketSize);
        else
            iBulkDataTd.SaveData(len);
        iBulkPipeIn.Transfer(iBulkDataTd, iStatus);
        User::WaitForRequest(iStatus);

        r = iStatus.Int();
        if (r != KErrNone)
        {
            if (r == KErrUsbStalled)
            {
                __BOTPRINT(_L("SendDataRxCmdL ClearRemoteStall"));
                iBulkPipeIn.ClearRemoteStall();
#ifdef MASSSTORAGE_PUBLISHER
                TMsPublisher publisher(TMsPublisher::KStallProperty);
#endif
                break;
            }
            DoResetRecovery();
            __BOTPRINT1(_L("Usb transfer error %d"),r);
            User::Leave(KErrGeneral);
        }

        TPtrC8 data = iBulkDataTd.Buffer();
        aCopyBuf.Append(data.Ptr(), data.Length());
        if(len > KResponsePacketSize)
            len -= KResponsePacketSize;
        else
            len = 0;
    }

    ReceiveCswL();
    TUint32 lenReceived = 0;

    r = ProcessInTransferL(lenReceived);
    aLen = lenReceived;
    aCopyBuf.SetLength(startPos + lenReceived);

    return r;
}
// -----------------------------------------------------------------------------
// TBTSUDataConverter::ConvertDataSignedL
// -----------------------------------------------------------------------------
//
TInt32 TBTSUDataConverter::ConvertDataSignedL( const TPtrC8& aData )
    {
    if ( aData.Length() != sizeof(TInt32) )
        {
        User::Leave( KErrArgument );
        }
    TUint32 rawVal = BigEndian::Get32(aData.Ptr());
    return *reinterpret_cast<TInt32*>(&rawVal); // reinterpret cast to extract signed nature "unscathed"
    }
EXPORT_C TInt CMTPTypeOpaqueData::Write( const TPtrC8 &aDes)
    {
    if(iBuffer.MaxSize() != 0)
        {
        iBuffer.Close();
        }
    
    iPtrBuffer.Set(const_cast<TUint8*>(aDes.Ptr()), aDes.Length(), aDes.Size());
    return KErrNone;
    }
Esempio n. 14
0
TUint16 CNcmNtb16Parser::DataTUint16(TUint aOffset, const TUint8* aBuf, TInt aBufLen)
    {
    if (0 == iQueLen)
        {
        return LittleEndian::Get16(aBuf + aOffset + iDataOffset);
        }
    else if (iDataLen <= aOffset)
        {
        return LittleEndian::Get16(aBuf + aOffset - iDataLen);
        }
    else
        {
        TUint16 ret = 0;
        TInt    i = 1;
        TPtrC8* pPtr = &iBufQueue[0];
        TUint   totalOffset = pPtr->Length() - iDataOffset;

        while(totalOffset <= aOffset)
            {
            pPtr = &iBufQueue[i];
            totalOffset += pPtr->Length();
            i++;
            __ASSERT_DEBUG(i<=iQueLen, User::Panic(KNTBParsePanic, __LINE__));
            }
        ret = pPtr->Ptr()[pPtr->Length() + aOffset - totalOffset];
        if (totalOffset > aOffset + 1)
            {
            ret += ((pPtr->Ptr()[pPtr->Length() + aOffset - totalOffset + 1])<<8)&0xFF00;
            }
        else if (i < iQueLen)
            {
            pPtr = &iBufQueue[i];
            ret += ((pPtr->Ptr()[0])<<8)&0xFF00;
            }
        else
            {
            ret += (aBuf[0]<<8)&0xFF00;
            }

        return ret;
        }
    }
// ----------------------------------------------------------------------------
// UntrustedCertificateInfoSymbian::ConstructL()
// ----------------------------------------------------------------------------
//
void UntrustedCertificateInfoSymbian::ConstructL(const QByteArray &aEncodedCert)
{
    TPtrC8 encodedCert( reinterpret_cast<const TText8*>( aEncodedCert.constData() ),
        aEncodedCert.length() );

    ASSERT( mCert == 0 );
    mCert = CX509Certificate::NewL( encodedCert );

    HBufC16* subjectBuf = NULL;
    X509CertNameParser::SubjectFullNameL( *mCert, subjectBuf );
    CleanupStack::PushL( subjectBuf );
    QT_TRYCATCH_LEAVING( mSubjectName =
        QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length()) );
    CleanupStack::PopAndDestroy( subjectBuf );

    HBufC16* issuerBuf = NULL;
    X509CertNameParser::IssuerFullNameL( *mCert, issuerBuf );
    CleanupStack::PushL( issuerBuf );
    QT_TRYCATCH_LEAVING( mIssuerName =
        QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length()));
    CleanupStack::PopAndDestroy( issuerBuf );

    TPtrC8 fingerprint = mCert->Fingerprint();
    QT_TRYCATCH_LEAVING( mFingerprint = QByteArray::fromRawData(
        reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length()) );

    mMd5Fingerprint = Md5FingerprintL( mCert->Encoding() );

    TPtrC8 serialNumber = mCert->SerialNumber();
    QT_TRYCATCH_LEAVING( mSerialNumber = QByteArray::fromRawData(
        reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length()) );

    const CValidityPeriod& validityPeriod = mCert->ValidityPeriod();
    convertDateTime(validityPeriod.Start(), mValidFrom);
    convertDateTime(validityPeriod.Finish(), mValidTo);

    mFormat = X509Certificate;

    const CSigningAlgorithmIdentifier& alg = mCert->SigningAlgorithm();
    mDigestAlgorithm = mapAlgorithm(alg.DigestAlgorithm().Algorithm());
    mAsymmetricAlgorithm = mapAlgorithm(alg.AsymmetricAlgorithm().Algorithm());
}
Esempio n. 16
0
TInt TMetaVarLenBase::CheckBuf( TPtrC8& aBuffer )
	{
	// Check if the descriptor is long enough
	if (aBuffer.Length() < (TInt)sizeof(TUint32))
		{
		return KErrArgument;
		}
	
	// Check if the descriptor is long enough
    TBuf8<sizeof(TUint32)> lenSubBuf;
    lenSubBuf.Copy(aBuffer.Ptr(), sizeof(TUint32));
    TUint length = *((TUint32*)lenSubBuf.Ptr());	
	if (aBuffer.Length() < (TInt)length)
		{
		return KErrArgument;
		}

	aBuffer.Set(aBuffer.Ptr() + sizeof(TUint32), aBuffer.Length() - sizeof(TUint32)); //update pointer
	return length;
	}
Esempio n. 17
0
EXPORT_C TInt TMetaArrayBase::Load(TPtrC8& aBuffer)
/**
 * Loads content of a meta object (in iData) from a descriptor
 */
	{
	Reset();
	if (aBuffer.Length() < (TInt)sizeof(TInt))
		{
		return KErrArgument;
		}
	TInt count = (*(TInt*)aBuffer.Ptr());
	TInt size = SizeOfType();
	aBuffer.Set(aBuffer.Ptr()+sizeof(TInt), aBuffer.Length()-sizeof(TInt)); //update pointer
	TInt error = KErrNone;
	for ( TInt n = 0; error == KErrNone && n < count; n++ )
		{
		error = Append( (TUint8*)aBuffer.Ptr() );
		aBuffer.Set(aBuffer.Ptr()+size, aBuffer.Length()-size); //update pointer
		}
	return error;
	}
// ----------------------------------------------------------------------------
// UntrustedCertificateInfoSymbian::Md5FingerprintL()
// ----------------------------------------------------------------------------
//
QByteArray UntrustedCertificateInfoSymbian::Md5FingerprintL( const TDesC8& aEncodedCert ) const
{
    CMD5* md5 = CMD5::NewL();
    CleanupStack::PushL( md5 );

    const TPtrC8 fingerprintSymbian = md5->Hash( aEncodedCert );
    QByteArray fingerprint( reinterpret_cast<const char*>( fingerprintSymbian.Ptr() ),
        fingerprintSymbian.Length() );

    CleanupStack::PopAndDestroy( md5 );
    return fingerprint;
}
Esempio n. 19
0
/**
Loads a drawsection from externalized data.

@param aData The parser for the externalized data.
@param aIndex The index of the drawsection in CCommandBuffer::iDrawSections to load from the externalized data.
*/
TInt CDrawSection::LoadL(const TWsGraphicMsgBufParser& aData, TInt aIndex)
	{
	if(aData.Uid(aIndex).iUid != KDrawSection.iUid)
		{
		return KErrArgument;
		}
		
	const TPtrC8 pckg = aData.Data(aIndex);	
	const TPtrC8 drawRectPtr = pckg.Left(sizeof(TRect));
	const TPtrC8 boundingRectPtr = pckg.Mid(sizeof(TRect), sizeof(TRect));
	const TPtrC8 segBufPtr = pckg.Mid(sizeof(TRect)*2);
	
	Mem::Copy(&iDrawRect, drawRectPtr.Ptr(), sizeof(TRect));
	Mem::Copy(&iBoundingRect, boundingRectPtr.Ptr(), sizeof(TRect));
	
	if(iSectionSegBuf)
		delete iSectionSegBuf;
	
	iSectionSegBuf = CBufSeg::NewL(KBufferSize);
	iSectionSegBuf->InsertL(0, segBufPtr);
	return KErrNone;	
	}
Esempio n. 20
0
EXPORT_C TInt TWsGraphicMsgAnimation::Load(const TWsGraphicMsgBufParser& aData,TInt aIndex)
	{
	if(aData.Uid(aIndex).iUid != TWsGraphicAnimation::ETypeId)
		{
		return KErrArgument;
		}
	const TPtrC8 pckg = aData.Data(aIndex);
	if(pckg.Size() != sizeof(TWsGraphicMsgAnimation))
		{
		return KErrCorrupt;
		}
	memcpy(this,pckg.Ptr(),sizeof(TWsGraphicMsgAnimation));
	return KErrNone;
	}
Esempio n. 21
0
QVariant QSymSQLResult::data(int idx)
{
    QVariant r;
    
    switch (d->stmt.ColumnType(idx)) {
    case ESqlBinary:
        {
            TPtrC8 data; 
            d->stmt.ColumnBinary(idx, data);
            return QByteArray(reinterpret_cast<const char *>(data.Ptr()), data.Length());
            break;
         }
    case ESqlInt:
        r = QVariant(d->stmt.ColumnInt(idx));
        break;
    case ESqlInt64:
        r = QVariant(d->stmt.ColumnInt64(idx));
        break;
    case ESqlReal:
        switch(numericalPrecisionPolicy()) {
        case QSql::LowPrecisionInt32:
            r = QVariant(d->stmt.ColumnInt(idx));
            break;
        case QSql::LowPrecisionInt64:
            r = QVariant(d->stmt.ColumnInt64(idx));
            break;
        case QSql::LowPrecisionDouble:
            r = QVariant(d->stmt.ColumnReal(idx));
            break;
        case QSql::HighPrecision:
        default:
            TPtrC res;
            d->stmt.ColumnText(idx, res);
            r = QVariant(qt_TDesC2QString(res));
            break;
        };
        break;
    case ESqlNull:
        r  = QVariant(QVariant::String);
        break;
    default:
        TPtrC res;
        d->stmt.ColumnText(idx, res);
        r = QVariant(qt_TDesC2QString(res));
        break;
    }

    return r;
}    
// ----------------------------------------------------------------------------
// CSipSecIpsecMechanism::SadbRegister
// ----------------------------------------------------------------------------
//
void CSipSecIpsecMechanism::SadbRegister()
{
    TPfkeyAnyExt ext;
    TInt s = iReceiveBuffer.NextExtension( ext );
    __ASSERT_DEBUG( s == KErrNone, User::Panic( KMsgPanic, s ) );
    TBool foundSupportedAuth( EFalse );
    while ( s == KErrNone && !foundSupportedAuth )
    {
        if ( ext.ExtType() == SADB_EXT_SUPPORTED_AUTH )
        {
            foundSupportedAuth = ETrue;
        }
        else
        {
            s = iReceiveBuffer.NextExtension( ext );
        }
    }

    if ( s != KErrNone )
    {
        return;
    }

    iCaps.iMode.Set( KTransMode );
    iCaps.iProt.Set( KEspProtocol );
    TInt len = ext.ExtLen() * KWordLen;
    TInt offset = KSizeOfSADBSupported;
    TPtrC8 alg;
    for ( ; offset<len; offset = offset+KSizeOfSADBAlg )
    {
        alg.Set( ext.Mid( offset, KSizeOfSADBAlg ) );
        const sadb_alg* a = reinterpret_cast<const sadb_alg*>( alg.Ptr() );
        if ( a->sadb_alg_id == SADB_AALG_MD5HMAC &&
                a->sadb_alg_maxbits >= MD5_KEYLENGTH &&
                a->sadb_alg_minbits <= MD5_KEYLENGTH )
        {
            iCaps.iAlgMd5.Set( KHmacMd596 );
        }
        if ( a->sadb_alg_id == SADB_AALG_SHA1HMAC &&
                a->sadb_alg_maxbits >= SHA_KEYLENGTH &&
                a->sadb_alg_minbits <= SHA_KEYLENGTH )
        {
            iCaps.iAlgSha.Set( KHmacSha196 );
        }
    }
}
Esempio n. 23
0
SHVStringBufferUTF8 SHVStringUTF8::Copy(const TPtrC8& aPtr)
{
SHVStringBufferUTF8 retVal;
size_t len = aPtr.Length();

	if (len)
	{
		retVal.Buffer = (SHVChar*)::malloc((len+1)*sizeof(SHVChar));
		if (retVal.Buffer)
		{
			memcpy(retVal.Buffer, aPtr.Ptr(), len*sizeof(SHVChar));
			retVal.Buffer[len] = 0;
		}
	}

	return retVal;
}
Esempio n. 24
0
EXPORT_C TInt TMetaVarLenBase::Load(TPtrC8& aBuffer)
/**
 * Loads content of descriptor data member
 */
	{
	// Check if the descriptor is long enough
	TInt errlen = CheckBuf( aBuffer );
	if (errlen < 0)
		{
		return errlen;
		}

	//and copy whatever we can into the client descriptor
	CopyBuf(aBuffer,errlen);

	aBuffer.Set(aBuffer.Ptr() + errlen, aBuffer.Length() - errlen); //update pointer
	return KErrNone;
	}
Esempio n. 25
0
QStringList S60FormatSupported::supportedPlayMimeTypesL()
{
    RArray<TUid> mediaIds; //search for both audio and video
    RMMFControllerImplInfoArray iControllers;
    m_controllerparam = CMMFControllerPluginSelectionParameters::NewL();
    m_playformatparam = CMMFFormatSelectionParameters::NewL();
    mediaIds.Append(KUidMediaTypeAudio);
    mediaIds.Append(KUidMediaTypeVideo);
    m_controllerparam->SetMediaIdsL(mediaIds, CMMFPluginSelectionParameters::EAllowOtherMediaIds);
    m_controllerparam->SetRequiredPlayFormatSupportL(*m_playformatparam);
    m_controllerparam->ListImplementationsL(iControllers);
    CDesC8ArrayFlat* controllerArray = new (ELeave) CDesC8ArrayFlat(1);
    for (TInt i = 0; i < iControllers.Count(); i++) {
        for (TInt j = 0; j < (iControllers[i]->PlayFormats()).Count(); j++) {
            const CDesC8Array& iarr = (iControllers[i]->PlayFormats()[j]->SupportedMimeTypes());
            TInt count = iarr.Count();
            for (TInt k = 0; k < count; k++) {
                TPtrC8 ptr = iarr.MdcaPoint(k);
                HBufC8* n = HBufC8::NewL(ptr.Length());
                TPtr8 ptr1 = n->Des();
                ptr1.Copy((TUint8*) ptr.Ptr(), ptr.Length());
                controllerArray->AppendL(ptr1);
            }
        }
    }

    // converting CDesC8Array to QStringList
    for (TInt x = 0; x < controllerArray->Count(); x++) {
        m_supportedplaymime.append(QString::fromUtf8(
                (const char*) (controllerArray->MdcaPoint(x).Ptr()),
                controllerArray->MdcaPoint(x).Length()));
    }

    // populating the list with only audio and controller mime types
    QStringList tempaudio = m_supportedplaymime.filter(QString("audio"));
    QStringList tempvideo = m_supportedplaymime.filter(QString("video"));

    m_supportedplaymime.clear();
    m_supportedplaymime = tempaudio + tempvideo;
    mediaIds.Close();
    delete controllerArray;
    iControllers.ResetAndDestroy();
    return m_supportedplaymime;
}
Esempio n. 26
0
void CDebugRouterClient::RunL()
	{
	TUint chunkSize = iSharedChunk.Size();
	const TUint KDataStartOffset = sizeof(SDebugChunkHeader);
	SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)iSharedChunk.Base();
	TUint start = chunkHeader->iStartOffset;
	TUint end = chunkHeader->iEndOffset;
	TUint overflows = chunkHeader->iOverflows;

	TBool wrap = (start > end);
	TUint endLen = wrap ? chunkSize - start : end - start;
	TUint startLen = wrap ? end - KDataStartOffset : 0;

	TPtrC8 endData(iSharedChunk.Base() + start, endLen);
	TPtrC8 startData;
	if (wrap) startData.Set(iSharedChunk.Base() + KDataStartOffset, startLen);
	TPtrC8 data(endData);

	while (data.Length())
		{
		TPtrC8 header = Read(iTempBuf, data, sizeof(SCloggerTraceInfo), startData);
		if (header.Length() < (TInt)sizeof(SCloggerTraceInfo))
			{
			ASSERT(EFalse); // for udeb
			break; // Something's broken
			}
		SCloggerTraceInfo info;
		Mem::Copy(&info, header.Ptr(), sizeof(SCloggerTraceInfo));
		ASSERT(info.iTraceType == 'K' || info.iTraceType == 'U' || info.iTraceType == 'P');
		TPtrC8 msg = Read(iTempBuf, data, info.iLength, startData);
		iServer.LogKernMessage(info.iTraceType, info.iTickCount, info.iThreadId, msg);
		}
	if (overflows)
		{
		_LIT8(KErr, "RDebug::Print buffer overflowed, %u calls not logged");
		iServer.LogError(KErr, overflows);
		}
	// Zero the memory so it's easier to read in the crashlog
	memclr(iSharedChunk.Base() + start, endLen);
	if (startLen) memclr(iSharedChunk.Base() + KDataStartOffset, startLen);
	
	StartRouting(-1); // Magic number to indicate no need to call EnableDebugRouting again
	}
Esempio n. 27
0
EXPORT_C TInt RSoundPlugIn::CommandReply(TInt aOpcode, const TPtrC8& aArgs)
/** Sends a command to the plug-in DLL and may receive a response.

If the correct plug-in is loaded, its implementation of  CommandReplyL() 
is called and its return code is returned by this function.

Specify an opcode of zero if you just want the identity of the plug-in DLL 
being used.

This function always causes a flush of the window server buffer.

@param aOpcode Opcode understood by both the window server client and the 
plug-in DLL. If an opcode of zero is specified, this is intercepted by the 
window server, and the third UID of the plug-in is returned. This allows 
the caller to identify the plug-in DLL being used.
@param aArgs Packaged arguments which are passed to the plug-in via the window 
server. 
@return KErrNone or another of the system error codes, as returned by the 
plug-in's CommandReplyL() implementation. ESoundWrongPlugIn is returned if no 
plug-in is loaded, or if the plug-in identified by the aUid parameter in Construct() 
is not loaded. */
	{
	return WriteReply(&aOpcode,sizeof(aOpcode),aArgs.Ptr(),aArgs.Length(),EWsClickOpCommandReply);
	}
void QBluetoothServiceDiscoveryAgentPrivate::VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType)
{
  qDebug() << "VisitAttributeValueL";
    QVariant var;
    TUint datasize = aValue.DataSize();
    
    switch (aType) {
    case ETypeNil:
        break;
    case ETypeUint:
        if (datasize == 8) {
            TUint64 value;
            aValue.Uint64(value);
            var = QVariant::fromValue(value);
        } else
            var = QVariant::fromValue(aValue.Uint());
        break;
    case ETypeInt:
            var = QVariant::fromValue(aValue.Int());
        break;
    case ETypeUUID: {
        TPtrC8 shortForm(aValue.UUID().ShortestForm());
        if (shortForm.Size() == 2) {
            QBluetoothUuid uuid(ntohs(*reinterpret_cast<const quint16 *>(shortForm.Ptr())));
            var = QVariant::fromValue(uuid);
        } else if (shortForm.Size() == 4) {
            QBluetoothUuid uuid(ntohl(*reinterpret_cast<const quint32 *>(shortForm.Ptr())));
            var = QVariant::fromValue(uuid);
        } else if (shortForm.Size() == 16) {
            QBluetoothUuid uuid(*reinterpret_cast<const quint128 *>(shortForm.Ptr()));
            var = QVariant::fromValue(uuid);
        }
        break;
    }
    case ETypeString: {
        TPtrC8 stringBuffer = aValue.Des();
        var = QVariant::fromValue(QString::fromLocal8Bit(reinterpret_cast<const char *>(stringBuffer.Ptr()), stringBuffer.Size()));
        break;
    }
    case ETypeBoolean:
        var = QVariant::fromValue(static_cast<bool>(aValue.Bool()));
        break;
    case ETypeDES:
        m_stack.push(QVariant::fromValue(QBluetoothServiceInfo::Sequence()));
        break;
    case ETypeDEA:
        m_stack.push(QVariant::fromValue(QBluetoothServiceInfo::Alternative()));
        break;
    case ETypeURL: {
        TPtrC8 stringBuffer = aValue.Des();
        var = QVariant::fromValue(QUrl(QString::fromLocal8Bit(reinterpret_cast<const char *>(stringBuffer.Ptr()), stringBuffer.Size())));
        break;
    }
    case ETypeEncoded:
        qWarning() << "Don't know how to handle encoded type.";
        break;
    default:
        qWarning() << "Don't know how to handle type" << aType;
    }

    if (aType != ETypeDES && aType != ETypeDEA) {
        if (m_stack.size() == 0) {
            // single value attribute, just push onto stack
            m_stack.push(var);
        } else if (m_stack.size() >= 1) {
            // sequence or alternate attribute, add non-DES -DEA values to DES or DEA
            if (m_stack.top().canConvert<QBluetoothServiceInfo::Sequence>()) {
                QBluetoothServiceInfo::Sequence *sequence = static_cast<QBluetoothServiceInfo::Sequence *>(m_stack.top().data());
                sequence->append(var);
            } else if (m_stack.top().canConvert<QBluetoothServiceInfo::Alternative>()) {
                QBluetoothServiceInfo::Alternative *alternative = static_cast<QBluetoothServiceInfo::Alternative *>(m_stack.top().data());
                alternative->append(var);
            } else {
                qWarning("Unknown type in the QVariant, should be either a QBluetoothServiceInfo::Sequence or an QBluetoothServiceInfo::Alternative");
            }
        }
    }
}
// -----------------------------------------------------------------------------
// CCMSX509CertificateList::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
EXPORT_C void CCMSX509CertificateList::ConstructL(
	const CX509Certificate& aSigningCertificate,
	const CArrayPtrFlat<CX509Certificate>& aRevokedCertificates )
    {
	ConstructL();

	// setting signature
	const CSigningAlgorithmIdentifier& signAlgorithm =
		aSigningCertificate.SigningAlgorithm();
	iParams->iSignatureAlgorithm =
		CCMSX509AlgorithmIdentifier::NewL( signAlgorithm.AsymmetricAlgorithm(),
										   signAlgorithm.DigestAlgorithm() );

	// setting issuer
	iParams->iIssuer =
		CX500DistinguishedName::NewL( aSigningCertificate.IssuerName() );

	// setting validity
	const CValidityPeriod& validity = aSigningCertificate.ValidityPeriod();
	iParams->iThisUpdate = validity.Start();
	iParams->iNextUpdate = validity.Finish();


	// copying revoked certificates
	TInt revCerts = aRevokedCertificates.Count();
	if( revCerts > 0 )
		{
		iParams->iRevokedCertificates =
			new( ELeave )CArrayPtrFlat< CCMSX509RevokedCertificate >
												( KDefaultGranularity );
		for( TInt i = 0; i < revCerts; i++ )
			{
			CX509Certificate* cert = aRevokedCertificates[ i ];
			CCMSX509RevokedCertificate* tmpRevCer =
				new(ELeave) CCMSX509RevokedCertificate();
			CleanupStack::PushL( tmpRevCer );
			// convert serial from des to int
            TPtrC8 serialDes = cert->SerialNumber();
            TInt length = serialDes.Size();
            const TUint8* ptr = serialDes.Ptr();
            TInt serial = ( ptr[ 0 ] & 0x80 ) ? -1 : 0;
            for( TInt j = 0; j < length; j++ )
                {
                serial <<= 8;
                serial += *ptr++;
                }
			tmpRevCer->iUserCertificateSerialNumber = serial;

			const CValidityPeriod& reValidity = cert->ValidityPeriod();
			tmpRevCer->iRevokationDate = reValidity.Start();

			// copying extensions
			const CArrayPtrFlat<CX509CertExtension>& extensions =
				cert->Extensions();
			TInt extensionCount = extensions.Count();
			if( extensionCount > 0 )
				{
				tmpRevCer->iExtensions =
					new(ELeave) CArrayPtrFlat<CX509CertExtension>
														( KDefaultGranularity );
				for( TInt j = 0; j < extensionCount; j++ )
					{
					CX509CertExtension* ext = extensions[ j ];
					CX509CertExtension* tmpExt =
									CX509CertExtension::NewLC( *ext );
					tmpRevCer->iExtensions->AppendL( tmpExt );
					CleanupStack::Pop( tmpExt );
					}
				}
			iParams->iRevokedCertificates->AppendL( tmpRevCer );
			CleanupStack::Pop( tmpRevCer );
			}
		}
	// copying possible extensions
	TInt extensionCount = aSigningCertificate.Extensions().Count();
	if( extensionCount > 0 )
		{
		iParams->iExtensions =
			new( ELeave )CArrayPtrFlat< CX509CertExtension >
														( KDefaultGranularity );
		const CArrayPtrFlat< CX509CertExtension >& extensions =
			aSigningCertificate.Extensions();

		for( TInt i = 0; i < extensionCount; i++ )
			{
			CX509CertExtension* copy = CX509CertExtension::NewL( *extensions[ i ] );
			CleanupStack::PushL( copy );
			iParams->iExtensions->AppendL( copy );
			CleanupStack::Pop( copy );
			}
		}

	// copying signature
	iParams->iSignature = aSigningCertificate.Signature().AllocL();
    }
Esempio n. 30
0
// -----------------------------------------------------------------------------
// C3GPExtParser::Is3GPExtMetadataL
// -----------------------------------------------------------------------------
//
EXPORT_C TBool C3GPExtParser::Is3GPExtMetadataL()
	{
#ifdef _DEBUG
	RDebug::Print(_L("C3GPExtParser::3GPExtMetadataL"));
#endif
	HBufC8* frame = HBufC8::NewLC( K3gpMetaLength );
	TUint8* buffer = CONST_CAST(TUint8*, frame->Ptr());

	MP4Err err;
	mp4_u8 udtaLocation = MP4_UDTA_MOOV;
	mp4_u32 bufferSize = K3gpMetaLength;
	mp4_u32 atomIndex = 0;

	err = MP4ParseGetUserDataAtom(iMP4Handle, udtaLocation, K3gpMetaMeta, buffer,
			bufferSize, atomIndex);
	if (bufferSize > (KMaxTInt / 2))
	    {
		User::Leave(KErrNotFound); // no data	    
	    }
	    
	if ( err == MP4_UDTA_NOT_FOUND )
		{
		if ( udtaLocation == MP4_UDTA_NONE || udtaLocation == MP4_UDTA_MOOV )
			{
#ifdef _DEBUG
	RDebug::Print(_L("3GPExtParser::Parse3GPExtL - NotFound"));
#endif
			CleanupStack::PopAndDestroy();  // frame
			return EFalse;
			}
		else
			{
			if ( udtaLocation & MP4_UDTA_AUDIOTRAK )
				{
				udtaLocation = MP4_UDTA_AUDIOTRAK;
				}
			else 	// MP4_UDTA_VIDEOTRAK
				{
				udtaLocation = MP4_UDTA_VIDEOTRAK;
				}
			}
#ifdef _DEBUG
	RDebug::Print(_L("3GPExtParser::Parse3GPExtL - New Location [%d]"), udtaLocation);
#endif
		err = MP4ParseGetUserDataAtom(iMP4Handle, udtaLocation, K3gpMetaMeta, buffer,
			bufferSize, atomIndex);
		}

	if ( err != MP4_OK )
		{
		if ( err == MP4_OUTPUT_BUFFER_TOO_SMALL )
			{
			iChunk.Close();
	
			User::LeaveIfError(iChunk.CreateLocal(bufferSize, bufferSize, EOwnerProcess));
			iChunkStatus = ETrue;
			buffer = iChunk.Base();
			err = MP4ParseGetUserDataAtom(iMP4Handle, udtaLocation, K3gpMetaMeta, buffer, bufferSize, atomIndex);
			if(err != MP4_OK)
				{
				CleanupStack::PopAndDestroy();  // frame
				return EFalse;
				}
			}
		else
			{
			CleanupStack::PopAndDestroy();  // frame
			return EFalse;
			//User::Leave( TranslateMP4Err(err) );
			}
		}

	TPtr8 des(buffer, bufferSize, bufferSize);
	
	// HDLR BOX
	_LIT8(KHdlr, "hdlr");
	TInt hdlrOffset = 16; // header box at constant offset
	TPtrC8 hdlrCheck = des.MidTPtr(hdlrOffset, 4);
	if(hdlrCheck !=  KHdlr)
	{ 
		CleanupStack::PopAndDestroy();  // frame
		return EFalse; // not 3GPExt
	}
	hdlrOffset -= 4; // hdlr box begins at size, 4 bytes back
	
	// get hdlr size
	TPtrC8 sizeHdlrDesc = des.Mid(hdlrOffset, 4);
	TInt32 sizeHdlr = 0;
	for(TInt i = 0 ; i <= 3; i++)
		{	
		sizeHdlr <<= 8;
		sizeHdlr |= sizeHdlrDesc[i];
		}
	if(sizeHdlr <= 0)
	    {
		CleanupStack::PopAndDestroy();  // frame
		return EFalse; // not 3GPExt
	    }
	
	// hdlr ptr
	if (des.Length() < (hdlrOffset + sizeHdlr))
	    {
	    CleanupStack::PopAndDestroy();  // frame
	    return EFalse;  // data corrupted
	    }	        
	TPtrC8 hdlr = des.Mid(hdlrOffset, sizeHdlr);
	
	// match mdirappl
	/**** Comment out the following lines - no need to test for "mdirappl" string	
	TPtrC8 text = hdlr.Mid(16, 8); // at 16 bytes from hdlr box
	_LIT8(KMdirappl, "mdirappl");
	if(text.Compare(KMdirappl) != 0)
	{
		CleanupStack::PopAndDestroy();  	// frame
		return EFalse; 						// not 3GPExt
	}
	*****/   // End comment out "mdirappl" 	

	// iLST BOX
	_LIT8(KIlst, "ilst");
	TInt ilstOffset = hdlrOffset + sizeHdlr + 4;
	if (ilstOffset > bufferSize)
	    {
		CleanupStack::PopAndDestroy();  // frame
		return EFalse; // not 3GPExt	    
	    }
	    
	TPtrC8 ilstCheck = des.MidTPtr(ilstOffset, 4);
	if(ilstCheck !=  KIlst)
	    {
	    ilstOffset = des.Find(KIlst);
	    if(ilstOffset == KErrNotFound)
	        {
	        CleanupStack::PopAndDestroy();  // frame
	        return EFalse; // no list box
	        }
	    }
	ilstOffset -=4; // ilst box begins at size, 4 bytes back
	
	// get ilst size
	TPtrC8 sizeIlstDesc = des.Mid(ilstOffset, 4);
	TUint32 sizeIlst = 0;
	for(TInt i = 0 ; i <= 3; i++)
		{	
		sizeIlst <<= 8;
		sizeIlst |= sizeIlstDesc[i];
		}
	if(sizeIlst <= 0 || sizeIlst > bufferSize - ilstOffset)
	{
		CleanupStack::PopAndDestroy();  // frame
		return EFalse; // no list box
	}
	
	// ilst 
	TPtrC8 tmp = des.Mid(ilstOffset, sizeIlst);
	const TUint8* tmpPtr = tmp.Ptr();
	ilst.Set(tmpPtr, sizeIlst);
	iExists = ETrue;
	
	ParseIlstBoxesL();
	CleanupStack::PopAndDestroy();  // frame	
	return ETrue;
	}