[svn r892] create help function: gmyth_scheduler_add_schedule_program trunk
authorrenatofilho
Fri Dec 21 14:07:54 2007 +0000 (2007-12-21)
branchtrunk
changeset 886781db4177ba2
parent 885 5224e0d6e2b9
child 887 9434eecdece9
[svn r892] create help function: gmyth_scheduler_add_schedule_program
gmyth/debian/changelog
gmyth/src/gmyth_common.h
gmyth/src/gmyth_epg.c
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
     1.1 --- a/gmyth/debian/changelog	Wed Nov 21 15:14:05 2007 +0000
     1.2 +++ b/gmyth/debian/changelog	Fri Dec 21 14:07:54 2007 +0000
     1.3 @@ -1,4 +1,4 @@
     1.4 -gmyth (0.4.1-indt1) unstable; urgency=low
     1.5 +gmyth (0.4.2-chinook-indt1) unstable; urgency=low
     1.6  
     1.7    * Patch from Tim Philipp to fix debian/control libcurl dependency
     1.8  
     2.1 --- a/gmyth/src/gmyth_common.h	Wed Nov 21 15:14:05 2007 +0000
     2.2 +++ b/gmyth/src/gmyth_common.h	Fri Dec 21 14:07:54 2007 +0000
     2.3 @@ -34,10 +34,10 @@
     2.4  #include "gmyth_programinfo.h"
     2.5  
     2.6  G_BEGIN_DECLS
     2.7 -/**
     2.8 - * The GMythChannelInfo structure represents the channel information
     2.9 - * stored in the backend database.
    2.10 - */
    2.11 +    /**
    2.12 +    * The GMythChannelInfo structure represents the channel information
    2.13 +    * stored in the backend database.
    2.14 +    */
    2.15      typedef struct {
    2.16      /** The channel ID in backend database */
    2.17      gint            channel_ID;
    2.18 @@ -50,7 +50,6 @@
    2.19  
    2.20      /** The channel icon path in the backend database */
    2.21      GString        *channel_icon;
    2.22 -
    2.23  } GMythChannelInfo;
    2.24  
    2.25  void            gmyth_free_channel_list     (GList *list);
     3.1 --- a/gmyth/src/gmyth_epg.c	Wed Nov 21 15:14:05 2007 +0000
     3.2 +++ b/gmyth/src/gmyth_epg.c	Fri Dec 21 14:07:54 2007 +0000
     3.3 @@ -266,10 +266,17 @@
     3.4           "    channel.name, program.previouslyshown, channel.commfree, "
     3.5           "    channel.outputfilters, program.seriesid, program.programid, "
     3.6           "    program.airdate, program.stars, program.originalairdate, "
     3.7 -         "    program.category_type, oldrecstatus.recordid, "
     3.8 +         "    program.category_type, record.recordid, "
     3.9           "    oldrecstatus.rectype, oldrecstatus.recstatus, "
    3.10 -         "    oldrecstatus.findid " "FROM program "
    3.11 +         "    oldrecstatus.findid "
    3.12 +         "FROM program "
    3.13           "LEFT JOIN channel ON program.chanid = channel.chanid "
    3.14 +         "LEFT JOIN record ON "
    3.15 +         "    program.chanid = record.chanid AND "
    3.16 +         "    DATE (program.starttime) = record.startdate AND "
    3.17 +         "    TIME (program.starttime) = record.starttime AND "
    3.18 +         "    DATE (program.endtime) = record.enddate AND "
    3.19 +         "    TIME (program.endtime) = record.endtime "
    3.20           "LEFT JOIN oldrecorded AS oldrecstatus ON "
    3.21           "    program.title = oldrecstatus.title AND "
    3.22           "    channel.callsign = oldrecstatus.station AND "
    3.23 @@ -321,6 +328,7 @@
    3.24          p->lastmodified->tv_sec = p->startts->tv_sec;
    3.25          p->lastmodified->tv_usec = p->startts->tv_usec;
    3.26  
    3.27 +
    3.28          p->title = g_string_new(row[3]);
    3.29          p->subtitle = g_string_new(row[4]);
    3.30          p->description = g_string_new(row[5]);
    3.31 @@ -345,6 +353,8 @@
    3.32          }
    3.33  
    3.34          p->catType = g_string_new(row[18]);
    3.35 +        if (row[19] != NULL)
    3.36 +            p->recordid =  g_ascii_strtoull(row[19], NULL, 10);
    3.37  
    3.38          *proglist = g_list_append(*proglist, p);
    3.39  
     4.1 --- a/gmyth/src/gmyth_scheduler.c	Wed Nov 21 15:14:05 2007 +0000
     4.2 +++ b/gmyth/src/gmyth_scheduler.c	Fri Dec 21 14:07:54 2007 +0000
     4.3 @@ -219,7 +219,7 @@
     4.4  
     4.5      g_string_printf(query_str,
     4.6                      "SELECT recordid,programid,chanid,starttime,startdate,"
     4.7 -                    "endtime,enddate,title,subtitle,description,category,type,parentid FROM record;");
     4.8 +                    "endtime,enddate,title,subtitle,description,category,type,parentid,seriesid FROM record;");
     4.9  
    4.10      if (scheduler->msqlquery == NULL) {
    4.11          g_warning("[%s] Scheduler db connection not initialized",
    4.12 @@ -244,10 +244,8 @@
    4.13  
    4.14              schedule->schedule_id =
    4.15                  (guint) g_ascii_strtoull(row[0], NULL, 10);
    4.16 -            schedule->program_id =
    4.17 -                (guint) g_ascii_strtoull(row[1], NULL, 10);
    4.18 -            schedule->channel_id =
    4.19 -                (guint) g_ascii_strtoull(row[2], NULL, 10);
    4.20 +            schedule->program_id = g_string_new (row[1]);
    4.21 +            schedule->channel_id = g_string_new (row[2]);
    4.22  
    4.23              /*
    4.24               * generate a time_t from a time and a date db field 
    4.25 @@ -278,6 +276,8 @@
    4.26                  schedule->parentid = (gint) g_ascii_strtoull (row[12], NULL, 10);
    4.27              }
    4.28  
    4.29 +            schedule->seriesid = g_string_new (row[13]);
    4.30 +
    4.31              (*schedule_list) = g_list_append(*(schedule_list), schedule);
    4.32          }
    4.33      }
    4.34 @@ -307,7 +307,7 @@
    4.35      g_string_printf(query_str,
    4.36                      "SELECT recordid,programid,chanid,starttime,progstart,"
    4.37                      "endtime,progend,title,subtitle,description,category,"
    4.38 -                    "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
    4.39 +                    "filesize,basename,seriesid FROM recorded WHERE recgroup != 'LiveTV'");
    4.40  
    4.41      if (scheduler->msqlquery == NULL) {
    4.42          g_warning("[%s] Scheduler db connection not initialized",
    4.43 @@ -333,9 +333,7 @@
    4.44              record->record_id = (guint) g_ascii_strtoull(row[0], NULL, 10);
    4.45              record->program_id =
    4.46                  (guint) g_ascii_strtoull(row[1], NULL, 10);
    4.47 -            record->channel_id =
    4.48 -                (guint) g_ascii_strtoull(row[2], NULL, 10);
    4.49 -
    4.50 +            record->channel_id = g_string_new (row[2]);
    4.51              record->start_time = gmyth_util_string_to_time_val(row[3]);
    4.52              record->end_time = gmyth_util_string_to_time_val(row[5]);
    4.53  
    4.54 @@ -345,6 +343,7 @@
    4.55              record->category = g_string_new(row[10]);
    4.56              record->filesize = g_ascii_strtoull(row[11], NULL, 10);
    4.57              record->basename = g_string_new(row[12]);
    4.58 +            record->seriesid = g_string_new(row[13]);
    4.59  
    4.60              (*recorded_list) = g_list_append((*recorded_list), record);
    4.61          }
    4.62 @@ -369,7 +368,7 @@
    4.63      g_string_printf(query_str,
    4.64                      "SELECT recordid,programid,chanid,starttime,progstart,"
    4.65                      "endtime,progend,title,subtitle,description,category,"
    4.66 -                    "filesize,basename FROM recorded "
    4.67 +                    "filesize,basename,seriesid FROM recorded "
    4.68                      "WHERE recgroup != 'LiveTV' AND basename = '%s'", basename);
    4.69  
    4.70      if (scheduler->msqlquery == NULL) {
    4.71 @@ -392,7 +391,7 @@
    4.72              record = g_new0(RecordedInfo, 1);
    4.73              record->record_id = (guint) g_ascii_strtoull(row[0], NULL, 10);
    4.74              record->program_id = (guint) g_ascii_strtoull(row[1], NULL, 10);
    4.75 -            record->channel_id = (guint) g_ascii_strtoull(row[2], NULL, 10);
    4.76 +            record->channel_id = g_string_new (row[2]);
    4.77              record->start_time = gmyth_util_string_to_time_val(row[3]);
    4.78              record->end_time = gmyth_util_string_to_time_val(row[5]);
    4.79              record->title = g_string_new(row[7]);
    4.80 @@ -401,6 +400,7 @@
    4.81              record->category = g_string_new(row[10]);
    4.82              record->filesize = g_ascii_strtoull(row[11], NULL, 10);
    4.83              record->basename = g_string_new(row[12]);
    4.84 +            record->seriesid = g_string_new(row[13]);
    4.85          }
    4.86      }
    4.87  
    4.88 @@ -434,6 +434,46 @@
    4.89      g_free(str_value);
    4.90  }
    4.91  
    4.92 +ScheduleInfo*
    4.93 +gmyth_scheduler_add_schedule_program (GMythScheduler * scheduler,
    4.94 +                                      GMythProgramInfo *program,
    4.95 +                                      GMythScheduleType type)
    4.96 +{
    4.97 +    ScheduleInfo *info;
    4.98 +
    4.99 +    info = g_new0 (ScheduleInfo, 1);
   4.100 +    info->program_id = g_string_new (program->programid->str);
   4.101 +    info->channel_id = g_string_new (program->chanid->str);
   4.102 +    info->start_time = g_new0 (GTimeVal, 1);
   4.103 +    *info->start_time = *program->startts;
   4.104 +    info->end_time = g_new0 (GTimeVal, 1);
   4.105 +    *info->end_time = *program->endts;
   4.106 +    info->seriesid = g_string_new (program->seriesid->str);
   4.107 +    info->title = g_string_new (program->title->str);
   4.108 +    info->subtitle = g_string_new (program->subtitle->str);
   4.109 +    info->description = g_string_new (program->description->str);
   4.110 +    info->category = g_string_new (program->category->str);
   4.111 +    info->type = type;
   4.112 +
   4.113 +    if (gmyth_scheduler_add_schedule_full (scheduler, info, type))
   4.114 +    {
   4.115 +        if (!program->recstartts)
   4.116 +            program->recstartts = g_new0 (GTimeVal, 1);
   4.117 +        *program->recstartts = *info->start_time;
   4.118 +
   4.119 +        if (!program->recendts)
   4.120 +            program->recendts = g_new0 (GTimeVal, 1);
   4.121 +        *program->recendts = *info->end_time;
   4.122 +
   4.123 +        program->recordid = info->schedule_id;
   4.124 +        return info;
   4.125 +    }
   4.126 +
   4.127 +    gmyth_schedule_info_free (info);
   4.128 +    return NULL;
   4.129 +}
   4.130 +
   4.131 +
   4.132  gboolean
   4.133  gmyth_scheduler_add_schedule_full (GMythScheduler * scheduler,
   4.134                               ScheduleInfo * schedule_info, GMythScheduleType type)
   4.135 @@ -459,8 +499,8 @@
   4.136      // Retrieves the station info
   4.137      query_str =
   4.138          g_strdup_printf
   4.139 -        ("SELECT callsign FROM channel WHERE chanid = \"%d\";",
   4.140 -         schedule_info->channel_id);
   4.141 +        ("SELECT callsign FROM channel WHERE chanid = \"%s\";",
   4.142 +         schedule_info->channel_id->str);
   4.143      msql_res =
   4.144          gmyth_query_process_statement(scheduler->msqlquery, query_str);
   4.145      if (msql_res == NULL) {
   4.146 @@ -477,8 +517,8 @@
   4.147      g_free(query_str);
   4.148  
   4.149      // _set_value (field, value, id);
   4.150 -    _set_int_value(scheduler->msqlquery, "chanid",
   4.151 -                   schedule_info->channel_id, rec_id);
   4.152 +    _set_value(scheduler->msqlquery, "chanid",
   4.153 +               schedule_info->channel_id->str, rec_id);
   4.154      _set_value(scheduler->msqlquery, "station", station, rec_id);
   4.155      _set_value(scheduler->msqlquery, "title", schedule_info->title->str,
   4.156                 rec_id);
   4.157 @@ -506,6 +546,8 @@
   4.158      // (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528),
   4.159      // rec_id);
   4.160  
   4.161 +    _set_value(scheduler->msqlquery, "seriesid",
   4.162 +               schedule_info->seriesid->str, rec_id);
   4.163      _set_value(scheduler->msqlquery, "parentid", "0", rec_id);
   4.164      _set_value(scheduler->msqlquery, "search", "0", rec_id);
   4.165  
   4.166 @@ -1128,6 +1170,9 @@
   4.167  void
   4.168  gmyth_recorded_info_free(RecordedInfo * info)
   4.169  {
   4.170 +    if (info->channel_id)
   4.171 +        g_string_free (info->channel_id, TRUE);
   4.172 +
   4.173      if (info->title != NULL)
   4.174          g_string_free(info->title, TRUE);
   4.175  
   4.176 @@ -1175,6 +1220,9 @@
   4.177  
   4.178      g_return_if_fail(info != NULL);
   4.179  
   4.180 +    if (info->channel_id)
   4.181 +        g_string_free (info->channel_id, TRUE);
   4.182 +
   4.183      if (info->title != NULL)
   4.184          g_string_free(info->title, TRUE);
   4.185  
     5.1 --- a/gmyth/src/gmyth_scheduler.h	Wed Nov 21 15:14:05 2007 +0000
     5.2 +++ b/gmyth/src/gmyth_scheduler.h	Fri Dec 21 14:07:54 2007 +0000
     5.3 @@ -99,12 +99,13 @@
     5.4  
     5.5  typedef struct {
     5.6      guint           schedule_id;
     5.7 -    guint           program_id;
     5.8 -    guint           channel_id;
     5.9 +    GString        *program_id;
    5.10 +    GString        *channel_id;
    5.11  
    5.12      GTimeVal       *start_time;
    5.13      GTimeVal       *end_time;
    5.14  
    5.15 +    GString        *seriesid;
    5.16      GString        *title;
    5.17      GString        *subtitle;
    5.18      GString        *description;
    5.19 @@ -119,11 +120,12 @@
    5.20  typedef struct {
    5.21      guint           record_id;
    5.22      guint           program_id;
    5.23 -    guint           channel_id;
    5.24 +    GString        *channel_id;
    5.25  
    5.26      GTimeVal       *start_time;
    5.27      GTimeVal       *end_time;
    5.28  
    5.29 +    GString         *seriesid;
    5.30      GString        *title;
    5.31      GString        *subtitle;
    5.32      GString        *description;
    5.33 @@ -162,6 +164,9 @@
    5.34  GMythProgramInfo*   gmyth_scheduler_get_recorded            (GMythScheduler * scheduler,
    5.35                                                               GString * channel,
    5.36                                                               GTimeVal * starttime);
    5.37 +ScheduleInfo*       gmyth_scheduler_add_schedule_program    (GMythScheduler * scheduler,
    5.38 +                                                             GMythProgramInfo *program,
    5.39 +                                                             GMythScheduleType type);
    5.40  gint                gmyth_scheduler_add_schedule            (GMythScheduler * scheduler,
    5.41                                                               ScheduleInfo * schedule_info);
    5.42  gboolean            gmyth_scheduler_add_schedule_full       (GMythScheduler * scheduler,
    5.43 @@ -170,7 +175,7 @@
    5.44  gboolean            gmyth_scheduler_add_exception           (GMythScheduler *scheduler,
    5.45                                                               gint schedule_id,
    5.46                                                               ScheduleInfo *exception_info);
    5.47 -gint                gmyth_scheduler_delete_schedule         (GMythScheduler * scheduler,
    5.48 +gboolean            gmyth_scheduler_delete_schedule         (GMythScheduler * scheduler,
    5.49                                                               gint record_id);
    5.50  gint                gmyth_scheduler_delete_recorded         (GMythScheduler * scheduler,
    5.51                                                               gint record_id);