[svn r847] - Fixed several bugs trunk
authormorphbr
Wed Sep 12 16:47:02 2007 +0100 (2007-09-12)
branchtrunk
changeset 84125fb81d23ef5
parent 840 5ab6a453da43
child 842 033a4a843332
[svn r847] - Fixed several bugs
- Included some help functions
gmyth/src/gmyth_programinfo.h
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
gmyth/src/gmyth_stringlist.c
gmyth/src/gmyth_stringlist.h
     1.1 --- a/gmyth/src/gmyth_programinfo.h	Wed Sep 05 21:30:56 2007 +0100
     1.2 +++ b/gmyth/src/gmyth_programinfo.h	Wed Sep 12 16:47:02 2007 +0100
     1.3 @@ -63,7 +63,6 @@
     1.4  
     1.5      /** The channel unique ID. */
     1.6      GString        *chanid;
     1.7 -
     1.8      /** The program start time. */
     1.9      GTimeVal       *startts;
    1.10      /** The program end time. */
    1.11 @@ -136,7 +135,11 @@
    1.12  
    1.13      GString        *recgroup;
    1.14      GString        *playgroup;
    1.15 +    gint            rectype;
    1.16 +    gint            recstatus;
    1.17      gint            recpriority;
    1.18 +    gint            dupin;
    1.19 +    gint            dupmethod;
    1.20  
    1.21      /** The file size of the recorded program.*/
    1.22      gint64          filesize;
     2.1 --- a/gmyth/src/gmyth_scheduler.c	Wed Sep 05 21:30:56 2007 +0100
     2.2 +++ b/gmyth/src/gmyth_scheduler.c	Wed Sep 12 16:47:02 2007 +0100
     2.3 @@ -510,7 +510,7 @@
     2.4      _set_value(scheduler->msqlquery, "search", "0", rec_id);
     2.5  
     2.6      if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) {
     2.7 -        _set_int_value(scheduler->msqlquery, "type", 4, rec_id);
     2.8 +        _set_int_value(scheduler->msqlquery, "type", 3, rec_id);
     2.9      } else if (type == GMYTH_SCHEDULE_ONE_OCCURRENCE) {
    2.10          _set_int_value(scheduler->msqlquery, "type", 1, rec_id);
    2.11      } else if (type == GMYTH_SCHEDULE_EXCEPTION) {
    2.12 @@ -665,6 +665,206 @@
    2.13      return update_backend(scheduler, record_id);
    2.14  }
    2.15  
    2.16 +
    2.17 +gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id,
    2.18 +                                             time_t start_time)
    2.19 +{
    2.20 +    MYSQL_RES      *msql_res;
    2.21 +    GString        *query_str = g_string_new("");
    2.22 +
    2.23 +    assert(scheduler);
    2.24 +    g_string_printf(query_str, "SELECT callsign FROM channel "
    2.25 +                    "WHERE chanid = \"%d\"", channel_id);
    2.26 +
    2.27 +    msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
    2.28 +
    2.29 +    if (msql_res) {
    2.30 +        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
    2.31 +        if (msql_row) {
    2.32 +            GString* callsign = g_string_new(msql_row[0]);
    2.33 +            GString* startts = gmyth_util_time_to_string(start_time);
    2.34 +            g_string_printf(query_str, "SELECT * FROM oldrecorded "
    2.35 +                            "WHERE station = \"%s\" AND starttime = \"%s\"",
    2.36 +                            callsign->str, startts->str);
    2.37 +            msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
    2.38 +            g_string_free(callsign, TRUE);
    2.39 +            g_string_free(startts, TRUE);
    2.40 +            g_string_free(query_str, TRUE);
    2.41 +            if (mysql_fetch_row(msql_res)) return TRUE;
    2.42 +        }
    2.43 +    }
    2.44 +    return FALSE;
    2.45 +}
    2.46 +
    2.47 +
    2.48 +gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id,
    2.49 +                                             time_t start_time)
    2.50 +
    2.51 +{
    2.52 +    MYSQL_RES      *msql_res;
    2.53 +    GString        *query_str = g_string_new("");
    2.54 +
    2.55 +    assert(scheduler);
    2.56 +    g_string_printf(query_str, "SELECT callsign FROM channel "
    2.57 +                    "WHERE chanid = \"%d\"", channel_id);
    2.58 +
    2.59 +    msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
    2.60 +    if (msql_res) {
    2.61 +        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
    2.62 +        if (msql_row) {
    2.63 +            GString* callsign = g_string_new(msql_row[0]);
    2.64 +            GString* startts = gmyth_util_time_to_string(start_time);
    2.65 +            g_string_printf(query_str, "UPDATE oldrecorded SET reactivate = 1 "
    2.66 +                            "WHERE station = \"%s\" AND starttime = \"%s\"",
    2.67 +                            callsign->str, startts->str);
    2.68 +            gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
    2.69 +            g_string_free(callsign, TRUE);
    2.70 +            g_string_free(startts, TRUE);
    2.71 +            g_string_free(query_str, TRUE);
    2.72 +            return TRUE;
    2.73 +        }
    2.74 +
    2.75 +    }
    2.76 +
    2.77 +    return FALSE;
    2.78 +}
    2.79 +
    2.80 +
    2.81 +/*
    2.82 + * This should only be used in special situations. We do not know the time that
    2.83 + * the recording was set. We just know that it is an "ongoing" record and then
    2.84 + * we have to use this to get it's info. It's always the oldest one -> first on list
    2.85 + *
    2.86 + */
    2.87 +GMythProgramInfo*
    2.88 +gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
    2.89 +                                     GString* channel)
    2.90 +{
    2.91 +    MYSQL_RES      *msql_res;
    2.92 +    GMythProgramInfo *proginfo = NULL;
    2.93 +    GString        *query_str = g_string_new("");
    2.94 +
    2.95 +    assert(scheduler);
    2.96 +
    2.97 +    g_string_printf(query_str,
    2.98 +                    "SELECT recorded.chanid,starttime,endtime,title,"
    2.99 +                    "subtitle,description,channel.channum,"
   2.100 +                    "channel.callsign,channel.name,channel.commfree,"
   2.101 +                    "channel.outputfilters,seriesid,programid,filesize,"
   2.102 +                    "lastmodified,stars,previouslyshown,originalairdate,"
   2.103 +                    "hostname,recordid,transcoder,playgroup,"
   2.104 +                    "recorded.recpriority,progstart,progend,basename,recgroup,"
   2.105 +                    "category,findid,duplicate "
   2.106 +                    "FROM recorded " "LEFT JOIN channel "
   2.107 +                    "ON recorded.chanid = channel.chanid "
   2.108 +                    "WHERE recorded.chanid = \"%s\" "
   2.109 +                    "ORDER BY starttime DESC", channel->str);
   2.110 +
   2.111 +    msql_res =
   2.112 +        gmyth_query_process_statement(scheduler->msqlquery, query_str->str);
   2.113 +
   2.114 +    if (msql_res) {
   2.115 +        MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
   2.116 +
   2.117 +        if (msql_row) {
   2.118 +            proginfo = gmyth_program_info_new();
   2.119 +
   2.120 +            proginfo->chanid = g_string_new(msql_row[0]);
   2.121 +            proginfo->recstartts = gmyth_util_string_to_time_val(msql_row[1]);
   2.122 +            proginfo->recendts = gmyth_util_string_to_time_val(msql_row[2]);
   2.123 +
   2.124 +            proginfo->title = g_string_new(msql_row[3]);
   2.125 +            proginfo->subtitle = g_string_new(msql_row[4]);
   2.126 +            proginfo->description = g_string_new(msql_row[5]);
   2.127 +
   2.128 +            proginfo->chanstr = g_string_new(msql_row[6]);
   2.129 +            proginfo->chansign = g_string_new(msql_row[7]);
   2.130 +            proginfo->channame = g_string_new(msql_row[8]);
   2.131 +            proginfo->chancommfree = (gint) g_ascii_strtoull(msql_row[9], NULL, 10);
   2.132 +            proginfo->chanOutputFilters = g_string_new(msql_row[10]);
   2.133 +            proginfo->seriesid = g_string_new(msql_row[11]);
   2.134 +            proginfo->programid = g_string_new(msql_row[12]);
   2.135 +            proginfo->filesize = g_ascii_strtoull(msql_row[13], NULL, 10);
   2.136 +
   2.137 +            proginfo->lastmodified = gmyth_util_string_to_time_val(msql_row[14]);
   2.138 +            proginfo->stars = g_ascii_strtod(msql_row[15], NULL);
   2.139 +            proginfo->repeat = (gint)g_ascii_strtoull(msql_row[16], NULL, 10);
   2.140 +
   2.141 +            if (msql_row[17] == NULL) {
   2.142 +                proginfo->originalAirDate = 0;
   2.143 +                proginfo->hasAirDate = FALSE;
   2.144 +            } else {
   2.145 +                proginfo->originalAirDate = gmyth_util_string_to_time_val(msql_row[17]);
   2.146 +                proginfo->hasAirDate = TRUE;
   2.147 +            }
   2.148 +
   2.149 +            proginfo->hostname = g_string_new(msql_row[18]);
   2.150 +            proginfo->recordid = (gint) g_ascii_strtoull(msql_row[19], NULL, 10);
   2.151 +            proginfo->transcoder = (gint) g_ascii_strtoull(msql_row[20], NULL, 10);
   2.152 +
   2.153 +            proginfo->playgroup = g_string_new(msql_row[21]);
   2.154 +            proginfo->recpriority = (gint) g_ascii_strtoull(msql_row[22], NULL, 10);
   2.155 +
   2.156 +            proginfo->startts = gmyth_util_string_to_time_val(msql_row[23]);
   2.157 +            proginfo->endts = gmyth_util_string_to_time_val(msql_row[24]);
   2.158 +            proginfo->pathname = g_string_new(g_strdup(msql_row[25]));
   2.159 +            proginfo->recgroup = g_string_new(msql_row[26]);
   2.160 +            proginfo->category = g_string_new(msql_row[27]);
   2.161 +            proginfo->findid = (gint) g_ascii_strtoull(msql_row[28], NULL, 10);
   2.162 +
   2.163 +            proginfo->recpriority2 = 0;
   2.164 +
   2.165 +            g_string_printf(query_str,
   2.166 +                            "SELECT dupmethod,dupin,parentid,type "
   2.167 +                            "FROM record WHERE recordid = \"%d\"", proginfo->recordid);
   2.168 +
   2.169 +            msql_res =
   2.170 +                gmyth_query_process_statement(scheduler->msqlquery,
   2.171 +                                              query_str->str);
   2.172 +
   2.173 +            if (msql_res) {
   2.174 +                MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
   2.175 +
   2.176 +                if (msql_row) {
   2.177 +                    proginfo->dupmethod = (gint) g_ascii_strtoull(msql_row[0], NULL, 10);
   2.178 +                    proginfo->dupin = (gint) g_ascii_strtoull(msql_row[1], NULL, 10);
   2.179 +                    proginfo->parentid = (gint) g_ascii_strtoull(msql_row[2], NULL, 10);
   2.180 +                    proginfo->rectype = 0;
   2.181 +                }
   2.182 +            }
   2.183 +
   2.184 +
   2.185 +            g_string_printf(query_str,
   2.186 +                            "SELECT sourceid,cardid,cardinputid,shareable "
   2.187 +                            "FROM cardinput");
   2.188 +
   2.189 +            msql_res =
   2.190 +                gmyth_query_process_statement(scheduler->msqlquery,
   2.191 +                                              query_str->str);
   2.192 +
   2.193 +            if (msql_res) {
   2.194 +                MYSQL_ROW msql_row = mysql_fetch_row(msql_res);
   2.195 +
   2.196 +                if (msql_row) {
   2.197 +                    proginfo->sourceid = 0;
   2.198 +                    proginfo->cardid = 0;
   2.199 +                    proginfo->inputid = 0;
   2.200 +                    if (msql_row[3] != NULL && g_ascii_strcasecmp("Y", msql_row[3]) == 0)
   2.201 +                        proginfo->shareable = 1;
   2.202 +                    else
   2.203 +                        proginfo->shareable = 0;
   2.204 +                }
   2.205 +            }
   2.206 +
   2.207 +
   2.208 +
   2.209 +        }
   2.210 +    }
   2.211 +
   2.212 +    g_string_free(query_str, TRUE);
   2.213 +    return proginfo;
   2.214 +}
   2.215 +
   2.216  /** Retrieves an existing recorded item information from database. The information
   2.217   * is used to fill the returned GMythProgramInfo.
   2.218   * 
     3.1 --- a/gmyth/src/gmyth_scheduler.h	Wed Sep 05 21:30:56 2007 +0100
     3.2 +++ b/gmyth/src/gmyth_scheduler.h	Wed Sep 12 16:47:02 2007 +0100
     3.3 @@ -151,6 +151,15 @@
     3.4                                                       GList ** rec_list);
     3.5  RecordedInfo*   gmyth_scheduler_get_recorded_info   (GMythScheduler *scheduler,
     3.6                                                       const char *basename);
     3.7 +
     3.8 +gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id,
     3.9 +                                             time_t start_time);
    3.10 +
    3.11 +gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id,
    3.12 +                                             time_t start_time);
    3.13 +GMythProgramInfo*
    3.14 +gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler,
    3.15 +                                     GString* channel);
    3.16  GMythProgramInfo *gmyth_scheduler_get_recorded      (GMythScheduler * scheduler,
    3.17                                                       GString * channel,
    3.18                                                       GTimeVal * starttime);
     4.1 --- a/gmyth/src/gmyth_stringlist.c	Wed Sep 05 21:30:56 2007 +0100
     4.2 +++ b/gmyth/src/gmyth_stringlist.c	Wed Sep 12 16:47:02 2007 +0100
     4.3 @@ -109,6 +109,24 @@
     4.4      return value_str;
     4.5  }
     4.6  
     4.7 +
     4.8 +/** Appends a gdouble to the string list.
     4.9 + *
    4.10 + * @param strlist The GMythStringList instance.
    4.11 + * @param value The gdouble to be appended.
    4.12 + *
    4.13 + * @return The appended gdouble converted to a GString object.
    4.14 + */
    4.15 +GString        *
    4.16 +gmyth_string_list_append_float(GMythStringList * strlist, const gdouble value)
    4.17 +{
    4.18 +    GString        *value_str = g_string_new("");
    4.19 +    g_string_printf(value_str, "%f", value);
    4.20 +    strlist->glist = g_list_append(strlist->glist, value_str);
    4.21 +    return value_str;
    4.22 +}
    4.23 +
    4.24 +
    4.25  /** Appends a guint64 to the string list.
    4.26   * 
    4.27   * @param strlist The GMythStringList instance.
     5.1 --- a/gmyth/src/gmyth_stringlist.h	Wed Sep 05 21:30:56 2007 +0100
     5.2 +++ b/gmyth/src/gmyth_stringlist.h	Wed Sep 12 16:47:02 2007 +0100
     5.3 @@ -75,6 +75,9 @@
     5.4  void            gmyth_string_list_clear_all(GMythStringList * strlist);
     5.5  int             gmyth_string_list_length(GMythStringList * strlist);
     5.6  
     5.7 +GString        *gmyth_string_list_append_float(GMythStringList * strlist,
     5.8 +                                             const gdouble value);
     5.9 +
    5.10  GString        *gmyth_string_list_append_int(GMythStringList * strlist,
    5.11                                               const gint value);
    5.12  GString        *gmyth_string_list_append_uint64(GMythStringList * strlist,