# HG changeset patch # User leo_sobral # Date 1173189976 0 # Node ID 0298ee6b74498e4f1b87dfe038a064757fbf20a2 # Parent dbf952e956b528655c35e64d4a451b7fe4fedc4a [svn r395] reverted invocation to strtoll and indented code, removing tabs diff -r dbf952e956b5 -r 0298ee6b7449 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Tue Mar 06 00:55:35 2007 +0000 +++ b/gmyth/src/gmyth_scheduler.c Tue Mar 06 14:06:16 2007 +0000 @@ -107,12 +107,12 @@ if (scheduler->backend_info) { g_object_unref (scheduler->backend_info); - scheduler->backend_info = NULL; + scheduler->backend_info = NULL; } if (scheduler->msqlquery) { g_object_unref (scheduler->msqlquery); - scheduler->msqlquery = NULL; + scheduler->msqlquery = NULL; } if (scheduler->profile != NULL) @@ -183,7 +183,7 @@ if (!gmyth_query_connect_with_timeout (scheduler->msqlquery, scheduler->backend_info, timeout)) { - g_warning ("[%s] Error while connecting to db", __FUNCTION__); + g_warning ("[%s] Error while connecting to db", __FUNCTION__); return FALSE; } @@ -229,8 +229,8 @@ "endtime,enddate,title,subtitle,description,category FROM record;"); if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return -1; + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return -1; } msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str); @@ -242,10 +242,10 @@ *schedule_list = NULL; while((row = mysql_fetch_row (msql_res)) != NULL) { - schedule = g_new0(ScheduleInfo, 1); + schedule = g_new0(ScheduleInfo, 1); - schedule->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10); - schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10); + schedule->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10); + schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10); schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10); /* generate a time_t from a time and a date db field */ @@ -263,7 +263,7 @@ schedule->description = g_string_new (row[9]); schedule->category = g_string_new (row[10]); - (*schedule_list) = g_list_append (*(schedule_list), schedule); + (*schedule_list) = g_list_append (*(schedule_list), schedule); } } @@ -309,7 +309,7 @@ (*recorded_list) = NULL; while((row = mysql_fetch_row (msql_res))!=NULL){ - record = g_new0(RecordedInfo, 1); + record = g_new0(RecordedInfo, 1); record->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10); record->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10); @@ -356,38 +356,38 @@ assert(scheduler); if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return FALSE; + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return FALSE; } //TODO: verify if this funtion realy does what it should do! g_string_printf (query_str, "REPLACE INTO record " - "(recordid, type, chanid, starttime, " - "startdate, endtime, enddate, title," - "profile, recpriority, maxnewest, inactive, " - "maxepisodes, autoexpire, startoffset, endoffset, " - "recgroup, dupmethod, dupin, station, " - "autocommflag, findday, findtime, findid, " - "search, autotranscode, transcoder, tsdefault, " - "autouserjob1, autouserjob2, autouserjob3, autouserjob4) " - " values ( %d, 1, %d, \"%s\"," //recordid, type, chanid, starttime - " \"%s\", \"%s\", \"%s\", \"%s\"," //startdate, endtime, enddate, title - "DEFAULT, 0, 0, 0, " //profile, recpriority, maxnewest, inactive - "0, 1, 0, 0, " //maxepisodes, autoexpire, startoffset, endoffset - "DEFAULT, 6, 15, %d, " //recgroup, dupmethod, dupin, station - "1, %d, \"%s\", %d, " //autocommflag, findday, findtime, findid - "5, 0, 29, 1, " //search, autotranscode, transcoder, tsdefault - "0, 0, 0, 0 );", //autouserjob1, autouserjob2, autouserjob3, autouserjob4 - schedule_info->record_id, schedule_info->channel_id, + "(recordid, type, chanid, starttime, " + "startdate, endtime, enddate, title," + "profile, recpriority, maxnewest, inactive, " + "maxepisodes, autoexpire, startoffset, endoffset, " + "recgroup, dupmethod, dupin, station, " + "autocommflag, findday, findtime, findid, " + "search, autotranscode, transcoder, tsdefault, " + "autouserjob1, autouserjob2, autouserjob3, autouserjob4) " + " values ( %d, 1, %d, \"%s\"," //recordid, type, chanid, starttime + " \"%s\", \"%s\", \"%s\", \"%s\"," //startdate, endtime, enddate, title + "DEFAULT, 0, 0, 0, " //profile, recpriority, maxnewest, inactive + "0, 1, 0, 0, " //maxepisodes, autoexpire, startoffset, endoffset + "DEFAULT, 6, 15, %d, " //recgroup, dupmethod, dupin, station + "1, %d, \"%s\", %d, " //autocommflag, findday, findtime, findid + "5, 0, 29, 1, " //search, autotranscode, transcoder, tsdefault + "0, 0, 0, 0 );", //autouserjob1, autouserjob2, autouserjob3, autouserjob4 + schedule_info->record_id, schedule_info->channel_id, gmyth_util_time_to_string_only_time( schedule_info->start_time ), gmyth_util_time_to_string_only_date( schedule_info->start_time ), - gmyth_util_time_to_string_only_date( schedule_info->start_time ), + gmyth_util_time_to_string_only_date( schedule_info->start_time ), gmyth_util_time_to_string_only_date( schedule_info->end_time ), schedule_info->title->str, //title - schedule_info->channel_id,//station - (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, //findday - gmyth_util_time_to_string_only_time( schedule_info->start_time ), //findtime - (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528)//findid + schedule_info->channel_id,//station + (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, //findday + gmyth_util_time_to_string_only_time( schedule_info->start_time ), //findtime + (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528)//findid ); gmyth_debug ( "Sending query to MySQL = %s.", query_str->str ); @@ -402,7 +402,7 @@ /* TODO: verify record_id = -1 semantics */ if (schedule_info->record_id <= 0) - schedule_info->record_id = get_record_id_from_database(scheduler); + schedule_info->record_id = get_record_id_from_database(scheduler); /* Notify the backend of changes */ update_backend(scheduler, schedule_info->record_id); @@ -469,10 +469,10 @@ assert(scheduler); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return FALSE; - } + if (scheduler->msqlquery == NULL) { + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return FALSE; + } //======================================== g_string_printf (query_str, @@ -501,19 +501,19 @@ gmyth_scheduler_get_recorded (GMythScheduler *scheduler, GString *channel, GTimeVal* starttime) { - MYSQL_RES *msql_res; - GMythProgramInfo *proginfo = NULL; - GString *query_str = g_string_new(""); - gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime); + MYSQL_RES *msql_res; + GMythProgramInfo *proginfo = NULL; + GString *query_str = g_string_new(""); + gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime); assert(scheduler); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return NULL; - } + if (scheduler->msqlquery == NULL) { + g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); + return NULL; + } - g_string_printf (query_str, "SELECT recorded.chanid,starttime,endtime,title, " + 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, " @@ -531,57 +531,57 @@ if (msql_res /*&& query.size() > 0*/) { - MYSQL_ROW msql_row = mysql_fetch_row (msql_res); - if (msql_row) { + 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->startts = gmyth_util_string_to_time_val (msql_row[23]); - proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]); - 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 = gmyth_program_info_new(); + + proginfo->chanid = g_string_new (msql_row[0]); + proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]); + proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]); + 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[0]); + 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->chanstr = g_string_new (msql_row[6]); - proginfo->chansign = g_string_new (msql_row[7]); - proginfo->channame = g_string_new (msql_row[0]); - proginfo->chancommfree = (gint) g_ascii_strtoll (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_strtoll (msql_row[13], NULL, 10); - - proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]); + 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_strtoll (msql_row[16], NULL, 10); + 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; - } + 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_strtoll (msql_row[19], NULL, 10); - proginfo->transcoder = (gint) g_ascii_strtoll (msql_row[20], NULL, 10); - - //proginfo->spread = -1; - //proginfo->programflags = proginfo->getProgramFlags(); - - proginfo->recgroup = g_string_new (msql_row[26]); - proginfo->playgroup = g_string_new (msql_row[21]); - proginfo->recpriority = (gint) g_ascii_strtoll (msql_row[22], NULL, 10); - - proginfo->pathname = g_string_new (msql_row[25]); + 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); - gmyth_debug ("One program info loaded from mysql database\n"); - } + //proginfo->spread = -1; + ////proginfo->programflags = proginfo->getProgramFlags(); + + proginfo->recgroup = g_string_new (msql_row[26]); + proginfo->playgroup = g_string_new (msql_row[21]); + proginfo->recpriority = (gint) g_ascii_strtoull (msql_row[22], NULL, 10); + + proginfo->pathname = g_string_new (msql_row[25]); + + gmyth_debug ("One program info loaded from mysql database\n"); + } } mysql_free_result (msql_res); @@ -603,14 +603,14 @@ assert(scheduler); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__); - return 0; - } + 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; + return record_id; } /** Notifies the backend of an update in the db. diff -r dbf952e956b5 -r 0298ee6b7449 gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Tue Mar 06 00:55:35 2007 +0000 +++ b/gmyth/src/gmyth_scheduler.h Tue Mar 06 14:06:16 2007 +0000 @@ -51,17 +51,17 @@ struct _GMythSchedulerClass { - GObjectClass parent_class; + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ + /* callbacks */ + /* no one for now */ }; struct _GMythScheduler { GObject parent; - unsigned long recordid; + unsigned long recordid; unsigned long type; unsigned long search; GString *profile;