# HG changeset patch # User renatofilho # Date 1182286873 -3600 # Node ID 4b5efa29028579b6cae7739dad775b6689cf2621 # Parent cb885ee44618c517250a8930ebe77362953a0cf0 [svn r761] create function to get recorded inf; fixe some headers indent diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_backendinfo.h --- a/gmyth/src/gmyth_backendinfo.h Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_backendinfo.h Tue Jun 19 22:01:13 2007 +0100 @@ -34,12 +34,19 @@ #include "gmyth_uri.h" G_BEGIN_DECLS -#define GMYTH_BACKEND_INFO_TYPE (gmyth_backend_info_get_type ()) -#define GMYTH_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfo)) -#define GMYTH_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) -#define IS_GMYTH_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_BACKEND_INFO_TYPE)) -#define IS_GMYTH_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE)) -#define GMYTH_BACKEND_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) +#define GMYTH_BACKEND_INFO_TYPE \ + (gmyth_backend_info_get_type ()) +#define GMYTH_BACKEND_INFO(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfo)) +#define GMYTH_BACKEND_INFO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) +#define IS_GMYTH_BACKEND_INFO(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_BACKEND_INFO_TYPE)) +#define IS_GMYTH_BACKEND_INFO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE)) +#define GMYTH_BACKEND_INFO_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass)) + typedef struct _GMythBackendInfo GMythBackendInfo; typedef struct _GMythBackendInfoClass GMythBackendInfoClass; @@ -56,7 +63,6 @@ struct _GMythBackendInfo { GObject parent; - /** The backend hostname or ip address. */ gchar *hostname; /** The username to connect to the mysql server. */ @@ -69,54 +75,36 @@ gint port; /** The backend status port for http connection */ gint status_port; - // gchar *path; - - // GMythURI* uri; }; -GType gmyth_backend_info_get_type(void); -GMythBackendInfo *gmyth_backend_info_new(void); -GMythBackendInfo *gmyth_backend_info_new_full(const gchar * hostname, - const gchar * username, - const gchar * password, - const gchar * db_name, - gint port); -GMythBackendInfo *gmyth_backend_info_new_with_uri(const gchar * uri_str); -void gmyth_backend_info_set_hostname(GMythBackendInfo * - backend_info, - const gchar * hostname); -void gmyth_backend_info_set_username(GMythBackendInfo * - backend_info, - const gchar * username); -void gmyth_backend_info_set_password(GMythBackendInfo * - backend_info, - const gchar * password); -void gmyth_backend_info_set_db_name(GMythBackendInfo * - backend_info, - const gchar * db_name); -void gmyth_backend_info_set_port(GMythBackendInfo * - backend_info, gint port); -void gmyth_backend_info_set_status_port(GMythBackendInfo * - backend_info, - gint port); - -const gchar *gmyth_backend_info_get_hostname(GMythBackendInfo * - backend_info); -const gchar *gmyth_backend_info_get_username(GMythBackendInfo * - backend_info); -const gchar *gmyth_backend_info_get_password(GMythBackendInfo * - backend_info); -const gchar *gmyth_backend_info_get_db_name(GMythBackendInfo * - backend_info); -gint gmyth_backend_info_get_port(GMythBackendInfo * - backend_info); - -GMythURI *gmyth_backend_info_get_uri(GMythBackendInfo * - backend_info); - -gboolean gmyth_backend_info_is_local_file(GMythBackendInfo * - backend_info); +GType gmyth_backend_info_get_type (void) G_GNUC_CONST;; +GMythBackendInfo* gmyth_backend_info_new (void); +GMythBackendInfo* gmyth_backend_info_new_full (const gchar *hostname, + const gchar *username, + const gchar *password, + const gchar *db_name, + gint port); +GMythBackendInfo* gmyth_backend_info_new_with_uri (const gchar *uri_str); +void gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, + const gchar *hostname); +void gmyth_backend_info_set_username (GMythBackendInfo *backend_info, + const gchar *username); +void gmyth_backend_info_set_password (GMythBackendInfo *backend_info, + const gchar *password); +void gmyth_backend_info_set_db_name (GMythBackendInfo *backend_info, + const gchar *db_name); +void gmyth_backend_info_set_port (GMythBackendInfo *backend_info, + gint port); +void gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info, + gint port); +const gchar* gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info); +const gchar* gmyth_backend_info_get_username (GMythBackendInfo *backend_info); +const gchar* gmyth_backend_info_get_password (GMythBackendInfo *backend_info); +const gchar* gmyth_backend_info_get_db_name (GMythBackendInfo *backend_info); +gint gmyth_backend_info_get_port (GMythBackendInfo *backend_info); +GMythURI* gmyth_backend_info_get_uri (GMythBackendInfo *backend_info); +gboolean gmyth_backend_info_is_local_file (GMythBackendInfo *backend_info); G_END_DECLS #endif /* __GMYTH_BACKEND_INFO_H__ */ diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_common.h --- a/gmyth/src/gmyth_common.h Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_common.h Tue Jun 19 22:01:13 2007 +0100 @@ -53,14 +53,11 @@ } GMythChannelInfo; -void gmyth_free_channel_list(GList * list); -void gmyth_free_program_list(GList * list); - -void gmyth_channel_info_free(GMythChannelInfo * channel_info); - - -void gmyth_channel_info_print(GMythChannelInfo * channel_info); -void gmyth_program_info_print(GMythProgramInfo * program_info); +void gmyth_free_channel_list (GList *list); +void gmyth_free_program_list (GList *list); +void gmyth_channel_info_free (GMythChannelInfo *channel_info); +void gmyth_channel_info_print (GMythChannelInfo *channel_info); +void gmyth_program_info_print (GMythProgramInfo *program_info); G_END_DECLS #endif /* GMYTH_COMMON_H_ */ diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_epg.h --- a/gmyth/src/gmyth_epg.h Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_epg.h Tue Jun 19 22:01:13 2007 +0100 @@ -60,31 +60,26 @@ GMythBackendInfo *backend_info; }; -GType gmyth_epg_get_type(void); - -GMythEPG *gmyth_epg_new(void); - -gboolean gmyth_epg_connect(GMythEPG * gmyth_epg, - GMythBackendInfo * backend_info); -gboolean gmyth_epg_disconnect(GMythEPG * gmyth_epg); - -gint gmyth_epg_get_channel_list(GMythEPG * gmyth_epg, - GList ** glist_ptr); -gint gmyth_epg_get_program_list(GMythEPG * gmyth_epg, - GList ** proglist, - const gint chanNum, - GTimeVal * starttime, - GTimeVal * endtime); - -GMythChannelInfo *gmyth_epg_get_channel_info(GMythEPG * gmyth_epg, - gint channel_id); - - -gboolean gmyth_epg_channel_has_icon(GMythEPG * gmyth_epg, - GMythChannelInfo * channel); -gboolean gmyth_epg_channel_get_icon(GMythEPG * gmyth_epg, - GMythChannelInfo * channel, - guint8 ** data, guint * length); +GType gmyth_epg_get_type (void) G_GNUC_CONST;; +GMythEPG* gmyth_epg_new (void); +gboolean gmyth_epg_connect (GMythEPG *gmyth_epg, + GMythBackendInfo *backend_info); +gboolean gmyth_epg_disconnect (GMythEPG *gmyth_epg); +gint gmyth_epg_get_channel_list (GMythEPG *gmyth_epg, + GList **glist_ptr); +gint gmyth_epg_get_program_list (GMythEPG *gmyth_epg, + GList **proglist, + gint chanNum, + GTimeVal *starttime, + GTimeVal *endtime); +GMythChannelInfo*gmyth_epg_get_channel_info (GMythEPG *gmyth_epg, + gint channel_id); +gboolean gmyth_epg_channel_has_icon (GMythEPG *gmyth_epg, + GMythChannelInfo *channel); +gboolean gmyth_epg_channel_get_icon (GMythEPG *gmyth_epg, + GMythChannelInfo *channel, + guint8 **data, + guint *length); G_END_DECLS #endif /* GMYTH_EPG_H_ */ diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_file.h --- a/gmyth/src/gmyth_file.h Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_file.h Tue Jun 19 22:01:13 2007 +0100 @@ -48,7 +48,8 @@ #define IS_GMYTH_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_FILE_TYPE)) #define IS_GMYTH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TYPE)) #define GMYTH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_TYPE, GMythFileClass)) - typedef enum { + +typedef enum { GMYTH_FILE_READ_OK = 0, GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1, GMYTH_FILE_READ_ERROR = 2, @@ -68,23 +69,22 @@ GObjectClass parent_class; }; -GType gmyth_file_get_type(void); -GMythFile *gmyth_file_new(GMythBackendInfo * backend_info); -gchar *gmyth_file_get_file_name(GMythFile * file); -void gmyth_file_set_file_name(GMythFile * file, - const gchar * filename); -gboolean gmyth_file_setup(GMythFile * file, const gchar * filename); -void gmyth_file_close(GMythFile * file); -gboolean gmyth_file_is_open(GMythFile * file); - -guint64 gmyth_file_get_filesize(GMythFile * file); -void gmyth_file_set_filesize(GMythFile * file, - guint64 filesize); - -gint64 gmyth_file_get_offset(GMythFile * file); -void gmyth_file_set_offset(GMythFile * file, gint64 offset); - -gchar *gmyth_file_get_uri(GMythFile * file); +GType gmyth_file_get_type (void); +GMythFile *gmyth_file_new (GMythBackendInfo *backend_info); +gchar *gmyth_file_get_file_name (GMythFile *file); +void gmyth_file_set_file_name (GMythFile *file, + const gchar *filename); +gboolean gmyth_file_setup (GMythFile *file, + const gchar *filename); +void gmyth_file_close (GMythFile *file); +gboolean gmyth_file_is_open (GMythFile *file); +guint64 gmyth_file_get_filesize (GMythFile *file); +void gmyth_file_set_filesize (GMythFile *file, + guint64 filesize); +gint64 gmyth_file_get_offset (GMythFile *file); +void gmyth_file_set_offset (GMythFile *file, + gint64 offset); +gchar *gmyth_file_get_uri (GMythFile *file); G_END_DECLS #endif /* __GMYTH_FILE_H__ */ diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.c Tue Jun 19 22:01:13 2007 +0100 @@ -347,6 +347,61 @@ return (*recorded_list == NULL) ? 0 : g_list_length(*recorded_list); } +RecordedInfo* +gmyth_scheduler_get_recorded_info (GMythScheduler *scheduler, + gint record_id) +{ + RecordedInfo *record; + MYSQL_RES *msql_res; + GString *query_str = g_string_new(""); + + assert(scheduler); + + g_string_printf(query_str, + "SELECT recordid,programid,chanid,starttime,progstart," + "endtime,progend,title,subtitle,description,category," + "filesize,basename FROM recorded " + "WHERE recgroup != 'LiveTV' AND recordid = %d", record_id); + + if (scheduler->msqlquery == NULL) { + g_warning("[%s] Scheduler db connection not initialized", + __FUNCTION__); + return -1; + } + + msql_res = + gmyth_query_process_statement(scheduler->msqlquery, + query_str->str); + + if (msql_res == NULL) { + g_warning("DB retrieval of recording list failed"); + return -1; + } else { + MYSQL_ROW row; + row = mysql_fetch_row(msql_res); + if (row != NULL) { + record = g_new0(RecordedInfo, 1); + record->record_id = (guint) g_ascii_strtoull(row[0], NULL, 10); + record->program_id = (guint) g_ascii_strtoull(row[1], NULL, 10); + record->channel_id = (guint) g_ascii_strtoull(row[2], NULL, 10); + record->start_time = gmyth_util_string_to_time_val(row[3]); + record->end_time = gmyth_util_string_to_time_val(row[5]); + record->title = g_string_new(row[7]); + record->subtitle = g_string_new(row[8]); + record->description = g_string_new(row[9]); + record->category = g_string_new(row[10]); + record->filesize = g_ascii_strtoull(row[11], NULL, 10); + record->basename = g_string_new(row[12]); + } + } + + mysql_free_result(msql_res); + g_string_free(query_str, TRUE); + + return record; +} + + static void _set_value(GMythQuery * myth_query, char *field, gchar * value, gint rec_id) diff -r cb885ee44618 -r 4b5efa290285 gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Thu Jun 14 20:40:47 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.h Tue Jun 19 22:01:13 2007 +0100 @@ -130,47 +130,37 @@ } RecordedInfo; -GType gmyth_scheduler_get_type(void); +GType gmyth_scheduler_get_type (void); -GMythScheduler *gmyth_scheduler_new(); -gboolean gmyth_scheduler_connect(GMythScheduler * scheduler, - GMythBackendInfo * backend_info); -gboolean gmyth_scheduler_connect_with_timeout(GMythScheduler * - scheduler, - GMythBackendInfo * - backend_info, +GMythScheduler *gmyth_scheduler_new (void); +gboolean gmyth_scheduler_connect (GMythScheduler * scheduler, + GMythBackendInfo * backend_info); +gboolean gmyth_scheduler_connect_with_timeout(GMythScheduler * scheduler, + GMythBackendInfo * backend_info, guint timeout); -gboolean gmyth_scheduler_disconnect(GMythScheduler * scheduler); - -gint gmyth_scheduler_get_schedule_list(GMythScheduler * - scheduler, - GList ** sched_list); -gint gmyth_scheduler_get_recorded_list(GMythScheduler * - scheduler, - GList ** rec_list); - -GMythProgramInfo *gmyth_scheduler_get_recorded(GMythScheduler * scheduler, - GString * channel, - GTimeVal * starttime); - -gint gmyth_scheduler_add_schedule(GMythScheduler * scheduler, - ScheduleInfo * schedule_info); - -gint gmyth_scheduler_delete_schedule(GMythScheduler * scheduler, - gint record_id); -gint gmyth_scheduler_delete_recorded(GMythScheduler * scheduler, - gint record_id); - -void gmyth_scheduler_recorded_info_get_preview(RecordedInfo * - info, - GByteArray * - data); - -void gmyth_recorded_info_free(RecordedInfo * info); -void gmyth_schedule_info_free(ScheduleInfo * info); - -void gmyth_recorded_info_list_free(GList * list); -void gmyth_schedule_info_list_free(GList * list); +gboolean gmyth_scheduler_disconnect (GMythScheduler * scheduler); +gint gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler, + GList ** sched_list); +gint gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler, + GList ** rec_list); +RecordedInfo* gmyth_scheduler_get_recorded_info (GMythScheduler *scheduler, + gint record_id); +GMythProgramInfo *gmyth_scheduler_get_recorded (GMythScheduler * scheduler, + GString * channel, + GTimeVal * starttime); +gint gmyth_scheduler_add_schedule (GMythScheduler * scheduler, + ScheduleInfo * schedule_info); +gint gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, + gint record_id); +gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler, + gint record_id); +void gmyth_scheduler_recorded_info_get_preview + (RecordedInfo * info, + GByteArray * data); +void gmyth_recorded_info_free (RecordedInfo * info); +void gmyth_schedule_info_free (ScheduleInfo * info); +void gmyth_recorded_info_list_free (GList * list); +void gmyth_schedule_info_list_free (GList * list); G_END_DECLS #endif /* __GMYTH_SCHEDULER_H__ */