# HG changeset patch # User melunko # Date 1187042095 -3600 # Node ID e51af4d0caf5d1ac07d184674ffb479d62796a5f # Parent 2b1824e138b108df0d8b5d2475c5ea287838c2c1 [svn r807] Added gmyth_scheduler_add_schedule_full() method diff -r 2b1824e138b1 -r e51af4d0caf5 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Mon Aug 13 22:29:00 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.c Mon Aug 13 22:54:55 2007 +0100 @@ -45,7 +45,6 @@ static void gmyth_scheduler_dispose(GObject * object); static void gmyth_scheduler_finalize(GObject * object); -static gint get_record_id_from_database(GMythScheduler * scheduler); static gboolean update_backend(GMythScheduler * scheduler, gint record_id); G_DEFINE_TYPE(GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT) @@ -425,17 +424,9 @@ g_free(str_value); } -/** Requests the Mysql database in the backend to add a new schedule. - * - * @param scheduler the GMythScheduler instance. - * @param schedule_info the ScheduleInfo with recording schedule information - * to be added. record_id = -1 to add a new schedule, otherwise this - * function will update the schedule in the db - * @return gboolean returns FALSE if some error occurs, TRUE otherwise - */ gboolean -gmyth_scheduler_add_schedule(GMythScheduler * scheduler, - ScheduleInfo * schedule_info) +gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler, + ScheduleInfo * schedule_info, GMythScheduleType type) { MYSQL_RES *msql_res; gchar *query_str = "INSERT record (recordid) VALUE (0);"; @@ -504,9 +495,16 @@ // _set_int_value (scheduler->msqlquery, "findid", // (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528), // rec_id); + _set_value(scheduler->msqlquery, "parentid", "0", rec_id); _set_value(scheduler->msqlquery, "search", "0", rec_id); - _set_value(scheduler->msqlquery, "type", "1", rec_id); + + if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) { + _set_value(scheduler->msqlquery, "type", "4", rec_id); + } else { + _set_value(scheduler->msqlquery, "type", "1", rec_id); + } + _set_value(scheduler->msqlquery, "recpriority", "0", rec_id); _set_value(scheduler->msqlquery, "startoffset", "0", rec_id); _set_value(scheduler->msqlquery, "endoffset", "0", rec_id); @@ -539,6 +537,22 @@ return update_backend(scheduler, rec_id); } +/** Requests the Mysql database in the backend to add a new schedule. + * + * @param scheduler the GMythScheduler instance. + * @param schedule_info the ScheduleInfo with recording schedule information + * to be added. record_id = -1 to add a new schedule, otherwise this + * function will update the schedule in the db + * @return gboolean returns FALSE if some error occurs, TRUE otherwise + */ +gboolean +gmyth_scheduler_add_schedule (GMythScheduler * scheduler, + ScheduleInfo * schedule_info) +{ + return gmyth_scheduler_add_schedule_full (scheduler, schedule_info, + GMYTH_SCHEDULE_ONE_OCCURRENCE); +} + /** Requests the Mysql database in the backend to remove an existing schedule. * * @param scheduler the GMythScheduler instance. @@ -729,29 +743,6 @@ return proginfo; } -/** Retrieves the next record id. - * - * @param scheduler The GMythScheduler instance. - * @return gint record_id if success, -1 otherwise - */ -static gint -get_record_id_from_database(GMythScheduler * scheduler) -{ - gint record_id; - - assert(scheduler); - - if (scheduler->msqlquery == NULL) { - g_warning("[%s] Scheduler db connection not initialized", - __FUNCTION__); - return 0; - } - - record_id = mysql_insert_id(scheduler->msqlquery->conn); - - return record_id; -} - /** Notifies the backend of an update in the db. * * @param record_id the id of the modified recording. diff -r 2b1824e138b1 -r e51af4d0caf5 gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Mon Aug 13 22:29:00 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.h Mon Aug 13 22:54:55 2007 +0100 @@ -36,12 +36,20 @@ #include "gmyth_backendinfo.h" G_BEGIN_DECLS + +typedef enum { + GMYTH_SCHEDULE_ONE_OCCURRENCE, + GMYTH_SCHEDULE_ALL_OCCURRENCES +} GMythScheduleType; + + #define GMYTH_SCHEDULER_TYPE (gmyth_scheduler_get_type ()) #define GMYTH_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SCHEDULER_TYPE, GMythScheduler)) #define GMYTH_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass)) #define IS_GMYTH_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_SCHEDULER_TYPE)) #define IS_GMYTH_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE)) #define GMYTH_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass)) + typedef struct _GMythScheduler GMythScheduler; typedef struct _GMythSchedulerClass GMythSchedulerClass; @@ -143,6 +151,9 @@ GTimeVal * starttime); gint gmyth_scheduler_add_schedule (GMythScheduler * scheduler, ScheduleInfo * schedule_info); +gboolean gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler, + ScheduleInfo * schedule_info, GMythScheduleType type); + gint gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint record_id); gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler,