Example #1
0
TBMNs TBMTimeInterval::EndNs()
	{
	//
	// Now, in the reverse order
	//
	TBMTicks stamp;
	::bmTimer.Stamp(&stamp);
	TTime time;	
	time.HomeTime();
	TBMNs ns = TTimeIntervalMicroSecondsToTBMNs(time.MicroSecondsFrom(iTime));
	//
	// If the interval fits in the high-precision timer period we can use it;
	// otherwise, use the low-precision timer.
	//
	if (ns < iStampPeriodNs)
		{
		stamp = TBMTicksDelta(iStamp, stamp);
		::bmTimer.TicksToNs(&stamp, &ns);
		}
	return ns;
	}
void CMsvScheduleSend::CreateScheduleL(const TTime& aTime, const TTimeIntervalMinutes& aValidityPeriod, const CArrayFixFlat<TTaskSchedulerCondition>& aSchConditions, TBool aPendingConditions, TSchedulerItemRef& aRef)
	{
	if( aPendingConditions )
		{
		CreateScheduleL(iScheduler, aSchConditions, aTime, aRef);
	#ifndef _MSG_NO_LOGGING
		TBuf<32> bufDate;
		aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B"));
		SCHSENDLOG(FLog(_L("\tCreated Schedule %d for pending %d conditions or %S"), aRef.iHandle, aSchConditions.Count(), &bufDate));
	#endif		
		}
	else
		{		
		CreateScheduleL(iScheduler, *iSettings, aTime, aValidityPeriod, aRef);
	#ifndef _MSG_NO_LOGGING
		TBuf<32> bufDate;
		aTime.FormatL(bufDate, _L("%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%.%*C4%:3%+B"));
		SCHSENDLOG(FLog(_L("\tCreated Schedule %d for %S"), aRef.iHandle, &bufDate));
	#endif
		}
	}
EXPORT_C void CMsvScheduleSend::RoundUpToMinute(TTime& aTime)
	{
	TDateTime dt(aTime.DateTime());

	if (dt.MicroSecond() != 0 || dt.Second() != 0)
		{
		dt.SetMicroSecond(0);
		dt.SetSecond(0);
		aTime = dt;
		aTime += (TTimeIntervalMinutes) 1;
		}
	}
// -----------------------------------------------------------------------------
// CCbsMessageCleanupTimer::StartTimer
// Starts the clean up timer.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CCbsMessageCleanupTimer::StartTimer()
    {    
    // Cancel a pending request
    if ( IsActive() )
        {
        Cancel();
        }

    // Get the current time
    TTime now;
    now.HomeTime();

    if ( iInterval.Int() > 0 )
        {
        TTime nextCleanup( 0 );
        nextCleanup = now + iInterval;
        
        // Start the timer
        At( nextCleanup );
        }
    }
EXPORT_C void CMemSpyEngineOutputSink::DataStreamTimeStampBeginL( const TTime& aTime )
{
    const TDateTime dt( aTime.DateTime() );

    // Build it up...
    HBufC* spec = HBufC::NewL( KMaxFileName );
    TPtr pName( spec->Des() );
    pName.Format( KMemSpyDataStreamFolderNameFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());

    DataStreamTimeStampEnd();
    iDataStreamTimeStampSpecifier = spec;
}
void CAlfPerfAppAvkonTestCaseBasic::NextCycleL()
    {
    TAlfCustomEventCommand command( KAlfPerfAppAvkonCmdNext, this );
    User::LeaveIfError( Env().Send( command, KCycleDurationMs ) );
    
    iCycleCounter++;
   
    iAnimTimer->Cancel();
    iAnimTimer->Start(KAnimSleepTimeUs, KAnimSleepTimeUs, TCallBack(AnimTimerCbL, this));
    iAnimFrameNum = 0;
    iCycleStartTime.UniversalTime();
    }
// -----------------------------------------------------------------------------
// CHttpCacheEntry::Accessed
//
// -----------------------------------------------------------------------------
//
void CHttpCacheEntry::Accessed()
    {
    TTime now;
    now.HomeTime();
    iLastAccessed = now.Int64();

    iRef++;

    if ( iEvictionCandidate )
        {
        iEvictionHandler->Accessed( *this );
        }

#ifdef __CACHELOG__
    _LIT( KAccessFormat, "entry accessed: %d" );
    TBuf<100> buf;
    buf.Format( KAccessFormat, iRef );
    HttpCacheUtil::WriteUrlToLog( 0, buf, iUrl->Des() );
#endif // __CACHELOG__

    }
Example #8
0
/*
-------------------------------------------------------------------------
-------------------------------------------------------------------------
*/
TBool CExPolicy_Server::IsTimeBeforeL(TTime& aTime,TTime& aCompare)
{
	TBool IsBefore(EFalse);
	TTimeIntervalMinutes MinInterval(0);
	TTimeIntervalHours 	 HourInterval(0);
	TTimeIntervalSeconds SecInterval(0);
	
	TTime TimeNow;
	TimeNow.HomeTime();
	
	TTimeIntervalDays DaysInterval = aTime.DaysFrom(aCompare);
	if(DaysInterval.Int() <= 0)
	{
		aTime.HoursFrom(aCompare,HourInterval);
		if(HourInterval.Int() <= 0)
		{
			aTime.MinutesFrom(aCompare,MinInterval);
			if(MinInterval.Int() <= 0)
			{
				aTime.SecondsFrom(aCompare, SecInterval);
				if(SecInterval.Int() <= 0)
				{
					IsBefore = ETrue;
				}
			}
		}
	}
	
	return IsBefore;
}
Example #9
0
void CBusyTestUnit::ThreadFunction()
	{
	// this runs in a separate thread and tries to use lots of CPU time up to percentage
	// nominally we run busy for loops for iPercentBusy/100ms, and then wait for rest of the
	// 100ms using User::After(). We keep doing this until we reach the target time, if there is
	// one
	
	const TInt KDefaultLoop = 10000;
	TTime timeAtStart; 
	timeAtStart.UniversalTime(); // time of start
	
	const TInt KLoopInterval =100000; // 100ms - loop time
	TTimeIntervalMicroSeconds32 busyInterval(KLoopInterval*iPercentBusy/100); // how much of loop time to be busy
	TTimeIntervalMicroSeconds32 quietInterval(KLoopInterval-busyInterval.Int()); // how much of loop time to be quiet
	
	while (ETrue)
		{
		// the interval, for loops for the busy bit and then a User::After()
		TTime startOfInterval;
		startOfInterval.UniversalTime();
		while (ETrue)
			{
			// the busy bit - iBusyVariable is volatile so should never be optimised out
			for (TInt i=0; i<KDefaultLoop; i++)
				{
				iBusyVariable = i;
				}
			TTime now;
			now.UniversalTime();
			if (startOfInterval + busyInterval < now)
				{
				// we're passed the time
				break;
				}
			}
		User::After(quietInterval);		
			
		if (iRunFor.Int64())
			{
			// check to see if we are passed the interval given at Start()
			TTime now;
			now.UniversalTime();
			if (timeAtStart + iRunFor < now)
				{
				// we're passed the time
				break;
				}
			}
		}
	}
Example #10
0
void CPhoneWatcher::DoRetrieveTSYNameL()
	{
#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
	CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
#else
	CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
#endif
	CleanupStack::PushL(db);

	CMDBField<TUint32>* globalSettingsField = new(ELeave) CMDBField<TUint32>(KCDTIdModemPhoneServicesSMS);
	CleanupStack::PushL(globalSettingsField);
	globalSettingsField->SetRecordId(1);
	globalSettingsField->LoadL(*db);
	TUint32 modemId = *globalSettingsField;
	CleanupStack::PopAndDestroy(globalSettingsField);
	
	CMDBField<TDesC>* tsyField = new(ELeave) CMDBField<TDesC>(KCDTIdTsyName);
	CleanupStack::PushL(tsyField);
	tsyField->SetRecordId(modemId);
	tsyField->SetMaxLengthL(KMaxTextLength);
	tsyField->LoadL(*db);
	iTSYName = *tsyField;
	CleanupStack::PopAndDestroy(tsyField);
	
	
	// Strip any file extension
	TInt pos = iTSYName.LocateReverse('.');
	if	(pos >= 0)
		iTSYName = iTSYName.Left(pos);

#ifdef WATCHER_TESTING
	{
	TTime now;
	now.UniversalTime();
	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidTestProp_ModemTableRefreshed.iUid, I64LOW(now.Int64())));
	}
#endif

	CleanupStack::PopAndDestroy(); // db or commsDatabase 
	}
Example #11
0
bool_t GetDatePacked(datetime_t t, datepack_t *tp, bool_t Local)
{
	TDateTime Date;
    TTime ot;
	if (!tp || t == INVALID_DATETIME_T) return 0;
	
    ot = DateTimeToSymbian(t);

    if (Local) 
    {
#ifndef SYMBIAN90
        TLocale locale;
        TTimeIntervalSeconds universalTimeOffset(locale.UniversalTimeOffset());
        ot += universalTimeOffset;
        if (locale.QueryHomeHasDaylightSavingOn())
        {
            TTimeIntervalHours daylightSaving(1);
            ot += daylightSaving;
        }
#else
        RTz TzServer;
        if (TzServer.Connect()==KErrNone)
        {
            CTzConverter* Converter = CTzConverter::NewL(TzServer); 
            Converter->ConvertToLocalTime(ot);
            delete Converter;
            TzServer.Close();
        }
#endif
    }

	Date = ot.DateTime();
	tp->Year = Date.Year();
	tp->Month = (int)Date.Month() + 1;
	tp->Day = Date.Day()+1;
	tp->Hour = Date.Hour();
	tp->Minute = Date.Minute();
	tp->Second = Date.Second();
	return 1;
}
Example #12
0
LOCAL_D void TestBKLastModifiedTimeL ()
	{
	TTime currentTime;		

	RBkDatabase db;
	db.OpenL ();
	CleanupClosePushL ( db );	
	// Create a new folder.
	RBkFolder folder = db.CreateFolderL ( KMyFolder );
	CleanupClosePushL ( folder );
	folder.SetDescriptionL ( KMyFolderDesc );

	db.CommitL(); // Commit the transaction.
	User::After ( KGeneralDelay );
	currentTime.HomeTime ();
	gTestWrapper->TEST( folder.LastModifiedL() < currentTime ); // Creation time.
	TTime newTime;
	newTime.HomeTime ();
	TRAPD( err, folder.SetLastModifiedL( newTime ) );
	// Should leave with KErrPermissionDenied error
	gTestWrapper->TESTE( err == KErrPermissionDenied, err );	

	CleanupStack::PopAndDestroy ( &folder ); // destroy/close
	// Open the above created folder.
	folder = db.OpenFolderL ( KMyFolder );
	CleanupClosePushL ( folder );
	folder.SetDescriptionL ( KMyFolderNewDesc );
 	
	db.CommitL (); 
	User::After ( KGeneralDelay );
	currentTime.HomeTime ();
	gTestWrapper->TEST( folder.LastModifiedL() < currentTime );  // Save time.
		
	Bookmark::TItemId id = folder.Id();
	CleanupStack::PopAndDestroy ( &folder );
	db.DeleteItemL ( id ); // mark for deleting	
	db.CommitL ();

	CleanupStack::PopAndDestroy ( &db );		
	}
Example #13
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"));
	
	}	
/** Creates files

	@param aSelector Configuration in case of manual execution
*/
LOCAL_C TInt TestAll(TAny* aSelector)
	{
	TInt r = 0;
	TTime startTime;
	TTime endTime;
	TTimeIntervalSeconds timeTaken;

	Validate(aSelector);
	
	gFormat = EFalse; 	// The card won't be formatted after this test execution
	
	startTime.HomeTime();
	
	TestFileCreate(aSelector);
	
	endTime.HomeTime();
	r = endTime.SecondsFrom(startTime, timeTaken);
	FailIfError(r);
	test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int());

	return KErrNone;
	}
CIpuTestHarness::~CIpuTestHarness()
//
//	D'tor
	{
	TTime endtime;
	endtime.UniversalTime();

	// Do resource handle leak test?
	if (iDoResourceLeakTest)
		ResourceLeakTest();

	//	End of tests - see if failed or ok
	if (iFailedTests->Count())
		{
		TestHarnessFailed();
		}
	else
		{
		TestHarnessComplete();
		}

	iFailedTests->ResetAndDestroy();
	delete iFailedTests;

	//	Log finish time
	TDateTime t = endtime.DateTime();
	LogIt(_L("Ended @ %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
	TTime difftime(endtime.Int64() - iStartTime.Int64());
	t = difftime.DateTime();
	LogIt(_L("Execution time %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond());

	//	Close logs and test harness
	iFlogger.CloseLog();
	
	// iTest test harness performs UHEAP MARK/UNMARK check upon creation/destruction
	//   therefore, it must be destroyed last since it is created first in 
	//   CIpuTestHarness
	iTest.Close();
	}
Example #16
0
TBMTicks TBMTimeInterval::End()
	{
	//
	// The same as the previous one but returns ticks
	//

	TBMTicks stamp;
	::bmTimer.Stamp(&stamp);
	TTime time;	
	time.HomeTime();
	TBMNs ns = TTimeIntervalMicroSecondsToTBMNs(time.MicroSecondsFrom(iTime));
	if (ns < iStampPeriodNs)
		{
		stamp = TBMTicksDelta(iStamp, stamp);
		}
	else
		{
			// multiply first - privileging precision to improbable overflow.
		stamp = (ns * iStampPeriod) / iStampPeriodNs; 
		}
	return stamp;
	}
// ---------------------------------------------------------------------------
// TPresCondValidity::ConvertToLocal()
// ---------------------------------------------------------------------------
//        
void TPresCondValidity::ConvertToLocal(TTime& aDateTime)
    {
    OPENG_DP(D_OPENG_LIT( " TPresCondValidity::ConvertToLocal()" ) );
    OPENG_DP(D_OPENG_LIT( "     ConvertToLocal aDateTime:"));
    LogDateTime(aDateTime.DateTime());

    TLocale myLocale;
    myLocale.Refresh();
    
    // getting UTC difference    
    TTimeIntervalSeconds uTCseconds = myLocale.UniversalTimeOffset();
    aDateTime = aDateTime + uTCseconds;
    }
Example #18
0
void CSTAnnounceList::ShuffleL()
{
	TTime now;
	now.HomeTime();
	TInt64 seed = now.Int64();

	for (TInt i=0; i<iTiers.Count(); i++)
	{
		TInt addressCount = iTiers[i]->MdcaCount();
			
		if (addressCount > 1)
			for (TInt j=0; j<addressCount; j++)
			{
				TInt pos = TInt(Math::Rand(seed)) % (addressCount-1);

				HBufC8* address = (*iTiers[i])[j].AllocLC();
				iTiers[i]->Delete(j);
				iTiers[i]->InsertL(pos, *address);
				CleanupStack::PopAndDestroy(); // address
			}
	}
}
// ----------------------------------------------------------------------------
// MPXDbUtil::DayNoInWeek
// ----------------------------------------------------------------------------
//
TInt MPXDbUtil::DayNoInWeek()
    {
    MPX_FUNC("MPXDbUtil::DayNoInWeek");

    TTime now;  // in microseconds
    now.HomeTime();

    // Calculate number of days in this week
    TDay dayNo = now.DayNoInWeek();
    TDay firstDay = TLocale().StartOfWeek();
    TInt numDay(0);
    if (firstDay == ESunday)
        {
        numDay = dayNo + 1;
        }
    else
        {
        numDay = dayNo - firstDay;
        }

    return numDay;
    }
Example #20
0
void CTimeout::Start(TInt64 aTime)
    {
//    TRACE_FUNCF((_L("aTime=%d iTime=%d"), aTime, iTime));
//    LOG_DEBUGF((_L("start timer aTime=%d iTime=%d"), aTime, iTime));
    if (aTime != 0)
        {
        iTime = aTime;
        }
    if (iTime < 2100000)
        {
        iTimer.After(iStatus, iTime * 1000);
        }
    else
        {
        TTime time;
        time.HomeTime();
        TTimeIntervalMicroSeconds delta = iTime * 1000;
        time += delta;
        iTimer.At(iStatus, time);
        }
    SetActive();
    }
Example #21
0
MNcdNode::TState CNcdNodeProxy::State() const
    {
    DLTRACEIN((_L("Node namespace=%S, id=%S"), &Namespace(), &Id() ));

    // Check if the link handle has been set, which means that also
    // link data has been internalized. Also, check if the metadata 
    // exists, which means that metadata has also been internalized.
    if ( LinkHandleSet() 
         && iMetadata != NULL )
        {
        DLINFO(("State was initialized"));
        // If state was initialized we have to check if the state
        // has acutally expired already 
        TTime now;
        now.HomeTime();

        DLINFO(("now time: %d", now.Int64() ));
        DLINFO(("expired time: %d", ExpiredTime().Int64() ));

        // We can just compare the times here. Server side
        // inserts the maximum value for the expired time if the
        // protocol has set never expire value for the validity delta.
        if ( now > ExpiredTime() )
            {
            DLTRACEOUT(("Expired"));
            return MNcdNode::EStateExpired;
            }
            
        DLTRACEOUT(("Initialized"));
        return MNcdNode::EStateInitialized;
        }
     else
        {
        // Node has not been initialized.
        DLTRACEOUT(("Not initialized"));
        return MNcdNode::EStateNotInitialized;
        }
    }
Example #22
0
void CTestPerf::ReadComplete(TInt aStatus)
	{
	if (iTrace)
		Test.Printf(_L("CTestPerf::ReadComplete(%d) len = %d/%d\r\n"), aStatus, iWriter->iDes.Length(), iWriter->iDes.MaxLength());

	if (aStatus!=KErrNone)
		{
		Fail(ETestFailRead, aStatus);
		return;
		}

	switch (iState)
		{
	case EWaitIO:
		iRetries = 0;
		iTimer->Cancel();
		iCount += iReader->iCount;
		iPackets++;
		{
		TTime end;
		end.UniversalTime();
		TInt64 difftime = (end.MicroSecondsFrom(iStartTime).Int64()+TInt64(500000))/TInt64(1000000);
		if (difftime==0)
			difftime = 1;
		TInt64 cps = MAKE_TINT64(0,iCount)/difftime;
		TInt rate = (I64INT(cps)*10000)/11520;

		iRate += rate;
		iSpeed += I64INT(cps);
		
		Test.Printf(_L("%c %6d %d (%dbps=%d.%02d%%)\r"), KSpinner[iSpin++ & 3], iPackets, iCount, iSpeed/iPackets, (iRate/iPackets)/100, (iRate/iPackets)%100);
		}
		Read();
		break;
	default:
		break;
		}
	}
void CEmTubePlaylistManager::RemoveOutdatedEntries( CEmTubePlaylist* aPlaylist )
	{
	TTime weekago;
	weekago.HomeTime();
	TTimeIntervalHours week( 24*7 );
	weekago -= week;
	TInt count = aPlaylist->EntriesCount();
	for(TInt i=count-1;i>0;i--)
		{
		CEmTubePlaylistEntry *e = aPlaylist->Entry( i );
		TTimeIntervalHours diff;
		e->Time().HoursFrom( weekago, diff );
		if( diff > week )
			{
			aPlaylist->RemoveEntry( i );
			delete e;
			}
		else
			{
			break;
			}
		}
	}
LOCAL_C void WriteTimeL( TTime aTime )
    {
    RFs fs;
    User::LeaveIfError( fs.Connect() );
    CleanupClosePushL(fs);
    HBufC8* text = HBufC8::NewLC(100);
    TPtr8 textptr(text->Des() );
// Date and Time display
    TBuf<256> dateString;
    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
    aTime.FormatL(dateString,KDate);
    textptr.Append(_L( "\r\n\t\t\t\tData:\t" ) );
    textptr.Append( dateString );
    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
    aTime.FormatL(dateString,KTime);
    textptr.Append(_L( "\r\n\t\t\t\tTime:\t" ) );
    textptr.Append( dateString );
    textptr.Append(_L( "\r\n" ) );
    textptr.Append(_L( "\r\n" ) );
    WriteLogL(textptr , fs);
    CleanupStack::PopAndDestroy(text);
    CleanupStack::PopAndDestroy(&fs); //fs
    }
Example #25
0
TInt CSpecialLog::UpdateL(TBool aForced)
{
	if (NULL == iFs)
		return KErrNotReady;

	if (EInitializing == iState)	// No need to flush during loading.
		return KErrNone;

	iState = EUnsaved;

	TTime now;
	TTimeIntervalMinutes diff;
	now.UniversalTime();

	// Check flush interval.
	if (!aForced && (now.MinutesFrom(iTimeLastSave, diff), diff < TTimeIntervalMinutes(KSpecialLogInterval)))
		return KErrNone;

	// Update time of last save.
	iTimeLastSave = now;

	return SaveL();
}
// -----------------------------------------------------------------------------
// CTFAStifTestLog::ConstructL
// -----------------------------------------------------------------------------
void CTFAStifTestLog::ConstructL( void )
    {
    TFileName fileName;
    TTime time;
    time.HomeTime();
    TDateTime dateTime = time.DateTime();
    RThread thread;
#ifdef __LOG_HTML__
    _LIT( KSuffix, "html" );
#else
    _LIT( KSuffix, "txt" );
#endif
    fileName.Format( _L( "%02d%02d%02d_%02d%02d%02d_%x.%S" ), 
        dateTime.Year() - 2000, dateTime.Month() + 1, dateTime.Day() + 1, 
        dateTime.Hour(), dateTime.Minute(), dateTime.Second(), 
        (TUint)thread.Id(), &KSuffix );
    iLogger = CStifLogger::NewL( _L( "c:\\logs\\testframework\\" ), fileName,
        CStifLogger::ETxt, CStifLogger::EFile, ETrue, EFalse, EFalse, EFalse, EFalse );
    iOverflowHandler = new ( ELeave ) TTFAOverflowHandler;
#ifdef __LOG_HTML__
    iLogger->Log( _L8( "<html><head><title>TFA Log</title></head>\r\n<body>\r\n" ) );
#endif
    }
void CMemSpyEngineSinkMetaData::ConstructL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime )
{
    iRoot = aRoot.AllocL();
    iContext = aContext.AllocL();
    iFolder = aFolder.AllocL();
    iExtension = aExtension.AllocL();

    const TDateTime dt = aFolderTime.DateTime();
    HBufC* spec = HBufC::NewLC( KMaxFileName );
    TPtr pName( spec->Des() );
    pName.Format( KMemSpyDataStreamFolderNameFormatSpec, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second());
    iFolderTimeStamp = pName.AllocL();
    CleanupStack::PopAndDestroy( spec );
}
Example #28
0
TPath CImageRescaler::GenerateDestPath(const TDesC& aSrcPath)
    {
    // Image file type
    TParse p;
    TInt err = p.Set(aSrcPath, NULL, NULL);
    TPath destFile;
    
    if (err == KErrNone)
        {
        // Generate the image path
        // Format <path>_timestamp_filename.ext
        destFile.Append(iImagesDirPath);
        destFile.Append(_L("_"));
        
        TTime time;
        time.UniversalTime();
        destFile.AppendNum(time.Int64());
        destFile.Append(_L("_"));
        destFile.Append(p.NameAndExt());
        }
    
    return destFile;
    }
void DoTestV4DatabaseL(TBool aOOMTest = ETrue)
    {
    if (aOOMTest)
        {
        CopyCdbFileToCDriveL(KDatabaseV4With4Entries);
        }
    else
        {
        CopyCdbFileToCDriveL(KDatabaseV4);
        }
    
    TTime startTime;
    TTime endTime;
        
        
    //Test end profiling
    startTime.UniversalTime(); //start profiling
    CContactDatabase* db=CContactDatabase::OpenL(KDatabaseCDrive); 
    endTime.UniversalTime(); //end profiling
    CleanupStack::PushL(db);
    
    //need to sort item otherwise CountL return 0 - only in old model
/*  CContactDatabase::TSortPref sortPref(KUidContactFieldGivenName);
    CArrayFix<CContactDatabase::TSortPref>* sortOrder=new(ELeave) CArrayFixFlat<CContactDatabase::TSortPref>(1);
    CleanupStack::PushL(sortOrder);
    sortOrder->AppendL(sortPref);
    db->SortL(sortOrder); //Takes ownership
    CleanupStack::Pop(sortOrder);*/

    TInt count=db->CountL();
    
    //Now compute delay and print on the screen
    TTimeIntervalMicroSeconds delay=endTime.MicroSecondsFrom(startTime);
    test.Printf(_L("A v4 database containing %d contacts was converted in %d ┬Ás\n"),count,delay.Int64());

    CleanupStack::PopAndDestroy(db); //db
    }
// ---------------------------------------------------------------------------
// TEST CASE: Start timer with At without connecting first
// ---------------------------------------------------------------------------
//
TInt CTestRFlexTimer::AtUtcWithoutConnect(
    TTestResult& aResult, 
    CTestFlexTimer* aCallback )
    {
    TRequestStatus status;

    // Test should panic with
    // Category: "KERN-EXEC"
    // Reason:   0
    aCallback->TestModuleIf().SetExitReason( 
        CTestModuleIf::EPanic,
        0 );
    
    // Do the actual test
    //-----------------------------------------------------

    RFlexTimer timer;

    TTime expirationTime;
    expirationTime.UniversalTime();
    expirationTime += TTimeIntervalMicroSeconds( 1000000 );
    
    timer.AtUTC( status, expirationTime );
    User::WaitForRequest( status ); // PANIC
    timer.Close();

    //-----------------------------------------------------

    // No panic, change result back to normal
    aCallback->TestModuleIf().SetExitReason( 
        CTestModuleIf::ENormal,
        KErrNone );

    aResult.SetResult( KErrGeneral, _L("Test case failed. No panic.") );
    
    return KErrNone;
    }