00001
00136 #ifndef LIBALARM_H_
00137 #define LIBALARM_H_
00138
00139 #include <stdint.h>
00140 #include <stdarg.h>
00141 #include <time.h>
00142
00143 #ifdef __cplusplus
00144 extern "C" {
00145 #elif 0
00146 }
00147 #endif
00148
00149
00150
00151
00152
00153 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00154 # ifdef ALARMD_MANGLE_MEMBERS
00155 # define ALARMD_CAT2(a,b) a##b
00156 # define ALARMD_PRIVATE(x) ALARMD_CAT2(x,_private)
00157 # else
00158 # define ALARMD_PRIVATE(x) x
00159 # endif
00160 #endif
00161
00162 #pragma GCC visibility push(default)
00163
00166 typedef long cookie_t;
00167
00168
00169
00170
00171
00202 typedef struct alarm_attr_t
00203 {
00205 char *attr_name;
00206
00208 int attr_type;
00209
00211 union
00212 {
00213 char *sval;
00214 time_t tval;
00215 int ival;
00216 } attr_data;
00217 } alarm_attr_t;
00218
00220 typedef enum alarmattrtype
00221 {
00222 ALARM_ATTR_NULL,
00223 ALARM_ATTR_INT,
00224 ALARM_ATTR_TIME,
00225 ALARM_ATTR_STRING,
00226 } alarmattrtype;
00227
00231
00240 void alarm_attr_ctor (alarm_attr_t *self);
00241
00250 void alarm_attr_dtor (alarm_attr_t *self);
00251
00260 void alarm_attr_set_null (alarm_attr_t *self);
00261
00272 void alarm_attr_set_string(alarm_attr_t *self, const char *val);
00273
00284 void alarm_attr_set_int (alarm_attr_t *self, int val);
00285
00296 void alarm_attr_set_time (alarm_attr_t *self, time_t val);
00297
00308 const char *alarm_attr_get_string(alarm_attr_t *self);
00309
00321 int alarm_attr_get_int (alarm_attr_t *self);
00322
00334 time_t alarm_attr_get_time (alarm_attr_t *self);
00335
00346 alarm_attr_t *alarm_attr_create (const char *name);
00347
00359 void alarm_attr_delete (alarm_attr_t *self);
00360
00369 void alarm_attr_delete_cb (void *self);
00370
00423 typedef enum alarmactionflags
00424 {
00425
00426
00427
00428
00429
00430
00432 ALARM_ACTION_TYPE_NOP = 0,
00433
00443 ALARM_ACTION_TYPE_SNOOZE = 1 << 0,
00444
00454 ALARM_ACTION_TYPE_DBUS = 1 << 1,
00455
00461 ALARM_ACTION_TYPE_EXEC = 1 << 2,
00462
00463 #if ALARMD_ACTION_BOOTFLAGS
00464
00465 ALARM_ACTION_TYPE_DESKTOP = 1 << 3,
00466
00468 ALARM_ACTION_TYPE_ACTDEAD = 1 << 8,
00469 #endif
00470
00475 ALARM_ACTION_TYPE_DISABLE = 1 << 10,
00476
00477
00478
00483 ALARM_ACTION_WHEN_QUEUED = 1 << 4,
00484
00493 ALARM_ACTION_WHEN_DELAYED = 1 << 11,
00494
00498 ALARM_ACTION_WHEN_TRIGGERED = 1 << 5,
00499
00510 ALARM_ACTION_WHEN_DISABLED = 1 << 9,
00511
00514 ALARM_ACTION_WHEN_RESPONDED = 1 << 6,
00515
00518 ALARM_ACTION_WHEN_DELETED = 1 << 7,
00519
00520
00521
00524 ALARM_ACTION_DBUS_USE_ACTIVATION = 1 << 12,
00525
00528 ALARM_ACTION_DBUS_USE_SYSTEMBUS = 1 << 13,
00529
00532 ALARM_ACTION_DBUS_ADD_COOKIE = 1 << 14,
00533
00534
00535
00550 ALARM_ACTION_EXEC_ADD_COOKIE = 1 << 15,
00551
00552
00553
00554 ALARM_ACTION_TYPE_MASK = (ALARM_ACTION_TYPE_SNOOZE |
00555 ALARM_ACTION_TYPE_DISABLE|
00556 ALARM_ACTION_TYPE_DBUS |
00557 ALARM_ACTION_TYPE_EXEC |
00558 #if ALARMD_ACTION_BOOTFLAGS
00559 ALARM_ACTION_TYPE_DESKTOP|
00560 ALARM_ACTION_TYPE_ACTDEAD|
00561 #endif
00562 0),
00563
00564 ALARM_ACTION_WHEN_MASK = (ALARM_ACTION_WHEN_QUEUED |
00565 ALARM_ACTION_WHEN_DELAYED |
00566 ALARM_ACTION_WHEN_TRIGGERED |
00567 ALARM_ACTION_WHEN_DISABLED |
00568 ALARM_ACTION_WHEN_RESPONDED |
00569 ALARM_ACTION_WHEN_DELETED),
00570
00571 } alarmactionflags;
00572
00615 typedef struct alarm_action_t
00616 {
00618 unsigned flags;
00619
00632 char *label;
00633
00640 char *exec_command;
00641
00648 char *dbus_interface;
00649
00657 char *dbus_service;
00658
00665 char *dbus_path;
00666
00673 char *dbus_name;
00674
00687 char *dbus_args;
00688
00689 } alarm_action_t;
00690
00691
00692
00693
00694
00698
00700 void alarm_action_ctor (alarm_action_t *self);
00702 void alarm_action_dtor (alarm_action_t *self);
00704 alarm_action_t *alarm_action_create (void);
00706 void alarm_action_delete (alarm_action_t *self);
00708 void alarm_action_delete_cb(void *self);
00709
00719 int alarm_action_is_button(const alarm_action_t *self);
00720
00733 int alarm_action_set_dbus_args (alarm_action_t *self, int type, ...);
00734
00739 void alarm_action_del_dbus_args (alarm_action_t *self);
00740
00751 int alarm_action_set_dbus_args_valist(alarm_action_t *self, int type, va_list va);
00752
00758 const char *alarm_action_get_label (const alarm_action_t *self);
00759
00765 const char *alarm_action_get_exec_command (const alarm_action_t *self);
00766
00772 const char *alarm_action_get_dbus_interface (const alarm_action_t *self);
00773
00779 const char *alarm_action_get_dbus_service (const alarm_action_t *self);
00780
00786 const char *alarm_action_get_dbus_path (const alarm_action_t *self);
00787
00793 const char *alarm_action_get_dbus_name (const alarm_action_t *self);
00794
00800 void alarm_action_set_label (alarm_action_t *self, const char *label);
00801
00807 void alarm_action_set_exec_command (alarm_action_t *self, const char *exec_command);
00808
00814 void alarm_action_set_dbus_interface (alarm_action_t *self, const char *dbus_interface);
00815
00821 void alarm_action_set_dbus_service (alarm_action_t *self, const char *dbus_service);
00822
00828 void alarm_action_set_dbus_path (alarm_action_t *self, const char *dbus_path);
00829
00835 void alarm_action_set_dbus_name (alarm_action_t *self, const char *dbus_name);
00836
00881 typedef struct alarm_recur_t
00882 {
00883
00884
00893 uint64_t mask_min;
00894
00901 uint32_t mask_hour;
00902
00909 uint32_t mask_mday;
00910
00917 uint32_t mask_wday;
00924 uint32_t mask_mon;
00925
00934 uint32_t special;
00935
00936 } alarm_recur_t;
00937
00944 typedef enum alarmrecurflags
00945 {
00947 ALARM_RECUR_MIN_DONTCARE = 0,
00949 ALARM_RECUR_MIN_ALL = (1ull << 60) - 1,
00950
00952 ALARM_RECUR_HOUR_DONTCARE = 0,
00954 ALARM_RECUR_HOUR_ALL = (1u << 24) - 1,
00955
00957 ALARM_RECUR_MDAY_DONTCARE = 0,
00959 ALARM_RECUR_MDAY_ALL = ~1u,
00962 ALARM_RECUR_MDAY_EOM = 1u,
00963
00965 ALARM_RECUR_WDAY_DONTCARE = 0,
00967 ALARM_RECUR_WDAY_ALL = (1u << 7) - 1,
00969 ALARM_RECUR_WDAY_SUN = (1u << 0),
00971 ALARM_RECUR_WDAY_MON = (1u << 1),
00973 ALARM_RECUR_WDAY_TUE = (1u << 2),
00975 ALARM_RECUR_WDAY_WED = (1u << 3),
00977 ALARM_RECUR_WDAY_THU = (1u << 4),
00979 ALARM_RECUR_WDAY_FRI = (1u << 5),
00981 ALARM_RECUR_WDAY_SAT = (1u << 6),
00983 ALARM_RECUR_WDAY_MONFRI = ALARM_RECUR_WDAY_SAT - ALARM_RECUR_WDAY_MON,
00985 ALARM_RECUR_WDAY_SATSUN = ALARM_RECUR_WDAY_SAT | ALARM_RECUR_WDAY_SUN,
00986
00988 ALARM_RECUR_MON_DONTCARE = 0,
00990 ALARM_RECUR_MON_ALL = (1u << 12) - 1,
00992 ALARM_RECUR_MON_JAN = (1u << 0),
00994 ALARM_RECUR_MON_FEB = (1u << 1),
00996 ALARM_RECUR_MON_MAR = (1u << 2),
00998 ALARM_RECUR_MON_APR = (1u << 3),
01000 ALARM_RECUR_MON_MAY = (1u << 4),
01002 ALARM_RECUR_MON_JUN = (1u << 5),
01004 ALARM_RECUR_MON_JUL = (1u << 6),
01006 ALARM_RECUR_MON_AUG = (1u << 7),
01008 ALARM_RECUR_MON_SEP = (1u << 8),
01010 ALARM_RECUR_MON_OCT = (1u << 9),
01012 ALARM_RECUR_MON_NOW = (1u << 10),
01014 ALARM_RECUR_MON_DEC = (1u << 11),
01015
01017 ALARM_RECUR_SPECIAL_NONE = 0,
01019 ALARM_RECUR_SPECIAL_BIWEEKLY = 1,
01021 ALARM_RECUR_SPECIAL_MONTHLY = 2,
01023 ALARM_RECUR_SPECIAL_YEARLY = 3,
01024 } alarmrecurflags;
01025
01029
01034 void alarm_recur_ctor (alarm_recur_t *self);
01035
01040 void alarm_recur_dtor (alarm_recur_t *self);
01041
01046 alarm_recur_t *alarm_recur_create (void);
01047
01052 void alarm_recur_delete (alarm_recur_t *self);
01053
01059 void alarm_recur_init_from_tm (alarm_recur_t *self, const struct tm *tm);
01060
01065 void alarm_recur_delete_cb (void *self);
01066
01075 time_t alarm_recur_align (const alarm_recur_t *self, struct tm *trg, const char *tz);
01076
01085 time_t alarm_recur_next (const alarm_recur_t *self, struct tm *trg, const char *tz);
01086
01095 typedef enum alarmeventflags
01096 {
01097
01098
01099
01100
01103 ALARM_EVENT_BOOT = 1 << 3,
01104
01107 ALARM_EVENT_ACTDEAD = 1 << 4,
01108
01112 ALARM_EVENT_SHOW_ICON = 1 << 5,
01113
01118 ALARM_EVENT_CONNECTED = 1 << 7,
01119
01126 ALARM_EVENT_RUN_DELAYED = 1 << 6,
01127
01134 ALARM_EVENT_POSTPONE_DELAYED = 1 << 9,
01135
01143 ALARM_EVENT_DISABLE_DELAYED = 1 << 12,
01144
01150 ALARM_EVENT_BACK_RESCHEDULE = 1 << 10,
01151
01156 ALARM_EVENT_DISABLED = 1 << 11,
01157
01161 ALARM_EVENT_CLIENT_BITS = 16,
01162
01165 ALARM_EVENT_CLIENT_MASK = (1 << ALARM_EVENT_CLIENT_BITS) - 1,
01166
01167 } alarmeventflags;
01168
01170 #define ALARM_RECURRING_SECONDS(n) (n)
01171
01172 #define ALARM_RECURRING_MINUTES(n) ((n)*60)
01173
01174 #define ALARM_RECURRING_HOURS(n) ((n)*60*60)
01175
01262 typedef struct alarm_event_t
01263 {
01274 cookie_t ALARMD_PRIVATE(cookie);
01275
01282 time_t ALARMD_PRIVATE(trigger);
01283
01290 char *title;
01291
01298 char *message;
01299
01306 char *sound;
01307
01314 char *icon;
01315
01317 unsigned flags;
01318
01325 char *alarm_appid;
01326
01333 time_t alarm_time;
01334
01341 struct tm alarm_tm;
01342
01357 char *alarm_tz;
01358
01366 time_t snooze_secs;
01367
01372 time_t snooze_total;
01373
01380 size_t action_cnt;
01381
01388 alarm_action_t *action_tab;
01389
01391 int response;
01392
01398 int recur_count;
01399
01402 time_t recur_secs;
01403
01408 size_t recurrence_cnt;
01416 alarm_recur_t *recurrence_tab;
01417
01422 size_t attr_cnt;
01438 alarm_attr_t **attr_tab;
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457 } alarm_event_t;
01458
01459
01460
01461
01462
01466
01475 void alarm_event_delete(alarm_event_t *self);
01476
01486 alarm_event_t *alarm_event_create(void);
01487
01494 alarm_event_t *alarm_event_create_ex(size_t actions);
01495
01500 void alarm_event_delete_cb(void *self);
01501
01506 void alarm_event_ctor(alarm_event_t *self);
01507
01512 void alarm_event_dtor(alarm_event_t *self);
01513
01522 cookie_t alarm_event_get_cookie(const alarm_event_t *self);
01523
01532 void alarm_event_set_cookie(alarm_event_t *self, cookie_t cookie);
01533
01542 time_t alarm_event_get_trigger(const alarm_event_t *self);
01543
01552 void alarm_event_set_trigger(alarm_event_t *self, time_t trigger);
01553
01559 const char *alarm_event_get_title (const alarm_event_t *self);
01560
01566 void alarm_event_set_title (alarm_event_t *self, const char *title);
01567
01573 const char *alarm_event_get_message (const alarm_event_t *self);
01574
01580 void alarm_event_set_message (alarm_event_t *self, const char *message);
01581
01587 const char *alarm_event_get_sound (const alarm_event_t *self);
01588
01594 void alarm_event_set_sound (alarm_event_t *self, const char *sound);
01595
01601 const char *alarm_event_get_icon (const alarm_event_t *self);
01602
01608 void alarm_event_set_icon (alarm_event_t *self, const char *icon);
01609
01615 const char *alarm_event_get_alarm_appid (const alarm_event_t *self);
01616
01622 void alarm_event_set_alarm_appid (alarm_event_t *self, const char *alarm_appid);
01623
01629 const char *alarm_event_get_alarm_tz (const alarm_event_t *self);
01630
01636 void alarm_event_set_alarm_tz (alarm_event_t *self, const char *alarm_tz);
01637
01650 int alarm_event_is_recurring(const alarm_event_t *self);
01651
01662 alarm_action_t *alarm_event_add_actions(alarm_event_t *self, size_t count);
01663
01669 alarm_action_t *alarm_event_get_action(const alarm_event_t *self, int index);
01670
01676 void alarm_event_del_actions(alarm_event_t *self);
01677
01690 int alarm_event_set_action_dbus_args(const alarm_event_t *self, int index, int type, ...);
01691
01701 const char *alarm_event_get_action_dbus_args(const alarm_event_t *self, int index);
01702
01710 void alarm_event_del_action_dbus_args(const alarm_event_t *self, int index);
01711
01722 alarm_recur_t *alarm_event_add_recurrences(alarm_event_t *self, size_t count);
01723
01736 alarm_recur_t *alarm_event_get_recurrence(const alarm_event_t *self, int index);
01737
01743 void alarm_event_del_recurrences(alarm_event_t *self);
01744
01756 void alarm_event_set_time(alarm_event_t *self, const struct tm *tm);
01757
01767 void alarm_event_get_time(const alarm_event_t *self, struct tm *tm);
01768
01787 int alarm_event_is_sane(const alarm_event_t *self);
01788
01798 void alarm_event_del_attrs (alarm_event_t *self);
01799
01809 void alarm_event_rem_attr (alarm_event_t *self, const char *name);
01810
01822 alarm_attr_t *alarm_event_get_attr (alarm_event_t *self, const char *name);
01823
01835 int alarm_event_has_attr (alarm_event_t *self, const char *name);
01836
01850 alarm_attr_t *alarm_event_add_attr (alarm_event_t *self, const char *name);
01851
01863 void alarm_event_set_attr_int (alarm_event_t *self, const char *name, int val);
01864
01876 void alarm_event_set_attr_time (alarm_event_t *self, const char *name, time_t val);
01877
01889 void alarm_event_set_attr_string (alarm_event_t *self, const char *name, const char *val);
01890
01904 int alarm_event_get_attr_int (alarm_event_t *self, const char *name, int def);
01905
01919 time_t alarm_event_get_attr_time (alarm_event_t *self, const char *name, time_t def);
01920
01934 const char *alarm_event_get_attr_string (alarm_event_t *self, const char *name, const char *def);
01935
01938
01939
01940
01941
01945
01957 cookie_t alarmd_event_add(const alarm_event_t *event);
01958
01981 cookie_t alarmd_event_add_with_dbus_params(const alarm_event_t *event,
01982 int type, ...);
01983
01993 int alarmd_event_del(cookie_t cookie);
01994
02016 cookie_t alarmd_event_update(const alarm_event_t *event);
02017
02043 cookie_t *alarmd_event_query(const time_t first, const time_t last,
02044 int32_t flag_mask, int32_t flags,
02045 const char *appid);
02046
02058 alarm_event_t *alarmd_event_get(cookie_t cookie);
02059
02071 int alarmd_set_default_snooze(unsigned int snooze);
02072
02079 unsigned int alarmd_get_default_snooze(void);
02080
02082 cookie_t alarmd_event_add_valist(const alarm_event_t *event, int type, va_list va);
02083
02086
02087
02088
02089
02094
02096 int alarmd_ack_dialog(cookie_t cookie, int button);
02097
02099 int alarmd_ack_queue(cookie_t *cookies, int count);
02100
02103
02104
02105
02106
02111
02113 int alarmd_set_debug(unsigned mask_set, unsigned mask_clr,
02114 unsigned flag_set, unsigned flag_clr);
02115
02118 #pragma GCC visibility pop
02119
02120 #ifdef __cplusplus
02121 };
02122 #endif
02123
02124 #endif