# HG changeset patch # User rosfran # Date 1169588247 0 # Node ID 73fa3a0f2f085e31fdef7aad7d2ccb8392c1a2ef # Parent 96b436a81e53f0333d42161d7bee32b63f47b8a8 [svn r292] GObject format to the GMythProgramInfo, new actions such as GET_PROGRAM_INFO and GET_CURRENT_RECORDER. diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_common.c --- a/gmyth/src/gmyth_common.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_common.c Tue Jan 23 21:37:27 2007 +0000 @@ -104,6 +104,6 @@ free_program_data(gpointer data, gpointer user_data) { if(data) - g_free((GMythProgramInfo*) data); + g_object_unref((GMythProgramInfo*) data); } diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_common.h --- a/gmyth/src/gmyth_common.h Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_common.h Tue Jan 23 21:37:27 2007 +0000 @@ -31,6 +31,8 @@ #include #include +#include "gmyth_programinfo.h" + G_BEGIN_DECLS /** @@ -39,118 +41,13 @@ */ typedef struct { /** The channel ID in backend database */ - int channel_ID; + gint channel_ID; /** The channel name in backend database */ GString *channel_name; } GMythChannelInfo; - -/** - * The GMythProgramInfo structure represents a program information - * stored in the database. It could be a program from the EPG data, - * a program scheduled to be recorded, or a program already recorded. - */ -typedef struct { - - /** The channel unique ID. */ - GString *chanid; - - /** The program start time. */ - GTimeVal* startts; - /** The program end time. */ - GTimeVal* endts; - /** The recording schedule start time. */ - GTimeVal* recstartts; - /** The recording schedule end time */ - GTimeVal* recendts; - - /** The program title. */ - GString *title; - /** The program subtitle. */ - GString *subtitle; - /** The program description. */ - GString *description; - /** The program category. */ - GString *category; - - GString *chanstr; - GString *chansign; - /** The associated channel name. */ - GString *channame; - int chancommfree; - GString *chanOutputFilters; - - GString *seriesid; - /** The program unique id. */ - GString *programid; - GString * catType; - - GString * sortTitle; - - /** A flag informing if the program has video or not. */ - gboolean isVideo; - int lenMins; - - GString *year; - double stars; - int repeat; - - GTimeVal* originalAirDate; - GTimeVal* lastmodified; - GTimeVal* lastInUseTime; - - gboolean hasAirDate; - - int spread; - int startCol; - -// enum RecStatusType recstatus; -// enum RecStatusType oldrecstatus; -// enum RecStatusType savedrecstatus; - int recpriority2; - int reactivate; - - int recordid; - int parentid; - //enum RecordingType rectype; - //enum RecordingDupInType dupin; - //enum RecordingDupMethodType dupmethod; - - /** The backend video source id associated to this program.*/ - int sourceid; - /** the backend input id associated to this program.*/ - int inputid; - /** The backend card id associated to this program.*/ - int cardid; - gboolean shareable; - gboolean duplicate; - - GString * schedulerid; - int findid; - - int programflags; - int transcoder; - - //proginfo->spread = -1; - //proginfo->programflags = proginfo->getProgramFlags(); - - GString *recgroup; - GString *playgroup; - int recpriority; - - /** The file size of the recorded program.*/ - long long filesize; - /** The file name of the recorded program.*/ - GString *pathname; - GString *hostname; - - /* AvailableStatusType availableStatus;*/ - -} GMythProgramInfo; - - void gmyth_free_channel_list(GList *list); void gmyth_free_program_list(GList *list); diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_epg.c --- a/gmyth/src/gmyth_epg.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_epg.c Tue Jan 23 21:37:27 2007 +0000 @@ -36,6 +36,7 @@ #include #include "gmyth_epg.h" +#include "gmyth_programinfo.h" #include "gmyth_util.h" #include "gmyth_debug.h" @@ -240,7 +241,7 @@ (*proglist) = NULL; while ((row = mysql_fetch_row (res_set)) != NULL) { - GMythProgramInfo *p = g_new0 (GMythProgramInfo, 1); + GMythProgramInfo *p = gmyth_program_info_new (); p->chanid = g_string_new (row[0]); p->startts = gmyth_util_string_to_time_val (row[1]); diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.c Tue Jan 23 21:37:27 2007 +0000 @@ -31,7 +31,148 @@ #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->chanid = NULL; + + /** The program start time. */ + gmyth_program_info->startts = NULL; + /** The program end time. */ + gmyth_program_info->endts = NULL; + /** The recording schedule start time. */ + gmyth_program_info->recstartts = NULL; + /** The recording schedule end time */ + gmyth_program_info->recendts = NULL; + + /** The program title. */ + gmyth_program_info->title = NULL; + /** The program subtitle. */ + gmyth_program_info->subtitle = NULL; + /** The program description. */ + gmyth_program_info->description = NULL; + /** The program category. */ + gmyth_program_info->category = NULL; + + gmyth_program_info->chanstr = NULL; + gmyth_program_info->chansign = NULL; + /** The associated channel name. */ + gmyth_program_info->channame = NULL; + gmyth_program_info->chancommfree = 0; + gmyth_program_info->chanOutputFilters = NULL; + + gmyth_program_info->seriesid = NULL; + /** The program unique id. */ + gmyth_program_info->programid = NULL; + gmyth_program_info->catType = NULL; + + gmyth_program_info->sortTitle = NULL; + + /** A flag informing if the program has video or not. */ + gmyth_program_info->isVideo = FALSE; + gmyth_program_info->lenMins = 0; + + gmyth_program_info->year = NULL; + gmyth_program_info->stars = 0.0f; + gmyth_program_info->repeat = 0; + + gmyth_program_info->originalAirDate = NULL; + gmyth_program_info->lastmodified = NULL; + gmyth_program_info->lastInUseTime = NULL; + + 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->schedulerid = NULL; + gmyth_program_info->findid = 0; + + gmyth_program_info->programflags = 0; + gmyth_program_info->transcoder = 0; + + gmyth_program_info->recgroup = NULL; + gmyth_program_info->playgroup = NULL; + gmyth_program_info->recpriority = 0; + + /** The file size of the recorded program.*/ + gmyth_program_info->filesize = -1; + + /** The file name of the recorded program.*/ + gmyth_program_info->pathname = NULL; + gmyth_program_info->hostname = NULL; + +} + +static void +gmyth_program_info_dispose (GObject *object) +{ + GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object); + + 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) @@ -85,7 +226,54 @@ } GMythProgramInfo* -gmyth_program_info_from_string_list () +gmyth_program_info_from_string_list ( GMythStringList *slist ) { - return NULL; + GMythProgramInfo *prog = gmyth_program_info_new(); + + g_return_val_if_fail (slist != NULL, NULL); + + prog->title = gmyth_string_list_read_string (slist); + prog->subtitle = gmyth_string_list_read_string (slist); + prog->description = gmyth_string_list_read_string (slist); + prog->category = gmyth_string_list_read_string (slist); + prog->chanid = gmyth_string_list_read_string (slist); + prog->chanstr = gmyth_string_list_read_string (slist); + prog->chansign = gmyth_string_list_read_string (slist); + prog->channame = gmyth_string_list_read_string (slist); + prog->pathname = gmyth_string_list_read_string (slist); + prog->filesize = gmyth_string_list_read_int64 (slist); + + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(startts) + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(endts) + prog->duplicate = gmyth_string_list_read_int (slist); + prog->shareable = gmyth_string_list_read_int (slist); + prog->findid = gmyth_string_list_read_int (slist); + prog->hostname = gmyth_string_list_read_string (slist); + prog->sourceid = gmyth_string_list_read_int (slist); + prog->cardid = gmyth_string_list_read_int (slist); + prog->inputid = gmyth_string_list_read_int (slist); + prog->recpriority = gmyth_string_list_read_int (slist); + gmyth_string_list_read_int (slist); + prog->recordid = gmyth_string_list_read_int (slist, prog->recordid); + gmyth_string_list_read_int (slist); + gmyth_string_list_read_int (slist); + gmyth_string_list_read_int (slist); + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recstartts) + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recendts) + prog->repeat = gmyth_string_list_read_int (slist); + prog->programflags = gmyth_string_list_read_int (slist); + prog->recgroup = gmyth_string_list_read_string (slist); //prog->(recgroup != "") ? recgroup : "Default") + prog->chancommfree = gmyth_string_list_read_int (slist); + prog->chanOutputFilters = gmyth_string_list_read_string (slist); + prog->seriesid = gmyth_string_list_read_string (slist); + prog->programid = gmyth_string_list_read_string (slist); + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(lastmodified) + gmyth_string_list_read_int (slist); //FLOAT_TO_LIST(stars) + gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(QDateTime(originalAirDate)) + prog->hasAirDate = gmyth_string_list_read_int (slist); + prog->playgroup = gmyth_string_list_read_char_array (slist); //prog->(playgroup != "") ? playgroup : "Default") + prog->recpriority2 = gmyth_string_list_read_int (slist); + + return prog; } + diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.h Tue Jan 23 21:37:27 2007 +0000 @@ -1,11 +1,161 @@ +/** + * GMyth Library + * + * @file gmyth/gmyth_common.h + * + * @brief

This file contains basic common functions for the gmyth library. + * + * 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 + */ #ifndef _GMYTH_PROGRAMINFO_H #define _GMYTH_PROGRAMINFO_H +#include +#include + #include "gmyth_stringlist.h" -#include "gmyth_common.h" -GMythStringList* gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist); -GMythProgramInfo* gmyth_program_info_from_string_list (); +G_BEGIN_DECLS -#endif +#define GMYTH_PROGRAM_INFO_TYPE (gmyth_program_info_get_type ()) +#define GMYTH_PROGRAM_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfo)) +#define GMYTH_PROGRAM_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfoClass)) +#define IS_GMYTH_PROGRAM_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_PROGRAM_INFO_TYPE)) +#define IS_GMYTH_PROGRAM_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_PROGRAM_INFO_TYPE)) +#define GMYTH_PROGRAM_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfoClass)) + +typedef struct _GMythProgramInfo GMythProgramInfo; +typedef struct _GMythProgramInfoClass GMythProgramInfoClass; + +struct _GMythProgramInfoClass +{ + GObjectClass parent_class; + + /* callbacks */ +}; + +/** + * The GMythProgramInfo structure represents a program information + * stored in the database. It could be a program from the EPG data, + * a program scheduled to be recorded, or a program already recorded. + */ +struct _GMythProgramInfo +{ + GObject parent; + + /** The channel unique ID. */ + GString *chanid; + + /** The program start time. */ + GTimeVal* startts; + /** The program end time. */ + GTimeVal* endts; + /** The recording schedule start time. */ + GTimeVal* recstartts; + /** The recording schedule end time */ + GTimeVal* recendts; + + /** The program title. */ + GString *title; + /** The program subtitle. */ + GString *subtitle; + /** The program description. */ + GString *description; + /** The program category. */ + GString *category; + + GString *chanstr; + GString *chansign; + /** The associated channel name. */ + GString *channame; + gint chancommfree; + GString *chanOutputFilters; + + GString *seriesid; + /** The program unique id. */ + GString *programid; + GString * catType; + + GString * sortTitle; + + /** A flag informing if the program has video or not. */ + gboolean isVideo; + gint lenMins; + + GString *year; + gdouble stars; + gint repeat; + + GTimeVal* originalAirDate; + GTimeVal* lastmodified; + GTimeVal* lastInUseTime; + + gboolean hasAirDate; + + gint spread; + gint startCol; + + gint recpriority2; + gint reactivate; + + gint recordid; + gint parentid; + + /** The backend video source id associated to this program.*/ + gint sourceid; + /** the backend input id associated to this program.*/ + gint inputid; + /** The backend card id associated to this program.*/ + gint cardid; + gboolean shareable; + gboolean duplicate; + + GString * schedulerid; + gint findid; + + gint programflags; + gint transcoder; + + GString *recgroup; + GString *playgroup; + gint recpriority; + + /** The file size of the recorded program.*/ + gint64 filesize; + + /** The file name of the recorded program.*/ + GString *pathname; + GString *hostname; + + /* AvailableStatusType availableStatus;*/ + +}; + +GType gmyth_program_info_type (void); + +GMythProgramInfo* gmyth_program_info_new (void); + +GMythStringList* gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist); +GMythProgramInfo* gmyth_program_info_from_string_list (GMythStringList *slist); + +G_END_DECLS + +#endif /*_GMYTH_PROGRAMINFO_H*/ diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_recorder.c Tue Jan 23 21:37:27 2007 +0000 @@ -79,13 +79,13 @@ { g_signal_handlers_destroy (object); - GMythRecorder *recorder = GMYTH_RECORDER(object); + GMythRecorder *recorder = GMYTH_RECORDER(object); gmyth_debug ("[%s] Closing control socket", __FUNCTION__); gmyth_socket_close_connection(recorder->myth_socket); g_object_unref (recorder->myth_socket); - G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object); + G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object); } /** Creates a new instance of GMythRecorder. @@ -428,6 +428,52 @@ } +/** + * Requests the actual program info from the MythTV backend server. + * + * @param recorder The GMythRecorder instance. + * @return The actual program info. + */ +GMythProgramInfo * +gmyth_recorder_get_current_program_info ( GMythRecorder *recorder ) +{ + GMythStringList *str_list; + GMythProgramInfo *program_info = gmyth_program_info_new(); + GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER ); + + str_list = gmyth_string_list_new (); + + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); + + gmyth_string_list_append_string (str_list, tmp_str); + + if ( recorder->myth_socket->mythtv_version >= 26 ) + gmyth_string_list_append_string (str_list, g_string_new ("GET_CURRENT_RECORDING")); + else + gmyth_string_list_append_string (str_list, g_string_new ("GET_PROGRAM_INFO")); + + gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + + g_string_free (tmp_str, TRUE); + + if (str_list == NULL) { + g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", __FUNCTION__); + return FALSE; + } + + program_info = gmyth_program_info_from_string_list( str_list ); + + if ( NULL == program_info ) { + g_warning ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", __FUNCTION__); + g_object_unref (program_info); + return NULL; + } + + g_object_unref (str_list); + return program_info; + +} + gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder ) { diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_recorder.h Tue Jan 23 21:37:27 2007 +0000 @@ -31,6 +31,7 @@ #include #include "gmyth_socket.h" +#include "gmyth_programinfo.h" #include #include @@ -67,9 +68,9 @@ /* socket descriptor */ GMythSocket *myth_socket; - int recorder_num; + gint recorder_num; GString *hostname; - int port; + gint port; }; @@ -95,6 +96,8 @@ const gchar* channel); gboolean gmyth_recorder_pause_recording ( GMythRecorder *recorder ); + +GMythProgramInfo *gmyth_recorder_get_current_program_info ( GMythRecorder *recorder ); gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder ); diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_uri.c Tue Jan 23 21:37:27 2007 +0000 @@ -345,6 +345,8 @@ g_return_val_if_fail( uri != NULL && uri->uri != NULL && uri->uri->str != NULL, FALSE ); + gmyth_debug( "This URI is a LiveTV recording..." ); + return ( g_strstr_len( uri->uri->str, strlen( uri->uri->str ), "/?" ) != NULL ); } diff -r 96b436a81e53 -r 73fa3a0f2f08 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Mon Jan 22 21:22:55 2007 +0000 +++ b/gmyth/src/gmyth_util.c Tue Jan 23 21:37:27 2007 +0000 @@ -428,7 +428,7 @@ GMythStringList *slist; GMythProgramInfo *program; - program = g_new0 (GMythProgramInfo, 1); + program = gmyth_program_info_new(); program->pathname = g_string_new (filename); slist = gmyth_string_list_new (); @@ -455,7 +455,6 @@ #if !GLIB_CHECK_VERSION (2, 10, 0) - /* Hacked from glib 2.10 */ static time_t