[svn r807] Added gmyth_scheduler_add_schedule_full() method trunk
authormelunko
Mon Aug 13 22:54:55 2007 +0100 (2007-08-13)
branchtrunk
changeset 801e51af4d0caf5
parent 800 2b1824e138b1
child 802 d0e8c542c38e
[svn r807] Added gmyth_scheduler_add_schedule_full() method
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
     1.1 --- a/gmyth/src/gmyth_scheduler.c	Mon Aug 13 22:29:00 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_scheduler.c	Mon Aug 13 22:54:55 2007 +0100
     1.3 @@ -45,7 +45,6 @@
     1.4  static void     gmyth_scheduler_dispose(GObject * object);
     1.5  static void     gmyth_scheduler_finalize(GObject * object);
     1.6  
     1.7 -static gint     get_record_id_from_database(GMythScheduler * scheduler);
     1.8  static gboolean update_backend(GMythScheduler * scheduler, gint record_id);
     1.9  
    1.10  G_DEFINE_TYPE(GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT)
    1.11 @@ -425,17 +424,9 @@
    1.12      g_free(str_value);
    1.13  }
    1.14  
    1.15 -/** Requests the Mysql database in the backend to add a new schedule.
    1.16 - * 
    1.17 - * @param scheduler the GMythScheduler instance.
    1.18 - * @param schedule_info the ScheduleInfo with recording schedule information
    1.19 - * to be added. record_id = -1 to add a new schedule, otherwise this
    1.20 - * function will update the schedule in the db
    1.21 - * @return gboolean returns FALSE if some error occurs, TRUE otherwise
    1.22 - */
    1.23  gboolean
    1.24 -gmyth_scheduler_add_schedule(GMythScheduler * scheduler,
    1.25 -                             ScheduleInfo * schedule_info)
    1.26 +gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
    1.27 +                             ScheduleInfo * schedule_info, GMythScheduleType type)
    1.28  {
    1.29      MYSQL_RES      *msql_res;
    1.30      gchar          *query_str = "INSERT record (recordid) VALUE (0);";
    1.31 @@ -504,9 +495,16 @@
    1.32      // _set_int_value (scheduler->msqlquery, "findid",
    1.33      // (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528),
    1.34      // rec_id);
    1.35 +
    1.36      _set_value(scheduler->msqlquery, "parentid", "0", rec_id);
    1.37      _set_value(scheduler->msqlquery, "search", "0", rec_id);
    1.38 -    _set_value(scheduler->msqlquery, "type", "1", rec_id);
    1.39 +
    1.40 +    if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) {
    1.41 +        _set_value(scheduler->msqlquery, "type", "4", rec_id);
    1.42 +    } else {
    1.43 +        _set_value(scheduler->msqlquery, "type", "1", rec_id);
    1.44 +    }
    1.45 +
    1.46      _set_value(scheduler->msqlquery, "recpriority", "0", rec_id);
    1.47      _set_value(scheduler->msqlquery, "startoffset", "0", rec_id);
    1.48      _set_value(scheduler->msqlquery, "endoffset", "0", rec_id);
    1.49 @@ -539,6 +537,22 @@
    1.50      return update_backend(scheduler, rec_id);
    1.51  }
    1.52  
    1.53 +/** Requests the Mysql database in the backend to add a new schedule.
    1.54 + * 
    1.55 + * @param scheduler the GMythScheduler instance.
    1.56 + * @param schedule_info the ScheduleInfo with recording schedule information
    1.57 + * to be added. record_id = -1 to add a new schedule, otherwise this
    1.58 + * function will update the schedule in the db
    1.59 + * @return gboolean returns FALSE if some error occurs, TRUE otherwise
    1.60 + */
    1.61 +gboolean
    1.62 +gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
    1.63 +                             ScheduleInfo * schedule_info)
    1.64 +{
    1.65 +    return gmyth_scheduler_add_schedule_full (scheduler, schedule_info, 
    1.66 +                                              GMYTH_SCHEDULE_ONE_OCCURRENCE);
    1.67 +}
    1.68 +
    1.69  /** Requests the Mysql database in the backend to remove an existing schedule.
    1.70   * 
    1.71   * @param scheduler the GMythScheduler instance.
    1.72 @@ -729,29 +743,6 @@
    1.73      return proginfo;
    1.74  }
    1.75  
    1.76 -/** Retrieves the next record id.
    1.77 - * 
    1.78 - * @param scheduler The GMythScheduler instance.
    1.79 - * @return gint record_id if success, -1 otherwise 
    1.80 - */
    1.81 -static  gint
    1.82 -get_record_id_from_database(GMythScheduler * scheduler)
    1.83 -{
    1.84 -    gint record_id;
    1.85 -
    1.86 -    assert(scheduler);
    1.87 -
    1.88 -    if (scheduler->msqlquery == NULL) {
    1.89 -        g_warning("[%s] Scheduler db connection not initialized",
    1.90 -                  __FUNCTION__);
    1.91 -        return 0;
    1.92 -    }
    1.93 -
    1.94 -    record_id = mysql_insert_id(scheduler->msqlquery->conn);
    1.95 -
    1.96 -    return record_id;
    1.97 -}
    1.98 -
    1.99  /** Notifies the backend of an update in the db.
   1.100   * 
   1.101   * @param record_id the id of the modified recording.
     2.1 --- a/gmyth/src/gmyth_scheduler.h	Mon Aug 13 22:29:00 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_scheduler.h	Mon Aug 13 22:54:55 2007 +0100
     2.3 @@ -36,12 +36,20 @@
     2.4  #include "gmyth_backendinfo.h"
     2.5  
     2.6  G_BEGIN_DECLS
     2.7 +
     2.8 +typedef enum {
     2.9 +    GMYTH_SCHEDULE_ONE_OCCURRENCE,
    2.10 +    GMYTH_SCHEDULE_ALL_OCCURRENCES
    2.11 +} GMythScheduleType;
    2.12 +
    2.13 +
    2.14  #define GMYTH_SCHEDULER_TYPE               (gmyth_scheduler_get_type ())
    2.15  #define GMYTH_SCHEDULER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SCHEDULER_TYPE, GMythScheduler))
    2.16  #define GMYTH_SCHEDULER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass))
    2.17  #define IS_GMYTH_SCHEDULER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_SCHEDULER_TYPE))
    2.18  #define IS_GMYTH_SCHEDULER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE))
    2.19  #define GMYTH_SCHEDULER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass))
    2.20 +
    2.21  typedef struct _GMythScheduler GMythScheduler;
    2.22  typedef struct _GMythSchedulerClass GMythSchedulerClass;
    2.23  
    2.24 @@ -143,6 +151,9 @@
    2.25                                                       GTimeVal * starttime);
    2.26  gint            gmyth_scheduler_add_schedule        (GMythScheduler * scheduler,
    2.27                                                       ScheduleInfo * schedule_info);
    2.28 +gboolean        gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
    2.29 +                             ScheduleInfo * schedule_info, GMythScheduleType type);
    2.30 +
    2.31  gint            gmyth_scheduler_delete_schedule     (GMythScheduler * scheduler,
    2.32                                                       gint record_id);
    2.33  gint            gmyth_scheduler_delete_recorded     (GMythScheduler * scheduler,