73
check_play_alarm(gchar *name, gchar *current_date)
78
timeinfo = localtime ( &rawtime );
81
gchar *date = g_key_file_get_string(loaded_alarms, name, "DateTime", NULL);
83
if (g_strcmp0(date, current_date) == 0) ret = TRUE;
90
73
is_date_excluded(gchar *alarm_name, gint day, gint month)
92
75
gchar *buffer, **split, **date_split;
244
move_to_missed(gchar *name)
247
gchar *buffer, **keys;
248
GKeyFile *temp_key = g_key_file_new();
250
g_key_file_load_from_file(temp_key, config_missed, G_KEY_FILE_NONE, NULL);
252
keys = g_key_file_get_keys(loaded_alarms, name, NULL, NULL);
256
if (keys[key] == NULL) break;
257
buffer = g_key_file_get_string(loaded_alarms, name, keys[key], NULL);
259
g_key_file_set_string(temp_key, name, keys[key], buffer);
265
buffer = g_key_file_to_data(temp_key, NULL, NULL);
267
g_file_set_contents(config_missed, buffer, -1, NULL);
269
g_key_file_free(temp_key);
276
manage_old_alarm(gchar *name)
278
gchar *type = g_key_file_get_string(loaded_alarms, name, "AlarmType", NULL);
279
gboolean snooze = g_key_file_get_boolean(loaded_alarms, name, "snoozed", NULL);
280
gboolean single = TRUE;
282
if (g_strcmp0(type, "Schedule") == 0) single = FALSE;
283
if (snooze) snooze = FALSE;
287
if (need_check_first)
289
move_to_missed(name);
294
update_list_entries();
299
if (single && !snooze && !running_snooze)
301
g_usleep(G_USEC_PER_SEC);
304
update_list_entries();
260
311
update_alarm_thread(void)
265
316
GTimeVal alarm_time, current_time;
266
317
gchar *iso_date, *time_left, *alarm_type, **alarms;
268
GString *date_string;
269
319
GtkTreeIter iter;
272
date_string = g_string_new(NULL);
273
323
time ( &rawtime );
274
324
timeinfo = localtime ( &rawtime );
275
325
gboolean snoozed;
277
g_string_append(date_string, g_strdup_printf("%i-", timeinfo->tm_year + 1900));
278
g_string_append(date_string, g_strdup_printf("%i-", timeinfo->tm_mon + 1));
279
g_string_append(date_string, g_strdup_printf("%iT", timeinfo->tm_mday));
280
g_string_append(date_string, g_strdup_printf("%i:", timeinfo->tm_hour));
281
g_string_append(date_string, g_strdup_printf("%i:", timeinfo->tm_min));
282
g_string_append(date_string, g_strdup_printf("%i", timeinfo->tm_sec));
284
328
alarms = g_key_file_get_groups(loaded_alarms, NULL);
395
run_alarm(alarms[count]);
396
manage_old_alarm(alarms[count]);
397
update_list_entries();
403
manage_old_alarm(alarms[count]);
352
move_to_missed(gchar *name)
355
gchar *buffer, **keys;
356
GKeyFile *temp_key = g_key_file_new();
358
g_key_file_load_from_file(temp_key, config_missed, G_KEY_FILE_NONE, NULL);
360
keys = g_key_file_get_keys(loaded_alarms, name, NULL, NULL);
364
if (keys[key] == NULL) break;
365
buffer = g_key_file_get_string(loaded_alarms, name, keys[key], NULL);
367
g_key_file_set_string(temp_key, name, keys[key], buffer);
373
buffer = g_key_file_to_data(temp_key, NULL, NULL);
375
g_file_set_contents(config_missed, buffer, -1, NULL);
377
g_key_file_free(temp_key);
384
manage_old_alarm(gchar *name)
386
gchar *type = g_key_file_get_string(loaded_alarms, name, "AlarmType", NULL);
387
gboolean snooze = g_key_file_get_boolean(loaded_alarms, name, "snoozed", NULL);
388
gboolean single = TRUE;
390
if (g_strcmp0(type, "Schedule") == 0) single = FALSE;
391
if (snooze) snooze = FALSE;
395
if (need_check_first)
397
move_to_missed(name);
402
update_list_entries();
407
if (single && !snooze && !running_snooze)
411
update_list_entries();
418
411
process_alarm_thread(void)
423
416
GTimeVal alarm_time, current_time;
424
417
gchar *iso_date, **alarms;
420
timeinfo = localtime ( &rawtime );
427
GString *date_string;
430
date_string = g_string_new(NULL);
432
timeinfo = localtime ( &rawtime );
433
g_string_append(date_string, g_strdup_printf("%i-", timeinfo->tm_year + 1900));
434
g_string_append(date_string, g_strdup_printf("%i-", timeinfo->tm_mon + 1));
435
g_string_append(date_string, g_strdup_printf("%iT", timeinfo->tm_mday));
436
g_string_append(date_string, g_strdup_printf("%i:", timeinfo->tm_hour));
437
g_string_append(date_string, g_strdup_printf("%i:", timeinfo->tm_min));
438
g_string_append(date_string, g_strdup_printf("%i", timeinfo->tm_sec));
440
427
if (timeinfo->tm_hour == 0 && timeinfo->tm_min == 0 && timeinfo->tm_sec == 0)
453
440
if (alarms[count] == NULL) break;
455
if (check_play_alarm(alarms[count], date_string->str))
458
run_alarm(alarms[count]);
462
442
iso_date = g_key_file_get_string(loaded_alarms, alarms[count], "DateTime", NULL);
463
443
g_time_val_from_iso8601(iso_date, &alarm_time);
464
444
g_free(iso_date);