# HG changeset patch # User morphbr # Date 1189612022 -3600 # Node ID 25fb81d23ef51532d348ef5d62a3274ce3cc180e # Parent 5ab6a453da43fc8713df1baf77f46fecc43ee7bf [svn r847] - Fixed several bugs - Included some help functions diff -r 5ab6a453da43 -r 25fb81d23ef5 gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Wed Sep 05 21:30:56 2007 +0100 +++ b/gmyth/src/gmyth_programinfo.h Wed Sep 12 16:47:02 2007 +0100 @@ -63,7 +63,6 @@ /** The channel unique ID. */ GString *chanid; - /** The program start time. */ GTimeVal *startts; /** The program end time. */ @@ -136,7 +135,11 @@ GString *recgroup; GString *playgroup; + gint rectype; + gint recstatus; gint recpriority; + gint dupin; + gint dupmethod; /** The file size of the recorded program.*/ gint64 filesize; diff -r 5ab6a453da43 -r 25fb81d23ef5 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Wed Sep 05 21:30:56 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.c Wed Sep 12 16:47:02 2007 +0100 @@ -510,7 +510,7 @@ _set_value(scheduler->msqlquery, "search", "0", rec_id); if (type == GMYTH_SCHEDULE_ALL_OCCURRENCES) { - _set_int_value(scheduler->msqlquery, "type", 4, rec_id); + _set_int_value(scheduler->msqlquery, "type", 3, rec_id); } else if (type == GMYTH_SCHEDULE_ONE_OCCURRENCE) { _set_int_value(scheduler->msqlquery, "type", 1, rec_id); } else if (type == GMYTH_SCHEDULE_EXCEPTION) { @@ -665,6 +665,206 @@ return update_backend(scheduler, record_id); } + +gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id, + time_t start_time) +{ + MYSQL_RES *msql_res; + GString *query_str = g_string_new(""); + + assert(scheduler); + g_string_printf(query_str, "SELECT callsign FROM channel " + "WHERE chanid = \"%d\"", channel_id); + + msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str); + + if (msql_res) { + MYSQL_ROW msql_row = mysql_fetch_row(msql_res); + if (msql_row) { + GString* callsign = g_string_new(msql_row[0]); + GString* startts = gmyth_util_time_to_string(start_time); + g_string_printf(query_str, "SELECT * FROM oldrecorded " + "WHERE station = \"%s\" AND starttime = \"%s\"", + callsign->str, startts->str); + msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str); + g_string_free(callsign, TRUE); + g_string_free(startts, TRUE); + g_string_free(query_str, TRUE); + if (mysql_fetch_row(msql_res)) return TRUE; + } + } + return FALSE; +} + + +gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id, + time_t start_time) + +{ + MYSQL_RES *msql_res; + GString *query_str = g_string_new(""); + + assert(scheduler); + g_string_printf(query_str, "SELECT callsign FROM channel " + "WHERE chanid = \"%d\"", channel_id); + + msql_res = gmyth_query_process_statement(scheduler->msqlquery, query_str->str); + if (msql_res) { + MYSQL_ROW msql_row = mysql_fetch_row(msql_res); + if (msql_row) { + GString* callsign = g_string_new(msql_row[0]); + GString* startts = gmyth_util_time_to_string(start_time); + g_string_printf(query_str, "UPDATE oldrecorded SET reactivate = 1 " + "WHERE station = \"%s\" AND starttime = \"%s\"", + callsign->str, startts->str); + gmyth_query_process_statement(scheduler->msqlquery, query_str->str); + g_string_free(callsign, TRUE); + g_string_free(startts, TRUE); + g_string_free(query_str, TRUE); + return TRUE; + } + + } + + return FALSE; +} + + +/* + * This should only be used in special situations. We do not know the time that + * the recording was set. We just know that it is an "ongoing" record and then + * we have to use this to get it's info. It's always the oldest one -> first on list + * + */ +GMythProgramInfo* +gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler, + GString* channel) +{ + MYSQL_RES *msql_res; + GMythProgramInfo *proginfo = NULL; + GString *query_str = g_string_new(""); + + assert(scheduler); + + g_string_printf(query_str, + "SELECT recorded.chanid,starttime,endtime,title," + "subtitle,description,channel.channum," + "channel.callsign,channel.name,channel.commfree," + "channel.outputfilters,seriesid,programid,filesize," + "lastmodified,stars,previouslyshown,originalairdate," + "hostname,recordid,transcoder,playgroup," + "recorded.recpriority,progstart,progend,basename,recgroup," + "category,findid,duplicate " + "FROM recorded " "LEFT JOIN channel " + "ON recorded.chanid = channel.chanid " + "WHERE recorded.chanid = \"%s\" " + "ORDER BY starttime DESC", channel->str); + + msql_res = + gmyth_query_process_statement(scheduler->msqlquery, query_str->str); + + if (msql_res) { + MYSQL_ROW msql_row = mysql_fetch_row(msql_res); + + if (msql_row) { + proginfo = gmyth_program_info_new(); + + proginfo->chanid = g_string_new(msql_row[0]); + proginfo->recstartts = gmyth_util_string_to_time_val(msql_row[1]); + proginfo->recendts = gmyth_util_string_to_time_val(msql_row[2]); + + proginfo->title = g_string_new(msql_row[3]); + proginfo->subtitle = g_string_new(msql_row[4]); + proginfo->description = g_string_new(msql_row[5]); + + proginfo->chanstr = g_string_new(msql_row[6]); + proginfo->chansign = g_string_new(msql_row[7]); + proginfo->channame = g_string_new(msql_row[8]); + proginfo->chancommfree = (gint) g_ascii_strtoull(msql_row[9], NULL, 10); + proginfo->chanOutputFilters = g_string_new(msql_row[10]); + proginfo->seriesid = g_string_new(msql_row[11]); + proginfo->programid = g_string_new(msql_row[12]); + proginfo->filesize = g_ascii_strtoull(msql_row[13], NULL, 10); + + proginfo->lastmodified = gmyth_util_string_to_time_val(msql_row[14]); + proginfo->stars = g_ascii_strtod(msql_row[15], NULL); + proginfo->repeat = (gint)g_ascii_strtoull(msql_row[16], NULL, 10); + + if (msql_row[17] == NULL) { + proginfo->originalAirDate = 0; + proginfo->hasAirDate = FALSE; + } else { + proginfo->originalAirDate = gmyth_util_string_to_time_val(msql_row[17]); + proginfo->hasAirDate = TRUE; + } + + proginfo->hostname = g_string_new(msql_row[18]); + proginfo->recordid = (gint) g_ascii_strtoull(msql_row[19], NULL, 10); + proginfo->transcoder = (gint) g_ascii_strtoull(msql_row[20], NULL, 10); + + proginfo->playgroup = g_string_new(msql_row[21]); + proginfo->recpriority = (gint) g_ascii_strtoull(msql_row[22], NULL, 10); + + proginfo->startts = gmyth_util_string_to_time_val(msql_row[23]); + proginfo->endts = gmyth_util_string_to_time_val(msql_row[24]); + proginfo->pathname = g_string_new(g_strdup(msql_row[25])); + proginfo->recgroup = g_string_new(msql_row[26]); + proginfo->category = g_string_new(msql_row[27]); + proginfo->findid = (gint) g_ascii_strtoull(msql_row[28], NULL, 10); + + proginfo->recpriority2 = 0; + + g_string_printf(query_str, + "SELECT dupmethod,dupin,parentid,type " + "FROM record WHERE recordid = \"%d\"", proginfo->recordid); + + msql_res = + gmyth_query_process_statement(scheduler->msqlquery, + query_str->str); + + if (msql_res) { + MYSQL_ROW msql_row = mysql_fetch_row(msql_res); + + if (msql_row) { + proginfo->dupmethod = (gint) g_ascii_strtoull(msql_row[0], NULL, 10); + proginfo->dupin = (gint) g_ascii_strtoull(msql_row[1], NULL, 10); + proginfo->parentid = (gint) g_ascii_strtoull(msql_row[2], NULL, 10); + proginfo->rectype = 0; + } + } + + + g_string_printf(query_str, + "SELECT sourceid,cardid,cardinputid,shareable " + "FROM cardinput"); + + msql_res = + gmyth_query_process_statement(scheduler->msqlquery, + query_str->str); + + if (msql_res) { + MYSQL_ROW msql_row = mysql_fetch_row(msql_res); + + if (msql_row) { + proginfo->sourceid = 0; + proginfo->cardid = 0; + proginfo->inputid = 0; + if (msql_row[3] != NULL && g_ascii_strcasecmp("Y", msql_row[3]) == 0) + proginfo->shareable = 1; + else + proginfo->shareable = 0; + } + } + + + + } + } + + g_string_free(query_str, TRUE); + return proginfo; +} + /** Retrieves an existing recorded item information from database. The information * is used to fill the returned GMythProgramInfo. * diff -r 5ab6a453da43 -r 25fb81d23ef5 gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Wed Sep 05 21:30:56 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.h Wed Sep 12 16:47:02 2007 +0100 @@ -151,6 +151,15 @@ GList ** rec_list); RecordedInfo* gmyth_scheduler_get_recorded_info (GMythScheduler *scheduler, const char *basename); + +gboolean gmyth_scheduler_was_recorded_before(GMythScheduler* scheduler, gint channel_id, + time_t start_time); + +gboolean gmyth_scheduler_reactivate_schedule(GMythScheduler* scheduler, gint channel_id, + time_t start_time); +GMythProgramInfo* +gmyth_scheduler_get_recorded_on_time(GMythScheduler* scheduler, + GString* channel); GMythProgramInfo *gmyth_scheduler_get_recorded (GMythScheduler * scheduler, GString * channel, GTimeVal * starttime); diff -r 5ab6a453da43 -r 25fb81d23ef5 gmyth/src/gmyth_stringlist.c --- a/gmyth/src/gmyth_stringlist.c Wed Sep 05 21:30:56 2007 +0100 +++ b/gmyth/src/gmyth_stringlist.c Wed Sep 12 16:47:02 2007 +0100 @@ -109,6 +109,24 @@ return value_str; } + +/** Appends a gdouble to the string list. + * + * @param strlist The GMythStringList instance. + * @param value The gdouble to be appended. + * + * @return The appended gdouble converted to a GString object. + */ +GString * +gmyth_string_list_append_float(GMythStringList * strlist, const gdouble value) +{ + GString *value_str = g_string_new(""); + g_string_printf(value_str, "%f", value); + strlist->glist = g_list_append(strlist->glist, value_str); + return value_str; +} + + /** Appends a guint64 to the string list. * * @param strlist The GMythStringList instance. diff -r 5ab6a453da43 -r 25fb81d23ef5 gmyth/src/gmyth_stringlist.h --- a/gmyth/src/gmyth_stringlist.h Wed Sep 05 21:30:56 2007 +0100 +++ b/gmyth/src/gmyth_stringlist.h Wed Sep 12 16:47:02 2007 +0100 @@ -75,6 +75,9 @@ void gmyth_string_list_clear_all(GMythStringList * strlist); int gmyth_string_list_length(GMythStringList * strlist); +GString *gmyth_string_list_append_float(GMythStringList * strlist, + const gdouble value); + GString *gmyth_string_list_append_int(GMythStringList * strlist, const gint value); GString *gmyth_string_list_append_uint64(GMythStringList * strlist,