mirror of https://git.48k.eu/ogserver
#942 add enum og_schedule_type
parent
8fa9ec647a
commit
63c4ea5e12
|
@ -3754,7 +3754,8 @@ static int og_dbi_schedule_get(void)
|
|||
time.am_pm = dbi_result_get_uint(result, "ampm");
|
||||
time.minutes = dbi_result_get_uint(result, "minutos");
|
||||
|
||||
og_schedule_create(schedule_id, task_id, &time);
|
||||
og_schedule_create(schedule_id, task_id, OG_SCHEDULE_TASK,
|
||||
&time);
|
||||
}
|
||||
|
||||
dbi_result_free(result);
|
||||
|
@ -3971,7 +3972,8 @@ static int og_task_schedule_create(struct og_msg_params *params)
|
|||
og_dbi_close(dbi);
|
||||
return -1;
|
||||
}
|
||||
og_schedule_create(schedule_id, atoi(params->task_id), ¶ms->time);
|
||||
og_schedule_create(schedule_id, atoi(params->task_id), OG_SCHEDULE_TASK,
|
||||
¶ms->time);
|
||||
og_schedule_refresh(og_loop);
|
||||
og_dbi_close(dbi);
|
||||
|
||||
|
|
|
@ -197,7 +197,8 @@ static void og_schedule_remove_duplicates()
|
|||
|
||||
static void og_schedule_create_weekdays(int month, int year,
|
||||
int *hours, int minutes, int week_days,
|
||||
uint32_t task_id, uint32_t schedule_id)
|
||||
uint32_t task_id, uint32_t schedule_id,
|
||||
enum og_schedule_type type)
|
||||
{
|
||||
struct og_schedule *schedule;
|
||||
int month_days[5];
|
||||
|
@ -235,6 +236,7 @@ static void og_schedule_create_weekdays(int month, int year,
|
|||
schedule->seconds = mktime(&tm);
|
||||
schedule->task_id = task_id;
|
||||
schedule->schedule_id = schedule_id;
|
||||
schedule->type = type;
|
||||
og_schedule_add(schedule);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +245,8 @@ static void og_schedule_create_weekdays(int month, int year,
|
|||
|
||||
static void og_schedule_create_weeks(int month, int year,
|
||||
int *hours, int minutes, int weeks,
|
||||
uint32_t task_id, uint32_t schedule_id)
|
||||
uint32_t task_id, uint32_t schedule_id,
|
||||
enum og_schedule_type type)
|
||||
{
|
||||
struct og_schedule *schedule;
|
||||
int month_days[7];
|
||||
|
@ -284,6 +287,7 @@ static void og_schedule_create_weeks(int month, int year,
|
|||
schedule->seconds = mktime(&tm);
|
||||
schedule->task_id = task_id;
|
||||
schedule->schedule_id = schedule_id;
|
||||
schedule->type = type;
|
||||
og_schedule_add(schedule);
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +296,8 @@ static void og_schedule_create_weeks(int month, int year,
|
|||
|
||||
static void og_schedule_create_days(int month, int year,
|
||||
int *hours, int minutes, int *days,
|
||||
uint32_t task_id, uint32_t schedule_id)
|
||||
uint32_t task_id, uint32_t schedule_id,
|
||||
enum og_schedule_type type)
|
||||
{
|
||||
struct og_schedule *schedule;
|
||||
struct tm tm;
|
||||
|
@ -315,12 +320,14 @@ static void og_schedule_create_days(int month, int year,
|
|||
schedule->seconds = mktime(&tm);
|
||||
schedule->task_id = task_id;
|
||||
schedule->schedule_id = schedule_id;
|
||||
schedule->type = type;
|
||||
og_schedule_add(schedule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
|
||||
enum og_schedule_type type,
|
||||
struct og_schedule_time *time)
|
||||
{
|
||||
int year, month, minutes;
|
||||
|
@ -346,21 +353,24 @@ void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
|
|||
hours, minutes,
|
||||
time->week_days,
|
||||
task_id,
|
||||
schedule_id);
|
||||
schedule_id,
|
||||
type);
|
||||
|
||||
if (time->weeks)
|
||||
og_schedule_create_weeks(month, year,
|
||||
hours, minutes,
|
||||
time->weeks,
|
||||
task_id,
|
||||
schedule_id);
|
||||
schedule_id,
|
||||
type);
|
||||
|
||||
if (time->days)
|
||||
og_schedule_create_days(month, year,
|
||||
hours, minutes,
|
||||
days,
|
||||
task_id,
|
||||
schedule_id);
|
||||
schedule_id,
|
||||
type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +399,7 @@ void og_schedule_update(struct ev_loop *loop, unsigned int schedule_id,
|
|||
unsigned int task_id, struct og_schedule_time *time)
|
||||
{
|
||||
og_schedule_delete(loop, schedule_id);
|
||||
og_schedule_create(schedule_id, task_id, time);
|
||||
og_schedule_create(schedule_id, task_id, OG_SCHEDULE_TASK, time);
|
||||
}
|
||||
|
||||
static void og_agent_timer_cb(struct ev_loop *loop, ev_timer *timer, int events)
|
||||
|
|
|
@ -17,15 +17,21 @@ struct og_schedule_time {
|
|||
uint32_t minutes;
|
||||
};
|
||||
|
||||
enum og_schedule_type {
|
||||
OG_SCHEDULE_TASK,
|
||||
};
|
||||
|
||||
struct og_schedule {
|
||||
struct list_head list;
|
||||
struct ev_timer timer;
|
||||
time_t seconds;
|
||||
unsigned int task_id;
|
||||
unsigned int schedule_id;
|
||||
enum og_schedule_type type;
|
||||
};
|
||||
|
||||
void og_schedule_create(unsigned int schedule_id, unsigned int task_id,
|
||||
enum og_schedule_type type,
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue