summaryrefslogtreecommitdiffstats
path: root/admin/Sources/Services/ogAdmServer/sources/schedule.h
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2020-01-22 13:32:12 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-02 12:32:36 +0200
commitd327da6d822dab340da5c5a4c1ba902905f4c2e7 (patch)
tree14326de2770871023946792b1d7cb3d579eb3047 /admin/Sources/Services/ogAdmServer/sources/schedule.h
parentc90cda478b274b7a54ef48ffcc3922bca8f553a3 (diff)
#942 Add support for scheduled tasks and commands
This field needs to be at least 31 bits long to store all days in a month. Other fields are also set to 32 bits because unsigned int length can change depending on the system. We also need to support the three ways that the ogAdmAgent and the WebConsole have to create an schedule. At first, we only supported the easiest method: * Hour, day, month and year -> 10:00, 28, february, 2020 This commit adds these two ways to create an schedule: * Hour, week day, month and year -> 10:00, Monday, february, 2020 * Hour, week, month and year -> 10:00, first week, february, 2020
Diffstat (limited to 'admin/Sources/Services/ogAdmServer/sources/schedule.h')
-rw-r--r--admin/Sources/Services/ogAdmServer/sources/schedule.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/admin/Sources/Services/ogAdmServer/sources/schedule.h b/admin/Sources/Services/ogAdmServer/sources/schedule.h
new file mode 100644
index 00000000..7195a051
--- /dev/null
+++ b/admin/Sources/Services/ogAdmServer/sources/schedule.h
@@ -0,0 +1,37 @@
+#ifndef _OG_SCHEDULE_H_
+#define _OG_SCHEDULE_H_
+
+#include <stdint.h>
+#include "dbi.h"
+#include "list.h"
+#include <ev.h>
+
+struct og_schedule_time {
+ uint32_t years;
+ uint32_t months;
+ uint32_t weeks;
+ uint32_t week_days;
+ uint32_t days;
+ uint32_t hours;
+ uint32_t am_pm;
+ uint32_t minutes;
+};
+
+struct og_schedule {
+ struct list_head list;
+ struct ev_timer timer;
+ time_t seconds;
+ unsigned int task_id;
+ unsigned int schedule_id;
+};
+
+void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
+ struct og_schedule_time *time);
+void og_schedule_update(struct ev_loop *loop, unsigned int schedule_id,
+ unsigned int task_id, struct og_schedule_time *time);
+void og_schedule_delete(struct ev_loop *loop, uint32_t schedule_id);
+void og_schedule_next(struct ev_loop *loop);
+void og_schedule_refresh(struct ev_loop *loop);
+void og_dbi_schedule_task(unsigned int task_id);
+
+#endif