Example #1
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;
}
Example #2
0
int clearAllFlipAlarms() {

	cookie_t *setAlarms, *iter;	//Container for alarm ID's
	alarm_event_t *thisAlarm;	//All alarm events
	alarm_action_t *act = 0;	//Action for this alarm event
	int i = 0;
	
	const char *dbusInterface = NULL;
	const char *dbusPath = NULL;
	
	int matchedAlarm =0;	//Does alarm match criteria?
	
	setAlarms = NULL;
	
	setAlarms = alarmd_event_query((time_t) 0, (time_t) INT_MAX, 0, 0, APPID);
	if (setAlarms == NULL) {
		printf("No alarms!\n");
		return 0;
	}
	
	if (setAlarms[0] == (cookie_t) 0) {
		printf("No alarms!\n");
	} else {
		//Alarms found!
		for (iter = setAlarms; *iter != (cookie_t) 0; iter++) {
			thisAlarm = alarmd_event_get(*iter);
			
			matchedAlarm = 0;
			
			//Shouldn't need to do this thanks to that APPID thing, but might as well just to be safe... never hurts!
			//Libalarm2 introduces multiple actions per alarm event, so we have to check them all
			for(i = 0; (act = alarm_event_get_action(thisAlarm, i)) != 0; ++i )
			{
				//printf("action%d.label = %s\n", i, alarm_action_get_label(act));

				dbusInterface = alarm_action_get_dbus_interface(act);
				dbusPath = alarm_action_get_dbus_path(act);

				if ((dbusInterface != NULL)  && (dbusPath != NULL)) {
					if (!strcmp(dbusInterface, DBUS_INTERFACE)) { 
						if (!strcmp(dbusPath, DBUS_PATH)) {	
							matchedAlarm = 1;
						}
					}
					//Should I be freeing these? guess so..
					//free(dbusInterface);
					//free(dbusPath);
				}
			}
			
			
			if (matchedAlarm) {
				clearFlipAlarm(*iter);
				printf("Cleared flip alarm %s\n", alarm_event_get_title(thisAlarm));
			}
			
			
			alarm_event_delete(thisAlarm);
		}
		

	}
	
	if (setAlarms != NULL) {
		free(setAlarms);
	}
	
	return 1;
	

}