1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/branches/gmyth-0.1b/src/gmyth_programinfo.c Wed Feb 14 21:28:49 2007 +0000
1.3 @@ -0,0 +1,460 @@
1.4 +/**
1.5 + * GMyth Library
1.6 + *
1.7 + * @file gmyth/gmyth_programinfo.c
1.8 + *
1.9 + * @brief <p> GMythFileTransfer deals with the file streaming media remote/local
1.10 + * transfering to the MythTV frontend.
1.11 + *
1.12 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
1.13 + * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
1.14 + *
1.15 + *//*
1.16 + *
1.17 + * This program is free software; you can redistribute it and/or modify
1.18 + * it under the terms of the GNU Lesser General Public License as published by
1.19 + * the Free Software Foundation; either version 2 of the License, or
1.20 + * (at your option) any later version.
1.21 + *
1.22 + * This program is distributed in the hope that it will be useful,
1.23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.25 + * GNU General Public License for more details.
1.26 + *
1.27 + * You should have received a copy of the GNU Lesser General Public License
1.28 + * along with this program; if not, write to the Free Software
1.29 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.30 + *
1.31 + */
1.32 +
1.33 +#ifdef HAVE_CONFIG_H
1.34 +#include "config.h"
1.35 +#endif
1.36 +
1.37 +#include <stdlib.h>
1.38 +#include <string.h>
1.39 +#include <assert.h>
1.40 +
1.41 +#include "gmyth_programinfo.h"
1.42 +#include "gmyth_util.h"
1.43 +#include "gmyth_debug.h"
1.44 +
1.45 +static void gmyth_program_info_class_init (GMythProgramInfoClass *klass);
1.46 +static void gmyth_program_info_init (GMythProgramInfo *object);
1.47 +
1.48 +static void gmyth_program_info_dispose (GObject *object);
1.49 +static void gmyth_program_info_finalize (GObject *object);
1.50 +
1.51 +G_DEFINE_TYPE(GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
1.52 +
1.53 +static void
1.54 +gmyth_program_info_class_init (GMythProgramInfoClass *klass)
1.55 +{
1.56 + GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
1.57 +
1.58 + gobject_class->dispose = gmyth_program_info_dispose;
1.59 + gobject_class->finalize = gmyth_program_info_finalize;
1.60 +}
1.61 +
1.62 +static void
1.63 +gmyth_program_info_init (GMythProgramInfo *gmyth_program_info)
1.64 +{
1.65 + gmyth_program_info->chancommfree = 0;
1.66 +
1.67 + /** A flag informing if the program has video or not. */
1.68 + gmyth_program_info->isVideo = FALSE;
1.69 + gmyth_program_info->lenMins = 0;
1.70 +
1.71 + gmyth_program_info->stars = 0.0f;
1.72 + gmyth_program_info->repeat = 0;
1.73 +
1.74 + gmyth_program_info->hasAirDate = FALSE;
1.75 +
1.76 + gmyth_program_info->spread = 0;
1.77 + gmyth_program_info->startCol = 0;
1.78 +
1.79 + gmyth_program_info->recpriority2 = 0;
1.80 + gmyth_program_info->reactivate = 0;
1.81 +
1.82 + gmyth_program_info->recordid = 0;
1.83 + gmyth_program_info->parentid = 0;
1.84 +
1.85 + /** The backend video source id associated to this program.*/
1.86 + gmyth_program_info->sourceid = 0;
1.87 + /** the backend input id associated to this program.*/
1.88 + gmyth_program_info->inputid = 0;
1.89 + /** The backend card id associated to this program.*/
1.90 + gmyth_program_info->cardid = 0;
1.91 + gmyth_program_info->shareable = FALSE;
1.92 + gmyth_program_info->duplicate = FALSE;
1.93 +
1.94 + gmyth_program_info->findid = 0;
1.95 +
1.96 + gmyth_program_info->programflags = 0;
1.97 + gmyth_program_info->transcoder = 0;
1.98 +
1.99 + gmyth_program_info->recpriority = 0;
1.100 +
1.101 + /** The file size of the recorded program.*/
1.102 + gmyth_program_info->filesize = -1;
1.103 +
1.104 +
1.105 +}
1.106 +
1.107 +static void
1.108 +gmyth_program_info_dispose (GObject *object)
1.109 +{
1.110 + GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
1.111 +
1.112 + if ( gmyth_program_info->chanid != NULL )
1.113 + {
1.114 + g_string_free( gmyth_program_info->chanid, TRUE );
1.115 + gmyth_program_info->chanid = NULL;
1.116 + }
1.117 +
1.118 + /** The program start time. */
1.119 + if ( gmyth_program_info->startts != NULL )
1.120 + {
1.121 + g_free( gmyth_program_info->startts);
1.122 + gmyth_program_info->startts = NULL;
1.123 + }
1.124 +
1.125 + /** The program end time. */
1.126 + if ( gmyth_program_info->endts != NULL )
1.127 + {
1.128 + g_free( gmyth_program_info->endts );
1.129 + gmyth_program_info->endts = NULL;
1.130 + }
1.131 +
1.132 + /** The recording schedule start time. */
1.133 + if ( gmyth_program_info->recstartts != NULL )
1.134 + {
1.135 + g_free( gmyth_program_info->recstartts );
1.136 + gmyth_program_info->recstartts = NULL;
1.137 + }
1.138 +
1.139 + /** The recording schedule end time */
1.140 + if ( gmyth_program_info->recendts != NULL )
1.141 + {
1.142 + g_free(gmyth_program_info->recendts);
1.143 + gmyth_program_info->recendts = NULL;
1.144 + }
1.145 +
1.146 + /** The program title. */
1.147 + if (gmyth_program_info->title != NULL )
1.148 + {
1.149 + g_string_free(gmyth_program_info->title, TRUE);
1.150 + gmyth_program_info->title = NULL;
1.151 + }
1.152 +
1.153 + /** The program subtitle. */
1.154 + if (gmyth_program_info->subtitle != NULL )
1.155 + {
1.156 + g_string_free(gmyth_program_info->subtitle, TRUE );
1.157 + gmyth_program_info->subtitle = NULL;
1.158 + }
1.159 + /** The program description. */
1.160 + if ( gmyth_program_info->description != NULL )
1.161 + {
1.162 + g_string_free( gmyth_program_info->description, TRUE );
1.163 + gmyth_program_info->description = NULL;
1.164 + }
1.165 +
1.166 + /** The program category. */
1.167 + if ( gmyth_program_info->category != NULL )
1.168 + {
1.169 + g_string_free( gmyth_program_info->category, TRUE );
1.170 + gmyth_program_info->category = NULL;
1.171 + }
1.172 +
1.173 + if ( gmyth_program_info->chanstr != NULL )
1.174 + {
1.175 + g_string_free( gmyth_program_info->chanstr, TRUE );
1.176 + gmyth_program_info->chanstr = NULL;
1.177 + }
1.178 + if ( gmyth_program_info->chansign != NULL )
1.179 + {
1.180 + g_string_free( gmyth_program_info->chansign, TRUE );
1.181 + gmyth_program_info->chansign = NULL;
1.182 + }
1.183 + /** The associated channel name. */
1.184 + if ( gmyth_program_info->channame != NULL )
1.185 + {
1.186 + g_string_free( gmyth_program_info->channame, TRUE );
1.187 + gmyth_program_info->channame = NULL;
1.188 + }
1.189 + if ( gmyth_program_info->chanOutputFilters != NULL )
1.190 + {
1.191 + g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
1.192 + gmyth_program_info->chanOutputFilters = NULL;
1.193 + }
1.194 +
1.195 + if ( gmyth_program_info->seriesid != NULL )
1.196 + {
1.197 + g_string_free( gmyth_program_info->seriesid, TRUE );
1.198 + gmyth_program_info->chanOutputFilters = NULL;
1.199 +
1.200 + }
1.201 + /** The program unique id. */
1.202 + if ( gmyth_program_info->programid != NULL )
1.203 + {
1.204 + g_string_free( gmyth_program_info->programid, TRUE );
1.205 + gmyth_program_info->programid = NULL;
1.206 +
1.207 + }
1.208 + if ( gmyth_program_info->catType != NULL )
1.209 + {
1.210 + g_string_free( gmyth_program_info->catType, TRUE );
1.211 + gmyth_program_info->catType = NULL;
1.212 +
1.213 + }
1.214 +
1.215 + if ( gmyth_program_info->sortTitle != NULL )
1.216 + {
1.217 + g_string_free( gmyth_program_info->sortTitle, TRUE );
1.218 + gmyth_program_info->sortTitle = NULL;
1.219 +
1.220 + }
1.221 +
1.222 + if ( gmyth_program_info->year != NULL )
1.223 + {
1.224 + g_string_free( gmyth_program_info->year, TRUE );
1.225 + gmyth_program_info->year = NULL;
1.226 +
1.227 + }
1.228 +
1.229 + if ( gmyth_program_info->originalAirDate != NULL )
1.230 + {
1.231 + g_free( gmyth_program_info->originalAirDate);
1.232 + gmyth_program_info->originalAirDate = NULL;
1.233 + }
1.234 + if ( gmyth_program_info->lastmodified != NULL )
1.235 + {
1.236 + g_free( gmyth_program_info->lastmodified );
1.237 + gmyth_program_info->lastmodified = NULL;
1.238 +
1.239 + }
1.240 + if (gmyth_program_info->lastInUseTime != NULL)
1.241 + {
1.242 + g_free( gmyth_program_info->lastInUseTime );
1.243 + gmyth_program_info->lastInUseTime = NULL;
1.244 + }
1.245 +
1.246 + if ( gmyth_program_info->schedulerid != NULL )
1.247 + {
1.248 + g_string_free( gmyth_program_info->schedulerid, TRUE );
1.249 + gmyth_program_info->schedulerid = NULL;
1.250 + }
1.251 +
1.252 + if ( gmyth_program_info->recgroup != NULL )
1.253 + {
1.254 + g_string_free( gmyth_program_info->recgroup, TRUE );
1.255 + gmyth_program_info->recgroup = NULL;
1.256 + }
1.257 + if ( gmyth_program_info->playgroup != NULL )
1.258 + {
1.259 + g_string_free( gmyth_program_info->playgroup, TRUE );
1.260 + gmyth_program_info->playgroup = NULL;
1.261 + }
1.262 +
1.263 + /** The file name of the recorded program.*/
1.264 + if ( gmyth_program_info->pathname != NULL)
1.265 + {
1.266 + g_string_free( gmyth_program_info->pathname, TRUE );
1.267 + gmyth_program_info->pathname = NULL;
1.268 + }
1.269 +
1.270 + if ( gmyth_program_info->hostname != NULL )
1.271 + {
1.272 + g_string_free( gmyth_program_info->hostname, TRUE );
1.273 + gmyth_program_info->hostname = NULL;
1.274 + }
1.275 +
1.276 + G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
1.277 +}
1.278 +
1.279 +static void
1.280 +gmyth_program_info_finalize (GObject *object)
1.281 +{
1.282 + g_signal_handlers_destroy (object);
1.283 +
1.284 + G_OBJECT_CLASS (gmyth_program_info_parent_class)->finalize (object);
1.285 +}
1.286 +
1.287 +/**
1.288 + * Creates a new instance of GMythProgramInfo.
1.289 + *
1.290 + * @return a new instance of GMythProgramInfo.
1.291 + */
1.292 +GMythProgramInfo*
1.293 +gmyth_program_info_new (void)
1.294 +{
1.295 + GMythProgramInfo *program_info = GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
1.296 +
1.297 + return program_info;
1.298 +}
1.299 +
1.300 +GMythStringList*
1.301 +gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist)
1.302 +{
1.303 + g_return_val_if_fail (prog != NULL, NULL);
1.304 + g_return_val_if_fail (slist != NULL, NULL);
1.305 +
1.306 + gmyth_string_list_append_string (slist, prog->title); /* 0 */
1.307 + gmyth_string_list_append_string (slist, prog->subtitle); /* 1 */
1.308 + gmyth_string_list_append_string (slist, prog->description); /* 2 */
1.309 + gmyth_string_list_append_string (slist, prog->category); /* 3 */
1.310 + gmyth_string_list_append_string (slist, prog->chanid); /* 4 */
1.311 + gmyth_string_list_append_string (slist, prog->chanstr); /* 5 */
1.312 + gmyth_string_list_append_string (slist, prog->chansign); /* 6 */
1.313 + gmyth_string_list_append_string (slist, prog->channame); /* 7 */
1.314 + gmyth_string_list_append_string (slist, prog->pathname); /* 8 */
1.315 +
1.316 + // fixme
1.317 + gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
1.318 + gmyth_string_list_append_int64 (slist, 10); /* 11 */
1.319 +
1.320 + if (prog->startts)
1.321 + gmyth_string_list_append_int (slist, prog->startts->tv_sec); /* 11 */ //DATETIME_TO_LIST(startts)
1.322 + else
1.323 + gmyth_string_list_append_int (slist, 0);
1.324 +
1.325 + if (prog->endts)
1.326 + gmyth_string_list_append_int (slist, prog->endts->tv_sec); /* 12 */ //DATETIME_TO_LIST(endts)
1.327 + else
1.328 + gmyth_string_list_append_int (slist, 0);
1.329 +
1.330 + gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
1.331 + gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
1.332 + gmyth_string_list_append_int (slist, prog->findid); /* 15 */
1.333 + gmyth_string_list_append_string (slist, prog->hostname); /* 16 */
1.334 + gmyth_string_list_append_int (slist, prog->sourceid); /* 17 */
1.335 + gmyth_string_list_append_int (slist, prog->cardid); /* 18 */
1.336 + gmyth_string_list_append_int (slist, prog->inputid); /* 19 */
1.337 + gmyth_string_list_append_int (slist, prog->recpriority); /* 20 */
1.338 + gmyth_string_list_append_int (slist, 0 /*prog->recstatus*/); /* 21 */
1.339 + gmyth_string_list_append_int (slist, prog->recordid); /* 22 */
1.340 + gmyth_string_list_append_int (slist, 0 /*prog->rectype*/); /* 23 */
1.341 + gmyth_string_list_append_int (slist, 0 /*prog->dupin*/); /* 24 */
1.342 + gmyth_string_list_append_int (slist, 0 /*prog->dupmethod*/); /* 25 */
1.343 + gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0); /* 26 */ //DATETIME_TO_LIST(recstartts)
1.344 + gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0); /* 27 */ //DATETIME_TO_LIST(recendts)
1.345 + gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
1.346 + gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
1.347 + gmyth_string_list_append_char_array (slist, "Default"); /* 30 */ //prog->(recgroup != "") ? recgroup : "Default")
1.348 + gmyth_string_list_append_int (slist, prog->chancommfree); /* 31 */
1.349 + gmyth_string_list_append_string (slist, prog->chanOutputFilters); /* 32 */
1.350 + gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
1.351 + gmyth_string_list_append_string (slist, prog->programid); /* 34 */
1.352 + gmyth_string_list_append_string (slist, ""); /* 35 */
1.353 + gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 36 */ //DATETIME_TO_LIST(lastmodified)
1.354 + gmyth_string_list_append_int (slist, 0); /* 37 */ //FLOAT_TO_LIST(stars)
1.355 + gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
1.356 + gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
1.357 + gmyth_string_list_append_char_array (slist, "Default"); /* 40 */ //prog->(playgroup != "") ? playgroup : "Default")
1.358 + gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
1.359 +
1.360 + return slist;
1.361 +}
1.362 +
1.363 +GMythProgramInfo*
1.364 +gmyth_program_info_from_string_list ( GMythStringList *slist )
1.365 +{
1.366 + GMythProgramInfo *prog = gmyth_program_info_new();
1.367 +
1.368 + g_return_val_if_fail (slist != NULL, NULL);
1.369 + /*
1.370 + Unknown
1.371 +
1.372 +
1.373 +
1.374 + 1000
1.375 + 9
1.376 + 1000
1.377 + Band
1.378 + /mnt/store//1000_20070125110059.nuv
1.379 + 0
1.380 + 0
1.381 + 1169733659
1.382 + 1169735400
1.383 + 0
1.384 + 0
1.385 + 0
1.386 + hmelo-desktop
1.387 + 0
1.388 + 1
1.389 + 0
1.390 + 0
1.391 + -2
1.392 + 0
1.393 + 0
1.394 + 15
1.395 + 6
1.396 + 1169733659
1.397 + 1169735400
1.398 + 0
1.399 + 0
1.400 + LiveTV
1.401 + 0
1.402 +
1.403 +
1.404 +
1.405 + 1169733659
1.406 + 0.000000
1.407 + -1
1.408 + 0
1.409 + Default
1.410 + 0
1.411 + */
1.412 + prog->title = gmyth_string_list_get_string (slist, 0);
1.413 + prog->subtitle = gmyth_string_list_get_string (slist, 1);
1.414 + prog->description = gmyth_string_list_get_string (slist, 2);
1.415 + prog->category = gmyth_string_list_get_string (slist, 3);
1.416 + prog->chanid = gmyth_string_list_get_string (slist, 4);
1.417 + prog->chanstr = gmyth_string_list_get_string (slist, 5);
1.418 + prog->chansign = gmyth_string_list_get_string (slist, 6);
1.419 + prog->channame = gmyth_string_list_get_string (slist, 7);
1.420 + prog->pathname = gmyth_string_list_get_string (slist, 8);
1.421 + prog->filesize = gmyth_string_list_get_int64 (slist, 9);
1.422 + gmyth_string_list_get_int64 (slist, 10);
1.423 +
1.424 + prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.425 + (time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts)
1.426 + prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.427 + (time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts)
1.428 + prog->duplicate = gmyth_string_list_get_int (slist, 13);
1.429 + prog->shareable = gmyth_string_list_get_int (slist, 14);
1.430 + prog->findid = gmyth_string_list_get_int (slist, 15);
1.431 + prog->hostname = gmyth_string_list_get_string (slist, 16);
1.432 + prog->sourceid = gmyth_string_list_get_int (slist, 17);
1.433 + prog->cardid = gmyth_string_list_get_int (slist, 18);
1.434 + prog->inputid = gmyth_string_list_get_int (slist, 19);
1.435 + prog->recpriority = gmyth_string_list_get_int (slist, 20);
1.436 + prog->reactivate = gmyth_string_list_get_int (slist, 21);
1.437 + prog->recordid = gmyth_string_list_get_int (slist, 22);
1.438 + gmyth_string_list_get_int (slist, 23);
1.439 + gmyth_string_list_get_int (slist, 24);
1.440 + gmyth_string_list_get_int (slist, 25);
1.441 + prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.442 + (time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts)
1.443 + prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.444 + (time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts)
1.445 + prog->repeat = gmyth_string_list_get_int (slist, 28);
1.446 + prog->programflags = gmyth_string_list_get_int (slist, 29);
1.447 + prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default")
1.448 + prog->chancommfree = gmyth_string_list_get_int (slist, 31);
1.449 + prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32);
1.450 + prog->seriesid = gmyth_string_list_get_string (slist, 33);
1.451 + prog->programid = gmyth_string_list_get_string (slist, 34);
1.452 + gmyth_string_list_get_string (slist, 35);
1.453 + prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.454 + (time_t)gmyth_string_list_get_int (slist, 36) ))->str ); //DATETIME_TO_LIST(lastmodified)
1.455 + gmyth_string_list_get_int (slist, 37); //FLOAT_TO_LIST(stars)
1.456 + prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
1.457 + (time_t)gmyth_string_list_get_int (slist, 38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
1.458 + prog->hasAirDate = gmyth_string_list_get_int (slist, 39);
1.459 + prog->playgroup = gmyth_string_list_get_string (slist, 40); //prog->(playgroup != "") ? playgroup : "Default")
1.460 + prog->recpriority2 = gmyth_string_list_get_int (slist, 41);
1.461 +
1.462 + return prog;
1.463 +}