/**
* GMyth Library
*
* @file gmyth/gmyth_programinfo.c
*
* @brief
GMythFileTransfer deals with the file streaming media remote/local
* transfering to the MythTV frontend.
*
* Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
* @author Leonardo Sobral Cunha
*
*//*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include
#include
#include
#include "gmyth_programinfo.h"
#include "gmyth_util.h"
#include "gmyth_debug.h"
static void gmyth_program_info_class_init (GMythProgramInfoClass *klass);
static void gmyth_program_info_init (GMythProgramInfo *object);
static void gmyth_program_info_dispose (GObject *object);
static void gmyth_program_info_finalize (GObject *object);
G_DEFINE_TYPE(GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
static void
gmyth_program_info_class_init (GMythProgramInfoClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->dispose = gmyth_program_info_dispose;
gobject_class->finalize = gmyth_program_info_finalize;
}
static void
gmyth_program_info_init (GMythProgramInfo *gmyth_program_info)
{
gmyth_program_info->chancommfree = 0;
/** A flag informing if the program has video or not. */
gmyth_program_info->isVideo = FALSE;
gmyth_program_info->lenMins = 0;
gmyth_program_info->stars = 0.0f;
gmyth_program_info->repeat = 0;
gmyth_program_info->hasAirDate = FALSE;
gmyth_program_info->spread = 0;
gmyth_program_info->startCol = 0;
gmyth_program_info->recpriority2 = 0;
gmyth_program_info->reactivate = 0;
gmyth_program_info->recordid = 0;
gmyth_program_info->parentid = 0;
/** The backend video source id associated to this program.*/
gmyth_program_info->sourceid = 0;
/** the backend input id associated to this program.*/
gmyth_program_info->inputid = 0;
/** The backend card id associated to this program.*/
gmyth_program_info->cardid = 0;
gmyth_program_info->shareable = FALSE;
gmyth_program_info->duplicate = FALSE;
gmyth_program_info->findid = 0;
gmyth_program_info->programflags = 0;
gmyth_program_info->transcoder = 0;
gmyth_program_info->recpriority = 0;
/** The file size of the recorded program.*/
gmyth_program_info->filesize = -1;
}
static void
gmyth_program_info_dispose (GObject *object)
{
GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
if ( gmyth_program_info->chanid != NULL )
{
g_string_free( gmyth_program_info->chanid, TRUE );
gmyth_program_info->chanid = NULL;
}
/** The program start time. */
if ( gmyth_program_info->startts != NULL )
{
g_free( gmyth_program_info->startts);
gmyth_program_info->startts = NULL;
}
/** The program end time. */
if ( gmyth_program_info->endts != NULL )
{
g_free( gmyth_program_info->endts );
gmyth_program_info->endts = NULL;
}
/** The recording schedule start time. */
if ( gmyth_program_info->recstartts != NULL )
{
g_free( gmyth_program_info->recstartts );
gmyth_program_info->recstartts = NULL;
}
/** The recording schedule end time */
if ( gmyth_program_info->recendts != NULL )
{
g_free(gmyth_program_info->recendts);
gmyth_program_info->recendts = NULL;
}
/** The program title. */
if (gmyth_program_info->title != NULL )
{
g_string_free(gmyth_program_info->title, TRUE);
gmyth_program_info->title = NULL;
}
/** The program subtitle. */
if (gmyth_program_info->subtitle != NULL )
{
g_string_free(gmyth_program_info->subtitle, TRUE );
gmyth_program_info->subtitle = NULL;
}
/** The program description. */
if ( gmyth_program_info->description != NULL )
{
g_string_free( gmyth_program_info->description, TRUE );
gmyth_program_info->description = NULL;
}
/** The program category. */
if ( gmyth_program_info->category != NULL )
{
g_string_free( gmyth_program_info->category, TRUE );
gmyth_program_info->category = NULL;
}
if ( gmyth_program_info->chanstr != NULL )
{
g_string_free( gmyth_program_info->chanstr, TRUE );
gmyth_program_info->chanstr = NULL;
}
if ( gmyth_program_info->chansign != NULL )
{
g_string_free( gmyth_program_info->chansign, TRUE );
gmyth_program_info->chansign = NULL;
}
/** The associated channel name. */
if ( gmyth_program_info->channame != NULL )
{
g_string_free( gmyth_program_info->channame, TRUE );
gmyth_program_info->channame = NULL;
}
if ( gmyth_program_info->chanOutputFilters != NULL )
{
g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
gmyth_program_info->chanOutputFilters = NULL;
}
if ( gmyth_program_info->seriesid != NULL )
{
g_string_free( gmyth_program_info->seriesid, TRUE );
gmyth_program_info->chanOutputFilters = NULL;
}
/** The program unique id. */
if ( gmyth_program_info->programid != NULL )
{
g_string_free( gmyth_program_info->programid, TRUE );
gmyth_program_info->programid = NULL;
}
if ( gmyth_program_info->catType != NULL )
{
g_string_free( gmyth_program_info->catType, TRUE );
gmyth_program_info->catType = NULL;
}
if ( gmyth_program_info->sortTitle != NULL )
{
g_string_free( gmyth_program_info->sortTitle, TRUE );
gmyth_program_info->sortTitle = NULL;
}
if ( gmyth_program_info->year != NULL )
{
g_string_free( gmyth_program_info->year, TRUE );
gmyth_program_info->year = NULL;
}
if ( gmyth_program_info->originalAirDate != NULL )
{
g_free( gmyth_program_info->originalAirDate);
gmyth_program_info->originalAirDate = NULL;
}
if ( gmyth_program_info->lastmodified != NULL )
{
g_free( gmyth_program_info->lastmodified );
gmyth_program_info->lastmodified = NULL;
}
if (gmyth_program_info->lastInUseTime != NULL)
{
g_free( gmyth_program_info->lastInUseTime );
gmyth_program_info->lastInUseTime = NULL;
}
if ( gmyth_program_info->schedulerid != NULL )
{
g_string_free( gmyth_program_info->schedulerid, TRUE );
gmyth_program_info->schedulerid = NULL;
}
if ( gmyth_program_info->recgroup != NULL )
{
g_string_free( gmyth_program_info->recgroup, TRUE );
gmyth_program_info->recgroup = NULL;
}
if ( gmyth_program_info->playgroup != NULL )
{
g_string_free( gmyth_program_info->playgroup, TRUE );
gmyth_program_info->playgroup = NULL;
}
/** The file name of the recorded program.*/
if ( gmyth_program_info->pathname != NULL)
{
g_string_free( gmyth_program_info->pathname, TRUE );
gmyth_program_info->pathname = NULL;
}
if ( gmyth_program_info->hostname != NULL )
{
g_string_free( gmyth_program_info->hostname, TRUE );
gmyth_program_info->hostname = NULL;
}
G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
}
static void
gmyth_program_info_finalize (GObject *object)
{
g_signal_handlers_destroy (object);
G_OBJECT_CLASS (gmyth_program_info_parent_class)->finalize (object);
}
/**
* Creates a new instance of GMythProgramInfo.
*
* @return a new instance of GMythProgramInfo.
*/
GMythProgramInfo*
gmyth_program_info_new (void)
{
GMythProgramInfo *program_info = GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
return program_info;
}
GMythStringList*
gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist)
{
g_return_val_if_fail (prog != NULL, NULL);
g_return_val_if_fail (slist != NULL, NULL);
gmyth_string_list_append_string (slist, prog->title); /* 0 */
gmyth_string_list_append_string (slist, prog->subtitle); /* 1 */
gmyth_string_list_append_string (slist, prog->description); /* 2 */
gmyth_string_list_append_string (slist, prog->category); /* 3 */
gmyth_string_list_append_string (slist, prog->chanid); /* 4 */
gmyth_string_list_append_string (slist, prog->chanstr); /* 5 */
gmyth_string_list_append_string (slist, prog->chansign); /* 6 */
gmyth_string_list_append_string (slist, prog->channame); /* 7 */
gmyth_string_list_append_string (slist, prog->pathname); /* 8 */
// fixme
gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
gmyth_string_list_append_int64 (slist, 10); /* 11 */
if (prog->startts)
gmyth_string_list_append_int (slist, prog->startts->tv_sec); /* 11 */ //DATETIME_TO_LIST(startts)
else
gmyth_string_list_append_int (slist, 0);
if (prog->endts)
gmyth_string_list_append_int (slist, prog->endts->tv_sec); /* 12 */ //DATETIME_TO_LIST(endts)
else
gmyth_string_list_append_int (slist, 0);
gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
gmyth_string_list_append_int (slist, prog->findid); /* 15 */
gmyth_string_list_append_string (slist, prog->hostname); /* 16 */
gmyth_string_list_append_int (slist, prog->sourceid); /* 17 */
gmyth_string_list_append_int (slist, prog->cardid); /* 18 */
gmyth_string_list_append_int (slist, prog->inputid); /* 19 */
gmyth_string_list_append_int (slist, prog->recpriority); /* 20 */
gmyth_string_list_append_int (slist, 0 /*prog->recstatus*/); /* 21 */
gmyth_string_list_append_int (slist, prog->recordid); /* 22 */
gmyth_string_list_append_int (slist, 0 /*prog->rectype*/); /* 23 */
gmyth_string_list_append_int (slist, 0 /*prog->dupin*/); /* 24 */
gmyth_string_list_append_int (slist, 0 /*prog->dupmethod*/); /* 25 */
gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0); /* 26 */ //DATETIME_TO_LIST(recstartts)
gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0); /* 27 */ //DATETIME_TO_LIST(recendts)
gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
gmyth_string_list_append_char_array (slist, "Default"); /* 30 */ //prog->(recgroup != "") ? recgroup : "Default")
gmyth_string_list_append_int (slist, prog->chancommfree); /* 31 */
gmyth_string_list_append_string (slist, prog->chanOutputFilters); /* 32 */
gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
gmyth_string_list_append_string (slist, prog->programid); /* 34 */
gmyth_string_list_append_string (slist, ""); /* 35 */
gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 36 */ //DATETIME_TO_LIST(lastmodified)
gmyth_string_list_append_int (slist, 0); /* 37 */ //FLOAT_TO_LIST(stars)
gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
gmyth_string_list_append_char_array (slist, "Default"); /* 40 */ //prog->(playgroup != "") ? playgroup : "Default")
gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
return slist;
}
GMythProgramInfo*
gmyth_program_info_from_string_list ( GMythStringList *slist )
{
GMythProgramInfo *prog = gmyth_program_info_new();
g_return_val_if_fail (slist != NULL, NULL);
/*
Unknown
1000
9
1000
Band
/mnt/store//1000_20070125110059.nuv
0
0
1169733659
1169735400
0
0
0
hmelo-desktop
0
1
0
0
-2
0
0
15
6
1169733659
1169735400
0
0
LiveTV
0
1169733659
0.000000
-1
0
Default
0
*/
prog->title = gmyth_string_list_get_string (slist, 0);
prog->subtitle = gmyth_string_list_get_string (slist, 1);
prog->description = gmyth_string_list_get_string (slist, 2);
prog->category = gmyth_string_list_get_string (slist, 3);
prog->chanid = gmyth_string_list_get_string (slist, 4);
prog->chanstr = gmyth_string_list_get_string (slist, 5);
prog->chansign = gmyth_string_list_get_string (slist, 6);
prog->channame = gmyth_string_list_get_string (slist, 7);
prog->pathname = gmyth_string_list_get_string (slist, 8);
prog->filesize = gmyth_string_list_get_int64 (slist, 9);
gmyth_string_list_get_int64 (slist, 10);
prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 11) ))->str ); //DATETIME_TO_LIST(startts)
prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 12) ))->str ); //DATETIME_TO_LIST(endts)
prog->duplicate = gmyth_string_list_get_int (slist, 13);
prog->shareable = gmyth_string_list_get_int (slist, 14);
prog->findid = gmyth_string_list_get_int (slist, 15);
prog->hostname = gmyth_string_list_get_string (slist, 16);
prog->sourceid = gmyth_string_list_get_int (slist, 17);
prog->cardid = gmyth_string_list_get_int (slist, 18);
prog->inputid = gmyth_string_list_get_int (slist, 19);
prog->recpriority = gmyth_string_list_get_int (slist, 20);
prog->reactivate = gmyth_string_list_get_int (slist, 21);
prog->recordid = gmyth_string_list_get_int (slist, 22);
gmyth_string_list_get_int (slist, 23);
gmyth_string_list_get_int (slist, 24);
gmyth_string_list_get_int (slist, 25);
prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 26) ))->str ); //DATETIME_TO_LIST(recstartts)
prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 27) ))->str ); //DATETIME_TO_LIST(recendts)
prog->repeat = gmyth_string_list_get_int (slist, 28);
prog->programflags = gmyth_string_list_get_int (slist, 29);
prog->recgroup = gmyth_string_list_get_string (slist, 30); //prog->(recgroup != "") ? recgroup : "Default")
prog->chancommfree = gmyth_string_list_get_int (slist, 31);
prog->chanOutputFilters = gmyth_string_list_get_string (slist, 32);
prog->seriesid = gmyth_string_list_get_string (slist, 33);
prog->programid = gmyth_string_list_get_string (slist, 34);
gmyth_string_list_get_string (slist, 35);
prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 36) ))->str ); //DATETIME_TO_LIST(lastmodified)
gmyth_string_list_get_int (slist, 37); //FLOAT_TO_LIST(stars)
prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat(
(time_t)gmyth_string_list_get_int (slist, 38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
prog->hasAirDate = gmyth_string_list_get_int (slist, 39);
prog->playgroup = gmyth_string_list_get_string (slist, 40); //prog->(playgroup != "") ? playgroup : "Default")
prog->recpriority2 = gmyth_string_list_get_int (slist, 41);
return prog;
}