コード例 #1
0
ファイル: scrumdemo.c プロジェクト: tidatida/alarmd
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;
}
コード例 #2
0
ファイル: maemo5alarm.cpp プロジェクト: baleboy/flexo
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;
}
コード例 #3
0
int setFlipAlarmByIndex(int alarmIndex) {
	alarm_event_t *newEvent = 0;
	alarm_action_t *act = 0;
	


	//First make sure the alarm has a time defined
	if (userAlarmDObjects[alarmIndex]->alarmTime == 0) {
		return 0;
	}
	
	//Clear event if previously existing to be safe
	if (userAlarmDObjects[alarmIndex]->alarmCookie > 0) {
		if (clearFlipAlarm(userAlarmDObjects[alarmIndex]->alarmCookie) == 0) {
			//Couldn't clear out old alarm!
			return 0;
		} else {
			userAlarmDObjects[alarmIndex]->alarmCookie = 0;
		}
	}

	//Now we create the alarm event struct based on the settings given
	// Initialize alarm to 0s
    //memset (&newEvent, 0, sizeof(alarm_event_t));
	
	newEvent = alarm_event_create();	//Create the default alarm struct.
	//Set the APP ID
	alarm_event_set_alarm_appid(newEvent, APPID);
	
	alarm_event_set_title(newEvent, "FlipClockAlarm");
	
	//Create the alarm action
	act = alarm_event_add_actions(newEvent, 1);
	//Setup the action
	newEvent->flags = ALARM_EVENT_BOOT | ALARM_EVENT_SHOW_ICON;
	
	alarm_action_set_dbus_interface(act, DBUS_INTERFACE);
	alarm_action_set_dbus_service(act, DBUS_SERVICE);
	alarm_action_set_dbus_path(act, DBUS_PATH);
	alarm_action_set_dbus_name(act, "triggerAlarm");
	act->flags = ALARM_ACTION_WHEN_TRIGGERED | ALARM_ACTION_DBUS_USE_ACTIVATION | ALARM_ACTION_TYPE_DBUS;
	
	
	
	//Setup the alarm event members
	//createDefaultAlarm(&newEvent);
	
	
	
	//Now populate it with our actual values
	//if (userPreferences.userAlarms[alarmIndex]->title != NULL) {
		//printf("Alarm title: %s %s\n", userPreferences.userAlarms[alarmIndex]->title, newEvent.title);
		//if (newEvent.title != NULL) {
			//free(newEvent.title);
		//}
		//newEvent.title = calloc(strlen(userPreferences.userAlarms[alarmIndex]->title), sizeof(char));
		//sprintf(newEvent.title, "boo %s", userPreferences.userAlarms[alarmIndex]->title); 
	//}

	newEvent->recur_secs =userPreferences.userAlarms[alarmIndex]->recurrence * 60;  // The alarm function is now in seconds...
	newEvent->recur_count =userPreferences.userAlarms[alarmIndex]->recurrenceCount;
	newEvent->alarm_time = (time_t) userAlarmDObjects[alarmIndex]->alarmTime;
	
	printf("trying to make actual alarmD call with recurrence %i %i\n", newEvent->recur_secs,userPreferences.userAlarms[alarmIndex]->recurrence );
	//userPreferences.userAlarms[alarmIndex]->alarmCookie = alarm_event_add(&newEvent);
	
	//Okay all good, let's try to add it
	userAlarmDObjects[alarmIndex]->alarmCookie = alarmd_event_add_with_dbus_params(newEvent, DBUS_TYPE_INT64, &userAlarmDObjects[alarmIndex]->alarmTime, DBUS_TYPE_INT32, &alarmIndex, DBUS_TYPE_INVALID);
	
	
	
	alarm_event_delete(newEvent);

	
	printf("AlarmD update status: %ld\n",userAlarmDObjects[alarmIndex]->alarmCookie);
	
	
	
	return 1;
}
コード例 #4
0
ファイル: maemo5alarm.cpp プロジェクト: baleboy/flexo
Maemo5Alarm::Maemo5Alarm(const QString& myapp)
    : m_set(false)
{
    m_data = alarm_event_create();
    alarm_event_set_alarm_appid(m_data, myapp.toAscii().constData());
}
コード例 #5
0
ファイル: scrumdemo.c プロジェクト: tidatida/alarmd
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;
}