예제 #1
0
void Maemo5Alarm::addDBusAction(const QString& text, const QString& service,
                                const QString& interface, const QString& path,
                                const QString& name)
{
    alarm_action_t *action;

    action = alarm_event_add_actions(m_data, 1);
    alarm_action_set_label(action, text.toAscii().constData());
    action->flags = ALARM_ACTION_WHEN_RESPONDED |
                    ALARM_ACTION_DBUS_USE_ACTIVATION | ALARM_ACTION_TYPE_DBUS;
    alarm_action_set_dbus_interface(action, interface.toAscii().constData());
    alarm_action_set_dbus_service(action, service.toAscii().constData());
    alarm_action_set_dbus_path(action, path.toAscii().constData());
    alarm_action_set_dbus_name(action, name.toAscii().constData());
}
예제 #2
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;
}