示例#1
0
void SimulateDiskChangeL()
	{
	// Set up for heap leak checking
	__UHEAP_MARK;

	// Make sure the file is not read-only
	TRAPD(err, EComTestUtils::MakeFileWriteableL(KHTI_PluginAtRootOfC));
	TRAP(err, EComTestUtils::MakeFileWriteableL(KHTIr_PluginAtRootOfC));

	// Simulate that the implementation dll is changed - change resouce file timestamp
	RFile file;
	User::LeaveIfError(file.Open(TheFs, KHTIr_PluginAtRootOfC, EFileRead | EFileWrite));
	TTime time;
	User::LeaveIfError(file.Modified(time));
	TTimeIntervalSeconds interval = 100;
	time += interval;
	User::LeaveIfError(file.SetModified(time));
	file.Close();

	// Replace the resource file with the newer version (newer timestamp)
	// The ECOM server will run the discovery process and will unload the old dll
	// and replace it with the newer dll
	TRAP(err, EComTestUtils::FileManCopyFileL(KHTI_PluginAtRootOfC, KHTI_PluginInstalledOnC));
	TEST2(err, KErrNone);
	TRAP(err, EComTestUtils::FileManCopyFileL(KHTIr_PluginAtRootOfC, KHTIr_PluginInstalledOnC));
	TEST2(err, KErrNone);

	WAIT_FOR3s; // wait for copy to complete

	__UHEAP_MARKEND;
	}
// --------------------------------------------------------------------------
// 
// --------------------------------------------------------------------------
void CMTPPictBridgeEnumerator::EnumerateObjectsL(TUint32 aStorageId)
    {
    OstTraceFunctionEntry0( CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL_ENTRY );
    const TUint storageId(iFramework.StorageMgr().DefaultStorageId());

    if ((aStorageId==KMTPStorageAll) || (aStorageId==storageId))
        {
        MMTPObjectMgr& objectMgr=iFramework.ObjectMgr();

        //delete the files which maybe impact printing
        TFileName        fullPath;        
		fullPath = PathInfo::PhoneMemoryRootPath();
		fullPath.Append(KHostDiscovery);
		OstTraceExt1( TRACE_NORMAL, CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );
		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
		iFramework.Fs().Delete(fullPath);
		
		fullPath = PathInfo::PhoneMemoryRootPath();
		fullPath.Append(KHostRequest);
	    OstTraceExt1( TRACE_NORMAL, DUP1_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );
		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
		iFramework.Fs().Delete(fullPath);
		
		fullPath = PathInfo::PhoneMemoryRootPath();
		fullPath.Append(KHostResponse);
        OstTraceExt1( TRACE_NORMAL, DUP2_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );		
		iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
		iFramework.Fs().Delete(fullPath);
		
        // enumerate device discovery file (create if not exist)

        RFile rf;
        CleanupClosePushL(rf);
        fullPath = PathInfo::PhoneMemoryRootPath();
        fullPath.Append(KDeviceDiscovery);
        OstTraceExt1( TRACE_NORMAL, DUP3_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, "full path is %S ", fullPath );                
        iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly);
        iFramework.Fs().Delete(fullPath);
        
        rf.Create(iFramework.Fs(), fullPath, EFileWrite);
        TTime time;
        time.HomeTime();
        rf.SetModified(time);
        CleanupStack::PopAndDestroy(&rf);
        
        CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewLC(iSingletons.DpController().FileDpId(), EMTPFormatCodeScript, storageId, fullPath);

        objectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent);
	    objectMgr.InsertObjectL(*objectP);
	    iDpsDiscoveryHandle = objectP->Uint( CMTPObjectMetaData::EHandle );
	    OstTrace1( TRACE_NORMAL, DUP4_CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL, 
	            "added discovery file iDpsDiscoveryHandle is 0x%08X", iDpsDiscoveryHandle );

        CleanupStack::PopAndDestroy(objectP);
        }
		iCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone);

    OstTraceFunctionExit0( CMTPPICTBRIDGEENUMERATOR_ENUMERATEOBJECTSL_EXIT );
    }
示例#3
0
static void testRFileSetModified(TDateTime* aDateTime, TTime* aTime, TBool validDate)
//
// Test RFile::SetModified() and RFile::Modified()
//
	{
	RFile file;
	TInt r=file.Replace(TheFs,_L("Y2KTEST.tst"),0);
	test_Value(r, r == KErrNone || r==KErrPathNotFound);	

	r=file.SetModified(*aTime);
	test_KErrNone(r);
	file.Close();
	
	TTime check;
	file.Open(TheFs,_L("Y2KTEST.tst"),EFileWrite);
	r=file.Modified(check);
	test_KErrNone(r);
	file.Close();
		
	TDateTime checkDateTime=check.DateTime();
	
	test(checkDateTime.Year()==aDateTime->Year());
	if (validDate)
		{
		test(checkDateTime.Month()==aDateTime->Month());
		test(checkDateTime.Day()==aDateTime->Day());
		}
	else
		{
		test(checkDateTime.Month()==aDateTime->Month()+1);
		test(checkDateTime.Day()==0);
		}

	check.FormatL(gDateBuf,_L("%*D%X%N%Y %1 %2 %3"));
	test.Printf(_L("Valid date: %S\n"),&gDateBuf);

	r=TheFs.Delete(_L("Y2KTEST.tst"));
	
	}