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(); } } }
/** Waits for alarm to start playing sounds @return True or False indicating if the sounds started playing at the correct time. */ TBool CTestSystemChangeUntil::WaitAndCheckSoundPlayStartL(TBool aUntilExpired) { TBuf<MAX_TEXT_MESSAGE> messageLog(0); TRequestStatus status; TAlarmId returnedAlarmId; FOREVER { iAlarmServerSession.NotifyChange(status,returnedAlarmId); User::WaitForRequest(status); if (status.Int() == EAlarmChangeEventSoundPlaying) { iNow.UniversalTime(); INFO_PRINTF3(KPlayStart,returnedAlarmId,iAlarmId); TDateTime aStartTime(iNow.DateTime()); messageLog.Format(KDateTime, aStartTime.Year(),TInt(aStartTime.Month()),aStartTime.Day(), aStartTime.Hour(),aStartTime.Minute(),aStartTime.Second(),aStartTime.MicroSecond()); FormatLogMessage(_L("Sound started (UTC time) to play at:- "), messageLog); TTimeIntervalMinutes minutesDifference; User::LeaveIfError(iNow.MinutesFrom(iSilentUntil, minutesDifference)); TInt difference = minutesDifference.Int(); if (aUntilExpired) { INFO_PRINTF3(KPlayStart,returnedAlarmId,iAlarmId); INFO_PRINTF1(_L("Sound Started At Expected Time")); iSoundStop = CalculateSoundStopL(iNow); return ETrue; } else { if (iNewSysGreaterExp) { INFO_PRINTF3(KPlayStart,returnedAlarmId,iAlarmId); INFO_PRINTF1(_L("Sound Started At Expected Time")); iSoundStop = CalculateSoundStopL(iNow); return ETrue; } else { if (difference == 0) { INFO_PRINTF3(KPlayStart,returnedAlarmId,iAlarmId); INFO_PRINTF1(_L("Sound Started At Expected Time")); iSoundStop = CalculateSoundStopL(iNow); return ETrue; } else { INFO_PRINTF1(KAlarmSoundStartError); return EFalse; } } } } } }
// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::ReadDateFieldsL // (other items were commented in a header) // ----------------------------------------------------------------------------- // void CPIMAgnToDoAdapter::ReadDateFieldsL(MPIMItemData& aData, CCalEntry& aEntry) { JELOG2(EPim); TTime nullTime = Time::NullTTime(); // The Agenda todo entry end field is the due date TTime due(aEntry.EndTimeL().TimeLocalL()); if (due != nullTime) { // Set due to the PIM API specific due date, in this case, the start of date // Note that PIM API uses times as UTC times so the due date must be in // correct format. Previously requested as local time -> do not change TPIMDate pimDueDate(StartOfDay(due)); // Date must be converted UTC time because acquired as local above ConvertTimeL(pimDueDate, EPIMDateUTC); TPIMFieldData dueFieldData(EPIMToDoDue, KPIMAttrNone, pimDueDate); aData.AddValueL(dueFieldData); // Get alarm. Ownership is transferred to the caller. Alarm cannot be set // if the due date is not set because the calculation is done as an offset // from the ToDo due date. CCalAlarm* calAlarm = aEntry.AlarmL(); if (calAlarm) { TTimeIntervalMinutes nativeValue = calAlarm->TimeOffset(); // The alarm is not needed anymore so it can be deleted delete calAlarm; calAlarm = NULL; // Change the time to the start of the due date TTime startOfDayLocal(StartOfDay(due)); // Calculate the difference from the start of due date and start time including // the original alarm offset which was previously read TTimeIntervalMinutes temp(0); User::LeaveIfError(startOfDayLocal.MinutesFrom(due, temp)); // Since it is not possible to substract TTimeIntervalMinutes // from TTime (probably a Symbian error), the difference has // to be calculated using the following way... TInt alarm = (nativeValue.Int() + temp.Int()) * KPIMSecondsInMinute; // Add alarm value to the item TPIMFieldData fieldData(EPIMToDoExtAlarm, EPIMFieldInt, KPIMAttrNone, alarm); // Add value to the PIM item data aData.AddValueL(fieldData); } } // Completion date. If the item has a completion date, the item is then completed // and completed flag is set to true in PIM API. Null time if not crossed out. TTime completed = aEntry.CompletedTimeL().TimeUtcL(); if (completed != nullTime) { TPIMFieldData dateData(EPIMToDoCompletionDate, KPIMAttrNone, completed); aData.AddValueL(dateData); // Note that boolean and integer fields must be identified in the constructor TPIMFieldData flag(EPIMToDoCompleted, EPIMFieldBoolean, KPIMAttrNone, ETrue); aData.AddValueL(flag); } }
// ----------------------------------------------------------------------------- // CPIMAgnEventAdapter::ReadAlarmFromAgnL // Reads alarm offset from the native Calendar entry. In case of Anniversary, // the offset is calculated from the midnight since native Calendar supports // only dates in these types of entries // ----------------------------------------------------------------------------- // void CPIMAgnEventAdapter::ReadAlarmFromAgnL(MPIMEventItem& aItem, CCalEntry& aEntry) { JELOG2(EPim); CCalAlarm* calAlarm = aEntry.AlarmL(); // The previous function call returns NULL if there is no alarm // set in the item. The ownership is transferred to the caller // if the alarm values has been added to the item. if (calAlarm) { TTimeIntervalMinutes nativeValue = calAlarm->TimeOffset(); // The alarm is not needed anymore so it can be deleted delete calAlarm; calAlarm = NULL; // nativeValue.Int() ); // Convert the alarm value based on the start time of the entry CCalEntry::TType entryType = aEntry.EntryTypeL(); // Events (memos) and anniversaries do not have time in the native // side, therefore alarm field in those entries need to be calculated // from the end of the day if (entryType == CCalEntry::EAnniv) { TTime start(aEntry.StartTimeL().TimeLocalL()); // Change the time to the end of the start date TTime startOfDayLocal(start); startOfDayLocal = StartOfDay(startOfDayLocal); // Calculate the difference from end of day and start time including // the original alarm offset which was previously read TTimeIntervalMinutes temp(0); User::LeaveIfError(startOfDayLocal.MinutesFrom(start, temp)); // Since it is not possible to substract TTimeIntervalMinutes // from TTime (probably a Symbian error), the difference has // to be calculated using the following way... nativeValue = nativeValue.Int() + temp.Int(); } TInt alarmValue = nativeValue.Int() * KPIMSecondsInMinute; // alarmValue ); // Add alarm value to the item TPIMFieldData fieldData(EPIMEventAlarm, EPIMFieldInt, KPIMAttrNone, alarmValue); aItem.ItemData().AddValueL(fieldData); } }
void SymbianLog::createFormattedBias() { TTime local, utc; TTimeIntervalMinutes bias; local.HomeTime(); utc.UniversalTime(); local.MinutesFrom(utc, bias); TInt totalMinutes = bias.Int(); TInt hours = totalMinutes / 60; TInt minutes = totalMinutes % 60; if (totalMinutes >= 0) { iFormattedBias.sprintf("GMT +%d:%02d", hours, minutes); } else { iFormattedBias.sprintf("GMT %d:%02d", hours, minutes); } }
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); } } }
TInt CUnknownZoneTest::CreateAndRunTestUnitL() { User::LeaveIfError(iTimeZoneServer.Connect()); // // Initially set home zone to London // CTzId* tzId = CTzId::NewL(_L8("Europe/London")); CleanupStack::PushL(tzId); iTimeZoneServer.SetTimeZoneL(*tzId); // // Call SetUnknownZoneTime. Set the time to a winter time in Europe/London // to check that the previous time zone settings are overridden by the new // unknown zone settings. // TDateTime winterDateTime(2006,EJanuary,10,10,0,0,0); // 11-Jan-2006 10:00 TTime localTime(winterDateTime); localTime.HomeTime(); TInt offset = 120; // UTC+2 iTimeZoneServer.SetUnknownZoneTimeL(localTime,offset); TTime utcTime(localTime); iTimeZoneServer.ConvertToUniversalTime(utcTime); TTimeIntervalMinutes diff; localTime.MinutesFrom(utcTime,diff); if (diff.Int() != offset) { ERR_PRINTF3(_L("Expected offset = %D, Retrieved offset = %D"),&offset,&diff); return KErrGeneral; } // convert back to local time and we should get the initial time again iTimeZoneServer.ConvertToLocalTime(utcTime); if (utcTime!=localTime) { ERR_PRINTF1(_L("ConvertToLocalTime failed")); return KErrGeneral; } // // Repeat again with a London summer time // // reset time zone to London iTimeZoneServer.SetTimeZoneL(*tzId); TDateTime summerDateTime(2006,EJune,10,10,0,0,0); // 11-June-2006 10:00 localTime = summerDateTime; localTime.HomeTime(); iTimeZoneServer.SetUnknownZoneTimeL(localTime,offset); utcTime = localTime; iTimeZoneServer.ConvertToUniversalTime(utcTime); localTime.MinutesFrom(utcTime,diff); if (diff.Int() != offset) { ERR_PRINTF3(_L("Expected offset = %D, Retrieved offset = %D"),&offset,&diff); return KErrGeneral; } // convert back to local time and we should get the initial time again iTimeZoneServer.ConvertToLocalTime(utcTime); if (utcTime!=localTime) { ERR_PRINTF1(_L("ConvertToLocalTime failed")); return KErrGeneral; } CleanupStack::PopAndDestroy(tzId); return KErrNone; }
/** Executes Alarm Server Test ** Set Alarm to notify, Set alarm sounds silent for in minutes. Change System before or after alarm expiry time. ** Sound start and stop should be as expected @return True or False indicating the result of the alarm server test */ TBool CTestSystemChangeFor::ExecuteTestL() { SetSystemTimeL(); SetInitalUtcOffsetL(); SetAlarmL(); // Set Global silent peroid duration in minutes (SetAlarmSoundsSilentFor) SetSilentForL(); // Determine wether to change system before or after alarm expires GetWaitToNotify(); iExpiryGreaterUntil = CheckExpGreaterUntilL(iInitialUtc); // wait for alarm to reach expiry time, then change system time, and then wait for sound start and stop if (iWaitToNotify) { if (!WaitToNotifyBeforeChangeL()) { return EFalse; } } // Get new system time and set ChangeSystemTimeL(); // Let the Alarm Server react to the System Time Change change User::After(KTimeToWait); iNow.UniversalTime(); VerifySilentUntil(); if (iWaitToNotify) // If alarm notified then alarm state should be Notifying { INFO_PRINTF1(_L("After System Time Change, checking state.....")); if(!CheckAlarmStatesL(EAlarmStateNotifying)) { return EFalse; } } TTimeIntervalMinutes minutesDifference; User::LeaveIfError(iSystemTime.MinutesFrom(iExpiryTime, minutesDifference)); TInt difference = minutesDifference.Int(); // wait for alarm to expire after system time change then wait for sound start and stop // new system time less than expiry time, so we wait for alarm to expire if (!iWaitToNotify && difference <= -1 && iMoveSystemTime < iExpiryTime) { if(!WaitToNotifyAfterChangeL()) { return EFalse; } } // new system time is equal or greater than expiry time // state should be notifying, so we don't wait for alarm to expire // Just need to check if alarm is in Notifying state as well as start.stop sounds timings if (!iWaitToNotify && difference >= -1 && iMoveSystemTime >= iExpiryTime) { INFO_PRINTF1(_L(" New System Time equal to Expiry Time or Greater, checking state.... ")); if(!CheckAlarmNotifyingL()) { return EFalse; } } // checks if sound start and stop timings are as expected if(!CheckStartStopSoundsL()) { return EFalse; } return ETrue; }
/** Executes Alarm Server Test ** Set Alarm to notify, Set alarm sounds silent until. Change System before or after alarm expiry time. ** Sound start and stop should be as expected @return True or False indicating the result of the alarm server test */ TBool CTestSystemChangeUntil::ExecuteTestL() { SetSystemTimeL(); SetInitalUtcOffsetL(); SetAlarmL(); // Set Global silent peroid duration in minutes (SetAlarmSoundsSilentFor) SetSilentUntilL(); iUTCUntil = CalculateUTCUntilL(iInitialUtc); // Determine wether to change utc before or after alarm expires GetWaitToNotify(); //Get New Offset and set iNewSysGreaterExp = EFalse; iUntilExpired = EFalse; iExpiryGreaterUntil = CheckExpGreaterUntilL(iInitialUtc); // wait for alarm to reach expiry time, then change system time, and then wait for sound start and stop if (iWaitToNotify) { if (!WaitToNotifyBeforeChangeL()) { return EFalse; } } // Get new system time and set ChangeSystemTimeL(); // Let the Alarm Server react to the System Time Change change User::After(KTimeToWait); iNow.UniversalTime(); // silent time should have not changed,after system time change if (iNow <= iUTCUntil) // If present utc time is greater then until time, then we dont check { // silent period as it will crash (getuntil crashes, as its time has passed if (!iWaitToNotify && !iExpiryGreaterUntil) //if silent period expired this will crash { if (!CheckSilentUntilL()) { return EFalse; } } } if (iWaitToNotify) // If alarm has expired, alarm should be in Notifying state, then validate for sound start and stop { INFO_PRINTF1(_L("After System Time Change, checking state.....")); if(!CheckAlarmStatesL(EAlarmStateNotifying)) { return EFalse; } } TTimeIntervalMinutes minutesDifference; User::LeaveIfError(iSystemTime.MinutesFrom(iExpiryTime, minutesDifference)); TInt difference = minutesDifference.Int(); // wait for alarm to expire after utc change then wait for sound start and stop // new system time less than expiry time, so we wait for alarm to expire if (!iWaitToNotify && difference <= -1 && iMoveSystemTime < iExpiryTime) { if (!WaitToNotifyAfterChangeL()) { return EFalse; } } // new system time is equal or greater than expiry time // state should be notifying,as alarm should expire immediately, so we dont wait for alarm to expire if (!iWaitToNotify && difference >= -1 && iMoveSystemTime >= iExpiryTime) { INFO_PRINTF1(_L(" New System Time equal to Expiry Time or Greater, checking state.... ")); if(!CheckAlarmStatesL(EAlarmStateNotifying)) { return EFalse; } WaitTimerExpiry(); INFO_PRINTF1(_L("This expiry notification is due to the timer invalidating due to System Time Change ")); iNewSysGreaterExp = ETrue; } if (iInitialUtc < 0) { INFO_PRINTF1(_L("More than an hour to go to play sounds ")); } else { if (!CheckStartStopTimingsL()) // checks if start and stop timings are as expected { return EFalse; } } return ETrue; }
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; } }