// PUBLIC FUNCTIONS bool DS1374RTC::readAlarm(time_t &t) { // TODO get rid of the unnecessary time conversions here tmElements_t tm; if (readAlarm(tm) == false) return false; t = makeTime(tm); return true; }
void KOEditorAlarms::selectionChanged( QListViewItem *listviewitem ) { AlarmListViewItem *item = dynamic_cast<AlarmListViewItem*>(listviewitem); mCurrentItem = item; mWidget->mTimeGroup->setEnabled( item ); mWidget->mTypeGroup->setEnabled( item ); if ( item ) { readAlarm( item->alarm() ); } }
uint8_t findNextAlarm(TimeValue &tv, AlarmValue *upcoming) { uint8_t idx, skip = 0, isupcoming = 0; uint8_t dowidx, dowcount; AlarmValue alarm; for(idx=0; idx<ALARM_MAX; idx++){ alarm = readAlarm(idx); // alarm is not enabled or does not happen on any day if(!alarm.en || !alarm.dow) continue; skip = 0; isupcoming++; //first alarm is automatically upcoming if(isupcoming==1){ *upcoming = alarm; continue; } // test if alarm can happen (have happened) today dowidx = tv.dow - 1; if((alarm.dow & _BV(dowidx))){ // alarm happens later today if((alarm.hour>tv.hour) || (alarm.hour == tv.hour && alarm.minute>tv.minute)){ // test if upcoming does not happen today or today, but later than alarm if(!(upcoming->dow & _BV(dowidx)) || (upcoming->hour<tv.hour || alarm.hour<upcoming->hour) || (alarm.hour == upcoming->hour && alarm.minute<upcoming->minute)){ *upcoming = alarm; continue; } } // alarm already happened today else{ // test if upcoming happens later today if((upcoming->dow & _BV(dowidx)) && (tv.hour<upcoming->hour || (tv.hour == upcoming->hour && tv.minute < upcoming->minute))){ continue; } } } else{ // test if upcoming happens later today if((upcoming->dow & _BV(dowidx)) && (tv.hour<upcoming->hour || (tv.hour == upcoming->hour && tv.minute < upcoming->minute))){ continue; } } //both tested alarm and upcoming does not happen till later day for(dowcount = 1; dowcount < 7; dowcount++){ dowidx = (tv.dow - 1 + dowcount) % 7; // alarm does not happen on tested day, but upcoming is if((upcoming->dow & _BV(dowidx)) && (!(alarm.dow & _BV(dowidx)))){ skip++; break; } // alarm does happen on tested day, upcoming isn't if(!(upcoming->dow & _BV(dowidx)) && (alarm.dow & _BV(dowidx))){ *upcoming = alarm; skip++; break; } // both happen on tested day if(alarm.dow & _BV(dowidx)){ break; } // neither happened on tested day, test another day } if(skip) continue; //at this point, both upcoming and alarm happen on the same day //tested alarm happens on later hour if(upcoming->hour < alarm.hour){ continue; } //tested alarm happens on the same hour but the same or later minute if(upcoming->hour==alarm.hour && upcoming->minute < alarm.minute){ continue; } //tested alarm happens earlier after all.. *upcoming = alarm; } return isupcoming; }
void IcalInterpreter::readEvent(const VEventComponent inVEventComponent, AppointmentBasics* &outAppBasics, QVector<AppointmentAlarm*>& outAppAlarmVector, AppointmentRecurrence* &outAppRecurrence ) { outAppBasics = new AppointmentBasics(); bool haveRecurrence = false; bool have_rdate = false; // rdate is somewhat special, see below... for( const Property p : inVEventComponent.m_properties ) { if( p.m_type == Property::PT_DESCRIPTION ) { outAppBasics->m_description = p.m_content; continue; } if( p.m_type == Property::PT_DTEND ) { outAppBasics->m_dtEnd = p.m_contentDateTime; Parameter pp; if( p.getParameterByType( Parameter::TZIDPARAM, pp ) ) { if( pp.m_contentTimeZone.isValid() ) outAppBasics->m_dtEnd.setTimeZone( pp.m_contentTimeZone ); } continue; } if( p.m_type == Property::PT_DTSTART ) { outAppBasics->m_dtStart = p.m_contentDateTime; Parameter pp; if( p.getParameterByType( Parameter::TZIDPARAM, pp ) ) { if( pp.m_contentTimeZone.isValid() ) outAppBasics->m_dtStart.setTimeZone( pp.m_contentTimeZone ); } continue; } if( p.m_type == Property::PT_DURATION ) { outAppBasics->m_dtEnd = outAppBasics->m_dtStart.addSecs( p.m_contentDuration.toSeconds() ); continue; } if( p.m_type == Property::PT_EXDATE ) { if( not haveRecurrence ) { outAppRecurrence = new AppointmentRecurrence(); haveRecurrence = true; } if( p.m_storageType == Property::PST_DATETIME ) outAppRecurrence->m_exceptionDates.append( p.m_contentDateTime ); else // PST_DATETIMELIST outAppRecurrence->m_exceptionDates.append( p.m_contentDateTimeVector ); continue; } if( p.m_type == Property::PT_RDATE ) { have_rdate = true; continue; } if( p.m_type == Property::PT_RRULE ) { if( not haveRecurrence ) { outAppRecurrence = new AppointmentRecurrence(); haveRecurrence = true; } readRecurrenceRRule( p, outAppRecurrence ); continue; } if( p.m_type == Property::PT_SEQUENCE ) { outAppBasics->m_sequence = p.m_contentInteger; continue; } if( p.m_type == Property::PT_SUMMARY ) { outAppBasics->m_summary = p.m_content; continue; } if( p.m_type == Property::PT_TRANSP ) { outAppBasics->m_busyFree = p.m_contentTransparency == Property::TT_TRANSPARENT ? AppointmentBasics::FREE : AppointmentBasics::BUSY; continue; } if( p.m_type == Property::PT_UID ) { outAppBasics->m_uid = p.m_content; continue; } } if( have_rdate ) { // The reason, why we loop again over all the properties is, that // the above finds out DT_START and DT_END. With this we can find out // length of an interval. Here, we can apply this interval length. quint64 intervalSeconds = outAppBasics->m_dtStart.secsTo( outAppBasics->m_dtEnd ); for( const Property p : inVEventComponent.m_properties ) { if( p.m_type != Property::PT_RDATE ) continue; if( not haveRecurrence ) { outAppRecurrence = new AppointmentRecurrence(); haveRecurrence = true; // might get overwritten duing readRecurrenceRRule() outAppRecurrence->m_frequency = AppointmentRecurrence::RFT_FIXED_DATES; } readRecurrenceRDates( p, intervalSeconds, outAppBasics->m_dtStart, outAppRecurrence ); } } for( const VAlarmComponent alarm : inVEventComponent.m_vAlarmComponents ) { AppointmentAlarm *appAlarm = new AppointmentAlarm(); readAlarm( alarm, outAppBasics, appAlarm ); outAppAlarmVector.append( appAlarm ); } }