/* ------------------------------------------------------------------------- ------------------------------------------------------------------------- */ 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; }
void CMsvScheduleSend::GetOffPeakL(TTime aFromTime, TTime& aStartTime, TTimeIntervalMinutes& aValidityPeriod) const { __ASSERT_DEBUG(iOffPeakTimes->Count() > 0, gPanic(EOffPeakTimesEmpty)); TMsvOffPeakTime opTime; TTime offPeakStart; User::LeaveIfError(iOffPeakTimes->GetNextOffPeakTime(aFromTime, opTime, offPeakStart)); aValidityPeriod = opTime.ValidityPeriod(); if (offPeakStart < aFromTime) { //aFromTime is within an off peak time aStartTime = aFromTime; TTimeIntervalMinutes mins; aStartTime.MinutesFrom(offPeakStart, mins); TInt minsInt = mins.Int(); __ASSERT_DEBUG(minsInt >= 0, gPanic(EInvalidValidityPeriod)); aValidityPeriod = opTime.ValidityPeriod(); aValidityPeriod = (TTimeIntervalMinutes) (aValidityPeriod.Int() - minsInt); } else { aStartTime = offPeakStart; } //To Do: Remove next line after testing __ASSERT_DEBUG(aValidityPeriod.Int() > 0, gPanic(EInvalidValidityPeriod)); }
// ----------------------------------------------------------------------------- // CUpdateManager::RunL // // Handles an active object's timer event. // ----------------------------------------------------------------------------- void CUpdateManager::RunL() { TTime currentTime; currentTime.HomeTime(); TTimeIntervalMinutes diff; currentTime.MinutesFrom(iLastAutoUpdate,diff); if (diff.Int() < 0) { for(TInt i =0 ; i < iQueueArray.Count(); i++) { iQueueArray[i]->ResetTimers(); } } iLastAutoUpdate.HomeTime(); if (iStatus.Int() == KErrNone || iStatus.Int() == KErrAbort) { StartTimer(); if(iAutoUpdateWhileRoaming) { UpdateL(); } else { iRoamingInfo->CheckForRoaming(); } } }
void CTzUserDataTest::CachedUserTimeZoneL(RTz& aRTz, TTest aWhatToTest) { test.Next(_L("Conver times - Server Response to Changes")); TInt offset = 60; TTime utctime (TDateTime(2000, EMay, 0, 0, 0, 0, 0)); //Convert a given time from UTC to local time using the user-defined time zone TTime localtime = utctime ; CreateUserTzAndSetCurrentTimeToL(aRTz, offset, offset); aRTz.ConvertToLocalTime(localtime); TTimeIntervalMinutes minutes; localtime.MinutesFrom(utctime, minutes); test (minutes == TTimeIntervalMinutes(offset)); localtime = utctime; //Convert a given time from UTC to local time when the corrent tz rule is updated if(aWhatToTest==EUpdateCachedTz) { offset = 120; UpdateCurrentTzL(aRTz, offset, offset); } else if(aWhatToTest==EDeleteCachedTz) { //Delete the current tz rule which result in system time reverting to the default time zone. DeleteCurrentTzL(aRTz); //Convert a given time from UTC to local time using an existing time zone which is the defaut time zone. CTzRules* currentRules = aRTz.GetTimeZoneRulesL(0, 9999,ETzUtcTimeReference ); CleanupStack::PushL(currentRules); offset = currentRules->GetOffsetL(utctime, ETzUtcTimeReference); CleanupStack::PopAndDestroy(currentRules); } aRTz.ConvertToLocalTime(localtime); localtime.MinutesFrom(utctime, minutes); test (minutes == TTimeIntervalMinutes(offset)); }
void CLocaLogicImpl::UpdateStats(const TDesC& aNodeName, const CBBBtDeviceList* devices, const TTime& aAtTime) { const TBBBtDeviceInfo* info=0; for (info=devices->First(); info; info=devices->Next()) { if (info->iMajorClass()==0x02 || info->iMajorClass()==0x01) { } else { continue; } TDevStats s; iDevStats->GetStatsL(*info, aNodeName, s); if (aAtTime > s.iLastSeen ) { TInt span=0; if (s.iFirstSeen==TTime(0)) s.iFirstSeen=aAtTime; if (s.iLastSeen + TTimeIntervalMinutes(3) < aAtTime) { s.iPreviousVisitBegin=s.iVisitBegin; s.iPreviousVisitEnd=s.iLastSeen; s.iVisitBegin=aAtTime; s.iCountStay++; span=1; } else { TTimeIntervalMinutes prev_span; s.iLastSeen.MinutesFrom(s.iVisitBegin, prev_span); if (prev_span.Int()==0) prev_span=1; else prev_span=TTimeIntervalMinutes(prev_span.Int()+1); s.iSumStay-=prev_span.Int(); s.iSquareSumStay-=(prev_span.Int()*prev_span.Int()); TTimeIntervalMinutes this_span; aAtTime.MinutesFrom(s.iVisitBegin, this_span); span=this_span.Int() + 1; } s.iLastSeen=aAtTime; s.iSumStay+=span; s.iSquareSumStay+=span*span; if (span > s.iMaxStay) s.iMaxStay=span; iDevStats->SetStatsL(*info, aNodeName, s); } } }
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(); }
void AppendTimeDifference(TDes8& aInto, TTime from, TTime now) { CALLSTACKITEM_N(_CL("CLocaLogicImpl"), _CL("~CLocaLogicImpl")); if (from > now) { TTime s=from; from=now; now=s; } for(;;) { TTimeIntervalMinutes mins; if (now.MinutesFrom(from, mins)!=KErrNone) { mins=61; } TTimeIntervalHours hours; if (now.HoursFrom(from, hours)!=KErrNone) { hours=25; } TTimeIntervalDays days; days=now.DaysFrom(from); if (mins < TTimeIntervalMinutes(60)) { aInto.AppendNum(mins.Int()); aInto.Append(_L8(" minutes ")); break; } else if ( hours < TTimeIntervalDays(24)) { aInto.AppendNum(hours.Int()); aInto.Append(_L8(" hours ")); from+=TTimeIntervalHours(hours); } else { aInto.AppendNum(days.Int()); aInto.Append(_L8(" days ")); from+=TTimeIntervalDays(days); } } }
TBool CTrialHandler::IsNowOkL(TBool& aFirstTime,TInt& aDaysLeft) { TBool ret(EFalse); aFirstTime = EFalse; RFs fsSession; User::LeaveIfError(fsSession.Connect()); TFindFile AufFolder2(fsSession); if(KErrNone == AufFolder2.FindByDir(KtxTrialHandFileFileName, KNullDesC)){ TFindFile AufFolder3(fsSession); if(KErrNone == AufFolder3.FindByDir(KtxTrialHandFileFileName2, KNullDesC)) { BaflUtils::DeleteFile(fsSession,AufFolder3.File()); } }else{ TFindFile AufFolder4(fsSession); if(KErrNone == AufFolder4.FindByDir(KtxTrialHandFileFileName2, KNullDesC)) { aFirstTime = ETrue; TParsePtrC parsse(AufFolder4.File()); TFileName hjelpper; hjelpper.Copy(parsse.Drive()); hjelpper.Append(KtxTrialHandFileFileName); BaflUtils::RenameFile(fsSession,AufFolder4.File(),hjelpper); } } TFindFile AufFolder5(fsSession); if(KErrNone == AufFolder5.FindByDir(KtxTrialHandFileFileName, KNullDesC)){ TTime homme; homme.HomeTime(); CDictionaryFileStore* MyDStore = CDictionaryFileStore::OpenLC(fsSession,AufFolder5.File(), TUid::Uid(0x102013AD)); TInt sYear(-1),sMonth(-1),sDay(-1),sHour(-1),sMinute(-1); TInt mYear(-1),mMonth(-1),mDay(-1),mHour(-1),mMinute(-1); TInt eYear(-1),eMonth(-1),eDay(-1),eHour(-1),eMinute(-1); TUid FileUid = {0x8867675}; if(MyDStore->IsPresentL(FileUid)) { FileUid.iUid = 0x1299; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1669; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4469; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4421; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4422; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); sMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9999; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1688; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4889; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4821; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x4822; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); mMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x6789; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eYear = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x1111; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eMonth = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9786; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eDay = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9721; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eHour = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } FileUid.iUid = 0x9722; if(MyDStore->IsPresentL(FileUid)) { RDictionaryReadStream in; in.OpenLC(*MyDStore,FileUid); eMinute = in.ReadInt32L(); CleanupStack::PopAndDestroy(1);// in } if(sYear == -1 && sMonth == -1 && sDay == -1 && mYear == -1 && mMonth == -1 && mDay == -1 && eYear == -1 && eMonth == -1 && eDay == -1){ FileUid.iUid = 0x1299; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out1; out1.AssignLC(*MyDStore,FileUid); out1.WriteInt32L(homme.DateTime().Year()); out1.CommitL(); CleanupStack::PopAndDestroy(1);// out1 FileUid.iUid = 0x1669; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out2; out2.AssignLC(*MyDStore,FileUid); out2.WriteInt32L((TInt)homme.DateTime().Month()); out2.CommitL(); CleanupStack::PopAndDestroy(1);// out2 FileUid.iUid = 0x4469; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out3; out3.AssignLC(*MyDStore,FileUid); out3.WriteInt32L(homme.DateTime().Day()); out3.CommitL(); CleanupStack::PopAndDestroy(1);// out3 FileUid.iUid = 0x4421; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out31; out31.AssignLC(*MyDStore,FileUid); out31.WriteInt32L(homme.DateTime().Hour()); out31.CommitL(); CleanupStack::PopAndDestroy(1);// out31 FileUid.iUid = 0x4422; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out32; out32.AssignLC(*MyDStore,FileUid); out32.WriteInt32L(homme.DateTime().Minute()); out32.CommitL(); CleanupStack::PopAndDestroy(1);// out32 FileUid.iUid = 0x6789; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } homme = homme + TTimeIntervalDays(4); RDictionaryWriteStream out4; out4.AssignLC(*MyDStore,FileUid); out4.WriteInt32L(homme.DateTime().Year()); out4.CommitL(); CleanupStack::PopAndDestroy(1);// out4 FileUid.iUid = 0x1111; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out5; out5.AssignLC(*MyDStore,FileUid); out5.WriteInt32L((TInt)homme.DateTime().Month()); out5.CommitL(); CleanupStack::PopAndDestroy(1);// out5 FileUid.iUid = 0x9786; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out6; out6.AssignLC(*MyDStore,FileUid); out6.WriteInt32L(homme.DateTime().Day()); out6.CommitL(); CleanupStack::PopAndDestroy(1);// out6 FileUid.iUid = 0x9721; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out61; out61.AssignLC(*MyDStore,FileUid); out61.WriteInt32L(homme.DateTime().Hour()); out61.CommitL(); CleanupStack::PopAndDestroy(1);// out61 FileUid.iUid = 0x9722; if(MyDStore->IsPresentL(FileUid)) { MyDStore->Remove(FileUid); MyDStore->CommitL(); } RDictionaryWriteStream out62; out62.AssignLC(*MyDStore,FileUid); out62.WriteInt32L(homme.DateTime().Minute()); out62.CommitL(); CleanupStack::PopAndDestroy(1);// out62 MyDStore->CommitL(); TTime nowwTimm; nowwTimm.HomeTime(); TTimeIntervalHours leftTimm; homme.HoursFrom(nowwTimm,leftTimm); aDaysLeft = leftTimm.Int(); ret = ETrue; }else{ TTime startTime(TDateTime(sYear,(TMonth)sMonth,sDay,sHour,sMinute,0,0)); TTime middleTime(TDateTime(mYear,(TMonth)mMonth,mDay,mHour,mMinute,0,0)); TTime edningTime(TDateTime(eYear,(TMonth)eMonth,eDay,eHour,eMinute,0,0)); TTimeIntervalMinutes sInterval(0); TTimeIntervalMinutes mInterval(0); TTimeIntervalMinutes eInterval(0); homme.MinutesFrom(startTime,sInterval); homme.MinutesFrom(middleTime,mInterval); edningTime.MinutesFrom(homme,eInterval); if(sInterval.Int() >= 0 && mInterval.Int() >= 0 && eInterval.Int() >= 0){ TTimeIntervalHours leftTimm; edningTime.HoursFrom(homme,leftTimm); aDaysLeft = leftTimm.Int(); ret = ETrue; } } }else{ /* RDictionaryWriteStream out3; out3.AssignLC(*MyDStore,FileUid); out3.WriteInt32L(12985674); out3.CommitL(); CleanupStack::PopAndDestroy(1);// out3 MyDStore->CommitL();*/ } CleanupStack::PopAndDestroy(1);// Store } fsSession.Close(); return ret; }
bool eap_am_type_securid_symbian_c::is_session_validL() { EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid(): EAP-tunneling type=0xfe%06x%08x\n"), m_tunneling_type.get_vendor_id(), m_tunneling_type.get_vendor_type())); HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); TPtr sqlStatement = buf->Des(); // Query all the relevant parameters _LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); if (m_eap_type == eap_type_generic_token_card) { sqlStatement.Format( KSQLQuery, &cf_str_EAP_GTC_max_session_validity_time_literal, &KGTCLastFullAuthTime, &KGtcTableName, &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingTypeVendorId, m_tunneling_type.get_vendor_id(), &KTunnelingType, m_tunneling_type.get_vendor_type()); } else { // Secure ID is not supported at the moment. // Treat this as session invalid. CleanupStack::PopAndDestroy(buf); // Delete buf. return false; } RDbView view; // Evaluate view User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); CleanupClosePushL(view); User::LeaveIfError(view.EvaluateAll()); // Get the first (and only) row view.FirstL(); view.GetL(); // Get column set so we get the correct column numbers CDbColSet* colSet = view.ColSetL(); CleanupStack::PushL(colSet); TInt64 maxSessionTime = view.ColInt64(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal)); TInt64 fullAuthTime = view.ColInt64(colSet->ColNo(KGTCLastFullAuthTime)); CleanupStack::PopAndDestroy(colSet); // Delete colSet. CleanupStack::PopAndDestroy(&view); // Close view. CleanupStack::PopAndDestroy(buf); // Delete buf. // If the max session time from DB is zero then we use the // one read from configuration file. if( maxSessionTime == 0) { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL("Session Validity - Using max session validity time from config file\n"))); maxSessionTime = m_max_session_time; // value from configuration file. } // Get the current time. TTime currentTime; currentTime.UniversalTime(); TTime lastFullAuthTime(fullAuthTime); #if defined(_DEBUG) || defined(DEBUG) TDateTime currentDateTime = currentTime.DateTime(); TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(), currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); #endif TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:interval in microseconds:"), &(interval.Int64()), sizeof(interval.Int64()) ) ); EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:max session time in microseconds:"), &(maxSessionTime), sizeof(maxSessionTime) ) ); #if defined(_DEBUG) || defined(DEBUG) TTimeIntervalMinutes intervalMins; TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); if(error == KErrNone) { EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_validL()") EAPL("interval in Minutes =%d\n"), intervalMins.Int())); } #endif if( maxSessionTime >= interval.Int64() ) { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session Valid \n"))); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); return true; } else { EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session NOT Valid \n"))); EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); return false; } }