Ejemplo n.º 1
0
LOCAL_C void DeleteGroupMembersCheckPersist()
	{
	test.Next(_L("Delete Group Members Check Persist"));
//
	TTime before;
	before.UniversalTime();
	for(TInt ii=1;ii<KLargeSizeRecords+1;ii++)
		{
		CntTest->Db()->DeleteContactL(ii);
		if (ii%100==0)
			test.Printf(_L("."));	// Just to show some life
		}
	TTime after;
	after.UniversalTime();
	TTimeIntervalSeconds secondsTaken;
	after.SecondsFrom(before,secondsTaken);
	test.Printf(_L(" TIME: %d  Secs"),secondsTaken.Int());
	test.Printf(_L("\n"));	
	//test.Getch();
//
	CContactIdArray* groups = CntTest->Db()->GetGroupIdListL();
	CleanupStack::PushL(groups);
	CContactItem* group = CntTest->Db()->ReadContactL((*groups)[0]);
	CContactIdArray* memberArray = STATIC_CAST(CContactGroup*,group)->ItemsContainedLC();
	test(memberArray->Count()==0);
	delete group;
	CleanupStack::PopAndDestroy(2); // groups memberArray
	}
Ejemplo n.º 2
0
LOCAL_C void DeleteManyGroups()
	{
//
	test.Next(_L("Delete MANY Groups"));
	TTime before;
	before.UniversalTime();
	for(TInt ii=6;ii<KLargeSizeRecords+6;ii++)
		{
		CntTest->Db()->DeleteContactL(ii);
		if (ii%100==0)
				test.Printf(_L("."));	// Just to show some life
		}
	TTime after;
	after.UniversalTime();
	TTimeIntervalSeconds secondsTaken;
	after.SecondsFrom(before,secondsTaken);
	test.Printf(_L(" TIME: %d  Secs"),secondsTaken.Int());
	test.Printf(_L("\n"));	
	//test.Getch();

//
	test.Next(_L("Test Card Membership Update"));
	test(CntTest->Db()->CountL()==5); // 5 contacts + own card
	for(TInt jj=1;jj<6;jj++)
	// add cards to all groups
		{
		CContactItem* contact = CntTest->Db()->ReadContactLC(jj);
		CContactIdArray* groups = STATIC_CAST(CContactCard*, contact)->GroupsJoinedLC();
		test(groups->Count()==0);
		CleanupStack::PopAndDestroy(2); // contact groups
		}
	CntTest->Db()->CompactL();
	}
Ejemplo n.º 3
0
GLDEF_C TInt E32Main()
    {
	CTrapCleanup* cleanup;
	cleanup=CTrapCleanup::New();
 	__UHEAP_MARK;

	test.Title();
	test.Start(_L("Starting tests..."));

	TTime timerC;
	timerC.HomeTime();
	
	DoTests();

	TTime endTimeC;
	endTimeC.HomeTime();
	TTimeIntervalSeconds timeTakenC;
	TInt r=endTimeC.SecondsFrom(timerC,timeTakenC);
	test(r==KErrNone);
	test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
	test.End();
	test.Close();
	__UHEAP_MARKEND;
	delete cleanup;
	return(KErrNone);
    }
Ejemplo n.º 4
0
void CPosition::RunL()
{
    TPosition position;
    iPositionInfo.GetPosition(position);

    TTime now;
    now.UniversalTime();

    TTimeIntervalSeconds interval = 0;
    now.SecondsFrom(position.Time(), interval);

    LOGARG("Interval between retrieved position and current time: %d secs", interval.Int());

    // Compare that retrieved data is not outdated
    if (iStatus == KErrNone && interval.Int() < 300)
    {
        iObserver.PositionUpdateL(iStatus.Int(), position);
    }
    else if (iStatus == KErrTimedOut)
    {
        iObserver.PositionUpdateL(iStatus.Int(), position);
    }
    else
    {
        iPositioner.NotifyPositionUpdate(iPositionInfo, iStatus);
        SetActive();

        iState = EGps;
    }
}
Ejemplo n.º 5
0
void CT_RMobileCallData::DoCmdGetCallDuration(const TTEFFunction& aSection)
	{
	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdGetCallDuration"));
	TInt callNameParameter;
	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
		{
		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
		SetBlockResult(EFail);
		}
	else
		{
		INFO_PRINTF1(_L("Getting mobile call"));
		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
		if(error != KErrNone)
			{
			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
			SetBlockResult(EFail);
			}
		else
			{
			TTimeIntervalSeconds duration = 0;
			error = iMobileCall->GetCallDuration(duration);
			if(error != KErrNone)
				{
				ERR_PRINTF2(_L("Failed to get call duration with error %d"), error);
				SetError(error);
				}
			else
				{
				INFO_PRINTF3(_L("Call %d duration was %d seconds"), callNameParameter, duration.Int());
				}
			}
		}
	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdGetCallDuration"));
	}
TUint CTupleStoreImpl::PutL(TTupleType aTupleType, const TTupleName& aTupleName, const TDesC& aSubName, 
		const TComponentName& aComponent,
		const TDesC8& aSerializedData, TBBPriority aPriority, TBool aReplace,
		const TTime& aLeaseExpires, TBool aKeepExisting)
{
	CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("PutL"));

	if (aTupleName.iModule.iUid == KBBAnyUidValue ||
		aTupleName.iId == KBBAnyId ||
		aComponent.iModule.iUid == KBBAnyUidValue ||
		aComponent.iId == KBBAnyId) User::Leave(KErrArgument);

	TUint ret;
	{
		TAutomaticTransactionHolder ath(*this);

		TBool exists=SeekNameL(aTupleType, aTupleName, aSubName);
		if (exists && aKeepExisting) {
			UpdateL();
			iTable.SetColL(ELeaseExpires, aLeaseExpires);
			MDBStore::PutL();
			return 0;
		} else if (exists && aReplace) {
			UpdateL();
		} else {
			InsertL();
			iTable.SetColL(ETupleType, aTupleType);
			iTable.SetColL(ENameModule, aTupleName.iModule.iUid);
			iTable.SetColL(ENameId, aTupleName.iId);
			iTable.SetColL(ENameSubName1, aSubName);
			iTable.SetColL(ENameSubName2, aSubName.Left(iSubNameIndexLength));
			iTable.SetColL(EPriority, aPriority);
			iTable.SetColL(EComponentModule, aComponent.iModule.iUid);
			iTable.SetColL(EComponentId, aComponent.iId);
		}
		ret=iTable.ColUint(ETupleId);

		if (aSerializedData.Length() > 0) {
			RADbColWriteStream w; w.OpenLA(iTable, EData);
			w.WriteUint32L(aSerializedData.Length());
			w.WriteL(aSerializedData);
			w.CommitL();
		} else {
			iTable.SetColNullL(EData);
		}
		iTable.SetColL(ELeaseExpires, aLeaseExpires);
		MDBStore::PutL();
	}

	if (aLeaseExpires < iNextExpiry) {
		TTime now=GetTime();
		TTimeIntervalSeconds s;
		aLeaseExpires.SecondsFrom(now, s);
		TInt wait=s.Int();
		iTimer->Wait(wait);
	}
	return ret;
}
Ejemplo n.º 7
0
GLDEF_C time_t as_time_t(const TTime& t)
{
    TTimeIntervalSeconds res;
    TInt err = t.SecondsFrom(UNIX_BASE, res);
    if (err)
        return -1;
    else
        return res.Int();
}
Ejemplo n.º 8
0
/*
Intended Usage:	Utility routine for converting from UTC to localtime.
*/
inline time_t toLocal (const time_t aUniversalTime)
{
#ifndef __SERIES60_MRT_1_0
    TTimeIntervalSeconds offset = User::UTCOffset();
    return aUniversalTime + offset.Int();
#else
    TLocale locale;
    return aUniversalTime + locale.UniversalTimeOffset().Int();
#endif //__SERIES60_MRT_1_0
}
void CTupleStoreImpl::CleanOldTuplesL()
{
	CALLSTACKITEM_N(_CL("CTupleStoreImpl"), _CL("CleanOldTuplesL"));

	SwitchIndexL(EIndexLeaseExpires);
	iTable.FirstL();
	iTable.GetL();

	TTupleName name; TBuf<KMaxTupleSubNameLength> subname;
	TTime expires;
	
	if (iTable.IsColNull(ELeaseExpires)) {
		expires=TTime(0);
	} else {
		expires=iTable.ColTime(ELeaseExpires);
	}
	TTime now=GetTime();
	TInt tupletype=-1;
	while (now > expires) {
		if ( iTable.IsColNull(ELeaseExpires) ) {
			UpdateL();
			iTable.SetColL( ELeaseExpires, Time::MaxTTime() );
			MDBStore::PutL();
		} else {
			tupletype=iTable.ColInt(ETupleType);
			if (tupletype == ETupleDataOrRequest) {
				name.iModule.iUid=iTable.ColInt(ENameModule);
				name.iId=iTable.ColInt(ENameId);
				subname=iTable.ColDes16(ENameSubName1);
			}
			MDBStore::DeleteL();
			if (tupletype == ETupleDataOrRequest) {
				iDeleteNotification.NotifyDeleted(name, subname);
			}
		}
		if (! iTable.NextL() ) return;
		iTable.GetL();
		if (iTable.IsColNull(ELeaseExpires)) {
			expires=TTime(0);
		} else {
			expires=iTable.ColTime(ELeaseExpires);
		}
	}
	if ( expires == TTime(0) || expires == Time::MaxTTime() ) return;

	TTimeIntervalSeconds s;
	TInt err=expires.SecondsFrom(now, s);
	if (err==KErrOverflow) return;

	iNextExpiry=expires;
	TInt wait=s.Int();
	iTimer->Wait(wait);
}
Ejemplo n.º 10
0
void TTestTimer::End()
    {
    iEnd.HomeTime();

    TTimeIntervalSeconds timeTaken;
    iEnd.SecondsFrom(iStart, timeTaken);
    TUint totalTime = timeTaken.Int();
    test.Printf(_L("Time taken is %dHrs:%dmins:%dsecs\n"),
                  totalTime/3600,
                  (totalTime/60)%60,
                  totalTime%60);
    }
Ejemplo n.º 11
0
void CMemoryUsageLogger::WriteToLog()
	{
	//seconds passed since start of application
	TTime currentTime;
	TTimeIntervalSeconds seconds;
	currentTime.UniversalTime();
	currentTime.SecondsFrom(iStartTime, seconds);
	
	if (seconds.Int() <= 60)
		{
		TInt heapTotal = 0;
		TInt heapAvail = 0;
		TInt chunkTotal = 0;
		TInt chunkAvail = 0;
		TInt cellsTotal = 0;
		TInt cellsAvail = 0;
		TInt heapStackTotal = 0;
		TInt ramTotal = 0;
		TInt ramAvail = 0;
		
		//get system memory info from hardware abstraction layer
		HAL::Get(HAL::EMemoryRAM, ramTotal);
		HAL::Get(HAL::EMemoryRAMFree, ramAvail);
		
		//get process UID
		TSecureId processUid(iProcess.SecureId());
		
		//get various heap and chunk memory sizes
		iHeap.AllocSize(heapTotal);
		if (heapTotal > iMaxHeapTotal)
			{
			iMaxHeapTotal = heapTotal;
			}
		iHeap.Available(heapAvail);
		chunkTotal = iHeap.Size();
		chunkAvail = chunkTotal - heapTotal;
		if (chunkTotal > iMaxChunkTotal)
			{
			iMaxChunkTotal = chunkTotal;
			}
		
		//get cells info
		cellsTotal = iHeap.Count(cellsAvail);
		
		//sum up the total heap and stack sizes
		heapStackTotal = heapTotal + iStackSize;
		
		//create log text and write to log file
		TBuf16<KLbsDevLogMaxBufSize> logData;
		logData.Format(KLogFormat, seconds.Int(), processUid.iId, iStackSize, heapTotal, heapAvail, chunkTotal, chunkAvail, cellsTotal, cellsAvail, heapStackTotal, ramTotal, ramAvail);
		iLogger.Write(logData);
		}
	}
void AddToPyDict(python_ptr<PyObject> &dict, char* name, const TTime& value)
{
	TDateTime epoch; epoch.Set(1970, EJanuary, 0, 0, 0, 0, 0);
	TTime e(epoch);
	TInt unixtime=0;
	TTimeIntervalSeconds secs;
	if (value!=TTime(0)) {
		User::LeaveIfError(value.SecondsFrom(e, secs));
		unixtime=secs.Int();
	}
	AddToPyDict(dict, name, unixtime);
}
Ejemplo n.º 13
0
void CLogMonitor::RunL()
{
    if(iStatus != KErrCancel)
        switch(iState)
        {
            case EWaitingChange:

                // if this doesn't appear to catch the event right
                // you could try sleeping a bit before fetching the event...
                // User::After(2000000);
                GetLatest();
                break;

            case EReadingLog:
                if(iRecentLogView)
                {
                    if(iRecentLogView->CountL() > 0)
                        GetFirstEventL();
                    else
                        StartMonitorL();
                }
                break;

            case EReadingFirstLog:
            case EReadingLogItems:
                if(iStatus == KErrNone && iRecentLogView)
                {
                    TLogFlags iFlags = iRecentLogView->Event().Flags();
                    if( !( iFlags & KLogEventRead ) )
                    {
                        const CLogEvent& ev=iRecentLogView->Event();
                        TTimeIntervalSeconds secs;
                        ev.Time().SecondsFrom(iLastTime,secs);
                        iLastTime=iRecentLogView->Event().Time();
                        qDebug()<<"secs"<<secs.Int();
                        if (abs(secs.Int())>0) iCallBack->LogEventL(ev);
                    }
                    //GetNextEventL();
                    StartMonitorL();
                }
                else
                    StartMonitorL();
                break;

            case EDeletingEvent:
                GetNextEventL();
                break;

            default:
                StartMonitorL();
                break;
        }
}
Ejemplo n.º 14
0
// ---------------------------------------------------------------------------
// TPresCondValidity::FormatToXMLTimeStringL()
// ---------------------------------------------------------------------------
//
TInt TPresCondValidity::FormatToXMLTimeStringL(TDes& aXMLTimeString, 
                                                    const TTime aUTCDateTime)
    {
    OPENG_DP(D_OPENG_LIT( " TPresCondValidity::FormatToXMLTimeString()" ) );
    OPENG_DP(D_OPENG_LIT( "     FormatToXMLTimeString aUTCDateTime:"));
    LogDateTime(aUTCDateTime.DateTime());

    // Initializing the locale
    TLocale myLocale, systemLocale;
    myLocale.Refresh();
    systemLocale.Refresh();
    myLocale.SetDateFormat(EDateJapanese);
    myLocale.SetDateSeparator('-',1);
    myLocale.SetDateSeparator('-',2);
    myLocale.SetDateSeparator('T',3);
    
    myLocale.SetTimeFormat(ETime24);
    myLocale.SetTimeSeparator(':',1);
    myLocale.SetTimeSeparator(':',2);
    myLocale.SetTimeSeparator(' ',3);
    myLocale.Set();
    
    // getting UTC difference    
    TTimeIntervalSeconds uTCseconds = systemLocale.UniversalTimeOffset();
    
    // processing main time and date component
    TTime mainTTime = aUTCDateTime + uTCseconds;            
    mainTTime.FormatL(aXMLTimeString, KPresDateTimeFormatString);
    
    // Processing for time difference
    TChar uTCtimeSign('+');
    TDateTime myUTCtime(0,EJanuary,0,0,0,0,0);
    TTime uTCTTime(myUTCtime);
    if(uTCseconds.Int()<0)
        {
        uTCtimeSign = '-';
        uTCseconds = (uTCseconds.Int())*(-1);        
        }
    uTCTTime = uTCTTime + uTCseconds;
    TBuf<KPresDateTimeBufLength> dateTimeUTCBuffer;
    uTCTTime.FormatL(dateTimeUTCBuffer, KPresUTCFormatString);


    // Appending the time difference to main string
    aXMLTimeString.Append(dateTimeUTCBuffer);
    
    // put time difference sign to main string
    aXMLTimeString[23] = uTCtimeSign;
    
    // putting the system locale back
    systemLocale.Set();
    return KErrNone;
    }
Ejemplo n.º 15
0
/**
   @SYMTestCaseID 		UIF-FEPTEST-0001
   @SYMPREQ				0000
   @SYMTestCaseDesc  	Launch the application and offer events.
   @SYMTestPriority 	High 
   @SYMTestStatus 		Implemented
   @SYMTestActions 		Launch an application with the editor window. The application is made to exit, when a timer expires.   
   						Load the FEP (TFEP1). Create character codes for text events. Offer the texts to the applciation for 
   						the TFEP1 to intercept.  
   						A succesful implementation ensures that the application exits without a crash.
  						Here the layout of the FEP UI is such that the Composition Window is integrated into the Target Control.  
   @SYMTestExpectedResults The test case fails if the app crashed with an exception and passes if the app exits cleanly
 */
void CDefocusingEdwinUi::RunTestStepL(TInt aStep)
	{
	User::After(TTimeIntervalMicroSeconds32(1));

	TTimeIntervalSeconds theInterval;

	TTime tm;
	tm.HomeTime();
	tm.SecondsFrom(iTmStart,theInterval);

	TInt theInt = theInterval.Int();

	if(iCurrentSecond < theInt)
		{
		if(KNumberOfSeconds-iCurrentSecond < 0)
			{
			iCoeEnv->InstallFepL(KNullUid);
			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
			return;
			}
		else
			{
			TBuf<100> message;
			message.Format(_L("%d seconds remaining"), KNumberOfSeconds-iCurrentSecond);
			User::InfoPrint(message);
		
			iCurrentSecond = theInt;
			}
		}
	TWsEvent theEvent;
	TKeyEvent *theKey = theEvent.Key();
	theKey->iScanCode = 0;
	theKey->iModifiers= 0;
	theKey->iRepeats=0;
	theKey->iCode = 'A';
	
	TInt nRes = aStep % 7;

	if(nRes == 6)
		{
		theKey->iCode = EKeyEnter;
		}
	else
		{
		theKey->iCode += nRes;
		}

	INFO_PRINTF2(_L("Simulate Key Event with code %d"), theKey->iCode);
	SendEventToWindowGroups(theEvent);
	}
Ejemplo n.º 16
0
// ------------------------------------------------------------------------
// CDRMConsume::DoCancelL
// ------------------------------------------------------------------------
//
void CDRMConsume::DoCancelL()
{
    DRMLOG( _L( "CDRMConsume::DoCancelL" ) );

    if ( iCurrentDelay )
    {
        TTimeIntervalSeconds secs;
        TTime trustedTime;
        TBool secureTime;

        CTimer::DoCancel();

        secureTime = SECURETIME( trustedTime );
        trustedTime.SecondsFrom( iTime, secs );

#ifdef RD_DRM_METERING
        // Update total cumulative time for content metering purposes
        iTotalCumulativeTime = iTotalCumulativeTime.Int() + secs.Int();
#endif

        // If the top level timed counter has not been activated yet
        // increment the counter
        if( ISSET( iTimedCounts, KChildToplevelCount ) )
        {
            iCumulativeDelayTop = iCumulativeDelayTop.Int() + secs.Int();
        }

        // If the child timed counter has not been activated yet
        // increment the counter
        if( ISSET( iTimedCounts, KChildPermCount ) )
        {
            iCumulativeDelayChild = iCumulativeDelayChild.Int() + secs.Int();
        }

        // Always >= 0.
        ConsumeTimedItemsL( secs,
                            secureTime,
                            trustedTime );
        iCurrentDelay = 0;
    }

    UpdateDBL();

    if ( SERVER->HasActiveCountConstraint( *iURI ) )
    {
        SERVER->RemoveActiveCountConstraint( *iURI );
    }

    DRMLOG( _L( "CDRMConsume::DoCancel ok" ) );
}
// -----------------------------------------------------------------------------
// CTransactionIDGenerator::AddSystemInfo
// -----------------------------------------------------------------------------
//
void CTransactionIDGenerator::AddSystemInfo( TDes8& aBuf ) const
    {
    TInt biggestBlock = 0;
    TInt totalAvailable = User::Available( biggestBlock );
    TInt value = biggestBlock + totalAvailable - User::CountAllocCells();
    ComputeChecksum( aBuf, &value, sizeof( value ) );

    TTimeIntervalSeconds inactivity = User::InactivityTime();
    if ( inactivity.Int() > 0 )
        {
        TUint8 byteVal = static_cast<TUint8>( inactivity.Int() & 0xff );
        aBuf.Append( &byteVal, sizeof( byteVal ) );
        }
    }
Ejemplo n.º 18
0
datetime_t SymbianToDateTime(TTime Time)
{
    // reference is 1st January 2001 00:00:00.000 UTC
	datetime_t Date = INVALID_DATETIME_T;
    TTime Reference(ToInt64(LL(0x00e05776f452a000)));
    TTimeIntervalSeconds Diff;

    if (Time.SecondsFrom(Reference,Diff) == KErrNone)
	{
		Date = Diff.Int();
		if (Date==INVALID_DATETIME_T) ++Date;
	}

	return Date;
}
Ejemplo n.º 19
0
void CSuspendTest::TimeSinceStart() const
	{
	TTimeIntervalSeconds timeTaken;
	TTime time;
	time.HomeTime();
	TInt r = time.SecondsFrom(iStartTime, timeTaken);
	test(r == KErrNone);
	TInt totalTime = timeTaken.Int();

	TInt seconds = totalTime % 60;
	TInt minutes = (totalTime / 60) % 60;
	TInt hours   = totalTime / 3600;

	test.Printf( _L("Time since test started = %d:%d:%d\n"), hours, minutes, seconds );
	}
Ejemplo n.º 20
0
TBool CDbEventListener::ListenForEvent(TTimeIntervalSeconds aTimeOut, TContactDbObserverEvent& aEvent)
    {
    CTimer::Cancel();

    if (iEventQueue.IsEmpty())
        {
        CTimer::After(aTimeOut.Int() * 1000000);
        // Keep execution here until the timer expires
        do  {
            CActiveScheduler::Start();
            }
        while (CTimer::IsActive());
        }

    if (!iEventQueue.IsEmpty())
        {
        aEvent = iEventQueue.Head();
        iEventQueue.PopHead();
        return ETrue;
        }
    else
        {
        return EFalse;
        }
    }
Ejemplo n.º 21
0
LOCAL_C void CheckLargePopulatedGroup()
	{
	test.Next(_L("Create MANY Contacts"));
	CntTest->CloseDatabase();
	CntTest->DeleteDatabaseL();
	CntTest->CreateDatabaseL();
	TRAP_IGNORE(PopulateDatabaseL(KLargeSizeRecords,ETrue));
	CContactItem* newGroup = CntTest->Db()->CreateContactGroupL(_L("Large Group"));
	CleanupStack::PushL(newGroup);
	TContactItemId groupId = newGroup->Id();
	test.Next(_L("Add MANY Contacts to a Group"));
	TTime before;
	before.UniversalTime();
	for(TInt ii=1;ii<KLargeSizeRecords+1;ii++)
		{
		CntTest->Db()->AddContactToGroupL(ii, groupId); //*tempContact,*newGroup);
		if (ii%100==0)
			test.Printf(_L("."));	// Just to show some life
		}
	test(TestGroupStateL(CntTest->Db(),1,KLargeSizeRecords));
	TTime after;
	after.UniversalTime();
	TTimeIntervalSeconds secondsTaken;
	after.SecondsFrom(before,secondsTaken);
	test.Printf(_L(" TIME: %d  Secs"),secondsTaken.Int());
	test.Printf(_L("\n"));	
	//test.Getch();
	CntTest->CloseDatabase();
	CntTest->OpenDatabaseL();
//
	CContactItem* familyGroup = CntTest->Db()->ReadContactL(groupId);
	CContactIdArray* memberArray = STATIC_CAST(CContactGroup*,familyGroup)->ItemsContainedLC();
	test(memberArray->Count()==KLargeSizeRecords);
	delete familyGroup;
//
	CContactItem* familyMember = CntTest->Db()->ReadContactL(2);
	CContactIdArray* groups = STATIC_CAST(CContactCard*, familyMember)->GroupsJoinedLC();
	test(groups->Count()==1);
	TContactItemId memberShip = (*groups)[0];
	test(memberShip==groupId);
	delete familyMember;
	CleanupStack::PopAndDestroy(3); // newGroup groups memberArray
	}
Ejemplo n.º 22
0
void MainWindow::GenerateKey(TDes8& aKey, TInt aLen)
        {
        aKey.Zero();

        TTime currentTime;
        currentTime.HomeTime();

        // ??000Ä꿪ʼ¼Æ??
        TInt startYear = 2000;

        // µ±Ç°Äê·Ý
        TInt currentYear = currentTime.DateTime().Year();
        TTime time(TDateTime(currentYear, EJanuary, 0, 0, 0, 0, 0));

        TTimeIntervalSeconds s;
        currentTime.SecondsFrom(time, s);

        // µÃµ½ÃëÊý
        TInt i = s.Int();

        aKey.AppendFormat(_L8("%X"), i);
        aKey.AppendFormat(_L8("%X"), currentYear - startYear);

        TInt len = aKey.Length();
        if (len > aLen)
                {
                aKey.Mid(0, aLen);
                }
        else
                {
                for (TInt i = 0; i < aLen - len; i++)
                        {
                        TTime theTime;
                        theTime.UniversalTime();
                        TInt64 randSeed(theTime.Int64());
                        TInt number(Math::Rand(randSeed) + i);

                        number = number % 10 + 48;
                        aKey.Append(number);
                        }
                }
        }
Ejemplo n.º 23
0
GLDEF_C TInt E32Main()
//
// Main entry point
//
    {
	TInt r;

    CTrapCleanup* cleanup;
    cleanup=CTrapCleanup::New();
    __UHEAP_MARK;

    test.Title();
    test.Start(_L("Starting tests..."));

    r=TheFs.Connect();
    test_KErrNone(r);

    // TheFs.SetAllocFailure(gAllocFailOn);
    TTime timerC;
    timerC.HomeTime();

	// Do the tests
    TRAP(r,CallTestsL());

    // reset the debug register
    TheFs.SetDebugRegister(0);

    TTime endTimeC;
    endTimeC.HomeTime();
    TTimeIntervalSeconds timeTakenC;
    r=endTimeC.SecondsFrom(timerC,timeTakenC);
    test_KErrNone(r);
    test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
    // TheFs.SetAllocFailure(gAllocFailOff);
    TheFs.Close();
    test.End();
    test.Close();
    __UHEAP_MARKEND;
    delete cleanup;
    return(KErrNone);
    }
Ejemplo n.º 24
0
/** 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;
	}
Ejemplo n.º 25
0
//Allow the calling process to retrieve the value used by a clock which 
//is specified by clock_id
EXPORT_C int clock_gettime (clockid_t clock_id, struct timespec *tp)
{
	int retval = -1;
	TTime t;
	TTimeIntervalSeconds iSeconds;
	TInt err;
	//We expect the user of the library to give us a valid pointer	
	if(tp == NULL)
	{
		errno = EFAULT;
		return retval;
	}

	switch(clock_id)
	{
		case CLOCK_REALTIME:
			//We use TTime::UniversalTime() call to get the Universal time
			t.UniversalTime();
			err = t.SecondsFrom(UNIX_BASE, iSeconds);
			t-=iSeconds;//extracting seconds info into iSeconds
			if (!err)
			{
				tp->tv_sec = iSeconds.Int();
				tp->tv_nsec = t.Int64();
				retval = 0;
			}
			break;
		
		default:
			//For all other clocks that cannot be supported or invalid clockids,
			//we set errno to invalid
			retval = -1;
			errno = EINVAL;
			break;
	}
	return retval;
}
Ejemplo n.º 26
0
/**
Determines whether the message should be sent and if so the time interval (in
seconds) that must elapse before aMessage should be sent.

The time interval is determined by the error action supplied. In the case of an
error action of ESendActionRetryConditionMet, the time interval indicates how
long the message can be pending conditions to be met before the message is failed.

The actual time period is defined in the iSettings object. This will be either
iPendingConditionsTimeout, iShortInterval, iLongInterval or an element of 
iVariableIntervals.

If the message should be sent then a value of ETrue is returned. A value of 
EFalse is returned if the message should not be sent. In this case the output
argument aInterval is not valid.

@param	aMessage
The message to be re-scheduled.

@param	aErrorAction
The error action that determines the re-schedule behaviour.

@param	aInterval
An output argument that holds the time interval to when the message should be
re-sent or when the message should be failed.

@return
A value of ETrue if the message should be sent or EFalse if it should not
*/
TBool CMsvScheduleSend::GetNextRetry(CMsvScheduledEntry& aMessage, const TMsvSendErrorAction& aErrorAction, TTimeIntervalSeconds& aInterval) const
	{
	TBool retVal = (aErrorAction.iAction != ESendActionFail);
	aInterval = 0;
	
	if( retVal )
		{
		if( aErrorAction.iAction == ESendActionRetryConditionMet )
			{
			// Interval given by the agent actions timeout value.
			aInterval = iSettings->PendingConditionsTimeout().Int() * 60;
			}
		else if( aErrorAction.iAction == ESendActionRetryImmediately )
			{
			aInterval = iSettings->ShortInterval();
			}
		else
			{
			if( aErrorAction.iRetrySpacing == ESendRetrySpacingVariable )
				{
				//Retrieve the variable spacing associated with the retry count
				const CArrayFixFlat<TTimeIntervalSeconds>& varIntervals = iSettings->VariableIntervals();
				const TInt count = varIntervals.Count();
				const TInt retry = aMessage.iData.Retries();

				if( count == 0 )
					{
					aInterval = iSettings->LongInterval();
					}
				else if( retry < count )
					{
					aInterval = varIntervals[retry];
					}
				else
					{
					aInterval = varIntervals[count - 1];
					}
				}
			else 
				{
				// Got here then aScheduleAction.iRetrySpacing == EStatic.
				aInterval = iSettings->LongInterval();
				}

			__ASSERT_DEBUG(aInterval.Int() > 0, gPanic(ERetryIntervalMustByPositive));
			}
		}
	return retVal;
	}
Ejemplo n.º 27
0
TVerdict CTestExRevUTC::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 */
	{
	SetTestStepResult(EFail);
	
	TBuf<90> pathVCF(KExportRevUTCFile);
	ExportItemL(pathVCF, EFalse);
	
	// read from the disk.
	ImportItemL(pathVCF,EFalse);
	TDateTime t = iRecordedTime.DateTime();
	TDateTime t1 = iTimeFromImport.DateTime();
	
	INFO_PRINTF7(_L("Recorded Last Modified Date Year: %d, Month: %d, Day: %d, Recorded Time Hr: %d, Min: %d, Sec: %d "), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second());
	INFO_PRINTF7(_L("Imported Last Modified Date Year: %d, Month: %d, Day: %d, Imported Time Hr: %d, Min: %d, Sec: %d "), t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second());
	
	TTimeIntervalSeconds secondsDifference;
	User::LeaveIfError(iTimeFromImport.SecondsFrom(iRecordedTime, secondsDifference));
	TInt difference = secondsDifference.Int();
	
	if (difference < 2 && difference > -2)
		{
		INFO_PRINTF1(_L("Recorded and Imported DateTime match"));
		SetTestStepResult(EPass);
		}
	else
		{
		INFO_PRINTF1(_L("Recorded and Imported DateTime does not match"));
		SetTestStepResult(EFail);
		}
		
	return TestStepResult();
	}
//---------------------------------------------------------------
// TestUniDataModelPlugin::createMMS
//---------------------------------------------------------------
void TestUniDataModelMMSPlugin::createMMS(TMsvId pId, TBool subjectField)
    {
    TMsvEntry indexEntry;
    indexEntry.iType = KUidMsvMessageEntry;
    indexEntry.iMtm = KUidMsgTypeMultimedia;
    indexEntry.iServiceId = iServiceId;
    indexEntry.iDate.HomeTime();
    
    // Convert TTime to QDateTime , this will be used for comparing the time of mesage 
    // when fetched from datamodel
    TTime unixEpoch(KUnixEpoch);
    TTimeIntervalSeconds seconds;
    TTime timeStamp = indexEntry.iDate;
    timeStamp.SecondsFrom(unixEpoch, seconds);
    retTimeStamp.setTime_t(seconds.Int());

    TMsvId parentId = pId;
    CMsvEntry* entry = CMsvEntry::NewL(*iMSession,parentId,TMsvSelectionOrdering());
    CleanupStack::PushL(entry);

    entry->SetEntryL(parentId);
    entry->CreateL(indexEntry);
    entry->SetEntryL(indexEntry.Id());
    iMmsClientMtm->SwitchCurrentEntryL(entry->EntryId());

    CMsvStore* store = iMmsClientMtm->Entry().EditStoreL();
    CleanupStack::PushL(store);
      
    //MMS Message ID Saved
    iMessageId = indexEntry.Id();
    
    //Adding Subject
    if(subjectField)
        {
        QString subject(TEST_MSG_SUBJECT);
        HBufC* subj = XQConversions::qStringToS60Desc(subject);
        iMmsClientMtm->SetSubjectL(*subj);
        }

    //Adding Sender
    QString sender(TEST_MSG_FROM1);
    HBufC* addr = XQConversions::qStringToS60Desc(sender);
    
    if (addr)
        {
        CleanupStack::PushL(addr);
        TBuf<32> name;
        name.Copy(addr->Left(32));
        indexEntry.iDetails.Set(name);
        
        iMmsClientMtm->SetSenderL(*addr);
        
        CleanupStack::PopAndDestroy(addr);
        }
    
    //Adding Recipient
    QString recipient(TEST_MSG_RECIEPIENT1);
    HBufC* addr2 = XQConversions::qStringToS60Desc(recipient);
    if (addr2)
        {
        CleanupStack::PushL(addr2);
        iMmsClientMtm->AddAddresseeL(EMsvRecipientTo,*addr2);
        CleanupStack::PopAndDestroy(addr2);
        }
    
    //Adding cCRecipient
    QString recipient2(TEST_MSG_RECIEPIENT2);
    HBufC* addr3 = XQConversions::qStringToS60Desc(recipient2);
    if (addr3)
        {
        CleanupStack::PushL(addr3);
        iMmsClientMtm->AddAddresseeL(EMsvRecipientCc,*addr3);
        CleanupStack::PopAndDestroy(addr3);
        }
      
    //Adding bCCRecipient
    QString recipient3(TEST_MSG_RECIEPIENT3);
	HBufC* addr4 = XQConversions::qStringToS60Desc(recipient3);
	if (addr4)
		{
		CleanupStack::PushL(addr4);
		iMmsClientMtm->AddAddresseeL(EMsvRecipientBcc,*addr4);
		CleanupStack::PopAndDestroy(addr4);
		}
	
    //Create Text Attachment
    TMsvAttachmentId attaId = 0;
    TFileName attachmentFile( _L("story.txt") );
    TBufC<12> story = _L( "Hello world!" );
    
    iMmsClientMtm->CreateTextAttachmentL(*store, attaId, story, attachmentFile, ETrue );
    qDebug() << "Text Attachment id" << attaId;
    
    //Image Attachment added to the message entry
    RFile attaFile;
	// Set filename of attachment
	TFileName name( KPictureFileName );
   
	CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
	CleanupStack::PushL( mimeHeaders );
   
	// Set values to mime headers
	mimeHeaders->SetContentTypeL( _L8( "image") );
	mimeHeaders->SetContentSubTypeL( _L8( "jpeg" ) );
   
	_LIT8(KMimeType, "image/jpeg");
	TBufC8<10> mimeType(KMimeType);
	// CreateAttachment2L will set the content type to attachment Info
   
	// Open the attachment file for reading
	attaFile.Open( iFs, name, EFileShareReadersOnly | EFileRead );
	CleanupClosePushL(attaFile);
   
	CMsvAttachment* attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
	// attaInfo ownerhip will be transferred to Attachment Manager.
	// It must not be pushed onto the cleanupStack before calling 
	// CreateAttachment2L.
   
	iMmsClientMtm->CreateAttachment2L(*store, attaFile,mimeType,*mimeHeaders,attaInfo,attaId);
	qDebug() << "Image Attachment id" << attaId;
	
	// Now Attachment Manager owns the attaInfo
	CleanupStack::Pop(); // attaFile.Close()
	CleanupStack::PopAndDestroy(); // mimeHeaders
        
    store->CommitL();
    
    CleanupStack::PopAndDestroy(store); // store
    
    iMmsClientMtm->SaveMessageL();
    
    //Saving the message size for future checking
    msgSize = iMmsClientMtm->MessageSize();
    
    CleanupStack::Pop(entry); // entry
    }
void CNsmlNetworkStatusEngine::EventL( const CConnMonEventBase& aConnMonEvent )
{

	DBG_FILE(_S8("CNsmlNetworkStatusEngine::EventL, BEGIN"));
	DBG_ARGS8(_S8("CNsmlNetworkStatusEngine::EventL event is ==  %d"), aConnMonEvent.EventType()  );
	switch ( aConnMonEvent.EventType() )
	{
	case EConnMonNetworkStatusChange:
	{
	const CConnMonNetworkStatusChange* eventNetworkStatus;
    eventNetworkStatus = ( const CConnMonNetworkStatusChange* ) &aConnMonEvent;
    iNetwStatus   = eventNetworkStatus->NetworkStatus();
    DBG_ARGS8(_S8("CNsmlNetworkStatusEngine::EventL EConnMonNetworkStatusChange: Network status event is ==  %d"), iNetwStatus  );   	
    switch( eventNetworkStatus->NetworkStatus() )
	{
		case EConnMonStatusActive:
		DBG_FILE(_S8("Network status ACTIVE"));
	    if(iTimerOn)
	    {
			iTimerOn = EFalse;
		    iSuspendDuration.HomeTime();
		    TTimeIntervalSeconds duration;
		    iSuspendDuration.SecondsFrom(iSuspendedTime,duration);
		    DBG_FILE_CODE(duration.Int(), _S8("CNsmlNetworkStatusEngine::EventL suspendDuration is "));        	 
			if ( iTimedExecuteStopSession ) 
			{
				iTimedExecuteStopSession->Cancel();
				delete iTimedExecuteStopSession;
				iTimedExecuteStopSession = NULL;
			}
		    if(duration.Int() >= KDMMaxHttpAutoResumeDurationSec)
			{
				iAgent->CompleteRequest();
			}
	    } // if itimerOn
	           
        break;
        case EConnMonStatusSuspended:
        DBG_FILE(_S8("HTTP  Network status SUSPEND and Timer will be set ON "));
	   	if(!iTimerOn)
		{
	    	CRepository *rep = NULL;
			TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ))
			iDMSmlSessionTimeout = -1;
			if(err1 == KErrNone)
			{
				TInt dmsessionTimeout = -1;
				rep->Get( KDevManDMSessionTimeout, dmsessionTimeout );
				delete rep;
				DBG_FILE_CODE(dmsessionTimeout, _S8("CNsmlNetworkStatusEngine::EventL session timeout duration from cenrep is "));        	 
				if( dmsessionTimeout < KNSmlDMMinSessionTimeout  || dmsessionTimeout > KNSmlDMMaxSessionTimeout )
				{
					dmsessionTimeout = -1;
					iDMSmlSessionTimeout = -1;
				}
				else
				{
					iDMSmlSessionTimeout =  dmsessionTimeout * 60* 1000000;
					iTimerOn = ETrue;
	    			iSuspendedTime.HomeTime();
	 		    	iTimedExecuteStopSession = CPeriodic::NewL (EPriorityNormal) ;
					iTimedExecuteStopSession->Start (
		    		TTimeIntervalMicroSeconds32(iDMSmlSessionTimeout)
		    		, TTimeIntervalMicroSeconds32(iDMSmlSessionTimeout)
		    		, TCallBack(StaticDoStopDMSession,this) ) ;
				}
			
			} // if KErrnone
			
	    	
	    } //if !iTimerON
		break;   
	    default: //for eventNetworkStatus->NetworkStatus()
		break;
     }
    break;
    }

	default: // for EConnMonNetworkStatusChange
	    break;
	}
}
Ejemplo n.º 30
0
void CNtp::RunL(void)
{
  TBool stop=ETrue;
  switch(iNtpState)
  {
    case ELookingUp:
      if(iStatus==KErrNone)
      {
        iAddress.SetPort(iPort);
        iAddress.SetAddress(TInetAddr::Cast(iNameEntry().iAddr).Address());
        iSendBuffer.SetLength(0);
        iSendBuffer.Append((KNtpVersion<<3)|KNtpModeClient);
        for(TInt i=1;i<KNtpPacketMin;i++) iSendBuffer.Append(0);
        iSocket.SendTo(iSendBuffer,iAddress,0,iStatus);
        iNtpState=ESending;
        SetActive();
        stop=EFalse;
      }
      break;
    case ESending:
      if(iStatus==KErrNone)
      {
        iSendStamp.HomeTime();
        iSocket.RecvFrom(iReceiveBuffer,iAddress,0,iStatus);
        iNtpState=EReceiving;
        SetActive();
        stop=EFalse;
      }
      break;
    case EReceiving:
      if(iStatus==KErrNone&&iReceiveBuffer.Length()>=KNtpPacketMin)
      {
        iReceiveStamp.HomeTime();
        TInt status=(iReceiveBuffer[0]>>6)&KNtpStatusAlarm,mode=(iReceiveBuffer[0]&0x07);
        if(status||mode!=KNtpModeServer)
        {
          if(!status) status=KNtpModeServer;
          iStatus=KNtpErrorBase-status;
        }
        else
        {
          TInt64 stamp(0),base(0xd504a2,0xc672e000);
          for(TInt i=0;i<4;i++)
          {
            stamp=stamp*256+(TUint)iReceiveBuffer[i+32];
          }
          stamp=stamp*1000000+base;
          iNewStamp=stamp;
          iNewStamp+=iTimeOffset;
          iNewStamp+=iCorrection;
          TTimeIntervalSeconds way;
          if(iReceiveStamp.SecondsFrom(iSendStamp,way)==KErrNone)
          {
            way=way.Int()/2;
            iNewStamp+=way;
          }
          User::SetHomeTime(iNewStamp);
        }
      }
      break;
    default:
      User::Invariant();
      break;
  }