//==================================================================== //----------+++--> Enumerate & display setup alarms incl. hourly chime: void UpdateAlarmMenu(HMENU hMenu) //--------------------------+++--> { wchar_t buf[MAX_PATH]; alarm_t pAS; int count; api.GetStr(L"", L"JihouFile", buf, _countof(buf), L""); if(buf[0]) EnableMenuItem(hMenu,IDM_CHIME,MF_BYCOMMAND|MF_ENABLED); if(TimetableSearchID(SCHEDID_CHIME)) { CheckMenuItem(hMenu,IDM_CHIME,MF_BYCOMMAND|MF_CHECKED); } count = GetAlarmNum(); if(count){ int idx; InsertMenu(hMenu,IDM_PROP_ALARM,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); for(idx=0; idx<count; ++idx) { ReadAlarmFromReg(&pAS,idx); wsprintf(buf, FMT(" %s (%i"), pAS.dlgmsg.name,idx+1); InsertMenu(hMenu, IDM_PROP_ALARM, MF_BYCOMMAND|MF_STRING, IDM_I_ALARM+idx, buf); if(pAS.uFlags&ALRM_ENABLED) CheckMenuItem(hMenu,IDM_I_ALARM+idx,MF_BYCOMMAND|MF_CHECKED); } InsertMenu(hMenu,IDM_PROP_ALARM,MF_BYCOMMAND|MF_SEPARATOR,0,NULL); } }
void TimetableRemove(int id) { Schedule* schedule = TimetableSearchID(id); if(schedule) { TimetableQueue(schedule, 0); free(schedule); } }
void AlarmEnable(int idx, int enable) { Schedule* alarm; if(idx < 0 || idx >= m_maxAlarm) return; ltoa(idx+1, (g_alarmkey+ALARMKEY_OFFSET), 10); if(enable < 0) { int status = api.GetInt(g_alarmkey, "Alarm", 0); if(enable == -1) { enable = !status; goto update_and_continue; } enable = status; alarm = NULL; } else { update_and_continue: api.SetInt(g_alarmkey, "Alarm", enable); alarm = TimetableSearchID(idx); } if(!enable) { if(alarm) { TimetableQueue(alarm, 0); free(alarm); } return; } if(!alarm) { alarm = (Schedule*)malloc(sizeof(Schedule)); if(!alarm) return; alarm->time = AlarmNextTimestamp(); alarm->id = idx; /// @note : on next backward incompatible change, store a single value including every "flag" alarm->data = 0; if(api.GetInt(g_alarmkey,"Alarm",0)) alarm->data |= ALRM_ENABLED; if(api.GetInt(g_alarmkey,"Once",0)) alarm->data |= ALRM_ONESHOT; if(api.GetInt(g_alarmkey,"12h",0)) alarm->data |= ALRM_12H; if(api.GetInt(g_alarmkey,"ChimeHr",0)) alarm->data |= ALRM_CHIMEHR; if(api.GetInt(g_alarmkey,"Repeat",0)) alarm->data |= ALRM_REPEAT; if(api.GetInt(g_alarmkey,"Blink",0)) alarm->data |= ALRM_BLINK; if(api.GetInt(g_alarmkey,"jrMsgUsed",0)) alarm->data |= ALRM_DIALOG; TimetableQueue(alarm, 1); } }
Schedule* TimetableAdd(int id, time_t ts, unsigned data) { Schedule* schedule; schedule = TimetableSearchID(id); if(schedule) { TimetableQueue(schedule, 0); if(ts > 86400) schedule->time = ts; } else { schedule = (Schedule*)malloc(sizeof(Schedule)); if(!schedule) return NULL; schedule->id = id; if(ts <= 86400) ts = time(NULL) + ts; schedule->time = ts; } schedule->data = data; TimetableQueue(schedule, 1); return schedule; }