[svn r395] reverted invocation to strtoll and indented code, removing tabs trunk
authorleo_sobral
Tue Mar 06 14:06:16 2007 +0000 (2007-03-06)
branchtrunk
changeset 3900298ee6b7449
parent 389 dbf952e956b5
child 391 ab427801f058
[svn r395] reverted invocation to strtoll and indented code, removing tabs
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
     1.1 --- a/gmyth/src/gmyth_scheduler.c	Tue Mar 06 00:55:35 2007 +0000
     1.2 +++ b/gmyth/src/gmyth_scheduler.c	Tue Mar 06 14:06:16 2007 +0000
     1.3 @@ -107,12 +107,12 @@
     1.4  
     1.5      if (scheduler->backend_info) { 
     1.6  	    g_object_unref (scheduler->backend_info);
     1.7 -    	scheduler->backend_info = NULL;
     1.8 +        scheduler->backend_info = NULL;
     1.9      }
    1.10  
    1.11      if (scheduler->msqlquery) { 
    1.12  	    g_object_unref (scheduler->msqlquery);
    1.13 -    	scheduler->msqlquery = NULL;
    1.14 +        scheduler->msqlquery = NULL;
    1.15      }
    1.16  
    1.17      if (scheduler->profile != NULL)
    1.18 @@ -183,7 +183,7 @@
    1.19  
    1.20      if (!gmyth_query_connect_with_timeout (scheduler->msqlquery, 
    1.21  			    scheduler->backend_info, timeout)) {
    1.22 -    	g_warning ("[%s] Error while connecting to db", __FUNCTION__);
    1.23 +        g_warning ("[%s] Error while connecting to db", __FUNCTION__);
    1.24          return FALSE;
    1.25      }
    1.26  
    1.27 @@ -229,8 +229,8 @@
    1.28      	"endtime,enddate,title,subtitle,description,category FROM record;");
    1.29  
    1.30      if (scheduler->msqlquery == NULL) {
    1.31 -	g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
    1.32 -	return -1;
    1.33 +        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
    1.34 +        return -1;
    1.35      }
    1.36      msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
    1.37  
    1.38 @@ -242,10 +242,10 @@
    1.39          *schedule_list = NULL;
    1.40          
    1.41          while((row = mysql_fetch_row (msql_res)) != NULL) {
    1.42 -        	schedule = g_new0(ScheduleInfo, 1);
    1.43 +            schedule = g_new0(ScheduleInfo, 1);
    1.44          	
    1.45 -        	schedule->record_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
    1.46 -        	schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
    1.47 +            schedule->record_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
    1.48 +            schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
    1.49              schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
    1.50              
    1.51              /* generate a time_t from a time and a date db field */
    1.52 @@ -263,7 +263,7 @@
    1.53              schedule->description = g_string_new (row[9]);
    1.54              schedule->category    = g_string_new (row[10]);
    1.55  
    1.56 -           (*schedule_list) = g_list_append (*(schedule_list), schedule);
    1.57 +            (*schedule_list) = g_list_append (*(schedule_list), schedule);
    1.58      	}
    1.59      }
    1.60  
    1.61 @@ -309,7 +309,7 @@
    1.62          (*recorded_list) = NULL;
    1.63          
    1.64          while((row = mysql_fetch_row (msql_res))!=NULL){
    1.65 -       	    record = g_new0(RecordedInfo, 1);
    1.66 +            record = g_new0(RecordedInfo, 1);
    1.67              
    1.68              record->record_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
    1.69              record->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
    1.70 @@ -356,38 +356,38 @@
    1.71      assert(scheduler);
    1.72      
    1.73      if (scheduler->msqlquery == NULL) {
    1.74 -	g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
    1.75 -	return FALSE;
    1.76 +        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
    1.77 +        return FALSE;
    1.78      }
    1.79  	
    1.80      //TODO: verify if this funtion realy does what it should do!
    1.81      g_string_printf (query_str, "REPLACE INTO record "
    1.82 -	    "(recordid, type, chanid, starttime, "
    1.83 -	    "startdate, endtime, enddate, title,"
    1.84 -	    "profile, recpriority, maxnewest, inactive, "
    1.85 -	    "maxepisodes, autoexpire, startoffset, endoffset, "
    1.86 -	    "recgroup, dupmethod, dupin, station, "
    1.87 -	    "autocommflag, findday, findtime, findid, "
    1.88 -	    "search, autotranscode, transcoder, tsdefault, "
    1.89 -	    "autouserjob1, autouserjob2, autouserjob3, autouserjob4) "
    1.90 -	    " values ( %d, 1, %d, \"%s\","	//recordid, type, chanid, starttime
    1.91 -	    " \"%s\", \"%s\", \"%s\", \"%s\"," //startdate, endtime, enddate, title
    1.92 -	    "DEFAULT, 0, 0, 0, "	//profile, recpriority, maxnewest, inactive
    1.93 -	    "0, 1, 0, 0, "			//maxepisodes, autoexpire, startoffset, endoffset
    1.94 -	    "DEFAULT, 6, 15, %d, " 	//recgroup, dupmethod, dupin, station
    1.95 -	    "1, %d, \"%s\", %d, "	//autocommflag, findday, findtime, findid
    1.96 -	    "5, 0, 29, 1, "			//search, autotranscode, transcoder, tsdefault
    1.97 -	    "0, 0, 0, 0 );",		//autouserjob1, autouserjob2, autouserjob3, autouserjob4
    1.98 -	    schedule_info->record_id, schedule_info->channel_id,
    1.99 +        "(recordid, type, chanid, starttime, "
   1.100 +        "startdate, endtime, enddate, title,"
   1.101 +        "profile, recpriority, maxnewest, inactive, "
   1.102 +        "maxepisodes, autoexpire, startoffset, endoffset, "
   1.103 +        "recgroup, dupmethod, dupin, station, "
   1.104 +        "autocommflag, findday, findtime, findid, "
   1.105 +        "search, autotranscode, transcoder, tsdefault, "
   1.106 +        "autouserjob1, autouserjob2, autouserjob3, autouserjob4) "
   1.107 +        " values ( %d, 1, %d, \"%s\","	//recordid, type, chanid, starttime
   1.108 +        " \"%s\", \"%s\", \"%s\", \"%s\"," //startdate, endtime, enddate, title
   1.109 +        "DEFAULT, 0, 0, 0, "	//profile, recpriority, maxnewest, inactive
   1.110 +        "0, 1, 0, 0, "			//maxepisodes, autoexpire, startoffset, endoffset
   1.111 +        "DEFAULT, 6, 15, %d, " 	//recgroup, dupmethod, dupin, station
   1.112 +        "1, %d, \"%s\", %d, "	//autocommflag, findday, findtime, findid
   1.113 +        "5, 0, 29, 1, "			//search, autotranscode, transcoder, tsdefault
   1.114 +        "0, 0, 0, 0 );",		//autouserjob1, autouserjob2, autouserjob3, autouserjob4
   1.115 +        schedule_info->record_id, schedule_info->channel_id,
   1.116          gmyth_util_time_to_string_only_time( schedule_info->start_time ),
   1.117          gmyth_util_time_to_string_only_date( schedule_info->start_time ),
   1.118 -	    gmyth_util_time_to_string_only_date( schedule_info->start_time ),
   1.119 +        gmyth_util_time_to_string_only_date( schedule_info->start_time ),
   1.120          gmyth_util_time_to_string_only_date( schedule_info->end_time ),
   1.121          schedule_info->title->str, //title
   1.122 -    	schedule_info->channel_id,//station
   1.123 -    	(gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, //findday
   1.124 -   		gmyth_util_time_to_string_only_time( schedule_info->start_time ), //findtime
   1.125 -   		(gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528)//findid
   1.126 +        schedule_info->channel_id,//station
   1.127 +        (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, //findday
   1.128 +        gmyth_util_time_to_string_only_time( schedule_info->start_time ), //findtime
   1.129 +   	    (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528)//findid
   1.130      );
   1.131      
   1.132      gmyth_debug ( "Sending query to MySQL = %s.", query_str->str );
   1.133 @@ -402,7 +402,7 @@
   1.134      
   1.135      /* TODO: verify record_id = -1 semantics */
   1.136      if (schedule_info->record_id <= 0)
   1.137 -	    schedule_info->record_id = get_record_id_from_database(scheduler);
   1.138 +        schedule_info->record_id = get_record_id_from_database(scheduler);
   1.139      
   1.140      /* Notify the backend of changes */
   1.141      update_backend(scheduler, schedule_info->record_id);
   1.142 @@ -469,10 +469,10 @@
   1.143  
   1.144      assert(scheduler);
   1.145      
   1.146 -	if (scheduler->msqlquery == NULL) {
   1.147 -		g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.148 -		return FALSE;
   1.149 -	}
   1.150 +    if (scheduler->msqlquery == NULL) {
   1.151 +        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.152 +        return FALSE;
   1.153 +    }
   1.154  
   1.155      //========================================
   1.156      g_string_printf (query_str, 
   1.157 @@ -501,19 +501,19 @@
   1.158  gmyth_scheduler_get_recorded (GMythScheduler *scheduler, 
   1.159                                GString *channel, GTimeVal* starttime)
   1.160  {
   1.161 -	MYSQL_RES *msql_res;
   1.162 -	GMythProgramInfo *proginfo = NULL;
   1.163 -	GString *query_str = g_string_new("");
   1.164 -	gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime);
   1.165 +    MYSQL_RES *msql_res;
   1.166 +    GMythProgramInfo *proginfo = NULL;
   1.167 +    GString *query_str = g_string_new("");
   1.168 +    gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime);
   1.169  
   1.170      assert(scheduler);
   1.171      
   1.172 -	if (scheduler->msqlquery == NULL) {
   1.173 -		g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.174 -		return NULL;
   1.175 -	}
   1.176 +    if (scheduler->msqlquery == NULL) {
   1.177 +        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.178 +        return NULL;
   1.179 +    }
   1.180  
   1.181 -	g_string_printf (query_str, "SELECT recorded.chanid,starttime,endtime,title, "
   1.182 +    g_string_printf (query_str, "SELECT recorded.chanid,starttime,endtime,title, "
   1.183                    "subtitle,description,channel.channum, "
   1.184                    "channel.callsign,channel.name,channel.commfree, "
   1.185                    "channel.outputfilters,seriesid,programid,filesize, "
   1.186 @@ -531,57 +531,57 @@
   1.187  
   1.188      if (msql_res /*&& query.size() > 0*/) {
   1.189      	
   1.190 -    	MYSQL_ROW msql_row = mysql_fetch_row (msql_res);
   1.191 -    	if (msql_row) {
   1.192 +            MYSQL_ROW msql_row = mysql_fetch_row (msql_res);
   1.193 +            if (msql_row) {
   1.194  
   1.195 -    		proginfo = gmyth_program_info_new();
   1.196 -    	
   1.197 -	        proginfo->chanid = g_string_new (msql_row[0]);
   1.198 -	        proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]);
   1.199 -	        proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]);
   1.200 -	        proginfo->recstartts = gmyth_util_string_to_time_val (msql_row[1]);
   1.201 -	        proginfo->recendts = gmyth_util_string_to_time_val (msql_row[2]);
   1.202 -	        proginfo->title = g_string_new (msql_row[3]);
   1.203 -	        proginfo->subtitle = g_string_new (msql_row[4]);
   1.204 -	        proginfo->description = g_string_new (msql_row[5]);
   1.205 +    		    proginfo = gmyth_program_info_new();
   1.206 + 
   1.207 +                proginfo->chanid = g_string_new (msql_row[0]);
   1.208 +                proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]);
   1.209 +                proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]);
   1.210 +                proginfo->recstartts = gmyth_util_string_to_time_val (msql_row[1]);
   1.211 +                proginfo->recendts = gmyth_util_string_to_time_val (msql_row[2]);
   1.212 +                proginfo->title = g_string_new (msql_row[3]);
   1.213 +                proginfo->subtitle = g_string_new (msql_row[4]);
   1.214 +                proginfo->description = g_string_new (msql_row[5]);
   1.215 +
   1.216 +                proginfo->chanstr = g_string_new (msql_row[6]);
   1.217 +                proginfo->chansign = g_string_new (msql_row[7]);
   1.218 +                proginfo->channame = g_string_new (msql_row[0]);
   1.219 +                proginfo->chancommfree = (gint) g_ascii_strtoull (msql_row[9], NULL, 10);
   1.220 +                proginfo->chanOutputFilters = g_string_new (msql_row[10]);
   1.221 +                proginfo->seriesid = g_string_new (msql_row[11]);
   1.222 +                proginfo->programid = g_string_new (msql_row[12]);
   1.223 +                proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10);
   1.224  	
   1.225 -	        proginfo->chanstr = g_string_new (msql_row[6]);
   1.226 -	        proginfo->chansign = g_string_new (msql_row[7]);
   1.227 -	        proginfo->channame = g_string_new (msql_row[0]);
   1.228 -	        proginfo->chancommfree = (gint) g_ascii_strtoll (msql_row[9], NULL, 10);
   1.229 -	        proginfo->chanOutputFilters = g_string_new (msql_row[10]);
   1.230 -	        proginfo->seriesid = g_string_new (msql_row[11]);
   1.231 -	        proginfo->programid = g_string_new (msql_row[12]);
   1.232 -	        proginfo->filesize = g_ascii_strtoll (msql_row[13], NULL, 10);
   1.233 -	
   1.234 -	        proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]);
   1.235 +                proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]);
   1.236  	        
   1.237 -	        proginfo->stars = g_ascii_strtod (msql_row[15], NULL);
   1.238 -	        proginfo->repeat = (gint) g_ascii_strtoll (msql_row[16], NULL, 10);
   1.239 +                proginfo->stars = g_ascii_strtod (msql_row[15], NULL);
   1.240 +                proginfo->repeat = (gint) g_ascii_strtoull (msql_row[16], NULL, 10);
   1.241  	        
   1.242 -	        if (msql_row[17] == NULL) {
   1.243 -	            proginfo->originalAirDate = 0;
   1.244 -	            proginfo->hasAirDate = FALSE;
   1.245 -	        } else {
   1.246 -	            proginfo->originalAirDate = gmyth_util_string_to_time_val (msql_row[17]);
   1.247 -	            proginfo->hasAirDate = TRUE;
   1.248 -	        }
   1.249 +                if (msql_row[17] == NULL) {
   1.250 +                    proginfo->originalAirDate = 0;
   1.251 +                    proginfo->hasAirDate = FALSE;
   1.252 +                } else {
   1.253 +                    proginfo->originalAirDate = gmyth_util_string_to_time_val (msql_row[17]);
   1.254 +                    proginfo->hasAirDate = TRUE;
   1.255 +                }
   1.256  	        
   1.257 -	        proginfo->hostname = g_string_new (msql_row[18]);
   1.258 -	        proginfo->recordid = (gint) g_ascii_strtoll (msql_row[19], NULL, 10);
   1.259 -	        proginfo->transcoder = (gint) g_ascii_strtoll (msql_row[20], NULL, 10);
   1.260 -	
   1.261 -	        //proginfo->spread = -1;
   1.262 -			//proginfo->programflags = proginfo->getProgramFlags();
   1.263 -	
   1.264 -	        proginfo->recgroup = g_string_new (msql_row[26]);
   1.265 -	        proginfo->playgroup = g_string_new (msql_row[21]);
   1.266 -	        proginfo->recpriority = (gint) g_ascii_strtoll (msql_row[22], NULL, 10);
   1.267 -	
   1.268 -	        proginfo->pathname = g_string_new (msql_row[25]);
   1.269 +                proginfo->hostname = g_string_new (msql_row[18]);
   1.270 +                proginfo->recordid = (gint) g_ascii_strtoull (msql_row[19], NULL, 10);
   1.271 +                proginfo->transcoder = (gint) g_ascii_strtoull (msql_row[20], NULL, 10);
   1.272  
   1.273 -	        gmyth_debug ("One program info loaded from mysql database\n");
   1.274 -    	}
   1.275 +                //proginfo->spread = -1;
   1.276 +                ////proginfo->programflags = proginfo->getProgramFlags();
   1.277 +                
   1.278 +                proginfo->recgroup = g_string_new (msql_row[26]);
   1.279 +                proginfo->playgroup = g_string_new (msql_row[21]);
   1.280 +                proginfo->recpriority = (gint) g_ascii_strtoull (msql_row[22], NULL, 10);
   1.281 +
   1.282 +                proginfo->pathname = g_string_new (msql_row[25]);
   1.283 +
   1.284 +                gmyth_debug ("One program info loaded from mysql database\n");
   1.285 +            }
   1.286      }
   1.287  
   1.288      mysql_free_result (msql_res);
   1.289 @@ -603,14 +603,14 @@
   1.290  
   1.291      assert(scheduler);
   1.292      
   1.293 -	if (scheduler->msqlquery == NULL) {
   1.294 -		g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.295 -		return 0;
   1.296 -	}
   1.297 +    if (scheduler->msqlquery == NULL) {
   1.298 +        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
   1.299 +        return 0;
   1.300 +    }
   1.301  
   1.302      record_id = mysql_insert_id (scheduler->msqlquery->conn);
   1.303  
   1.304 -	return record_id;
   1.305 +    return record_id;
   1.306  }	
   1.307  	
   1.308  /** Notifies the backend of an update in the db.
     2.1 --- a/gmyth/src/gmyth_scheduler.h	Tue Mar 06 00:55:35 2007 +0000
     2.2 +++ b/gmyth/src/gmyth_scheduler.h	Tue Mar 06 14:06:16 2007 +0000
     2.3 @@ -51,17 +51,17 @@
     2.4  
     2.5  struct _GMythSchedulerClass
     2.6  {
     2.7 -  GObjectClass parent_class;
     2.8 +    GObjectClass parent_class;
     2.9  
    2.10 -  /* callbacks */
    2.11 -  /* no one for now */
    2.12 +    /* callbacks */
    2.13 +    /* no one for now */
    2.14  };
    2.15  
    2.16  struct _GMythScheduler
    2.17  {
    2.18      GObject parent;
    2.19  
    2.20 -  	unsigned long recordid;
    2.21 +    unsigned long recordid;
    2.22      unsigned long type;
    2.23      unsigned long search;
    2.24      GString *profile;