[svn r583] New functions to get the channel list, fixes on the gmyth/gmyth.h references.
1.1 --- a/gmyth/src/gmyth.h Thu Apr 19 22:38:46 2007 +0100
1.2 +++ b/gmyth/src/gmyth.h Thu Apr 19 23:03:58 2007 +0100
1.3 @@ -29,29 +29,29 @@
1.4 #ifndef _GMYTH_H_
1.5 #define _GMYTH_H_
1.6
1.7 -#include <gmyth_backendinfo.h>
1.8 -#include <gmyth_common.h>
1.9 -#include <gmyth_debug.h>
1.10 -#include <gmyth_epg.h>
1.11 -#include <gmyth_file.h>
1.12 -#include <gmyth_file_local.h>
1.13 -#include <gmyth_file_transfer.h>
1.14 -#include <gmyth_livetv.h>
1.15 -#include <gmyth_monitor_handler.h>
1.16 -#include <gmyth_programinfo.h>
1.17 -#include <gmyth_query.h>
1.18 -#include <gmyth_recorder.h>
1.19 -#include <gmyth_remote_util.h>
1.20 -#include <gmyth_scheduler.h>
1.21 -#include <gmyth_socket.h>
1.22 -#include <gmyth_stringlist.h>
1.23 -#include <gmyth_tvchain.h>
1.24 -#include <gmyth_uri.h>
1.25 -#include <gmyth_util.h>
1.26 -#include <gmyth_http.h>
1.27 -#include <gmyth_vlc.h>
1.28 -#include <gmyth_jobqueue.h>
1.29 -#include <gmyth_transcoder.h>
1.30 -#include <gmyth_recprofile.h>
1.31 +#include <gmyth/gmyth_backendinfo.h>
1.32 +#include <gmyth/gmyth_common.h>
1.33 +#include <gmyth/gmyth_debug.h>
1.34 +#include <gmyth/gmyth_epg.h>
1.35 +#include <gmyth/gmyth_file.h>
1.36 +#include <gmyth/gmyth_file_local.h>
1.37 +#include <gmyth/gmyth_file_transfer.h>
1.38 +#include <gmyth/gmyth_livetv.h>
1.39 +#include <gmyth/gmyth_monitor_handler.h>
1.40 +#include <gmyth/gmyth_programinfo.h>
1.41 +#include <gmyth/gmyth_query.h>
1.42 +#include <gmyth/gmyth_recorder.h>
1.43 +#include <gmyth/gmyth_remote_util.h>
1.44 +#include <gmyth/gmyth_scheduler.h>
1.45 +#include <gmyth/gmyth_socket.h>
1.46 +#include <gmyth/gmyth_stringlist.h>
1.47 +#include <gmyth/gmyth_tvchain.h>
1.48 +#include <gmyth/gmyth_uri.h>
1.49 +#include <gmyth/gmyth_util.h>
1.50 +#include <gmyth/gmyth_http.h>
1.51 +#include <gmyth/gmyth_vlc.h>
1.52 +#include <gmyth/gmyth_jobqueue.h>
1.53 +#include <gmyth/gmyth_transcoder.h>
1.54 +#include <gmyth/gmyth_recprofile.h>
1.55
1.56 #endif /* _GMYTH_H_ */
2.1 --- a/gmyth/src/gmyth_livetv.c Thu Apr 19 22:38:46 2007 +0100
2.2 +++ b/gmyth/src/gmyth_livetv.c Thu Apr 19 23:03:58 2007 +0100
2.3 @@ -512,15 +512,19 @@
2.4 /* check if the program chain could be obtained from the MythTV protocol message */
2.5 if ( prog_info != NULL )
2.6 {
2.7 - /*
2.8 - GMythProgramInfo *ch_prog = gmyth_util_get_recording_from_channel( livetv->backend_info, channel );
2.9 - if ( ch_prog != NULL )
2.10 + gmyth_backend_info_set_username( livetv->tvchain->backend_info, "mythtv" );
2.11 + gmyth_backend_info_set_password( livetv->tvchain->backend_info, "mythtv" );
2.12 + gmyth_backend_info_set_db_name( livetv->tvchain->backend_info, "mythconverg" );
2.13 + GList* prog_list = gmyth_tvchain_get_program_info_from_channel( livetv->tvchain, channel );
2.14 + GMythProgramInfo *ch_prog = NULL;
2.15 + if ( prog_list != NULL && g_list_length(prog_list) > 0 )
2.16 {
2.17 - gmyth_debug( "Channel program info!" );
2.18 + ch_prog = (GMythProgramInfo*)g_list_nth_data( prog_list, 0 );
2.19 + gmyth_debug( "Channel program info (from a list with size = %d)!", g_list_length(prog_list) );
2.20 gmyth_program_info_print( ch_prog );
2.21 }
2.22 - */
2.23 - gmyth_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) );
2.24 +
2.25 + gmyth_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) );
2.26 livetv->proginfo = prog_info;
2.27 /* testing change channel */
2.28 //gmyth_recorder_spawntv_no_tvchain( livetv->recorder );
3.1 --- a/gmyth/src/gmyth_tvchain.c Thu Apr 19 22:38:46 2007 +0100
3.2 +++ b/gmyth/src/gmyth_tvchain.c Thu Apr 19 23:03:58 2007 +0100
3.3 @@ -284,6 +284,134 @@
3.4 return ret;
3.5 }
3.6
3.7 +/**
3.8 + * Get all the program info entries in the database.
3.9 + *
3.10 + * @param tvchain The GMythTVChain instance.
3.11 + *
3.12 + * @return A program info listage.
3.13 + */
3.14 +GList *
3.15 +gmyth_tvchain_get_program_info_list (GMythTVChain *tvchain)
3.16 +{
3.17 + GList *prog_list = NULL;
3.18 + MYSQL_ROW msql_row;
3.19 + MYSQL_RES *msql_res = NULL;
3.20 + GMythQuery *gmyth_query = NULL;
3.21 + GString *stmt_str = NULL;
3.22 +
3.23 + g_mutex_lock( tvchain->mutex );
3.24 +
3.25 + gmyth_query = gmyth_query_new ();
3.26 + if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
3.27 + gmyth_debug ("Could not connect to db.");
3.28 + goto done;
3.29 + }
3.30 +
3.31 + stmt_str = g_string_new ("");
3.32 + g_string_printf (stmt_str,
3.33 + "SELECT channum, icon "
3.34 + "FROM channel "
3.35 + "ORDER BY channum;");
3.36 +
3.37 + msql_res = gmyth_query_process_statement(gmyth_query, stmt_str->str);
3.38 + if (msql_res != NULL) {
3.39 +
3.40 + while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
3.41 + GMythProgramInfo *entry = gmyth_program_info_new();
3.42 + entry->channame = g_string_new (msql_row[0]);
3.43 + entry->chansign = g_string_new (msql_row[1]);
3.44 +
3.45 + gmyth_debug( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", entry->channame->str,
3.46 + entry->chansign->str, (gchar*)msql_row[0], (gchar*)msql_row[1] );
3.47 +
3.48 + prog_list = g_list_append (prog_list, entry);
3.49 + }
3.50 + } else {
3.51 + gmyth_debug ("Query error when trying to get the channel list from database!\n");
3.52 + goto done;
3.53 + }
3.54 +
3.55 +done:
3.56 + g_mutex_unlock( tvchain->mutex );
3.57 +
3.58 + if ( stmt_str != NULL )
3.59 + g_string_free (stmt_str, TRUE);
3.60 +
3.61 + if ( msql_res != NULL )
3.62 + mysql_free_result (msql_res);
3.63 +
3.64 + if ( gmyth_query != NULL )
3.65 + g_object_unref (gmyth_query);
3.66 +
3.67 + return prog_list;
3.68 +}
3.69 +
3.70 +/**
3.71 + * Get all the program info entries in the database, given a channel name.
3.72 + *
3.73 + * @param tvchain The GMythTVChain instance.
3.74 + * @param channel The channel name.
3.75 + *
3.76 + * @return A program info listage, based on a given channel name.
3.77 + */
3.78 +GList *
3.79 +gmyth_tvchain_get_program_info_from_channel (GMythTVChain *tvchain, const gchar* channel)
3.80 +{
3.81 + GList *prog_list = NULL;
3.82 + MYSQL_ROW msql_row;
3.83 + MYSQL_RES *msql_res = NULL;
3.84 + GMythQuery *gmyth_query = NULL;
3.85 + GString *stmt_str = NULL;
3.86 +
3.87 + g_mutex_lock( tvchain->mutex );
3.88 +
3.89 + gmyth_query = gmyth_query_new ();
3.90 + if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
3.91 + gmyth_debug ("Could not connect to db.");
3.92 + goto done;
3.93 + }
3.94 +
3.95 + stmt_str = g_string_new ("");
3.96 + g_string_printf (stmt_str,
3.97 + "SELECT channum, icon "
3.98 + "FROM channel "
3.99 + "WHERE channum = \"%s\" ORDER BY channum;",
3.100 + channel);
3.101 +
3.102 + msql_res = gmyth_query_process_statement(gmyth_query, stmt_str->str);
3.103 + if (msql_res != NULL) {
3.104 +
3.105 + while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
3.106 + GMythProgramInfo *entry = gmyth_program_info_new();
3.107 + entry->channame = g_string_new (msql_row[0]);
3.108 + entry->chansign = g_string_new (msql_row[1]);
3.109 +
3.110 + gmyth_debug( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", entry->channame->str,
3.111 + entry->chansign->str, (gchar*)msql_row[0], (gchar*)msql_row[1] );
3.112 +
3.113 + prog_list = g_list_append (prog_list, entry);
3.114 + }
3.115 + } else {
3.116 + gmyth_debug ("Query error when trying to get the channel list from database!\n");
3.117 + goto done;
3.118 + }
3.119 +
3.120 +done:
3.121 + g_mutex_unlock( tvchain->mutex );
3.122 +
3.123 + if ( stmt_str != NULL )
3.124 + g_string_free (stmt_str, TRUE);
3.125 +
3.126 + if ( msql_res != NULL )
3.127 + mysql_free_result (msql_res);
3.128 +
3.129 + if ( gmyth_query != NULL )
3.130 + g_object_unref (gmyth_query);
3.131 +
3.132 + return prog_list;
3.133 +}
3.134 +
3.135 /** Returns the internal index for the TV chain related to the given
3.136 * channel and start time.
3.137 *
4.1 --- a/gmyth/src/gmyth_tvchain.h Thu Apr 19 22:38:46 2007 +0100
4.2 +++ b/gmyth/src/gmyth_tvchain.h Thu Apr 19 23:03:58 2007 +0100
4.3 @@ -106,6 +106,11 @@
4.4 struct LiveTVChainEntry *entry);
4.5 GMythProgramInfo* gmyth_tvchain_get_program_at (GMythTVChain *tvchain, gint index);
4.6
4.7 +GList* gmyth_tvchain_get_program_info_from_channel (GMythTVChain *tvchain,
4.8 + const gchar* channel);
4.9 +
4.10 +GList* gmyth_tvchain_get_program_info_list (GMythTVChain *tvchain);
4.11 +
4.12 G_END_DECLS
4.13
4.14 #endif /*LIVETVCHAIN_H_*/