// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateGetParentsIdsQueryL(
        const RArray<TInt>& aEntryIdArray, CCaSqlQuery* aSqlQuery,
        const RArray<TInt>& aParentIdArray )
    {
    DEBUG(("_CA_:CASqlQueryCreator::CreateGetParentsIdsQueryL"));
    RBuf entryIdList;
    entryIdList.CleanupClosePushL();
    CreateIdListL( aEntryIdArray.Count(), entryIdList, KSQLGEEntryId );
    RBuf parentIdList;
    parentIdList.CleanupClosePushL();
    CreateIdListL( aParentIdArray.Count(), parentIdList, KSQLGEIdGroup );

    RBuf query;
    query.CleanupClosePushL();
    query.CreateL( KSQLGetParentIds().Length() + entryIdList.Length() );
    query.AppendFormat( KSQLGetParentIds, &entryIdList );
    if( aParentIdArray.Count() > 0 )
        {
        query.ReAllocL( query.Length() + parentIdList.Length()
                + KSQLNotINIds().Length() );
        query.AppendFormat( KSQLNotINIds, &parentIdList );
        }

    aSqlQuery->SetQueryL( query );

    CleanupStack::PopAndDestroy( &query );
    CleanupStack::PopAndDestroy( &parentIdList );
    CleanupStack::PopAndDestroy( &entryIdList );
    }
示例#2
0
void CPluginUtils::AddUrlParamL( RBuf& aBuf, const TDesC& aParam, const TDesC& aValue, TBool aLast)
	{
	aBuf.ReAllocL( aBuf.Length() + 1 + aParam.Length() + aValue.Length() );
	aBuf.Append( aParam );
	aBuf.Append( _L("=") );
	aBuf.Append( aValue );

	if( !aLast )
		{
		aBuf.ReAllocL( aBuf.Length() + 1 );
		aBuf.Append( _L("&") );
		}
	}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::ModifyQueryForSortOrderLastMostUsedL(
        const CCaInnerQuery::TSortAttribute aSortType, RBuf& aQuery )
    {
    DEBUG(("_CA_:CASqlQueryCreator::ModifyQueryForSortOrderLastMostUsedL"));

    RBuf descPart;
    descPart.CleanupClosePushL();
    if( aSortType == CCaInnerQuery::MostUsedDesc || 
         aSortType == CCaInnerQuery::LastUsedDesc )
        {
        descPart.CreateL( KDesc );
        }
    else
        {
        descPart.CreateL( KNullDesC );
        }

    RBuf usageDataQuery;
    usageDataQuery.CleanupClosePushL();
    if( aSortType == CCaInnerQuery::MostUsed || 
         aSortType == CCaInnerQuery::MostUsedDesc )
        {
        usageDataQuery.CreateL( KSQLGetMostUsed );
        }
    else
        {
        usageDataQuery.CreateL( KSQLGetLastUsed );
        }

    RBuf newQuery;
    newQuery.CleanupClosePushL();
    newQuery.CreateL( KSQLGetListByLaunchDataPart1().Length() +
            KSQLGetListByLaunchDataPart1().Length() +
            KSQLGetListByLaunchDataPart3().Length() +
            usageDataQuery.Length() +
            descPart.Length() +
            aQuery.Length() );
    newQuery.Append( KSQLGetListByLaunchDataPart1 );
    newQuery.Append( aQuery );
    newQuery.Append( KSQLGetListByLaunchDataPart2 );
    newQuery.Append( usageDataQuery );
    newQuery.Append( KSQLGetListByLaunchDataPart3 );
    newQuery.Append( descPart );
    aQuery.Close();
    aQuery.CreateL( newQuery );

    CleanupStack::PopAndDestroy( &newQuery );
    CleanupStack::PopAndDestroy( &usageDataQuery );
    CleanupStack::PopAndDestroy( &descPart );
    }
示例#4
0
void CPluginUtils::AddUrlParamL( RBuf& aBuf, const TDesC& aParam, TInt aValue, TBool aLast )
	{
	TBuf<12> t;
	t.Format( _L("%d"), aValue );
	aBuf.ReAllocL( aBuf.Length() + 1 + aParam.Length() + t.Length() );
	aBuf.Append( aParam );
	aBuf.Append( _L("=") );
	aBuf.Append( t );

	if( !aLast )
		{
		aBuf.ReAllocL( aBuf.Length() + 1 );
		aBuf.Append( _L("&") );
		}
	}
void CQueueEntry::InternalizeL( RReadStream& aStream )
    {
    TInt size;
    RBuf text;
	CleanupClosePushL( text );
    RBuf8 text8;
	CleanupClosePushL( text8 );

    size =  aStream.ReadInt32L( );
    text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetUrlL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetTitleL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetTagsL(text);

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetDescriptionL( text );

    size =  aStream.ReadInt32L( );
    if( size > text.Length() ) text.ReAllocL( size );
    aStream.ReadL( text, size ); 
    SetFilename( text );

	CleanupStack::PopAndDestroy( &text8 );
	CleanupStack::PopAndDestroy( &text );
    
    iType = (TEntryType) aStream.ReadInt32L( );

	iStatus = (TEntryStatus) aStream.ReadInt32L( );

	iCategory = (TMovieCategory) aStream.ReadInt32L( );

	iPublic = aStream.ReadInt32L( );
		
	iSize = aStream.ReadInt32L( );

	iUid = aStream.ReadInt32L( );
    }
示例#6
0
HBufC* CPluginUtils::ConvertUtfToUnicodeL( const TDesC8& aUtf7 )
	{

	RBuf output;
	CleanupClosePushL( output );
	
	TBuf16<20> outputBuffer;
	TPtrC8 remainderOfUtf7( aUtf7 );

	for(;;)
		{
		const TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(outputBuffer, remainderOfUtf7);
		if (returnValue==CnvUtfConverter::EErrorIllFormedInput)
			return NULL;
		else if (returnValue<0)
			return NULL;
        
		output.ReAllocL( output.Length() + outputBuffer.Length() );
		output.Append( outputBuffer );

        if (returnValue == 0)
            break;

        remainderOfUtf7.Set(remainderOfUtf7.Right(returnValue));
		}

	HBufC* ret = output.AllocL();
	
	CleanupStack::PopAndDestroy( &output );
	return ret;
	}
示例#7
0
// -----------------------------------------------------------------------------
// CMoveObject::MoveObjectL
// Move object operation
// -----------------------------------------------------------------------------
//
void CMoveObject::MoveObjectL()
    {
    PRINT( _L( "MM MTP => CMoveObject::MoveObjectL" ) );
    TMTPResponseCode responseCode = EMTPRespCodeOK;

    GetParametersL();

    RBuf newObjectName;
    newObjectName.CreateL( KMaxFileName );
    newObjectName.CleanupClosePushL(); // + newObjectName
    newObjectName = *iDest;

    TPtrC suid( iObjectInfo->DesC( CMTPObjectMetaData::ESuid ) );
    TParsePtrC fileNameParser( suid );
    if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() )
        <= newObjectName.MaxLength() )
        {
        newObjectName.Append( fileNameParser.NameAndExt() );
        responseCode = CanMoveObjectL( suid, newObjectName );

        if ( responseCode == EMTPRespCodeOK )
            MoveFileL( newObjectName );
        }
    else
        // Destination is not appropriate for the full path name shouldn't be longer than 255
        responseCode = EMTPRespCodeInvalidDataset;

    SendResponseL( responseCode );

    CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName

    PRINT1( _L( "MM MTP <= CMoveObject::MoveObjectL responseCode = 0x%x" ), responseCode );
    }
/**
A helper function of MoveObjectL.
@param aNewFolderName the new file folder name after the folder is moved.
*/
void CMTPMoveObject::MoveFolderL()
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEFOLDERL_ENTRY );

    RBuf oldFolderName;
    oldFolderName.CreateL(KMaxFileName);
    oldFolderName.CleanupClosePushL();
    oldFolderName = iObjectInfo->DesC(CMTPObjectMetaData::ESuid);
    iPathToMove = oldFolderName.AllocL();

    if (iObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId())
    {
        GetPreviousPropertiesL(oldFolderName);
        // Remove backslash.
        oldFolderName.SetLength(oldFolderName.Length() - 1);
        SetPreviousPropertiesL(*iNewRootFolder);
        _LIT(KBackSlash, "\\");
        oldFolderName.Append(KBackSlash);

        iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewRootFolder);
        iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
        iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
        iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo);
    }

    CleanupStack::PopAndDestroy(); // oldFolderName.

    OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEFOLDERL_EXIT );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateFindIconQueryL( CCaInnerEntry* aEntry,
        CCaSqlQuery* aQuery)
    {
    RBuf iconQuery;
    iconQuery.CleanupClosePushL();
    iconQuery.CreateL( KSQLGetIconIdWhere );

    if( aEntry->Icon()->FileName().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconFileName().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconFileName );
        iconQuery.Append( KAnd );
        }
    else
        { 
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconFileName().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconFileName );
        iconQuery.Append( KAnd );
        }

    if( aEntry->Icon()->SkinId().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconSkinId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconSkinId );
        iconQuery.Append( KAnd );
        }
    else
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconSkinId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconSkinId );
        iconQuery.Append( KAnd );
        }

    if( aEntry->Icon()->ApplicationId().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconAppId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconAppId );
        iconQuery.Append( KAnd );
        }
    else
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconAppId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconAppId );
        iconQuery.Append( KAnd );
        }

    if (!iconQuery.Right(KAnd().Length()).Compare(KAnd))
        {    
        iconQuery.Delete( iconQuery.Length() - KAnd().Length(), KAnd().Length() );
        }
    
    aQuery->SetQueryL( iconQuery );
    CleanupStack::PopAndDestroy( &iconQuery );
    }
 /*
  * Save Form data, function to be executed when save option is selected. 
  * Creates the second form which allows for selecting the category.
  */
 TBool CYPagesForm1::SaveFormDataL()
{  
    CAknPopupFieldText* popupFieldText = static_cast <CAknPopupFieldText*> (ControlOrNull(EYPagesPopup));
 	if (popupFieldText) {		
		TInt categoryIndex = popupFieldText->CurrentValueIndex();
		TBuf <30> KMyTextFile;
		KMyTextFile.Format(_L("D:\\YPages\\%d%d.txt"), iColor, categoryIndex);
		
		RFs fileServer;
 	    User :: LeaveIfError (fileServer.Connect());
 	    RFile file;
 	    User::LeaveIfError(file.Open(fileServer, KMyTextFile, EFileRead|EFileStreamText));
 	    CleanupClosePushL(file);
 	    
 	    TFileText fileText;
 	    fileText.Set(file);
 	    
 	    TBuf<100> buffer;
 	    buffer = _L("");

 	    RBuf rBuf;
 	    rBuf.Create(buffer);
 	    rBuf.CleanupClosePushL();
 	    
 	  
 	    TInt err = KErrNone;
 	    while(err != KErrEof) {
 			err = fileText.Read(buffer);
 	    
 			if ((err != KErrNone) && (err != KErrEof)) {
 				User :: Leave(err);
 			}
 			if (KErrNone == err) {
 				rBuf.ReAllocL(rBuf.Length() + buffer.Length()+2);
 				rBuf.Append(buffer);
 				rBuf.Append(_L("\n"));
 			}
 	    }
 	    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(rBuf);
 	    dlg->PrepareLC(R_ABOUT_HEADING_PANE);
   	    dlg->SetHeaderTextL(_L(""));  
   	    dlg->RunLD();
 	    		     
 	    CleanupStack::PopAndDestroy(&rBuf);
 	    CleanupStack::PopAndDestroy(&file);
 	    
 	    fileServer.Close();

 	
 	}

        

 	return ETrue;
 }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateUpdateIconQueryL(
        const CCaInnerEntry* aEntry, CCaSqlQuery* aQuery )
    {
    DEBUG(("_CA_:CASqlQueryCreator::CreateUpdateIconQueryL"));
    RBuf query;
    query.CleanupClosePushL();
    query.CreateL( KSQLUpdateIcon().Length() );
    query.Append( KSQLUpdateIcon );
    if( aEntry->Icon()->FileName().Compare( KNullDesC ) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconFileName().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconFileName );
        query.Append( KComma );
        }
    if( aEntry->Icon()->SkinId().Compare( KNullDesC ) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconSkinId().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconSkinId );
        query.Append( KComma );
        }
     if( aEntry->Icon()->ApplicationId().Compare(KNullDesC) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconAppId().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconAppId );
        }
    if( !query.Right( KComma().Length() ).Compare( KComma ) )
        {
        query.Delete( query.Length() - KComma().Length(), KComma().Length() );
        }
    // add WHERE expr
    query.ReAllocL( query.Length() + KSQLUpdateIconWhere().Length() );
    query.Append( KSQLUpdateIconWhere );

    aQuery->SetQueryL( query );
    aQuery->SetTableType( CCaSqlQuery::EIconTable );

    CleanupStack::PopAndDestroy( &query );
    }
void AppendL(RBuf& aBuf, const TDesC& aDes, TBool aQuote)
	{
	const TInt requiredSpace = aDes.Length() + ((aBuf.Length() == 0) ? 0 : KEnumSeparator().Length()) + (aQuote ? 2 : 0);
	if ((aBuf.Length() + requiredSpace) > aBuf.MaxLength())
		{
		aBuf.ReAllocL(Max(aBuf.Length() * 2, aBuf.Length() + requiredSpace));
		}
	if (aBuf.Length() > 0)
		{
		aBuf.Append(KEnumSeparator);
		}
	if (aQuote)
		{
		aBuf.Append(KEnumQuote);
		}
	aBuf.Append(aDes);
	if (aQuote)
		{
		aBuf.Append(KEnumQuote);
		}
	}
// ----------------------------------------------------------
// CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL
// Shows the notifier in backround 
// ----------------------------------------------------------
//
void CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndCompleteL()
	{
	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete()"));
	
	//get full path to the DCMO resource file
	TParse* parser = new (ELeave) TParse;
	parser->Set(KDcmoResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL);
	CleanupStack::PushL(parser);
	TFileName* fileName = new (ELeave) TFileName;
	*fileName = parser->FullName();
	CleanupStack::PopAndDestroy(parser);
	CleanupStack::PushL(fileName);
	
	//create the resource reader object that we need to use several times
	CTulStringResourceReader* reader = CTulStringResourceReader::NewL(*fileName);
	CleanupStack::PushL(reader);
	
	//get pointer to the message part of the notifier
	TPtrC resourceString;
	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_DISABLE));

	//create descriptor with a max length to fit the localised "disabled" text + new line + "Bluetooth"
	RBuf content;
	content.CreateL(resourceString.Length() + KNewLine().Length() + KDefaultBluetoothStringLength);
	CleanupClosePushL(content);
	
	//add resource string and new line character to the content descriptor
	content.Append(resourceString);	
	content.Append(KNewLine());
	
	//get pointer to the Bluetooth name part of the notifier (can't assume this is actually "Bluetooth" in all languages)
	resourceString.Set(reader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH));
	
	//check that the resource string will fit into the content descriptor
	TInt requiredLength = content.Length() + resourceString.Length();
	if (requiredLength > content.MaxLength())
		{
		//allocate more space in the content descriptor
		content.ReAllocL(requiredLength);
		}
	
	//add resource string to the content descriptor
	content.Append(resourceString);	
	
	//display the notifier and complete
	iNotifUiUtil->ShowInfoNoteL(content, ECmdBTnotifUnavailable);
	CompleteMessage(KErrNone);
	
	//pop and destroy the content descriptor, resource reader and file name
	CleanupStack::PopAndDestroy(3, fileName);
	
	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::ShowNoteAndComplete() complete"));
	}
示例#14
0
void CPluginUtils::AddMultipartParamL( RBuf& aBuf, const TDesC& aParam, const TDesC& aValue )
	{
	aBuf.ReAllocL( aBuf.Length() + KBoundary().Length() + aParam.Length() + aValue.Length() + 2 + 2 + 2 + 2 + 2 + 1 + KDisposition().Length() );
	aBuf.Append( _L("--") );
	aBuf.Append( KBoundary() );
	aBuf.Append( KCrLf );
	aBuf.Append( KDisposition() );
	aBuf.Append( aParam );
	aBuf.Append( _L("\"") );
	aBuf.Append( KCrLf );
	aBuf.Append( KCrLf );
	aBuf.Append( aValue );
	aBuf.Append( KCrLf );
	}
示例#15
0
/**
Initialize the counter with the numeric equivalent of the descriptor contents
This function is here to demonstrate reading from the client address space.
Note that in this example, the client and the server are part of the same process,
*/
void CCountServSession::SetFromStringL(const RMessage2& aMessage)
	{
	
	  // length of passed descriptor (1st parameter passed from client)
	TInt deslen = aMessage.GetDesLength(0);
	
	  // Passed data will be saved in this descriptor.
    RBuf buffer;
      
      // Max length set to the value of "deslen", but current length is zero
    buffer.CreateL(deslen);
      
      // Do the right cleanup if anything subsequently goes wrong
    buffer.CleanupClosePushL();
    
      // Copy the client's descriptor data into our buffer.
    aMessage.ReadL(0,buffer,0);
    
      // Now do a validation to make sure that the string only has digits
    if (buffer.Length() == 0)
        {
    	User::Leave(ENonNumericString);
        }
    
    TLex16 lexer;
    
    lexer.Assign(buffer);
    while (!lexer.Eos())
        {
        TChar thechar;
        
        thechar = lexer.Peek();
        if (!thechar.IsDigit())
            {
        	User::Leave(ENonNumericString);
            }
        lexer.Inc();
        }
       
      // Convert to a simple TInt value. 
    lexer.Assign(buffer);           
    if (lexer.Val(iCount))
        {
    	User::Leave(ENonNumericString);
        }
    	
	  // Clean up the memory acquired by the RBuf variable "buffer"
	CleanupStack::PopAndDestroy();
	}
示例#16
0
void CWindowGroupListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/)
	{
	SWgInfo& info = *reinterpret_cast<SWgInfo*>(aInfo);
	CApaWindowGroupName* wgName = info.iName;
	name.Copy(wgName->Caption());
	_LIT(KUnnamed, "<Untitled window group>");
	if (name.Length() == 0) name.Copy(KUnnamed);

	TThreadId tid;
	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
	if (res == KErrNone)
		{
		res = tid;
		}
	more.Format(_L("Busy=%i System=%i Tid=%i"), wgName->IsBusy(), wgName->IsSystem(), res);
	}
示例#17
0
void CPluginUtils::AddMultipartParamL( RBuf& aBuf, const TDesC& aParam, TInt aValue )
	{
	TBuf<12> t;
	t.Format( _L("%d"), aValue );

	aBuf.ReAllocL( aBuf.Length() + KBoundary().Length() + aParam.Length() + t.Length() + 2 + 2 + 2 + 2 + 2 + 1 + KDisposition().Length() );
	aBuf.Append( _L("--") );
	aBuf.Append( KBoundary() );
	aBuf.Append( KCrLf );
	aBuf.Append( KDisposition() );
	aBuf.Append( aParam );
	aBuf.Append( _L("\"") );
	aBuf.Append( KCrLf );
	aBuf.Append( KCrLf );
	aBuf.Append( t );
	aBuf.Append( KCrLf );
	}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::PopulateQueryWithIdListL( const TInt aIdEntryCount,
        CCaSqlQuery* aQuery, const TDesC& aSqlQueryText )
    {
    DEBUG(("_CA_:CASqlQueryCreator::PopulateQueryWithIdListL"));
    RBuf entryIdList;
    entryIdList.CleanupClosePushL();

    CreateIdListL( aIdEntryCount, entryIdList, KSQLEntryId );

    RBuf query;
    query.CleanupClosePushL();
    query.CreateL( aSqlQueryText.Length() + entryIdList.Length() );
    query.AppendFormat( aSqlQueryText, &entryIdList );

    aQuery->SetQueryL( query );

    CleanupStack::PopAndDestroy( &query );
    CleanupStack::PopAndDestroy( &entryIdList );
    }
示例#19
0
EXPORT_C void SoftwareTypeRegInfoUtils::SerializeUniqueSwTypeNamesL(const RPointerArray<Usif::CSoftwareTypeRegInfo>& aSwTypeRegInfoArray, RBuf& aSerializedNames)
	{
	const TInt numNames = aSwTypeRegInfoArray.Count();
	
	TInt bufLen = 0;
	for (TInt i=0; i<numNames; ++i)
		{
		const Usif::CSoftwareTypeRegInfo& info = *aSwTypeRegInfoArray[i];
		bufLen += info.UniqueSoftwareTypeName().Length() + sizeof(TChar);
		}
	
	aSerializedNames.ReAllocL(aSerializedNames.Length()+bufLen);
	
	for (TInt i=0; i<numNames; ++i)
		{
		const Usif::CSoftwareTypeRegInfo& info = *aSwTypeRegInfoArray[i];
		aSerializedNames.Append(info.UniqueSoftwareTypeName());
		aSerializedNames.Append(static_cast<TChar>(KUniqueNameSeparator));
		}
	}
示例#20
0
void CIoReadTest::DoRunL()
	{
	// read the file into memory
	ReadFileL();
	
	LeaveIfErr(iIoFile.Create(IoSession(), iFile, RIoFile::ERead), _L("Cannot create file end point for '%S'"), &iFile);
	
	iFileReader.CreateL(IoSession());
	iIoFile.AttachL(iFileReader, RIoEndPoint::EForeground);
	
	iFileReader.SetReadModeL(iReadMode);
	
	iReadBuf.CreateL(iReadSize);
	
	
	iFileBuffer = CTextBuffer::NewL(0x20);
	TInt err;
	do
		{
		iReadBuf.Zero();
		err = iFileReader.Read(iReadBuf);
		iFileBuffer->AppendL(iReadBuf);
		} while (err == KErrNone);
		
	if (err!=KErrEof) LeaveIfErr(err, _L("Unexpected error from RIoReadHandle::Read"));
	
	TInt completion = 0;
	if (iFileBuffer->Length() != iFileContents.Length())
		{
		PrintWarning(_L("Amount of data read from file (%d) differs from file size (%d)."), iFileBuffer->Length(), iFileContents.Length());
		completion = 1;
		}
	if (iFileBuffer->Descriptor().Compare(iFileContents) != 0)
		{
		PrintWarning(_L("Data read from file differs from file contents."));
		completion = 1;
		}
	Complete(completion);
	}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::ModifyQueryForSortOrderL(
        const CCaInnerQuery::TSortAttribute aSortType, RBuf& aQuery,
        TBool aSortByGroup )
    {
    DEBUG(("_CA_:CASqlQueryCreator::ModifyQueryForSortOrderL"));
    switch ( aSortType )
        {
        case CCaInnerQuery::Name:
            {
            aQuery.ReAllocL( aQuery.Length()
                    + KSQLSortOrderNameAsc().Length() );
            aQuery.Append( KSQLSortOrderNameAsc );
            break;
            }
        case CCaInnerQuery::NameDesc:
            {
            aQuery.ReAllocL( aQuery.Length()
                    + KSQLSortOrderNameDesc().Length() );
            aQuery.Append( KSQLSortOrderNameDesc );
            break;
            }
        case CCaInnerQuery::CreatedTimestamp:
            {
            aQuery.ReAllocL( aQuery.Length()
                    + KSQLSortOrderCreatedTimestampAsc().Length() );
            aQuery.Append( KSQLSortOrderCreatedTimestampAsc );
            break;
            }
        case CCaInnerQuery::CreatedTimestampDesc:
            {
            aQuery.ReAllocL( aQuery.Length()
                    + KSQLSortOrderCreatedTimestampDesc().Length() );
            aQuery.Append( KSQLSortOrderCreatedTimestampDesc );
            break;
            }
        case CCaInnerQuery::MostUsed:
        case CCaInnerQuery::MostUsedDesc:
        case CCaInnerQuery::LastUsed:
        case CCaInnerQuery::LastUsedDesc:
            {
            ModifyQueryForSortOrderLastMostUsedL( aSortType, aQuery );
            break;
            }
        case CCaInnerQuery::DefaultDesc:
            {
            if( aSortByGroup )
                {
                aQuery.ReAllocL( aQuery.Length()
                        + KSQLSortOrderDefaultDesc().Length() );
                aQuery.Append( KSQLSortOrderDefaultDesc );
                }
            else
                {
                aQuery.ReAllocL( aQuery.Length()
                        + KSQLSortOrderIdDesc().Length() );
                aQuery.Append( KSQLSortOrderIdDesc );
                }
            break;
            }
        case CCaInnerQuery::Default:
        default:
            {
            if( aSortByGroup )
                {
                aQuery.ReAllocL( aQuery.Length()
                        + KSQLSortOrderDefault().Length() );
                aQuery.Append( KSQLSortOrderDefault );
                }
            else
                {
                aQuery.ReAllocL( aQuery.Length()
                        + KSQLSortOrderIdAsc().Length() );
                aQuery.Append( KSQLSortOrderIdAsc );
                }
            break;
            }
        }
    }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateGetEntriesQueryByQueryL(
        const CCaInnerQuery* aQuery, CCaSqlQuery* aSqlQuery )
    {
    DEBUG(("_CA_:CASqlQueryCreator::CreateGetEntriesQueryByQueryL"));
    RBuf whereStatement;
    whereStatement.CleanupClosePushL();

    TUint flagsOn = aQuery->GetFlagsOn();
    if( flagsOn != 0 )
        {
        whereStatement.ReAllocL( KAnd().Length() + whereStatement.Length()
                + KSQLGetEntryFlagsOn().Length() );
        whereStatement.Append( KAnd );
        whereStatement.Append( KSQLGetEntryFlagsOn );
        }

    TUint flagsOff = aQuery->GetFlagsOff();
    if( flagsOff != 0 )
        {
        whereStatement.ReAllocL( KAnd().Length() + whereStatement.Length()
                + KSQLGetEntryFlagsOff().Length() );
        whereStatement.Append( KAnd );
        whereStatement.Append( KSQLGetEntryFlagsOff );
        }

    TInt role = aQuery->GetRole();
    if( role != 0 )
        {
        whereStatement.ReAllocL( KAnd().Length() + whereStatement.Length()
                + KSQLGetEntryRole().Length() );
        whereStatement.Append( KAnd );
        whereStatement.Append( KSQLGetEntryRole );
        }

    TUint uid = aQuery->GetUid();
    if( uid != 0 )
        {
        whereStatement.ReAllocL( KAnd().Length() + whereStatement.Length()
                + KSQLGetEntryUid().Length() );
        whereStatement.Append( KAnd );
        whereStatement.Append( KSQLGetEntryUid );
        }

    const CDesC16ArrayFlat* typeNames = aQuery->GetEntryTypeNames();

    if( typeNames && typeNames->MdcaCount() > 0 )
        {
        RBuf typeNameWhereStatement;
        typeNameWhereStatement.CleanupClosePushL();
        for( TInt i = 0; i < typeNames->MdcaCount(); i++ )
            {
            typeNameWhereStatement.ReAllocL(
                    typeNameWhereStatement.Length()
                    + typeNames->MdcaPoint( i ).Length()
                    + KSingleQuotes().Length() * 2 + KComma().Length() );
            typeNameWhereStatement.Append( KSingleQuotes );
            typeNameWhereStatement.Append( typeNames->MdcaPoint( i ) );
            typeNameWhereStatement.Append( KSingleQuotes );
            if( i != typeNames->MdcaCount() - 1 )
                {
                typeNameWhereStatement.Append( KComma );
                }
            }
        whereStatement.ReAllocL( KAnd().Length()
                + KSQLGetEntryTypeNames().Length()
                + typeNameWhereStatement.Length()
                + whereStatement.Length() );
        whereStatement.Append( KAnd );
        whereStatement.AppendFormat( KSQLGetEntryTypeNames,
                &typeNameWhereStatement );
        CleanupStack::PopAndDestroy( &typeNameWhereStatement );
        }
    
    if( aQuery->GetAttributes().Count() )
        {
        RBuf whereAttributes;
        whereAttributes.CleanupClosePushL();
        whereAttributes.CreateL( KEmpty );
        
        for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ )
            {
            // at1.AT_NAME = 'Attribute_Name_1' AND at1.AT_VALUE = 'Attribute_VALUE_1'
            TPtrC atrName( aQuery->GetAttributes().operator [](j-1)->Name() );
            TPtrC atrValue( aQuery->GetAttributes().operator [](j-1)->Value() );

            whereAttributes.ReAllocL( whereAttributes.Length() + 2 * KAnd().Length() + 
                    4 * KSingleQuotes().Length() +
                    2 * KMaxIntNumLength + 
                    2 * KAt().Length() + 2 * KDot().Length() + 2 * KEqual().Length() +
                    KColumnAttrName().Length() + KColumnAttrValue().Length() +
                    atrName.Length() + atrValue.Length() );
            
            whereAttributes.Append( KAnd );
            
            whereAttributes.Append( KAt );
            whereAttributes.AppendNum( j );
            whereAttributes.Append( KDot );
            whereAttributes.Append( KColumnAttrName );
            whereAttributes.Append( KEqual );
            whereAttributes.Append( KSingleQuotes );
            whereAttributes.Append( atrName );
            whereAttributes.Append( KSingleQuotes );
            
            whereAttributes.Append( KAnd );
            
            whereAttributes.Append( KAt );
            whereAttributes.AppendNum( j );
            whereAttributes.Append( KDot );
            whereAttributes.Append( KColumnAttrValue );
            whereAttributes.Append( KEqual );
            whereAttributes.Append( KSingleQuotes );
            whereAttributes.Append( atrValue );
            whereAttributes.Append( KSingleQuotes );
            
            }
        
        whereStatement.ReAllocL( whereStatement.Length() + whereAttributes.Length() );
        whereStatement.Append( whereAttributes );
        
        CleanupStack::PopAndDestroy( &whereAttributes );
        }

    RBuf leftJoins;
    leftJoins.CleanupClosePushL();
    leftJoins.CreateL( KEmpty );
    if( aQuery->GetAttributes().Count() )
        {
        for( TInt j=1; j <= aQuery->GetAttributes().Count(); j++ )
            {
            // LEFT JOIN CA_ATTRIBUTE as at1 ON ENTRY_ID = at1.AT_ENTRY_ID
            leftJoins.ReAllocL( leftJoins.Length() + 
                    KLeftJoinCaAttrubute1().Length() + KMaxIntNumLength +
                    KLeftJoinCaAttrubute2().Length() + KMaxIntNumLength +
                    KLeftJoinCaAttrubute3().Length()
                    );
            
            leftJoins.Append( KLeftJoinCaAttrubute1 );
            leftJoins.AppendNum( j );
            leftJoins.Append( KLeftJoinCaAttrubute2 );
            leftJoins.AppendNum( j );
            leftJoins.Append( KLeftJoinCaAttrubute3 );
            }
        }
    
    
    whereStatement.ReAllocL( whereStatement.Length() + 
            KGroupBy().Length() + KColumnEntryId().Length() );
    whereStatement.Append( KGroupBy );
    whereStatement.Append( KColumnEntryId );

    TInt groupId = aQuery->GetParentId();
    RBuf query;
    query.CleanupClosePushL();
    if( groupId > 0 )
        {
        RBuf getListByParentId2withWhere;
        getListByParentId2withWhere.CleanupClosePushL();
        getListByParentId2withWhere.CreateL( KSQLGetListByParentId2().Length() + whereStatement.Length() );
        getListByParentId2withWhere.AppendFormat( KSQLGetListByParentId2, &whereStatement );
        
        query.ReAllocL( KSQLGetListByParentId1().Length() +  leftJoins.Length() +
                getListByParentId2withWhere.Length() );
        query.Append( KSQLGetListByParentId1 );
        query.Append( leftJoins );
        query.Append( getListByParentId2withWhere );
        CleanupStack::PopAndDestroy( &getListByParentId2withWhere );
        }
    else if ( aQuery->GetChildId() > 0 )
        {
        RBuf getListByCildIdwithWhere;
        getListByCildIdwithWhere.CleanupClosePushL();
        getListByCildIdwithWhere.CreateL( KSQLGetListByChildId().Length() + whereStatement.Length() );
        getListByCildIdwithWhere.AppendFormat( KSQLGetListByChildId, &whereStatement );
        
        query.ReAllocL( KSQLGetListByParentId1().Length() +  leftJoins.Length() +
                getListByCildIdwithWhere.Length() );
        query.Append( KSQLGetListByParentId1 );
        query.Append( leftJoins );
        query.Append( getListByCildIdwithWhere );
        CleanupStack::PopAndDestroy( &getListByCildIdwithWhere );
        }
    else
        {
        query.CreateL( KSQLGetList1().Length() );
        query.Append( KSQLGetList1 );
        query.ReAllocL( query.Length() + leftJoins.Length() + KSQLGetList2().Length() );
        query.Append( leftJoins );
        query.Append( KSQLGetList2 );
        if( whereStatement.Length() >= KAnd().Length() )
            {
            TPtrC ptrWhereStatement( whereStatement.Right(
                    whereStatement.Length() - KAnd().Length() ) );
            query.ReAllocL( query.Length() +  KWhere().Length()
                    + ptrWhereStatement.Length() );

            query.Append( KWhere );
            query.Append( ptrWhereStatement );
            }
        }

    CCaInnerQuery::TSortAttribute sort = aQuery->GetSort();
    ModifyQueryForSortOrderL( sort, query, groupId > 0 );

    if( aQuery->GetCount() > 0 )
        {
        query.ReAllocL( query.Length() + KLimit().Length()
                + KMaxIntNumLength );
        query.Append( KLimit );
        TInt limitCount = aQuery->GetCount();
        query.AppendNum( limitCount );
        }

    aSqlQuery->SetQueryL( query );
    CleanupStack::PopAndDestroy( &query );
    CleanupStack::PopAndDestroy( &leftJoins );
    CleanupStack::PopAndDestroy( &whereStatement );
    }
示例#23
0
/**
move object operations
@return A valid MTP response code.
*/
TMTPResponseCode CMTPMoveObject::MoveObjectL()
{
    OstTraceFunctionEntry0( CMTPMOVEOBJECT_MOVEOBJECTL_ENTRY );
    TMTPResponseCode responseCode = EMTPRespCodeOK;

    GetParametersL();

    RBuf newObjectName;
    newObjectName.CreateL(KMaxFileName);
    newObjectName.CleanupClosePushL();
    newObjectName = *iDest;

    const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
    TParsePtrC fileNameParser(suid);

    // Check if the object is a folder or a file.
    if(!iIsFolder)
    {
        if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength())
        {
            newObjectName.Append(fileNameParser.NameAndExt());
        }
        responseCode = CanMoveObjectL(suid, newObjectName);
    }
    else // It is a folder.
    {
        TFileName rightMostFolderName;
        LEAVEIFERROR(BaflUtils::MostSignificantPartOfFullName(suid, rightMostFolderName),
                     OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_MOVEOBJECTL, "extract most significant part of %S failed", suid));

        if((newObjectName.Length() + rightMostFolderName.Length() + 1) <= newObjectName.MaxLength())
        {
            newObjectName.Append(rightMostFolderName);
            // Add backslash.
            _LIT(KBackSlash, "\\");
            newObjectName.Append(KBackSlash);
        }
    }

    iNewRootFolder = newObjectName.AllocL();
    OstTraceExt1( TRACE_NORMAL, CMTPMOVEOBJECT_MOVEOBJECTL, "%S", *iNewRootFolder );

    if(responseCode == EMTPRespCodeOK)
    {
        delete iFileMan;
        iFileMan = NULL;
        iFileMan = CFileMan::NewL(iFramework.Fs());

        if(!iIsFolder)
        {
            MoveFileL(newObjectName);
        }
        else
        {
            MoveFolderL();
            SendResponseL(responseCode);
        }
    }
    CleanupStack::PopAndDestroy(); // newObjectName.
    OstTraceFunctionExit0( CMTPMOVEOBJECT_MOVEOBJECTL_EXIT );
    return responseCode;
}
示例#24
0
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CCaUsifScanner::CreateCaEntryFromEntryL(
        const CComponentEntry* aEntry, CCaInnerEntry* aCaEntry )
    {
    aCaEntry->SetRole( EItemEntryRole );
    aCaEntry->SetEntryTypeNameL( KCaTypePackage );
    if( !aEntry->SoftwareType().Compare( KSoftwareTypeNative ) )
        {
        aCaEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueNative );
        }
    else if( !aEntry->SoftwareType().Compare( KSoftwareTypeJava ) )
        {
        aCaEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueJava );
        }
    else if( !aEntry->SoftwareType().Compare( KSoftwareTypeWidget ) )
        {
        aCaEntry->AddAttributeL( KCaAttrAppType, KCaAttrAppTypeValueCWRT );
        }
    if( aEntry->Name().Compare( KNullDesC ) )
        {
        aCaEntry->SetTextL( aEntry->Name() );
        }
    if( !aEntry->IsHidden() )
        {
        aCaEntry->SetFlags( EVisible );
        }
    if( aEntry->IsRemovable() )
        {
        aCaEntry->SetFlags( aCaEntry->GetFlags() | ERemovable );
        
        TChar drive;
        RBuf drives;        
        drives.CreateL(KMaxFileName);
        CleanupClosePushL( drives );
        const TInt driveListLen(aEntry->InstalledDrives().Length());
        for (TInt i( 0 ); i < driveListLen; ++i) 
            {
            // Skip PhoneMemory and if we have some icon resolved
            if (aEntry->InstalledDrives()[i] != '\0' && drives.Length() == 0
                    && (DriveInfo::GetDefaultDrive(
                            DriveInfo::EDefaultPhoneMemory, drive ) == KErrNone
                            && TChar('A'+ i) != TChar(drive)))
                {
                TUint drvStatus( 0 );
                int err = DriveInfo::GetDriveStatus( iFs, i, drvStatus );
                if ( ( drvStatus & DriveInfo::EDriveInternal ) &&
                     ( drvStatus & DriveInfo::EDriveExternallyMountable ) ){
                    // Mass Storage
                    drives.Append(_L("qtg_mono_hard_disk"));
                    }
                else if(drvStatus & DriveInfo::EDriveRemote ||
                        drvStatus & DriveInfo::EDriveUsbMemory)
                    {
                    // Usb or remote drive
                    drives.Append(_L("qtg_mono_usb"));
                    }
                else if( ( drvStatus & DriveInfo::EDriveRemovable ) &&
                     ( drvStatus & DriveInfo::EDriveExternallyMountable ) )
                    {
                    // MMC
                    drives.Append(_L("qtg_mono_memory_in_use"));
                    }
                }
            }
        if (drives.Length() > 0) {
            aCaEntry->AddAttributeL( KCaAttrDrivesIconIds, drives );
        }
        CleanupStack::PopAndDestroy( &drives );
        }

    
    // entries obtained with usif should have component id.
    //it's needed for uninstalling
    RBuf compIdDesc;
    CleanupClosePushL( compIdDesc );
    compIdDesc.CreateL( KCaMaxAttrValueLen );
    compIdDesc.Num( aEntry->ComponentId() );
    aCaEntry->AddAttributeL( KCaAttrComponentId, compIdDesc );
    CleanupStack::PopAndDestroy( &compIdDesc );
    }
void CConeErrorMsgTestAppUi::TestLeaveWithErrorTextL(const TDesC& aErrorText, const TDesC* aContextErrorText, const TBool& aExceedMaxDesc)
	{
	RBuf testMsg;
	testMsg.CreateL(aErrorText);
	testMsg.CleanupClosePushL();
	
	TInt err=KErrNone;
	
	if (aContextErrorText)
		{
		RBuf testConMsg;
		testConMsg.CreateL(*aContextErrorText);
		testConMsg.CleanupClosePushL();
		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg, &testConMsg));
	
		TDes& errConRxText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
		RBuf errConMsg;
		errConMsg.CreateL(errConRxText);
		errConMsg.CleanupClosePushL();
		INFO_PRINTF3(_L("Err Cntxt Msg Tx: %S, Err Cntxt Msg Rx: %S"), &testConMsg, &errConMsg);
		if (aExceedMaxDesc)
			{
			TEST(testConMsg!=errConMsg);
			TEST(errConMsg.Length()==80); // KErrorContextTextLength
			TEST(errConMsg[79]==KBaflCharTruncation);
			testConMsg.Delete(80, 1); // remove the last char
			testConMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
			TEST(testConMsg==errConMsg);
			}
		else
			{
			TEST(testConMsg==errConMsg);
			}
		
		CleanupStack::PopAndDestroy(2);
		}
	else
		{
		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg));
		
		TDes& errConText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
		INFO_PRINTF3(_L("Actual Context Length: %d, Expected Context Length: %d"), errConText.Length(), 0);			
		TEST(errConText.Length()==0);
		}

	INFO_PRINTF3(_L("Actual Leave Code: %d, Expected Leave Code: %d"), err, KErrExtendedWithText);
	TEST(err==KErrExtendedWithText);
	
	TDes& errRxText = ((CTestCoeEnv *)iCoeEnv)->TestErrorText();
	RBuf errMsg;
	errMsg.CreateL(errRxText);
	errMsg.CleanupClosePushL();
	INFO_PRINTF3(_L("Err Msg Tx: %S, Err Msg Rx: %S"), &testMsg, &errMsg);
	if (aExceedMaxDesc)
		{
		TEST(testMsg!=errMsg);
		TEST(errMsg.Length()==80); // KErrorTextLength
		TEST(errMsg[79]==KBaflCharTruncation);
		testMsg.Delete(80, 1); // remove the last char
		testMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
		TEST(testMsg==errMsg);
		}
	else
		{
		TEST(testMsg==errMsg);
		}

	CleanupStack::PopAndDestroy(2);
	}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateUpdateQueryEntryL(
        const CCaInnerEntry* aEntry, CCaSqlQuery* aQuery )
    {
    DEBUG( ("_CA_:CASqlQueryCreator::CreateUpdateQueryEntryL") );
    RBuf query;
    query.CleanupClosePushL();
    query.CreateL( KSQLUpdateEntry().Length() );
    query.Append( KSQLUpdateEntry );
    // text
    if( aEntry->GetText().Length() != 0 )
        {
        query.ReAllocL( query.Length() + KSQLUpdateEntryText().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateEntryText );
        query.Append( KComma );
        }
    // description
    query.ReAllocL( query.Length() + KSQLUpdateEntryDescription().Length()
            + KComma().Length() );
    query.Append( KSQLUpdateEntryDescription );
    query.Append( KComma );
    // role
    query.ReAllocL( query.Length() + KSQLUpdateEntryRole().Length()
            + KComma().Length() );
    query.Append( KSQLUpdateEntryRole );
    query.Append( KComma );
    // type_name
    if( aEntry->GetEntryTypeName().Length() != 0 )
        {
        query.ReAllocL( query.Length() + KSQLUpdateEntryTypeName().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateEntryTypeName );
        query.Append( KComma );
        }
    // id_icon
    TIconType iconType = CaSqlQueryCreator::CheckIconType( aEntry );
    if( iconType == ENullIconToRemove || iconType == ENullIcon )
        {
        query.ReAllocL( query.Length( ) + 
                KSQLUpdateEntryIdIconNull().Length() + KComma().Length() );
        query.Append( KSQLUpdateEntryIdIconNull );
        }
    else
        { 
        query.ReAllocL( query.Length( ) + KSQLUpdateEntryIdIcon().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateEntryIdIcon );
        }
    query.Append( KComma );
    // check if entry's Uid was set
    if( aEntry->GetUid() )
        {
        query.ReAllocL( query.Length() + KSQLUpdateEntryUid().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateEntryUid );
        query.Append( KComma );
        }
    else
        {
        query.ReAllocL( query.Length() + KSQLUpdateEntryUidNULL().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateEntryUidNULL );
        query.Append( KComma );
        }
    //flags
    query.ReAllocL( query.Length() + KSQLUpdateEntryFlags().Length()
            + KComma().Length() );
    query.Append( KSQLUpdateEntryFlags );

    query.ReAllocL( query.Length() + KSQLUpdateWhere().Length() );
    query.Append( KSQLUpdateWhere );

    aQuery->SetQueryL( query );
    CleanupStack::PopAndDestroy( &query );
    }
void IntegrityDeleteFileL(const TDesC& aPath, CIntegrityTreeLeaf* aLeaf, RFs& aFs, 
							   RLoader& aLoader, CFileMan& aFileMan)
	{
    _LIT(KSysBin, "\\sys\\bin");
	RBuf name;
	name.CreateL(aPath, KMaxFileName);
	CleanupClosePushL(name);
	name.Append(aLeaf->Name());

	TEntry entry;
	TInt err = aFs.Entry(name, entry);
	if (err == KErrNone)
		{
		aFs.SetAtt(name, 0, KEntryAttReadOnly);
		if(entry.IsDir())
			{
			// Make sure to append slash before calling RmDir - otherwise it deletes the parent directory			
			if (name[name.Length()-1] != KPathDelimiter) 
	  			{
  				name.Append(KPathDelimiter);
  				}
			User::LeaveIfError(aFileMan.RmDir(name));
			}
		else
			{			
            if ( aLeaf->Type() == EBackupFile ) // Implies a commit operation is in progress
                {
                
                 if ( IsBinary(entry) )
                     {
                     // Forming the file name so the renamed file can be under sys/bin
					 // for special delete mechanism using RLoader::Delete
                     RBuf tmpName;
                     TParsePtrC fileName(name);
                     tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
                     CleanupClosePushL(tmpName);

                     tmpName.Append(fileName.Drive());
                     tmpName.Append(KSysBin);
                     tmpName.Append(fileName.Path());
                     tmpName.Append(fileName.NameAndExt());

					 DEBUG_PRINTF3(_L("Integrity Services - Renaming %S to %S"), &name, &tmpName);
                     aFileMan.Rename(name,tmpName,CFileMan::EOverWrite);
                     User::LeaveIfError(aLoader.Delete(tmpName)); // Using RLoader delete for paged binaries
					 DEBUG_PRINTF2(_L("Integrity Services - Deleted renamed file %S"), &tmpName);

					 // prune the directory tree if possible
                     RemoveDirectoryTreeL(aFs, tmpName);
                     CleanupStack::PopAndDestroy(&tmpName);
                     }
                 else
                     {
                     User::LeaveIfError(aFileMan.Delete(name));
                     }
                }
            else
                {
				// Need to use RLoader Delete which can be used during deletion of Added files during Rollback
                User::LeaveIfError(aLoader.Delete(name));
                }
			}
			
		// prune the directory tree if possible
		RemoveDirectoryTreeL(aFs, name);
		}
	else if(err != KErrNotFound && err != KErrPathNotFound)
		{
		DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);
		User::Leave(err);
		}
	else
	    {

		DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name);

	    // Check for any renamed files to move it to sys/bin for special delete mechanism
	    RBuf tmpName;
	    TParsePtrC fileName(name);
	    tmpName.CreateL(name.Length() + KSysBin.iTypeLength);
	    CleanupClosePushL(tmpName);

	    tmpName.Append(fileName.Drive());
	    tmpName.Append(KSysBin);
	    tmpName.Append(fileName.Path());
	    tmpName.Append(fileName.NameAndExt());
		DEBUG_PRINTF2(_L("Integrity Services - Removing  %S renamed binary files if any"), &tmpName);

	    aLoader.Delete(tmpName);
		// prune the directory tree if possible
	    RemoveDirectoryTreeL(aFs, tmpName);
	    CleanupStack::PopAndDestroy(&tmpName);
	    }

	CleanupStack::PopAndDestroy(&name);
	}
// ---------------------------------------------------------------------------
// CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL
// ---------------------------------------------------------------------------
//
void CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL( TMeterState aNextState )
    {
    RFile roapTrigger;
    DRM::CFileNameContainer* triggerFileName(NULL);

    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDoDownloadAndHandleRoapTriggerL() );
    // If no Trigger URL then nothing to download. So finish transaction
    if ( !iTriggerUrl || iTriggerUrl->Length() <= 0 )
        {
        Continue( EComplete, KErrNone );
        return;
        }

    triggerFileName=DRM::CFileNameContainer::NewLC();
#ifndef RD_MULTIPLE_DRIVE

    User::LeaveIfError( roapTrigger.Temp(
            iFs, KHelperTriggerFilePath, triggerFileName->iBuffer, EFileWrite ) );

#else //RD_MULTIPLE_DRIVE
    _LIT( KDrive, "%c:\\" );
    TInt driveNumber( -1 );
    TChar driveLetter;
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber );
    iFs.DriveToChar( driveNumber, driveLetter );

    DRM::CFileNameContainer*
        helperTriggerFilePath( DRM::CFileNameContainer::NewLC() );

    helperTriggerFilePath->iBuffer.Format( KDrive, ( TUint )driveLetter );

    User::LeaveIfError( roapTrigger.Temp( iFs, helperTriggerFilePath->iBuffer,
                triggerFileName->iBuffer, EFileWrite ) );
    CleanupStack::PopAndDestroy( helperTriggerFilePath );
    helperTriggerFilePath=NULL;

#endif
    UpdateBufferL< HBufC, TFileName >( iFileName, triggerFileName->iBuffer );
    CleanupStack::PopAndDestroy( triggerFileName );
    triggerFileName=NULL;

    try
		{
		// create and start download
        QString downloadUrl((QChar*)iTriggerUrl->Des().Ptr(),iTriggerUrl->Length());
        iDownload = iDlMgr->createDownload( downloadUrl );
		iRoHandlerDMgrEventHandler = q_check_ptr(new QRoHandlerDMgrEventHandler(*this, *iDownload));
		}
    catch(const std::exception& exception)
		{
		qt_symbian_exception2LeaveL(exception);
		}
    		
    CleanupClosePushL( roapTrigger );

    
	DRMDEBUG2(
		RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(),
		&RoHdlrDMgrWrDebugLiterals::KStrDlCreated() );
	iDownloadSuccess = EFalse;
	iConnectionError = EFalse;

	SetDefaultAccessPointL();
        
	try
		{
		RBuf fileName;
		User::LeaveIfError(fileName.Create(KMaxFileName));
		CleanupClosePushL(fileName);
		roapTrigger.Name(fileName);
		const QVariant& roapTriggerValue( QString((QChar*) fileName.Ptr(), fileName.Length()) );
		CleanupStack::PopAndDestroy(&fileName);
		iDownload->setAttribute(FileName,roapTriggerValue);
		const QVariant& val(ETrue);
		iDownload->setAttribute(ContentType, val);
		iDownload->start();
		}
	catch(const std::exception& exception)
		{
		qt_symbian_exception2LeaveL(exception);
		}
	
	// wait until download is finished
	iState = aNextState;
	TRequestStatus* status( &iStatus );
	*status = KRequestPending;
	SetActive();
        
    CleanupStack::PopAndDestroy( &roapTrigger );
    }