コード例 #1
0
// -----------------------------------------------------------------------------
// CGetPartialObject::VerifyParametersL
// Verify if the parameter of the request (i.e. offset) is good.
// -----------------------------------------------------------------------------
//
TBool CGetPartialObject::VerifyParametersL()
    {
    PRINT( _L( "MM MTP => CGetPartialObject::VerifyParametersL" ) );

    __ASSERT_DEBUG( iRequestChecker, Panic( EMmMTPDpRequestCheckNull ) );
    TBool result = EFalse;
    iObjectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
    iOffset = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
    iPartialDataLength = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );

    PRINT3( _L( "MM MTP <> CGetPartialObject::VerifyParametersL iObjectHandle = 0x%x, iOffset = 0x%x, iMaxLength = 0x%x " ),
        iObjectHandle,
        iOffset,
        iPartialDataLength );

    //get object info, but do not have the ownship of the object
    CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo( iObjectHandle );
    __ASSERT_DEBUG( objectInfo, Panic( EMmMTPDpObjectNull ) );

    const TDesC& suid( objectInfo->DesC( CMTPObjectMetaData::ESuid ) );
    PRINT1( _L( "MM MTP <> CGetPartialObject::VerifyParametersL suid = %S" ), &suid );

    TEntry fileEntry;
    User::LeaveIfError( iFramework.Fs().Entry( suid, fileEntry ) );
    if ( iOffset < fileEntry.FileSize() )
        {
        result = ETrue;
        }

    PRINT1( _L( "MM MTP <= CGetPartialObject::VerifyParametersL result = %d" ), result );
    return result;
    }
コード例 #2
0
ファイル: problem_3.c プロジェクト: risgk/misra_c_problems
int main(int argc, const char * argv[])
{
    int x, y=1, z;

    if( y!=0) x=5;
    PRINT1(d,x);    //(3.1)

    if(y==0) x=3;
    else x=5;
    PRINT1(d,x);    //(3.2)

    x=1;
    if(y<0) if (y>0) x=3;
        else x=5;
    PRINT1(d,x);    //(3.3)

    if (z=y<0) x=3;
    else if (y==0) x=5;
    else x=7;
    PRINT2(d,x,z);  //(3.4)

    if(z =(y==0))x=5;
    x=3;
    PRINT2(d,x,z);  //(3.5)

    if(x=z=y);
    x=3;
    PRINT2(d,x,z);  //(3.6)
    return 0;
}
コード例 #3
0
// ----------------------------------------------------------------------------
// CPcsKeyMap::GetMappedString
// ----------------------------------------------------------------------------
QString CPcsKeyMap::GetMappedString(QString aSource) const
	{
#if defined(WRITE_PRED_SEARCH_LOGS)
	const int KLogLength = 30;
	TBuf<KLogLength> log(aSource.left(KLogLength).utf16());
	PRINT1(_L("Enter CPcsKeyMap::GetMappedString input '%S'"), &log);
#endif

	QString destination;
	TBool skipHashStar = DetermineSpecialCharBehaviour(aSource);
	TInt length = aSource.length();

    for (int i = 0; i < length; ++i)
        {
        if (aSource[i] == KSpaceChar)
            {
            destination.append(KSeparatorChar);
            }
        else
			{
			QChar ch(0);
            ch = MappedKeyForChar(aSource[i]);
			if (!ShouldSkipChar(ch, skipHashStar))
				{
				destination.append(ch);
				}
			}
		}
#if defined(WRITE_PRED_SEARCH_LOGS)
	log = destination.left(KLogLength).utf16();
	PRINT1(_L("End CPcsKeyMap::GetMappedString result '%S'"), &log);
#endif
    return destination;
	}
コード例 #4
0
TBool CPredictiveSearchSynchronizer::CheckIfPredSearchTableExistsL(
	const TDesC& aTableName) const
	{
	PRINT1(_L("CPredictiveSearchSynchronizer::CheckIfPredSearchTableExistsL table='%S'"),
		   &aTableName);

	_LIT(KSelectFirstTableFormat,
		 "SELECT name FROM sqlite_master WHERE type='table' AND name='%S';");

	TInt bufSize = KSelectFirstTableFormat().Length() +
				   aTableName.Length();
	HBufC* select = HBufC::NewLC(bufSize);
	select->Des().AppendFormat(KSelectFirstTableFormat, &aTableName);
	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
    stmnt.PrepareL(iDatabase, *select);

	TBool tableExists = (stmnt.Next() == KSqlAtRow);

	CleanupStack::PopAndDestroy(&stmnt);
	CleanupStack::PopAndDestroy(select);

	PRINT1(_L("CPredictiveSearchSynchronizer::CheckIfPredSearchTablesExistL return %d"),
		   tableExists);
	return tableExists;
	}
コード例 #5
0
// -----------------------------------------------------------------------------
// CMediaMtpDataProviderEnumerator::RunL
// Update the mpx db flag for round trip
// -----------------------------------------------------------------------------
//
void CMediaMtpDataProviderEnumerator::RunL()
    {
    PRINT1( _L( "MM MTP => CMediaMtpDataProviderEnumerator::RunL iStorages.Count() = %d" ), iStorages.Count() );

    if ( iStorages.Count() > 0 )
        {
        const CMTPStorageMetaData& storage( iFramework.StorageMgr().StorageL( iStorages[0] ) );
        TPtrC root( storage.DesC( CMTPStorageMetaData::EStorageSuid ) );
        GetModifiedContentL( root );
        TRAPD( err, iDataProvider.GetWrapperL().UpdateMusicCollectionL( root ) );
        if ( err != KErrNone )
            {
            PRINT1( _L("MM MTP <> CMediaMtpDataProviderEnumerator::RunL, UpdateMusicCollectionL err =%d "), err );            
            }
        iStorages.Remove( 0 );
        TRequestStatus* status = &iStatus;
        User::RequestComplete( status, iStatus.Int() );
        SetActive();
        }
    else
        {
        iStorages.Reset();
        SignalCompleteL( iDataProvider );
        }
    PRINT( _L( "MM MTP <= CMediaMtpDataProviderEnumerator::RunL" ) );
    }
コード例 #6
0
// -----------------------------------------------------------------------------
// CSendObject::SaveEmptyFileL
// -----------------------------------------------------------------------------
//
void CSendObject::SaveEmptyFileL()
    {
    PRINT( _L( "MM MTP => CSendObject::SaveEmptyFileL" ) );

    if ( EMTPFormatCodeAbstractAudioVideoPlaylist == iObjectFormat )
        {
        TInt err = iFileReceived->File().SetAtt( KEntryAttSystem | KEntryAttHidden,
            KEntryAttReadOnly | KEntryAttNormal );
        if ( err != KErrNone )
            PRINT1( _L( "MM MTP <> CSendObject::SaveEmptyFileL err = %d" ), err );
        iDpConfig.GetWrapperL().AddDummyFileL( iFullPath );
        }

    // Set subformat code to avoid MPX query for the first time to GetObjectReference,
    // in which case references has been kept in fw.
    if ( MmMtpDpUtility::HasReference( iObjectFormat ) )
        iReceivedObjectInfo->SetUint( CMTPObjectMetaData::EFormatSubCode, EMTPSubFormatCodeUndefined );

    // add playlist to MPX DB
    TRAPD( err, AddMediaToStoreL() );

    if ( err != KErrNone )
        iRollbackList.Append( &CSendObject::RemoveObjectFromDbL );
    else
        iRollbackList.Reset();

    PRINT1( _L( "MM MTP <= CSendObject::SaveEmptyFileL err = %d" ), err );
    }
コード例 #7
0
// -----------------------------------------------------------------------------
// CSendObject::ExistsL
// Check if the file already exists on the storage.
// -----------------------------------------------------------------------------
//
TBool CSendObject::ExistsL( const TDesC& aName ) const
    {
    PRINT1( _L( "MM MTP => CSendObject::Exists aName = %S" ), &aName );
    // This detects both files and folders
    TBool ret( EFalse );
    ret = BaflUtils::FileExists( iFramework.Fs(), aName );

#ifdef MMMTPDP_REPLACE_EXIST_FILE
    if( ret )
        {
        // delete the old one and replace
        TInt delErr = iFramework.Fs().Delete( aName );
        PRINT1( _L( "MM MTP <> CSendObject::Exists delErr = %d" ), delErr );
        // delete from the metadata DB
        TRAPD( err, iFramework.ObjectMgr().RemoveObjectL( aName ) );
        PRINT1( _L( "MM MTP <> CSendObject::Exists err = %d" ), err );
        if( err == KErrNone )
            {
            // do nothing, ignore warning
            }
        // delete from video/mpx DB
        CMTPObjectMetaData* objectInfo = CMTPObjectMetaData::NewLC(); // + objectInfo
        if ( iFramework.ObjectMgr().ObjectL( aName, *objectInfo ) )
            {
            TRAP_IGNORE( iWrapper.DeleteObjectL( aName,
                    objectInfo->Uint( CMTPObjectMetaData::EFormatCode ) ) );
            }
        CleanupStack::PopAndDestroy( objectInfo ); // - objectInfo
        ret = EFalse;
        }
#endif
    PRINT1( _L( "MM MTP <= CSendObject::Exists ret = %d" ), ret );
    return ret;
    }
コード例 #8
0
// -----------------------------------------------------------------------------
// CGetObject::ServiceL
// GetObject request handler
// -----------------------------------------------------------------------------
//
void CGetObject::ServiceL()
    {
    PRINT( _L( "MM MTP => CGetObject::ServiceL" ) );
    
    MmMtpDpUtility::SetPSStatus(EMtpPSStatusActive);

    // Get the objectinfo
    TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
    PRINT1( _L( "MM MTP <> CGetObject::ServiceL objectHandle = 0x%x" ), objectHandle );

    // NOTE: shouldn't be deleted in destructor, don't have the ownership
    iObjectInfo = iRequestChecker->GetObjectInfo( objectHandle );

    if ( iObjectInfo != NULL )
        {
        // Get the file
        GetObjectL( iObjectInfo->DesC( CMTPObjectMetaData::ESuid  ) );

        // Send the data (file)
        SendDataL( *iFileObject );
        }
    else
        {
        // The object handle has already been checked, so an invalid handle can
        // only occur if it was invalidated during a context switch between
        // the validation time and now.
        iError = EMTPRespCodeInvalidObjectHandle;
        }

    PRINT1( _L( "MM MTP <= CGetObject::ServiceL iError = 0x%x" ), iError );
    }
コード例 #9
0
void CacheSize(TUint aMin, TUint aMax)
	{
	SVMCacheInfo info;
	if (UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&info,0) != KErrNone)
		{
		return;
		}
	
	if (aMin > 0 || aMax > 0)
		{
		if (aMin > 0)
			{
			info.iMinSize = aMin;
			}
		if (aMax > 0)
			{
			info.iMaxSize = aMax;
			}
		UserSvr::HalFunction(EHalGroupVM,EVMHalSetCacheSize,(TAny*)info.iMinSize,(TAny*)info.iMaxSize);
		if (UserSvr::HalFunction(EHalGroupVM,EVMHalGetCacheSize,&info,0) != KErrNone)
			{
			return;
			}
		}

	PRINT1(_L("Paging Cache min size %d"),info.iMinSize);
	PRINT1(_L("  max size %d"),info.iMaxSize);
	PRINT1(_L("  current size %d\n"),info.iCurrentSize);
	}
コード例 #10
0
// ----------------------------------------------------------------------------
// C12keyKeyMap::ReadExtraCharacters
// The special chars that are listed in HbKeyboardSctPortrait, but not in
// HbKeyboardVirtual12Key, are mapped to key-* except the hardcoded characters
// "+*#".
// ----------------------------------------------------------------------------
TInt C12keyKeyMap::ReadExtraCharacters(const HbInputLanguage& aLanguage)
	{
	PRINT(_L("C12keyKeyMap::ReadExtraCharacters"));

	TInt count(0); // How many new keys have been mapped

#if defined(NEW_KEYMAP_FACTORY_API)
	// Takes ownership
	QScopedPointer<const HbKeymap> keymap(
		HbKeymapFactory::instance()->keymap(aLanguage, HbKeymapFactory::NoCaching));
#else
	const HbKeymap* keymap =
		HbKeymapFactory::instance()->keymap(aLanguage, HbKeymapFactory::Default);
#endif

	if (keymap)
		{
		TInt i(0);
		const HbMappedKey* mappedKey = keymap->keyForIndex(HbKeyboardSctPortrait, i);
		while (mappedKey)
			{
			AddNewKeyToMap(EKeyStar, mappedKey->characters(HbModifierNone), count);
			mappedKey = keymap->keyForIndex(HbKeyboardSctPortrait, ++i);
			}
		}
	else
		{
		PRINT1(_L("no keymap for language %d"), aLanguage.language());
		}

    PRINT1(_L("End C12keyKeyMap::ReadExtraCharacters added %d chars"), count);
	return count;
	}
コード例 #11
0
// ----------------------------------------------------------------------------
// CCsServer::RefreshConversations
// Refresh conversations.
// ----------------------------------------------------------------------------
void CCsServer::RefreshConversations()
{
    // NOTE:- NO CHECK DONE NOW ON NUMBER OF PLUGINS TO KEEP IT SIMPLE.
    // NOT EXPECTED TO BE MORE THAN 1 PLUGIN FOR TB 9.2.

    // Delete and recreate cache.
    if (iConversationCache)
    {
        delete iConversationCache;
        iConversationCache = NULL;

        iCsCachingStatus = KCachingStatusUnknown;
        TRAPD(error, iConversationCache = CCsConversationCache::
                NewL(iContactsManager, this));
        if (error != KErrNone)
        {
            PRINT1 ( _L("CCsServer::RefreshConversations - Error:%d"), error );
        }
    }

    // Notify client to refresh
    NotifySessions(NULL, KConversationEventRefresh);
    NotifySessions(NULL, KConversationEventListRefresh);
    // Read again.
    TRAPD(error, iConversationPlugin->GetConversationsL());
    if (error != KErrNone)
    {
        PRINT1 ( _L("CCsServer::RefreshConversations - Error:%d"), error );
    }
}
コード例 #12
0
ファイル: cholmod_factor.c プロジェクト: Al-th/matlab
int CHOLMOD(reallocate_factor)
(
    /* ---- input ---- */
    size_t nznew,	/* new # of entries in L */
    /* ---- in/out --- */
    cholmod_factor *L,	/* factor to modify */
    /* --------------- */
    cholmod_common *Common
)
{
    /* ---------------------------------------------------------------------- */
    /* get inputs */
    /* ---------------------------------------------------------------------- */

    RETURN_IF_NULL_COMMON (FALSE) ;
    RETURN_IF_NULL (L, FALSE) ;
    RETURN_IF_XTYPE_INVALID (L, CHOLMOD_REAL, CHOLMOD_ZOMPLEX, FALSE) ;
    PRINT1 (("realloc factor: xtype %d\n", L->xtype)) ;
    if (L->is_super)
    {
	/* L must be simplicial, and not symbolic */
	ERROR (CHOLMOD_INVALID, "L invalid") ;
	return (FALSE) ;
    }
    Common->status = CHOLMOD_OK ;
    PRINT1 (("realloc factor %g to %g\n", (double) L->nzmax, (double) nznew)) ;

    /* ---------------------------------------------------------------------- */
    /* resize (or allocate) the L->i and L->x components of the factor */
    /* ---------------------------------------------------------------------- */

    CHOLMOD(realloc_multiple) (nznew, 1, L->xtype, &(L->i), NULL,
	    &(L->x), &(L->z), &(L->nzmax), Common) ;
    return (Common->status == CHOLMOD_OK) ;
}
コード例 #13
0
TBool CPredictiveSearchSynchronizer::ReadMailAddressesL(CContactItem& aContact)
	{
	PRINT(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL"));

	// SELECT value FROM comm_addr
	//	 WHERE contact_id = [contact id value] AND type = [type value];
    _LIT(KSelectMailAddrFormat, "SELECT %S FROM %S WHERE %S = %d AND %S = %d;");
	const TInt KContactIdLength = 10;
	const TInt KCommAddrTypeLength = 2; // CPplCommAddrTable::EEmailAddress is enum
	TInt bufSize = KSelectMailAddrFormat().Length() +
				   KCommAddrValue().Length() +
				   KSqlContactCommAddrTableName().Length() +
				   KCommAddrContactId().Length() +
				   KContactIdLength +
				   KCommAddrType().Length() +
				   KCommAddrTypeLength;
	HBufC* sqlStatement = HBufC::NewLC(bufSize);
	sqlStatement->Des().AppendFormat(KSelectMailAddrFormat,
		&KCommAddrValue,
		&KSqlContactCommAddrTableName,
		&KCommAddrContactId,
		aContact.Id(),
		&KCommAddrType,
		CPplCommAddrTable::EEmailAddress);

	RSqlStatement stmnt;
	CleanupClosePushL(stmnt);
	PRINT1(_L("prepare SQL statement:%S"), sqlStatement);
    stmnt.PrepareL(iDatabase, *sqlStatement);

	const TInt KValueIndex = 0;
	TBool foundMailAddress(EFalse);
	TInt err(KErrNone);
    while ((err = stmnt.Next()) == KSqlAtRow)
        {
		TPtrC value;
		if (stmnt.ColumnText(KValueIndex, value) == KErrNone)
			{
			PRINT2(_L("  id=%d, found mail address=%S"), aContact.Id(), &value);
			CContactItemField* field =
				CContactItemField::NewLC(KStorageTypeText, KUidContactFieldEMail);
			CContactTextField* textfield = field->TextStorage();
			textfield->SetTextL(value);
			aContact.AddFieldL(*field); // Takes ownership
			CleanupStack::Pop(field);
			foundMailAddress = ETrue;
			}
        }

    if (err != KSqlAtEnd)
        {
		PRINT1(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL SQL err=%d"), err);
        User::Leave(err);
        }
    CleanupStack::PopAndDestroy(&stmnt);
	CleanupStack::PopAndDestroy(sqlStatement);
	PRINT1(_L("CPredictiveSearchSynchronizer::ReadMailAddressesL return %d"), foundMailAddress);
	return foundMailAddress;
	}
コード例 #14
0
ファイル: uhidd_cc.c プロジェクト: HenryHu/uhidd
static void
cc_process_volume_usage(struct hid_appcol *ha, struct hid_report *hr, int value)
{
	struct hid_interface *hi;
	struct hid_field *hf;
	int i, flags, total;
	struct hid_key keycodes[MAX_KEYCODE];
	uint16_t key;

	/*
	 * HUG_VOLUME has Usage Type LC (linear control). Usually it has
	 * value range [-Min, Max]. Positive value n increments the volume
	 * by n. Negative value -n decrements the volumn by n. To fit in
	 * our key press/release model, HUG_VOLUME is simulated by
	 * pressing/releasing HUG_VOLUME_UP or HUG_VLOLUME_DOWN n times.
	 */

	hi = hid_appcol_get_parser_private(ha);
	assert(hi != NULL);

	/* Do nothing if value is 0. */
	if (value == 0)
		return;

	/* The keyboard driver needs to know the total number of keys. */
	total = 0;
	hf = NULL;
	while ((hf = hid_report_get_next_field(hr, hf, HID_INPUT)) != NULL) {
		flags = hid_field_get_flags(hf);
		if (flags & HIO_CONST)
			continue;
		for (i = 0; i < hf->hf_count; i++)
			total++;
	}
	if (total >= MAX_KEYCODE)
		return;

	if (value < 0)
		key = HUG_VOLUME_DOWN;
	else
		key = HUG_VOLUME_UP;
	value = abs(value);

	memset(keycodes, 0, sizeof(keycodes));
	for (i = 0; i < value; i++) {
		/* Key press. */
		keycodes[0].code = key;
		keycodes[0].up = HUP_CONSUMER;
		kbd_input(ha, 0, keycodes, total);
		if (verbose > 1)
			PRINT1("hid codes: 0x%02X (HUG_VOLUME)\n",
			    keycodes[0].code);
		/* Key release. */
		keycodes[0].code = 0;
		kbd_input(ha, 0, keycodes, total);
		if (verbose > 1)
			PRINT1("hid codes: none (HUG_VOLUME)\n");
	}
}
コード例 #15
0
// ---------------------------------------------------------------------------
// CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL
// Gets a piece of metadata from the collection
// ---------------------------------------------------------------------------
//
EXPORT_C void CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL( const TUint16 aPropCode,
    MMTPType& aNewData,
    const CMTPObjectMetaData& aObjectMetaData )
    {
    PRINT( _L( "MM MTP => CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );

    TMPXGeneralCategory category = Category( aObjectMetaData );
    switch ( category )
        {
        case EMPXAbstractAlbum:
            if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() )
                {
                TBuf<KMtpMaxDateTimeStringLength> timeStr;
                MmMtpDpUtility::GetObjectDateModifiedL( iFs,
                    aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
                    timeStr );
                PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr );

                ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
                break;
                }
            // else
            // Fall through on purpoe to get from mpx
        case EMPXPlaylist:
        case EMPXSong:
            {
            iMmMtpDpMetadataMpxAccess->GetObjectMetadataValueL( aPropCode,
                aNewData,
                aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
                category );
            }
            break;
        case EMPXVideo:
            if ( aPropCode == EMTPObjectPropCodeDateAdded && EMTPTypeString == aNewData.Type() )
                {
                TBuf<KMtpMaxDateTimeStringLength> timeStr;
                MmMtpDpUtility::GetObjectDateModifiedL( iFs,
                    aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ),
                    timeStr );
                PRINT1( _L( "MM MTP <> CGetObjectPropList::ServiceOneObjectPropertyL Date time %S" ), &timeStr );

                ( ( CMTPTypeString & ) aNewData ).SetL( timeStr );
                }
            else
                {
                iMmMtpDpMetadataVideoAccess->GetObjectMetadataValueL( aPropCode,
                    aNewData,
                    aObjectMetaData );
                }
            break;
        default:
            // do nothing
            break;
        }

    PRINT( _L( "MM MTP <= CMmMtpDpMetadataAccessWrapper::GetObjectMetadataValueL" ) );
    }
コード例 #16
0
void CreateChunk(RChunk * aChunk, TUint aSize)
	{
	TESTNEXT(_L("Creating a paged chunk"));
	TChunkCreateInfo createInfo;
	PRINT1(_L("Creating chunk size 0x%08X bytes "),aSize);
	PRINT1(_L("at index %d\n"),gNextChunk);
	createInfo.SetPaging(TChunkCreateInfo::EPaged);
	createInfo.SetNormal(aSize,aSize);
	test_KErrNone(aChunk->Create(createInfo));
	}
コード例 #17
0
// -----------------------------------------------------------------------------
// CMediaMtpDataProvider::Supported
// Defines the supported operations and formats of the data provider
// -----------------------------------------------------------------------------
//
void CMediaMtpDataProvider::Supported( TMTPSupportCategory aCategory,
    RArray<TUint>& aArray ) const
    {
    switch ( aCategory )
        {
        case EEvents:
            break;

        case EObjectCaptureFormats:
        case EObjectPlaybackFormats:
            {
            TInt count = sizeof( KMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 );
            for ( TInt i = 0; i < count; i++ )
                {
                aArray.Append( KMediaMtpDataProviderSupportedFormats[i] );
                }
            PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported format count = %d" ), count );
            }
            break;

        case EOperations:
            {
            TInt count = sizeof( KMediaMtpDataProviderSupportedOperations ) / sizeof( TUint16 );

            for ( TInt i = 0; i < count; i++ )
                {
                aArray.Append( KMediaMtpDataProviderSupportedOperations[i] );
                }
            PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported operation count = %d" ), count );
            }
            break;

        case EObjectProperties:
            {
            TInt count = iSupportedPropAll.Count();

            for ( TInt i = 0; i < count; i++ )
                {
                aArray.Append( iSupportedPropAll[i] );
                }
            PRINT1( _L( "MM MTP <> CMediaMtpDataProvider::Supported properties count = %d" ), aArray.Count() );
            }
            break;

        case EStorageSystemTypes:
            {
            aArray.Append( CMTPStorageMetaData::ESystemTypeDefaultFileSystem );
            }
            break;

        default:
            // Unrecognised category, leave aArray unmodified.
            break;
        }
    }
コード例 #18
0
// -----------------------------------------------------------------------------
// CSendObject::MatchStoreAndParentL
// -----------------------------------------------------------------------------
//
TMTPResponseCode CSendObject::MatchStoreAndParentL()
    {
    TMTPResponseCode responseCode = EMTPRespCodeOK;

    iStorageId = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
    iParentHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
    PRINT2( _L( "MM MTP <> CSendObject::MatchStoreAndParentL, iStorageId = 0x%x, iParentHandle = 0x%x" ),
        iStorageId,
        iParentHandle );

    if ( iStorageId == KMTPStorageDefault )
        {
        iStorageId = iDpConfig.GetDefaultStorageIdL();
        PRINT1( _L( "MM MTP <> CSendObject::GetDefaultStorageIdL, iStorageId = 0x%x" ), iStorageId );
        }

    delete iParentSuid;
    iParentSuid = NULL;

    if( iParentHandle == KMTPHandleNone )   // parentHandle is not used by initiator, set it to root
        {
        iParentHandle = KMTPHandleAll;
        }
    if ( iParentHandle == KMTPHandleAll )   // According to spec, KMTPHandleAll means initiator wish to place in the root
        {
        PRINT( _L( "MM MTP <> CSendObject::MatchStoreAndParentL, iParentSuid = KMTPHandleAll" ) );
        iParentSuid = iFramework.StorageMgr().StorageL( iStorageId ).DesC( CMTPStorageMetaData::EStorageSuid ).AllocL();
        PRINT1( _L( "MM MTP <> CSendObject::MatchStoreAndParentL, iParentSuid = %S" ), iParentSuid );
        }
    else    // parentHandle is specified by initiator
        {
        // does not take owernship
        CMTPObjectMetaData* parentObjInfo = iRequestChecker->GetObjectInfo( iParentHandle );
        __ASSERT_DEBUG( parentObjInfo, Panic( EMmMTPDpObjectNull ) );

        if ( parentObjInfo->Uint( CMTPObjectMetaData::EStorageId ) != iStorageId )
            {
            responseCode = EMTPRespCodeInvalidObjectHandle;
            PRINT( _L( "MM MTP <> CSendObject::MatchStoreAndParentL, STORAGEID DOES NOT MATCH WITH PARENTHANDLE!" ) );
            }
        else
            {
            iParentSuid = parentObjInfo->DesC( CMTPObjectMetaData::ESuid ).AllocL();
            }
        }
    PRINT1( _L( "MM MTP <> CSendObject::MatchStoreAndParentL, iParentSuid = %S" ), iParentSuid );

    if ( ( responseCode == EMTPRespCodeOK ) && !BaflUtils::PathExists( iFramework.Fs(), *iParentSuid ) )
        {
        responseCode = EMTPRespCodeInvalidDataset;
        }

    return responseCode;
    }
コード例 #19
0
// -----------------------------------------------------------------------------
// CSendObject::CheckSendingState
// Helper Functions
// Verify if the SendObject request comes after SendObjectInfo request
// @return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise
// EMTPRespCodeNoValidObjectInfo
// -----------------------------------------------------------------------------
//
TMTPResponseCode CSendObject::CheckSendingStateL()
    {
    PRINT( _L( "MM MTP => CSendObject::CheckSendingState" ) );

    TMTPResponseCode result = EMTPRespCodeOK;
    iOperationCode = Request().Uint16( TMTPTypeRequest::ERequestOperationCode );
    PRINT1( _L( "MM MTP <> CSendObject iOperationCode = 0x%x" ), iOperationCode );

    if ( iOperationCode == EMTPOpCodeSendObject )
        {
        // In ParseRouter everytime SendObject gets resolved then will be removed from Registry
        // right away therefore we need reRegister it here again in case possible cancelRequest
        // against this SendObject being raised.
        iExpectedSendObjectRequest.SetUint32( TMTPTypeRequest::ERequestSessionID,
            iSessionId );
        iFramework.RouteRequestRegisterL( iExpectedSendObjectRequest,
            iConnection );
        }

    if ( iProgress == EObjectNone )
        {
        if ( iOperationCode == EMTPOpCodeSendObject )
            {
            PRINT( _L( "MM MTP <> CSendObject::CheckSendingState  EMTPRespCodeNoValidObjectInfo" ) );
            result = EMTPRespCodeNoValidObjectInfo;
            }
        }
    else if ( iProgress == EObjectInfoSucceed )
        {
        if ( iOperationCode == EMTPOpCodeSendObjectInfo )
            {
            delete iObjectInfo;
            iObjectInfo = NULL;
            Rollback();
            iProgress = EObjectNone;
            }
        else if ( iOperationCode == EMTPOpCodeSendObjectPropList )
            {
            delete iObjectPropList;
            iObjectPropList = NULL;
            Rollback();
            iProgress = EObjectNone;
            }
        }
    else
        {
        Panic( EMmMTPDpSendObjectStateInvalid );
        }

    PRINT1( _L( "MM MTP <= CSendObject::CheckSendingState result = 0x%x" ), result );

    return result;
    }
コード例 #20
0
// -----------------------------------------------------------------------------
// CMmMtpDpMetadataAccessWrapper::DeleteDummyFile
// Delete one dummy file from dummy files array
// -----------------------------------------------------------------------------
//
EXPORT_C void CMmMtpDpMetadataAccessWrapper::DeleteDummyFile( const TDesC& aDummyFileName )
    {
    PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile aDummyFileName(%S)" ), &aDummyFileName );
    TInt pos = 0;
    if ( iAbstractMediaArray->Count() > 0 )
        {
        if ( 0 == iAbstractMediaArray->Find( aDummyFileName, pos ) )
            {
            PRINT1( _L( "MM MTP <> CMmMtpDpMetadataAccessWrapper::DeleteDummyFile pos = %d" ), pos );
            iAbstractMediaArray->Delete( pos );
            }
        }
    }
コード例 #21
0
void ThreadedAudioDevice::waitForThread(int waitMs)
{
	if (!isPassive()) {
		assert(_thread != 0);	// should not get called again!
		PRINT1("ThreadedAudioDevice::waitForThread: waiting for thread to finish\n");
		if (pthread_join(_thread, NULL) == -1) {
			PRINT0("ThreadedAudioDevice::doStop: terminating thread!\n");
			// JWM: pthread_cancel is not available in Android
			//pthread_cancel(_thread);
			//_thread = 0;
		}
		PRINT1("\tThreadedAudioDevice::waitForThread: thread done\n");
	}
}
コード例 #22
0
static int allocate_simplicial_numeric
(
    cholmod_factor *L,
    cholmod_common *Common
)
{
    Int n ;
    Int *Lp, *Lnz, *Lprev, *Lnext ;
    size_t n1, n2 ;

    PRINT1 (("Allocate simplicial\n")) ;

    ASSERT (L->xtype == CHOLMOD_PATTERN || L->is_super) ;
    ASSERT (L->p == NULL) ;
    ASSERT (L->nz == NULL) ;
    ASSERT (L->prev == NULL) ;
    ASSERT (L->next == NULL) ;

    n = L->n ;

    /* this cannot cause size_t overflow */
    n1 = ((size_t) n) + 1 ;
    n2 = ((size_t) n) + 2 ;

    Lp = CHOLMOD(malloc) (n1, sizeof (Int), Common) ;
    Lnz = CHOLMOD(malloc) (n, sizeof (Int), Common) ;
    Lprev = CHOLMOD(malloc) (n2, sizeof (Int), Common) ;
    Lnext = CHOLMOD(malloc) (n2, sizeof (Int), Common) ;

    if (Common->status < CHOLMOD_OK)
    {
	CHOLMOD(free) (n1, sizeof (Int), Lp,    Common) ;
	CHOLMOD(free) (n,   sizeof (Int), Lnz,   Common) ;
	CHOLMOD(free) (n2, sizeof (Int), Lprev, Common) ;
	CHOLMOD(free) (n2, sizeof (Int), Lnext, Common) ;
	PRINT1 (("Allocate simplicial failed\n")) ;
	return (FALSE) ;	/* out of memory */
    }

    /* ============================================== commit the changes to L */

    L->p = Lp ;
    L->nz = Lnz ;
    L->prev = Lprev ;
    L->next = Lnext ;
    /* initialize a doubly linked list for columns in natural order */
    natural_list (L) ;
    PRINT1 (("Allocate simplicial done\n")) ;
    return (TRUE) ;
}
コード例 #23
0
// -----------------------------------------------------------------------------
// CSendObject::SetFileProperties
// -----------------------------------------------------------------------------
//
void CSendObject::SetFileProperties()
    {
    PRINT1( _L( "MM MTP => CSendObject::SetFileProperties iProtectionStatus = %d" ), iProtectionStatus );

    if ( iFileReceived != NULL )
        {
        if ( iProtectionStatus == EMTPProtectionNoProtection
            || iProtectionStatus == EMTPProtectionReadOnly )
            {
            TInt err = KErrNone;
            if ( iProtectionStatus == EMTPProtectionNoProtection )
                {
                err = iFileReceived->File().SetAtt( KEntryAttNormal, KEntryAttReadOnly );
                }
            else
                {
                err = iFileReceived->File().SetAtt( KEntryAttReadOnly, KEntryAttNormal );
                }
    
            if ( err != KErrNone )
                {
                PRINT1( _L( "MM MTP <> CSendObject::SetFileProperties SetAtt err = %d" ), err );
                }
            }

        if( iDateMod != NULL )
            {
            TTime modTime( 0 );
            TInt err = MmMtpDpUtility::DesToTTime( *iDateMod, modTime );
            if( err == KErrNone )
                {
                err = iFileReceived->File().SetModified( modTime );
                PRINT1( _L( "MM MTP <> CSendObject::SetFileProperties SetModified err = %d" ), err );
                }
            }

        // Close the file after SetFileProperties to make sure other process won't open
        // the file successfully right at the time calling RFile::SetAtt.
        if ( iObjectSize > 0 )
            {
            delete iFileReceived;
            iFileReceived = NULL;
            }
        else
            iFileReceived->File().Close();
        }

    PRINT( _L( "MM MTP <= CSendObject::SetFileProperties" ) );
    }
コード例 #24
0
void ThreadedAudioDevice::waitForThread(int waitMs)
{
	if (!isPassive()) {
//f		assert(_thread != 0);	// should not get called again!
		PRINT1("ThreadedAudioDevice::waitForThread: waiting for thread to finish\n");
//		if (pthread_join(_thread, NULL) == -1) {
//			PRINT0("ThreadedAudioDevice::doStop: terminating thread!\n");
//#ifndef OF_ANDROID
//			pthread_cancel(_thread);
//#endif
//			_thread = 0;
//		}
		PRINT1("\tThreadedAudioDevice::waitForThread: thread done\n");
	}
}
コード例 #25
0
// -----------------------------------------------------------------------------
// CMoveObject::CanMoveObjectL
// Check if we can move the file to the new location
// -----------------------------------------------------------------------------
//
TMTPResponseCode CMoveObject::CanMoveObjectL( const TDesC& aOldName,
    const TDesC& aNewName ) const
    {
    PRINT2( _L( "MM MTP => CMoveObject::CanMoveObjectL aOldName = %S, aNewName = %S" ),
        &aOldName,
        &aNewName );
    TMTPResponseCode result = EMTPRespCodeOK;

    TEntry fileEntry;
    User::LeaveIfError( iFramework.Fs().Entry( aOldName, fileEntry ) );
    TInt drive = iFramework.StorageMgr().DriveNumber( iStorageId );
    User::LeaveIfError( drive );
    TVolumeInfo volumeInfo;
    User::LeaveIfError( iFramework.Fs().Volume( volumeInfo, drive ) );

    if ( volumeInfo.iFree < fileEntry.FileSize() )
        {
        result = EMTPRespCodeStoreFull;
        }
    else if ( BaflUtils::FileExists( iFramework.Fs(), aNewName ) )
        {
#ifdef MMMTPDP_REPLACE_EXIST_FILE
        // delete the old one and replace
        TInt delErr = iFramework.Fs().Delete( aNewName );
        PRINT1( _L( "MM MTP <> CMoveObject::CanMoveObjectL delErr = %d" ), delErr );
        // delete from the metadata DB
        TRAPD( err, iFramework.ObjectMgr().RemoveObjectL( aNewName ) );
        PRINT1( _L( "MM MTP <> CMoveObject::CanMoveObjectL err = %d" ), err );
        // delete from video/mpx DB
        CMTPObjectMetaData* objectInfo = CMTPObjectMetaData::NewLC(); // + objectInfo
        if ( iFramework.ObjectMgr().ObjectL( aNewName, *objectInfo ) )
            {
            TRAP( err, iDpConfig.GetWrapperL().DeleteObjectL( aNewName,
                objectInfo->Uint( CMTPObjectMetaData::EFormatCode ) ) );
            }
        CleanupStack::PopAndDestroy( objectInfo ); // - objectInfo
        if ( err )
            {
            // do nothing
            }
#else
        result = EMTPRespCodeInvalidParentObject;
#endif
        }

    PRINT1( _L( "MM MTP <= CMoveObject::CanMoveObjectL result = 0x%x" ), result );
    return result;
    }
コード例 #26
0
// ----------------------------------------------------------------------------
// CPcsKeyMap::GetMappedStringL
// ----------------------------------------------------------------------------
HBufC* CPcsKeyMap::GetMappedStringL(const TDesC& aSource) const
    {
    PRINT1(_L("Enter CPcsKeyMap::GetMappedStringL input '%S'"), &aSource);

	QString source((QChar*)aSource.Ptr(), aSource.Length());
	QString result;
	TInt err(KErrNone);
	QT_TRYCATCH_ERROR(err, result = GetMappedString(source));
	User::LeaveIfError(err);

    HBufC* destination = HBufC::NewL(result.length());
	destination->Des().Copy(result.utf16());

    PRINT1(_L("End CPcsKeyMap::GetMappedStringL result '%S'"), destination);
    return destination;
    }
コード例 #27
0
int ThreadedAudioDevice::waitForDevice(unsigned int wTime) {
	int ret;
	unsigned waitSecs = int(wTime / 1000.0);
	unsigned waitUsecs = 1000 * (wTime - unsigned(waitSecs * 1000));
	// Wait wTime msecs for select to return, then bail.
	if (!stopping()) {
		int nfds = _device + 1;
		struct timeval tv;
		tv.tv_sec = waitSecs;
		tv.tv_usec = waitUsecs;
		// If wTime == 0, wait forever by passing NULL as the final arg.
//		if (!isPlaying())
//			printf("select(%d, 0x%x, 0x%x, NULL, 0x%x)...\n", 
//					nfds, &_rfdset, &_wfdset, wTime == 0 ?  NULL : &tv);
		int selret = ::select(nfds, &_rfdset, &_wfdset,
							  NULL, wTime == 0 ?  NULL : &tv);
		if (selret <= 0) {
			if (errno != EINTR)
				fprintf(stderr,
						"ThreadedAudioDevice::waitForDevice: select %s\n",
						(selret == 0) ? "timed out" : "returned error");
			ret = -1;
		}
		else {
			setFDSet();
			ret = 0;
		}
	}
	else {
		PRINT1("ThreadedAudioDevice::waitForDevice: stopping == true\n");
		ret = 1;
	}
	return ret;
}
コード例 #28
0
// -----------------------------------------------------------------------------
// CDescriptionUtility::NewRangeFormDescriptionL
//
// -----------------------------------------------------------------------------
//
EXPORT_C CMTPTypeObjectPropDesc* CDescriptionUtility::NewRangeFormDescriptionL( TUint16 aPropertyCode,
    TUint32 aMinValue,
    TUint32 aMaxValue,
    TUint32 aStepValue,
    TBool aIsReadOnly )
    {
    PRINT1( _L( "MM MTP => CDescriptionUtility::NewRangeFormDescriptionL, aPropertyCode = 0x%x" ),
        aPropertyCode );
    CMTPTypeObjectPropDescRangeForm* form =
        CMTPTypeObjectPropDescRangeForm::NewLC( EMTPTypeUINT32 ); // + form

    // Set expected values
    form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMinimumValue, aMinValue );
    form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EMaximumValue, aMaxValue );
    form->SetUint32L( CMTPTypeObjectPropDescRangeForm::EStepSize, aStepValue );

    CMTPTypeObjectPropDesc::TPropertyInfo propertyInfo;
    propertyInfo.iDataType = EMTPTypeUINT32;
    propertyInfo.iFormFlag = CMTPTypeObjectPropDesc::ERangeForm;
    propertyInfo.iGetSet = !aIsReadOnly;

    CMTPTypeObjectPropDesc* propertyDesc = CMTPTypeObjectPropDesc::NewL( aPropertyCode,
        propertyInfo,
        form );    // + propertyDesc

    CleanupStack::PopAndDestroy( form ); // - form
    PRINT( _L( "MM MTP <= CDescriptionUtility::NewRangeFormDescriptionL" ) );

    return propertyDesc;
    }
コード例 #29
0
// -----------------------------------------------------------------------------
// CMoveObject::MoveFileL
// A helper function of MoveObjectL
// -----------------------------------------------------------------------------
//
void CMoveObject::MoveFileL( const TDesC& aNewFileName )
    {
    HBufC* oldFileName = iObjectInfo->DesC( CMTPObjectMetaData::ESuid ).AllocLC(); // + oldFileName
    PRINT2( _L( "MM MTP => CMoveObject::MoveFileL old name = %S, aNewFileName = %S" ),
        oldFileName,
        &aNewFileName );

    if ( iStorageId == iObjectInfo->Uint( CMTPObjectMetaData::EStorageId ) )
        iSameStorage = ETrue;
    else
        iSameStorage = EFalse;

    // Move the file first no matter if it will fail in Get/SetPreviousPropertiesL
    // Already trapped inside
    GetPreviousPropertiesL( *iObjectInfo );
    TRAP_IGNORE( SetPropertiesL( aNewFileName ) );

    CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() );
    CleanupStack::PushL( fileMan ); // + fileMan
    TInt err = fileMan->Move( *oldFileName, aNewFileName );
    PRINT1( _L( "MM MTP <> CMoveObject::MoveFileL err = %d" ), err );
    User::LeaveIfError( err );
    CleanupStack::PopAndDestroy( fileMan ); // - fileMan
    CleanupStack::PopAndDestroy( oldFileName );     // - oldFileName

    PRINT( _L( "MM MTP <= CMoveObject::MoveFileL" ) );
    }
コード例 #30
0
// -----------------------------------------------------------------------------
// CMoveObject::GetParametersL
// Retrieve the parameters of the request
// -----------------------------------------------------------------------------
//
void CMoveObject::GetParametersL()
    {
    PRINT( _L( "MM MTP => CMoveObject::GetParametersL" ) );

    __ASSERT_DEBUG( iRequestChecker, Panic( EMmMTPDpRequestCheckNull ) );

    TUint32 objectHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
    iStorageId = Request().Uint32( TMTPTypeRequest::ERequestParameter2 );
    iNewParentHandle = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
    PRINT3( _L( "MM MTP <> objectHandle = 0x%x, iStorageId = 0x%x, iNewParentHandle = 0x%x" ),
        objectHandle,
        iStorageId,
        iNewParentHandle );

    // not taking owernship
    iObjectInfo = iRequestChecker->GetObjectInfo( objectHandle );
    __ASSERT_DEBUG( iObjectInfo, Panic( EMmMTPDpObjectNull ) );

    if ( iNewParentHandle == KMTPHandleNone )
        {
        SetDefaultParentObjectL();
        }
    else
        {
        CMTPObjectMetaData* parentObject = iRequestChecker->GetObjectInfo( iNewParentHandle );
        __ASSERT_DEBUG( parentObject, Panic( EMmMTPDpObjectNull ) );

        delete iDest;
        iDest = NULL;
        iDest = parentObject->DesC( CMTPObjectMetaData::ESuid ).AllocL();
        PRINT1( _L( "MM MTP <> CMoveObject::GetParametersL iDest = %S" ), iDest );
        }
    PRINT( _L( "MM MTP <= CMoveObject::GetParametersL" ) );
    }