[svn r333] Fixed bug on do_get_file_info.
4 * @file gmyth/gmyth_programinfo.c
6 * @brief <p> GMythFileTransfer deals with the file streaming media remote/local
7 * transfering to the MythTV frontend.
9 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
10 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 #include "gmyth_programinfo.h"
39 #include "gmyth_util.h"
40 #include "gmyth_debug.h"
42 static void gmyth_program_info_class_init (GMythProgramInfoClass *klass);
43 static void gmyth_program_info_init (GMythProgramInfo *object);
45 static void gmyth_program_info_dispose (GObject *object);
46 static void gmyth_program_info_finalize (GObject *object);
48 G_DEFINE_TYPE(GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
51 gmyth_program_info_class_init (GMythProgramInfoClass *klass)
53 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
55 gobject_class->dispose = gmyth_program_info_dispose;
56 gobject_class->finalize = gmyth_program_info_finalize;
60 gmyth_program_info_init (GMythProgramInfo *gmyth_program_info)
62 gmyth_program_info->chancommfree = 0;
64 /** A flag informing if the program has video or not. */
65 gmyth_program_info->isVideo = FALSE;
66 gmyth_program_info->lenMins = 0;
68 gmyth_program_info->stars = 0.0f;
69 gmyth_program_info->repeat = 0;
71 gmyth_program_info->hasAirDate = FALSE;
73 gmyth_program_info->spread = 0;
74 gmyth_program_info->startCol = 0;
76 gmyth_program_info->recpriority2 = 0;
77 gmyth_program_info->reactivate = 0;
79 gmyth_program_info->recordid = 0;
80 gmyth_program_info->parentid = 0;
82 /** The backend video source id associated to this program.*/
83 gmyth_program_info->sourceid = 0;
84 /** the backend input id associated to this program.*/
85 gmyth_program_info->inputid = 0;
86 /** The backend card id associated to this program.*/
87 gmyth_program_info->cardid = 0;
88 gmyth_program_info->shareable = FALSE;
89 gmyth_program_info->duplicate = FALSE;
91 gmyth_program_info->findid = 0;
93 gmyth_program_info->programflags = 0;
94 gmyth_program_info->transcoder = 0;
96 gmyth_program_info->recpriority = 0;
98 /** The file size of the recorded program.*/
99 gmyth_program_info->filesize = -1;
105 gmyth_program_info_dispose (GObject *object)
107 GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
109 if ( gmyth_program_info->chanid != NULL )
111 g_string_free( gmyth_program_info->chanid, TRUE );
112 gmyth_program_info->chanid = NULL;
115 /** The program start time. */
116 if ( gmyth_program_info->startts != NULL )
118 g_free( gmyth_program_info->startts);
119 gmyth_program_info->startts = NULL;
122 /** The program end time. */
123 if ( gmyth_program_info->endts != NULL )
125 g_free( gmyth_program_info->endts );
126 gmyth_program_info->endts = NULL;
129 /** The recording schedule start time. */
130 if ( gmyth_program_info->recstartts != NULL )
132 g_free( gmyth_program_info->recstartts );
133 gmyth_program_info->recstartts = NULL;
136 /** The recording schedule end time */
137 if ( gmyth_program_info->recendts != NULL )
139 g_free(gmyth_program_info->recendts);
140 gmyth_program_info->recendts = NULL;
143 /** The program title. */
144 if (gmyth_program_info->title != NULL )
146 g_string_free(gmyth_program_info->title, TRUE);
147 gmyth_program_info->title = NULL;
150 /** The program subtitle. */
151 if (gmyth_program_info->subtitle != NULL )
153 g_string_free(gmyth_program_info->subtitle, TRUE );
154 gmyth_program_info->subtitle = NULL;
156 /** The program description. */
157 if ( gmyth_program_info->description != NULL )
159 g_string_free( gmyth_program_info->description, TRUE );
160 gmyth_program_info->description = NULL;
163 /** The program category. */
164 if ( gmyth_program_info->category != NULL )
166 g_string_free( gmyth_program_info->category, TRUE );
167 gmyth_program_info->category = NULL;
170 if ( gmyth_program_info->chanstr != NULL )
172 g_string_free( gmyth_program_info->chanstr, TRUE );
173 gmyth_program_info->chanstr = NULL;
175 if ( gmyth_program_info->chansign != NULL )
177 g_string_free( gmyth_program_info->chansign, TRUE );
178 gmyth_program_info->chansign = NULL;
180 /** The associated channel name. */
181 if ( gmyth_program_info->channame != NULL )
183 g_string_free( gmyth_program_info->channame, TRUE );
184 gmyth_program_info->channame = NULL;
186 if ( gmyth_program_info->chanOutputFilters != NULL )
188 g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
189 gmyth_program_info->chanOutputFilters = NULL;
192 if ( gmyth_program_info->seriesid != NULL )
194 g_string_free( gmyth_program_info->seriesid, TRUE );
195 gmyth_program_info->chanOutputFilters = NULL;
198 /** The program unique id. */
199 if ( gmyth_program_info->programid != NULL )
201 g_string_free( gmyth_program_info->programid, TRUE );
202 gmyth_program_info->programid = NULL;
205 if ( gmyth_program_info->catType != NULL )
207 g_string_free( gmyth_program_info->catType, TRUE );
208 gmyth_program_info->catType = NULL;
212 if ( gmyth_program_info->sortTitle != NULL )
214 g_string_free( gmyth_program_info->sortTitle, TRUE );
215 gmyth_program_info->sortTitle = NULL;
219 if ( gmyth_program_info->year != NULL )
221 g_string_free( gmyth_program_info->year, TRUE );
222 gmyth_program_info->year = NULL;
226 if ( gmyth_program_info->originalAirDate != NULL )
228 g_free( gmyth_program_info->originalAirDate);
229 gmyth_program_info->originalAirDate = NULL;
231 if ( gmyth_program_info->lastmodified != NULL )
233 g_free( gmyth_program_info->lastmodified );
234 gmyth_program_info->lastmodified = NULL;
237 if (gmyth_program_info->lastInUseTime != NULL)
239 g_free( gmyth_program_info->lastInUseTime );
240 gmyth_program_info->lastInUseTime = NULL;
243 if ( gmyth_program_info->schedulerid != NULL )
245 g_string_free( gmyth_program_info->schedulerid, TRUE );
246 gmyth_program_info->schedulerid = NULL;
249 if ( gmyth_program_info->recgroup != NULL )
251 g_string_free( gmyth_program_info->recgroup, TRUE );
252 gmyth_program_info->recgroup = NULL;
254 if ( gmyth_program_info->playgroup != NULL )
256 g_string_free( gmyth_program_info->playgroup, TRUE );
257 gmyth_program_info->playgroup = NULL;
260 /** The file name of the recorded program.*/
261 if ( gmyth_program_info->pathname != NULL)
263 g_string_free( gmyth_program_info->pathname, TRUE );
264 gmyth_program_info->pathname = NULL;
267 if ( gmyth_program_info->hostname != NULL )
269 g_string_free( gmyth_program_info->hostname, TRUE );
270 gmyth_program_info->hostname = NULL;
273 G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
277 gmyth_program_info_finalize (GObject *object)
279 g_signal_handlers_destroy (object);
281 G_OBJECT_CLASS (gmyth_program_info_parent_class)->finalize (object);
285 * Creates a new instance of GMythProgramInfo.
287 * @return a new instance of GMythProgramInfo.
290 gmyth_program_info_new (void)
292 GMythProgramInfo *program_info = GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
298 gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist)
300 g_return_val_if_fail (prog != NULL, NULL);
301 g_return_val_if_fail (slist != NULL, NULL);
303 gmyth_string_list_append_string (slist, prog->title); /* 0 */
304 gmyth_string_list_append_string (slist, prog->subtitle); /* 1 */
305 gmyth_string_list_append_string (slist, prog->description); /* 2 */
306 gmyth_string_list_append_string (slist, prog->category); /* 3 */
307 gmyth_string_list_append_string (slist, prog->chanid); /* 4 */
308 gmyth_string_list_append_string (slist, prog->chanstr); /* 5 */
309 gmyth_string_list_append_string (slist, prog->chansign); /* 6 */
310 gmyth_string_list_append_string (slist, prog->channame); /* 7 */
311 gmyth_string_list_append_string (slist, prog->pathname); /* 8 */
314 gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
315 gmyth_string_list_append_int64 (slist, 10); /* 11 */
318 gmyth_string_list_append_int (slist, prog->startts->tv_sec); /* 11 */ //DATETIME_TO_LIST(startts)
320 gmyth_string_list_append_int (slist, 0);
323 gmyth_string_list_append_int (slist, prog->endts->tv_sec); /* 12 */ //DATETIME_TO_LIST(endts)
325 gmyth_string_list_append_int (slist, 0);
327 gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
328 gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
329 gmyth_string_list_append_int (slist, prog->findid); /* 15 */
330 gmyth_string_list_append_string (slist, prog->hostname); /* 16 */
331 gmyth_string_list_append_int (slist, prog->sourceid); /* 17 */
332 gmyth_string_list_append_int (slist, prog->cardid); /* 18 */
333 gmyth_string_list_append_int (slist, prog->inputid); /* 19 */
334 gmyth_string_list_append_int (slist, prog->recpriority); /* 20 */
335 gmyth_string_list_append_int (slist, 0 /*prog->recstatus*/); /* 21 */
336 gmyth_string_list_append_int (slist, prog->recordid); /* 22 */
337 gmyth_string_list_append_int (slist, 0 /*prog->rectype*/); /* 23 */
338 gmyth_string_list_append_int (slist, 0 /*prog->dupin*/); /* 24 */
339 gmyth_string_list_append_int (slist, 0 /*prog->dupmethod*/); /* 25 */
340 gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0); /* 26 */ //DATETIME_TO_LIST(recstartts)
341 gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0); /* 27 */ //DATETIME_TO_LIST(recendts)
342 gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
343 gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
344 gmyth_string_list_append_char_array (slist, "Default"); /* 30 */ //prog->(recgroup != "") ? recgroup : "Default")
345 gmyth_string_list_append_int (slist, prog->chancommfree); /* 31 */
346 gmyth_string_list_append_string (slist, prog->chanOutputFilters); /* 32 */
347 gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
348 gmyth_string_list_append_string (slist, prog->programid); /* 34 */
349 gmyth_string_list_append_string (slist, ""); /* 35 */
350 gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 36 */ //DATETIME_TO_LIST(lastmodified)
351 gmyth_string_list_append_int (slist, 0); /* 37 */ //FLOAT_TO_LIST(stars)
352 gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
353 gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
354 gmyth_string_list_append_char_array (slist, "Default"); /* 40 */ //prog->(playgroup != "") ? playgroup : "Default")
355 gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
361 gmyth_program_info_from_string_list ( GMythStringList *slist )
363 GMythProgramInfo *prog = gmyth_program_info_new();
365 g_return_val_if_fail (slist != NULL, NULL);
375 /mnt/store//1000_20070125110059.nuv
409 prog->title = gmyth_string_list_get_string (slist, 0);
410 prog->subtitle = gmyth_string_list_get_string (slist, 1);
411 prog->description = gmyth_string_list_get_string (slist, 2);
412 prog->category = gmyth_string_list_get_string (slist, 3);
413 prog->chanid = gmyth_string_list_get_string (slist, 4);
414 prog->chanstr = gmyth_string_list_get_string (slist, 5);
415 prog->chansign = gmyth_string_list_get_string (slist, 6);
416 prog->channame = gmyth_string_list_get_string (slist, 7);
417 prog->pathname = gmyth_string_list_get_string (slist, 8);
418 prog->filesize = gmyth_string_list_get_int64 (slist, 9);
419 gmyth_string_list_get_int64 (slist, 10);
421 prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
422 (time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts)
423 prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
424 (time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts)
425 prog->duplicate = gmyth_string_list_get_int (slist, 13);
426 prog->shareable = gmyth_string_list_get_int (slist, 14);
427 prog->findid = gmyth_string_list_get_int (slist, 15);
428 prog->hostname = gmyth_string_list_get_string (slist, 16);
429 prog->sourceid = gmyth_string_list_get_int (slist, 17);
430 prog->cardid = gmyth_string_list_get_int (slist, 18);
431 prog->inputid = gmyth_string_list_get_int (slist, 19);
432 prog->recpriority = gmyth_string_list_get_int (slist, 20);
433 prog->reactivate = gmyth_string_list_get_int (slist, 21);
434 prog->recordid = gmyth_string_list_get_int (slist, 22);
435 gmyth_string_list_get_int (slist, 23);
436 gmyth_string_list_get_int (slist, 24);
437 gmyth_string_list_get_int (slist, 25);
438 prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
439 (time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts)
440 prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
441 (time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts)
442 prog->repeat = gmyth_string_list_get_int (slist, 28);
443 prog->programflags = gmyth_string_list_get_int (slist, 29);
444 prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default")
445 prog->chancommfree = gmyth_string_list_get_int (slist, 31);
446 prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32);
447 prog->seriesid = gmyth_string_list_get_string (slist, 33);
448 prog->programid = gmyth_string_list_get_string (slist, 34);
449 gmyth_string_list_get_string (slist, 35);
450 prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
451 (time_t)gmyth_string_list_get_int (slist, 36) ))->str ); //DATETIME_TO_LIST(lastmodified)
452 gmyth_string_list_get_int (slist, 37); //FLOAT_TO_LIST(stars)
453 prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
454 (time_t)gmyth_string_list_get_int (slist, 38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
455 prog->hasAirDate = gmyth_string_list_get_int (slist, 39);
456 prog->playgroup = gmyth_string_list_get_string (slist, 40); //prog->(playgroup != "") ? playgroup : "Default")
457 prog->recpriority2 = gmyth_string_list_get_int (slist, 41);