Exemplo n.º 1
0
static
cookie_t
scrumdemo_clock_recurring(int h, int m, int wd, int verbose)
{
  printf("\n----( recurring alarm %02d:%02d every %s )----\n\n",
         h,m, (wd < 0) ? "day" : scrumdemo_wday_name[wd]);

  alarm_event_t  *eve = 0;
  alarm_action_t *act = 0;
  alarm_recur_t  *rec = 0;
  cookie_t        aid = 0;

  // event
  eve = alarm_event_create();
  alarm_event_set_alarm_appid(eve, APPID);
  alarm_event_set_title(eve, "-- title --");
  alarm_event_set_message(eve, "-- message --");

  eve->flags |= ALARM_EVENT_BACK_RESCHEDULE;
  eve->flags |= ALARM_EVENT_BOOT;
  eve->flags |= ALARM_EVENT_SHOW_ICON;

  // STOP
  act = alarm_event_add_actions(eve, 1);
  act->flags |= ALARM_ACTION_WHEN_RESPONDED;
  alarm_action_set_label(act, "Stop");

  // action: SNOOZE
  act = alarm_event_add_actions(eve, 1);
  act->flags |= ALARM_ACTION_WHEN_RESPONDED;
  act->flags |= ALARM_ACTION_TYPE_SNOOZE;
  alarm_action_set_label(act, "Snooze");

  // action: recurrence
  rec = alarm_event_add_recurrences(eve, 1);
  rec->mask_hour = 1u   << h;
  rec->mask_min  = 1ull << m;
  rec->mask_wday = (wd < 0) ? ALARM_RECUR_WDAY_ALL : (1u << wd);
  eve->recur_count = -1;

  // send -> alarmd
  aid = alarmd_event_add(eve);
  printf("cookie = %d\n", (int)aid);
  alarm_event_delete(eve);

  if( (eve = alarmd_event_get(aid)) )
  {
    int d=0,h=0,m=0,s=0,t=0;
    t = scrumdemo_timediff(ticker_get_time(),eve->trigger, &d,&h,&m,&s);
    printf("Time left: %dd %dh %dm %ds (%d)\n", d,h,m,s, t);
    printf("\n");
    alarm_event_delete(eve);
  }

  return aid;
}
Exemplo n.º 2
0
void Maemo5Alarm::copy(const Maemo5Alarm& other)
{
    alarm_event_set_alarm_appid(m_data, other.m_data->alarm_appid);
    alarm_event_set_message(m_data, other.m_data->message);
    m_data->alarm_time = other.m_data->alarm_time;

    alarm_action_t *act, *other_act;
    if (other.m_data->action_cnt > 0) {
         for (quint32 i = 0 ; i < other.m_data->action_cnt ; ++i) {
             act = alarm_event_add_actions(m_data, 1);
             other_act = alarm_event_get_action(other.m_data, i);
             act->flags = other_act->flags;
             alarm_action_set_label(act, other_act->label);
             alarm_action_set_exec_command(act, other_act->exec_command);
         }
    }
    m_set = other.m_set;
}
Exemplo n.º 3
0
static
cookie_t
scrumdemo_clock_oneshot(int h, int m, int wd, int verbose)
{
  /* - defined in local time
   * -> leave alarm_tz unset
   * -> re-evaluated if tz changes
   *
   * - do not add recurrence masks
   *
   * - set up trigger time via alarm_tm field
   * -> set tm_hour and tm_min fields as required
   * -> if specific weekday is requested set also tm_wday field
   *
   * - if alarm is missed it must be disabled
   * -> set event flag ALARM_EVENT_DISABLE_DELAYED
   *
   * - if user presses "stop", event must be disabled
   * -> set action flag ALARM_ACTION_TYPE_DISABLE
   */

  printf("\n----( oneshot alarm %02d:%02d %s )----\n\n",
         h,m, (wd < 0) ? "anyday" : scrumdemo_wday_name[wd]);

  alarm_event_t  *eve = 0;
  alarm_action_t *act = 0;
  cookie_t        aid = 0;

  // event
  eve = alarm_event_create();
  alarm_event_set_alarm_appid(eve, APPID);
  alarm_event_set_title(eve, "-- title --");
  alarm_event_set_message(eve, "-- message --");

  eve->flags |= ALARM_EVENT_DISABLE_DELAYED;
  eve->flags |= ALARM_EVENT_BOOT;
  eve->flags |= ALARM_EVENT_SHOW_ICON;

  // action: STOP
  act = alarm_event_add_actions(eve, 1);
  act->flags |= ALARM_ACTION_WHEN_RESPONDED;
  act->flags |= ALARM_ACTION_TYPE_DISABLE;
  alarm_action_set_label(act, "Stop");

  // action: SNOOZE
  act = alarm_event_add_actions(eve, 1);
  act->flags |= ALARM_ACTION_WHEN_RESPONDED;
  act->flags |= ALARM_ACTION_TYPE_SNOOZE;
  alarm_action_set_label(act, "Snooze");

  eve->alarm_tm.tm_hour = h;
  eve->alarm_tm.tm_min  = m;
  eve->alarm_tm.tm_wday = wd;

  // send -> alarmd
  aid = alarmd_event_add(eve);
  printf("cookie = %d\n", (int)aid);
  alarm_event_delete(eve);

  if( (eve = alarmd_event_get(aid)) )
  {
    int d=0,h=0,m=0,s=0,t=0;
    t = scrumdemo_timediff(ticker_get_time(),eve->trigger, &d,&h,&m,&s);
    printf("Time left: %dd %dh %dm %ds (%d)\n", d,h,m,s, t);
    printf("\n");
    alarm_event_delete(eve);
  }

  return aid;
}