[svn r417] Added some documentation. Some string memory leak resolved. Memory handling errors in GMythStringlist solved. Some improvements in gmyth_jobqueue. Some other fixes
1.1 --- a/gmyth/src/gmyth_backendinfo.c Sat Mar 10 15:01:25 2007 +0000
1.2 +++ b/gmyth/src/gmyth_backendinfo.c Mon Mar 19 17:11:23 2007 +0000
1.3 @@ -59,7 +59,7 @@
1.4 backend_info->password = NULL;
1.5 backend_info->db_name = NULL;
1.6 backend_info->port = -1;
1.7 - backend_info->uri = NULL;
1.8 + backend_info->status_port = -1;
1.9 }
1.10
1.11 static void
1.12 @@ -77,14 +77,8 @@
1.13 backend_info->password = NULL;
1.14 backend_info->db_name = NULL;
1.15 backend_info->port = -1;
1.16 + backend_info->status_port = -1;
1.17
1.18 -/*
1.19 - if ( backend_info->uri != NULL )
1.20 - {
1.21 - g_object_unref(backend_info->uri);
1.22 - backend_info->uri = NULL;
1.23 - }
1.24 -*/
1.25 G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object);
1.26 }
1.27
1.28 @@ -115,9 +109,6 @@
1.29 {
1.30 GMythBackendInfo *backend_info =
1.31 GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
1.32 -
1.33 - backend_info->uri = gmyth_uri_new_with_value(
1.34 - g_strdup_printf( "myth://%s:%s@%s:%d/?%s", username, password, hostname, port, db_name ) );
1.35
1.36 gmyth_backend_info_set_hostname (backend_info, hostname);
1.37 gmyth_backend_info_set_username (backend_info, username);
1.38 @@ -134,19 +125,21 @@
1.39 GMythBackendInfo *backend_info =
1.40 GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
1.41
1.42 - backend_info->uri = gmyth_uri_new_with_value( uri_str );
1.43 + GMythURI *uri = gmyth_uri_new_with_value( uri_str );
1.44
1.45 - gchar** path_parts = g_strsplit( gmyth_uri_get_path( backend_info->uri ), "&", -1 );
1.46 + gchar** path_parts = g_strsplit( gmyth_uri_get_path (uri), "&", -1 );
1.47
1.48 - gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host ( backend_info->uri ) );
1.49 - gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( backend_info->uri ) );
1.50 - gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( backend_info->uri ) );
1.51 + gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri) );
1.52 + gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user (uri) );
1.53 + gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password (uri) );
1.54 +
1.55 /* gets the path info to database name, from the URI, and removes the trash chars */
1.56 gmyth_backend_info_set_db_name (backend_info, path_parts != NULL && path_parts[0] != NULL
1.57 && strlen( path_parts[0] ) > 0 ? g_strstrip( g_strdup( g_strdelimit( path_parts[0], "/?", ' ' ) ) )
1.58 - : gmyth_uri_get_path( backend_info->uri ) );
1.59 - gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port( backend_info->uri ) );
1.60 + : gmyth_uri_get_path (uri) );
1.61 + gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port (uri) );
1.62
1.63 + g_object_unref (uri);
1.64 g_strfreev( path_parts );
1.65
1.66 return backend_info;
1.67 @@ -157,11 +150,10 @@
1.68 {
1.69 g_return_if_fail (backend_info != NULL);
1.70
1.71 - if ( NULL == hostname || strlen(hostname) <= 0 )
1.72 - {
1.73 - gmyth_debug ( "Error trying to set a hostname equals to NULL." );
1.74 + if ( NULL == hostname || strlen(hostname) <= 0 ) {
1.75 + gmyth_debug ( "Error trying to set a hostname equals to NULL." );
1.76 } else {
1.77 - backend_info->hostname = g_strdup (hostname);
1.78 + backend_info->hostname = g_strdup (hostname);
1.79 }
1.80 }
1.81
1.82 @@ -194,11 +186,10 @@
1.83 {
1.84 g_return_if_fail (backend_info != NULL);
1.85
1.86 - if ( port <= 0 )
1.87 - {
1.88 - gmyth_debug ( "Error trying to set a port less than 0." );
1.89 + if ( port <= 0 ) {
1.90 + gmyth_debug ( "Error trying to set a port less than 0." );
1.91 } else {
1.92 - backend_info->port = port;
1.93 + backend_info->port = port;
1.94 }
1.95 }
1.96
1.97 @@ -207,11 +198,10 @@
1.98 {
1.99 g_return_if_fail (backend_info != NULL);
1.100
1.101 - if ( port <= 0 )
1.102 - {
1.103 - gmyth_debug ( "Error trying to set the status port to less than zero." );
1.104 + if ( port <= 0 ) {
1.105 + gmyth_debug ( "Error trying to set the status port to less than zero." );
1.106 } else {
1.107 - backend_info->status_port = port;
1.108 + backend_info->status_port = port;
1.109 }
1.110 }
1.111
1.112 @@ -255,18 +245,17 @@
1.113 return backend_info->port;
1.114 }
1.115
1.116 -const GMythURI*
1.117 +GMythURI*
1.118 gmyth_backend_info_get_uri (GMythBackendInfo *backend_info)
1.119 {
1.120 -
1.121 - if ( NULL == backend_info->uri )
1.122 - {
1.123 - backend_info->uri = gmyth_uri_new_with_value(
1.124 - g_strdup_printf( "myth://%s:%s@%s:%d/?%s", backend_info->username, backend_info->password,
1.125 - backend_info->hostname, backend_info->port, backend_info->db_name ) );
1.126 - }
1.127 -
1.128 - return backend_info->uri;
1.129 + GMythURI *uri = NULL;
1.130 + gchar* uri_str = g_strdup_printf( "myth://%s:%s@%s:%d/?%s", backend_info->username, backend_info->password,
1.131 + backend_info->hostname, backend_info->port, backend_info->db_name );
1.132 + uri = gmyth_uri_new_with_value (uri_str);
1.133 +
1.134 + g_free (uri_str);
1.135 +
1.136 + return uri;
1.137 }
1.138
1.139
2.1 --- a/gmyth/src/gmyth_backendinfo.h Sat Mar 10 15:01:25 2007 +0000
2.2 +++ b/gmyth/src/gmyth_backendinfo.h Mon Mar 19 17:11:23 2007 +0000
2.3 @@ -56,15 +56,21 @@
2.4 {
2.5 GObject parent;
2.6
2.7 + /** The backend hostname or ip address. */
2.8 gchar *hostname;
2.9 + /** The username to connect to the mysql server. */
2.10 gchar *username;
2.11 + /** The password to connect to the mysql server. */
2.12 gchar *password;
2.13 + /** The mythtv's mysql database name. */
2.14 gchar *db_name;
2.15 + /** The backend port. */
2.16 gint port;
2.17 + /** The backend status port for http connection */
2.18 gint status_port;
2.19 - gchar *path;
2.20 + //gchar *path;
2.21
2.22 - GMythURI* uri;
2.23 + //GMythURI* uri;
2.24 };
2.25
2.26
2.27 @@ -94,9 +100,7 @@
2.28 const gchar* gmyth_backend_info_get_db_name (GMythBackendInfo *backend_info);
2.29 gint gmyth_backend_info_get_port (GMythBackendInfo *backend_info);
2.30
2.31 -const GMythURI* gmyth_backend_info_get_uri (GMythBackendInfo *backend_info);
2.32 -
2.33 -/*const gchar* gmyth_backend_info_get_full_uri (GMythBackendInfo *backend_info);*/
2.34 +GMythURI* gmyth_backend_info_get_uri (GMythBackendInfo *backend_info);
2.35
2.36 G_END_DECLS
2.37
3.1 --- a/gmyth/src/gmyth_common.c Sat Mar 10 15:01:25 2007 +0000
3.2 +++ b/gmyth/src/gmyth_common.c Mon Mar 19 17:11:23 2007 +0000
3.3 @@ -36,26 +36,24 @@
3.4 static void free_channel_data(gpointer data, gpointer user_data);
3.5 static void free_program_data(gpointer data, gpointer user_data);
3.6
3.7 -/** Frees the memory allocated to the GMythChannelInfo objects inside list.
3.8 +/**
3.9 + * Frees the memory allocated to the GMythChannelInfo objects inside list.
3.10 * The list memory is also released by g_list_free(). If LIST is NULL it
3.11 * simply returns.
3.12 *
3.13 * @param list the GList containing a list of GMythChannelInfo to free.
3.14 */
3.15 void
3.16 -gmyth_free_channel_list(GList *list)
3.17 +gmyth_free_channel_list (GList *list)
3.18 {
3.19 - if (list == NULL) {
3.20 - g_warning ("%s received null GList as parameter", __FUNCTION__);
3.21 - return;
3.22 - }
3.23 + g_return_if_fail (list != NULL);
3.24
3.25 - g_list_foreach (list, free_channel_data, NULL);
3.26 -
3.27 - g_list_free (list);
3.28 + g_list_foreach (list, free_channel_data, NULL);
3.29 + g_list_free (list);
3.30 }
3.31
3.32 -/** Frees the memory allocated to the GMythProgramInfo objects inside list.
3.33 +/**
3.34 + * Frees the memory allocated to the GMythProgramInfo objects inside list.
3.35 * The list memory is also released by g_list_free(). If list is NULL it
3.36 * simply returns.
3.37 *
3.38 @@ -64,61 +62,63 @@
3.39 void
3.40 gmyth_free_program_list(GList *list)
3.41 {
3.42 - if (list == NULL) {
3.43 - g_warning ("%s received null GList as parameter", __FUNCTION__);
3.44 - return;
3.45 - }
3.46 + g_return_if_fail (list != NULL);
3.47
3.48 - g_list_foreach (list, free_program_data, NULL);
3.49 -
3.50 - g_list_free (list);
3.51 + g_list_foreach (list, free_program_data, NULL);
3.52 + g_list_free (list);
3.53 }
3.54
3.55 +#ifdef GMYTH_USE_DEBUG
3.56 +/**
3.57 + * Prints the channel info to the standard output. The gmyth debug must be enabled.
3.58 + * @param channel_info the GMythChannelInfo instance
3.59 + */
3.60 void
3.61 -gmyth_channel_info_print(GMythChannelInfo *channel_info)
3.62 +gmyth_channel_info_print (GMythChannelInfo *channel_info)
3.63 {
3.64 - if ( channel_info != NULL )
3.65 - {
3.66 - gmyth_debug("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n",
3.67 + if ( channel_info != NULL ) {
3.68 + gmyth_debug("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n",
3.69 channel_info->channel_name->str, channel_info->channel_num->str,
3.70 channel_info->channel_ID);
3.71 - }
3.72 + }
3.73 }
3.74
3.75 +/**
3.76 + * Prints the program info to the standard output. The gmyth debug must be enabled.
3.77 + * @param channel_info the GMythProgramInfo instance
3.78 + */
3.79 void
3.80 gmyth_program_info_print(GMythProgramInfo *program_info)
3.81 {
3.82 -
3.83 - if ( program_info != NULL ) {
3.84 -
3.85 - gmyth_debug( "ProgramInfo\n\tTitle = %s\n\t"
3.86 - "Description = %s\n\t"
3.87 - "Start time= %s\t"
3.88 - "End time = %s\n"
3.89 - "Path name = %s\n"
3.90 - "File size = %lld\n"
3.91 - , program_info->title->str,
3.92 - program_info->description->str,
3.93 - gmyth_util_time_to_string_from_time_val(program_info->startts),
3.94 - gmyth_util_time_to_string_from_time_val(program_info->endts),
3.95 - program_info->pathname->str,
3.96 - program_info->filesize );
3.97 -
3.98 - }
3.99 -
3.100 + g_return_if_fail (program_info);
3.101 +
3.102 + gmyth_debug( "ProgramInfo\n\tTitle = %s\n\t"
3.103 + "Description = %s\n\t"
3.104 + "Start time= %s\t"
3.105 + "End time = %s\n"
3.106 + "Path name = %s\n"
3.107 + "File size = %lld\n",
3.108 + program_info->title->str,
3.109 + program_info->description->str,
3.110 + gmyth_util_time_to_string_from_time_val(program_info->startts),
3.111 + gmyth_util_time_to_string_from_time_val(program_info->endts),
3.112 + program_info->pathname->str,
3.113 + program_info->filesize );
3.114 }
3.115 +#endif
3.116
3.117 static void
3.118 -free_channel_data(gpointer data, gpointer user_data)
3.119 +free_channel_data (gpointer data, gpointer user_data)
3.120 {
3.121 - if(data)
3.122 - g_free((GMythChannelInfo*) data);
3.123 + // Frees the GMythChannelInfo structure
3.124 + g_free(data);
3.125 }
3.126
3.127 static void
3.128 free_program_data(gpointer data, gpointer user_data)
3.129 {
3.130 - if(data)
3.131 - g_object_unref((GMythProgramInfo*) data);
3.132 + g_return_if_fail (data != NULL);
3.133 +
3.134 + g_object_unref((GMythProgramInfo*) data);
3.135 }
3.136
4.1 --- a/gmyth/src/gmyth_common.h Sat Mar 10 15:01:25 2007 +0000
4.2 +++ b/gmyth/src/gmyth_common.h Mon Mar 19 17:11:23 2007 +0000
4.3 @@ -53,8 +53,10 @@
4.4 void gmyth_free_channel_list(GList *list);
4.5 void gmyth_free_program_list(GList *list);
4.6
4.7 -void gmyth_channel_info_print(GMythChannelInfo *channel_info);
4.8 -void gmyth_program_info_print(GMythProgramInfo *program_info);
4.9 +#ifdef GMYTH_USE_DEBUG
4.10 +void gmyth_channel_info_print (GMythChannelInfo *channel_info);
4.11 +void gmyth_program_info_print (GMythProgramInfo *program_info);
4.12 +#endif
4.13
4.14 G_END_DECLS
4.15
5.1 --- a/gmyth/src/gmyth_epg.c Sat Mar 10 15:01:25 2007 +0000
5.2 +++ b/gmyth/src/gmyth_epg.c Mon Mar 19 17:11:23 2007 +0000
5.3 @@ -51,7 +51,7 @@
5.4 static void
5.5 gmyth_epg_class_init (GMythEPGClass *klass)
5.6 {
5.7 - GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
5.8 + GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
5.9
5.10 gobject_class->dispose = gmyth_epg_dispose;
5.11 gobject_class->finalize = gmyth_epg_finalize;
5.12 @@ -66,9 +66,14 @@
5.13 static void
5.14 gmyth_epg_dispose (GObject *object)
5.15 {
5.16 - //GMythEPG *gmyth_epg = GMYTH_EPG(object);
5.17 + GMythEPG *gmyth_epg = GMYTH_EPG(object);
5.18
5.19 - G_OBJECT_CLASS (gmyth_epg_parent_class)->dispose (object);
5.20 + if (gmyth_epg->sqlquery != NULL) {
5.21 + g_object_unref (gmyth_epg->sqlquery);
5.22 + gmyth_epg->sqlquery = NULL;
5.23 + }
5.24 +
5.25 + G_OBJECT_CLASS (gmyth_epg_parent_class)->dispose (object);
5.26 }
5.27
5.28 static void
5.29 @@ -103,7 +108,7 @@
5.30 {
5.31 assert(gmyth_epg);
5.32
5.33 - if (gmyth_epg->sqlquery == NULL) {
5.34 + if (gmyth_epg->sqlquery == NULL) {
5.35 gmyth_debug ("[%s] Creating gmyth_query", __FUNCTION__);
5.36 gmyth_epg->sqlquery = gmyth_query_new ( );
5.37 }
5.38 @@ -124,14 +129,14 @@
5.39 gboolean
5.40 gmyth_epg_disconnect (GMythEPG *gmyth_epg)
5.41 {
5.42 - assert(gmyth_epg);
5.43 + assert(gmyth_epg);
5.44
5.45 - if (gmyth_epg->sqlquery != NULL) {
5.46 - g_object_unref (gmyth_epg->sqlquery);
5.47 + if (gmyth_epg->sqlquery != NULL) {
5.48 + g_object_unref (gmyth_epg->sqlquery);
5.49 gmyth_epg->sqlquery = NULL;
5.50 - }
5.51 + }
5.52
5.53 - return TRUE;
5.54 + return TRUE;
5.55 }
5.56
5.57 /** Retrieves the available list of channels from the backend Mysql database.
5.58 @@ -143,14 +148,14 @@
5.59 gint
5.60 gmyth_epg_get_channel_list (GMythEPG *gmyth_epg, GList **glist_ptr)
5.61 {
5.62 - MYSQL_RES *msql_res;
5.63 + MYSQL_RES *msql_res;
5.64
5.65 assert(gmyth_epg);
5.66
5.67 msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery,
5.68 "SELECT chanid, channum, name FROM channel;");
5.69
5.70 - (*glist_ptr) = NULL;
5.71 + (*glist_ptr) = NULL;
5.72
5.73 if (msql_res == NULL) {
5.74 g_warning ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
5.75 @@ -159,19 +164,20 @@
5.76 MYSQL_ROW row;
5.77 GMythChannelInfo *channel_info;
5.78
5.79 - while ((row = mysql_fetch_row (msql_res)) != NULL){
5.80 + while ((row = mysql_fetch_row (msql_res)) != NULL) {
5.81
5.82 - channel_info = g_new0(GMythChannelInfo, 1);
5.83 + channel_info = g_new0(GMythChannelInfo, 1);
5.84 channel_info->channel_ID = g_ascii_strtoull (row[0], NULL, 10);
5.85 channel_info->channel_num = g_string_new (row[1]);
5.86 channel_info->channel_name = g_string_new (row[2]);
5.87 -
5.88 +#ifdef GMYTH_USE_DEBUG
5.89 gmyth_channel_info_print(channel_info);
5.90 -
5.91 +#endif
5.92 (*glist_ptr) = g_list_append ((*glist_ptr), channel_info);
5.93 }
5.94 }
5.95 mysql_free_result (msql_res);
5.96 +
5.97 return (!(*glist_ptr)) ? 0 : g_list_length (*glist_ptr);
5.98 }
5.99
5.100 @@ -286,8 +292,8 @@
5.101
5.102 *proglist = g_list_append((*proglist), p);
5.103
5.104 -#if 0
5.105 - gmyth_program_info_print(p);
5.106 +#ifdef GMYTH_USE_DEBUG
5.107 + gmyth_program_info_print (p);
5.108 #endif
5.109 }
5.110
6.1 --- a/gmyth/src/gmyth_jobqueue.c Sat Mar 10 15:01:25 2007 +0000
6.2 +++ b/gmyth/src/gmyth_jobqueue.c Mon Mar 19 17:11:23 2007 +0000
6.3 @@ -66,11 +66,14 @@
6.4 * @return the value returned by the backend
6.5 *
6.6 */
6.7 -static GString* send_command(GMythSocket *socket, gchar* action,
6.8 +static gchar* send_command(GMythSocket *socket, gchar* action,
6.9 gchar* job, gint chanid, gchar* starttime,
6.10 gchar* options)
6.11 {
6.12 GString* command = g_string_new ("");
6.13 + GString* ret_str;
6.14 + gchar* ret;
6.15 +
6.16 GMythStringList *retlist = gmyth_string_list_new();
6.17
6.18 g_string_printf(command, "JOBQUEUE %s %s %d %s %s", action, job,
6.19 @@ -83,7 +86,16 @@
6.20
6.21 // receive answer
6.22 gmyth_socket_read_stringlist (socket, retlist);
6.23 - return gmyth_string_list_get_string(retlist, 0);
6.24 + ret_str = gmyth_string_list_get_string(retlist, 0);
6.25 +
6.26 + ret = ret_str->str;
6.27 + g_string_free( ret_str, FALSE);
6.28 + g_string_free (command, TRUE);
6.29 +
6.30 + gmyth_string_list_clear_all (retlist);
6.31 + g_object_unref (retlist);
6.32 +
6.33 + return ret;
6.34 }
6.35
6.36
6.37 @@ -96,9 +108,9 @@
6.38 */
6.39 static gboolean test_result(gchar* ret, gchar* value)
6.40 {
6.41 - if (g_ascii_strcasecmp(ret, value) == 0)
6.42 + if (g_ascii_strcasecmp(ret, value) == 0) {
6.43 return TRUE;
6.44 - else {
6.45 + } else {
6.46 g_debug("JobQueue Error: %s", ret);
6.47 return FALSE;
6.48 }
6.49 @@ -111,14 +123,15 @@
6.50 * @return TRUE if the job was added, FALSE if not
6.51 *
6.52 */
6.53 -gint gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job)
6.54 +gboolean gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job)
6.55 {
6.56 - //fixme: disconnect this socket
6.57 GMythSocket *socket = backend_connect (transcode->backend_info);
6.58 - if (socket != NULL)
6.59 - {
6.60 + gboolean res = FALSE;
6.61 +
6.62 + if (socket != NULL) {
6.63 GString* options = g_string_new ("");
6.64 -
6.65 + gchar* ret;
6.66 +
6.67 if (g_ascii_strcasecmp(job, "JOB_TRANSCODE") == 0)
6.68 {
6.69 if (transcode->cutlist)
6.70 @@ -131,21 +144,19 @@
6.71 if (transcode->profile != NULL)
6.72 g_string_append_printf(options, " %s", transcode->profile);
6.73 }
6.74 + ret = send_command(socket, "ADD", job, transcode->chanid,
6.75 + transcode->starttime, options->str);
6.76 + res = test_result(ret, "JOBQUEUE_OK");
6.77 + gmyth_socket_close_connection (socket);
6.78
6.79 - //fixme: allocation
6.80 - GString* ret = send_command(socket, "ADD", job, transcode->chanid,
6.81 - transcode->starttime, options->str);
6.82 -
6.83 - g_free(options);
6.84 - g_free(socket);
6.85 - int res = test_result(ret->str, "JOBQUEUE_OK");
6.86 - g_free(ret);
6.87 -
6.88 - return res;
6.89 + g_object_unref (socket);
6.90 + g_string_free (options, TRUE);
6.91 + g_free (ret);
6.92 } else {
6.93 g_debug("JobQueue Connection Failed");
6.94 - return -1;
6.95 }
6.96 +
6.97 + return res;
6.98 }
6.99
6.100 /** Function to change a job cmd inside JOBQUEUE
6.101 @@ -160,19 +171,23 @@
6.102 gchar* job)
6.103 {
6.104 GMythSocket *socket = backend_connect(transcode->backend_info);
6.105 - if (socket != NULL)
6.106 - {
6.107 + gboolean res;
6.108 +
6.109 + if (socket != NULL) {
6.110 GString* ret = send_command(socket, action, job,
6.111 transcode->chanid,
6.112 transcode->starttime, "");
6.113
6.114 - g_free(socket);
6.115 - int res = test_result(ret->str, "JOBQUEUE_CHANGED_CMD_OK");
6.116 - g_free(ret);
6.117 + res = test_result(ret->str, "JOBQUEUE_CHANGED_CMD_OK");
6.118
6.119 - return res;
6.120 + gmyth_socket_close_connection (socket);
6.121 + g_object_unref (socket);
6.122 +
6.123 + g_string_free(ret, TRUE);
6.124 +
6.125 } else {
6.126 g_debug("JobQueue Connection Failed");
6.127 - return -1;
6.128 }
6.129 +
6.130 + return res;
6.131 }
7.1 --- a/gmyth/src/gmyth_jobqueue.h Sat Mar 10 15:01:25 2007 +0000
7.2 +++ b/gmyth/src/gmyth_jobqueue.h Mon Mar 19 17:11:23 2007 +0000
7.3 @@ -44,8 +44,8 @@
7.4
7.5 G_BEGIN_DECLS
7.6
7.7 -gint gmyth_jobqueue_add_job (GMythTranscoder* transcoder, gchar* job);
7.8 -gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcoder, gchar* action,
7.9 +gboolean gmyth_jobqueue_add_job (GMythTranscoder* transcoder, gchar* job);
7.10 +gboolean gmyth_jobqueue_change_cmd (GMythTranscoder* transcoder, gchar* action,
7.11 gchar* job);
7.12
7.13 G_END_DECLS
8.1 --- a/gmyth/src/gmyth_livetv.c Sat Mar 10 15:01:25 2007 +0000
8.2 +++ b/gmyth/src/gmyth_livetv.c Mon Mar 19 17:11:23 2007 +0000
8.3 @@ -458,24 +458,15 @@
8.4 } /* if - Program Info */
8.5
8.6 /* prints program info data text */
8.7 +#ifdef GMYTH_USE_DEBUG
8.8 gmyth_debug( "New ProgramInfo...\n" );
8.9 gmyth_program_info_print( prog_info );
8.10 - /* DEBUG message */
8.11 - /*
8.12 - gmyth_debug( "Old ProgramInfo...\n" );
8.13 - gmyth_program_info_print( livetv->proginfo );
8.14 - */
8.15 - /*
8.16 - GMythProgramInfo* prog_inf = gmyth_recorder_get_next_program_info( livetv->recorder, BROWSE_DIRECTION_UP );
8.17 -
8.18 - gmyth_debug( "Next ProgramInfo...\n" );
8.19 - gmyth_program_info_print( prog_inf );
8.20 - */
8.21 -
8.22 +#endif
8.23 +
8.24 /* check if the program chain could be obtained from the MythTV protocol message */
8.25 if ( prog_info != NULL )
8.26 {
8.27 - g_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) );
8.28 + gmyth_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) );
8.29 livetv->proginfo = prog_info;
8.30 /* testing change channel */
8.31 //gmyth_recorder_spawntv_no_tvchain( livetv->recorder );
9.1 --- a/gmyth/src/gmyth_programinfo.c Sat Mar 10 15:01:25 2007 +0000
9.2 +++ b/gmyth/src/gmyth_programinfo.c Mon Mar 19 17:11:23 2007 +0000
9.3 @@ -107,8 +107,8 @@
9.4 GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
9.5
9.6 if ( gmyth_program_info->chanid != NULL ) {
9.7 - g_string_free( gmyth_program_info->chanid, TRUE );
9.8 - gmyth_program_info->chanid = NULL;
9.9 + g_string_free( gmyth_program_info->chanid, TRUE );
9.10 + gmyth_program_info->chanid = NULL;
9.11 }
9.12
9.13 /** The program start time. */
10.1 --- a/gmyth/src/gmyth_scheduler.c Sat Mar 10 15:01:25 2007 +0000
10.2 +++ b/gmyth/src/gmyth_scheduler.c Mon Mar 19 17:11:23 2007 +0000
10.3 @@ -497,6 +497,8 @@
10.4 gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime);
10.5
10.6 assert(scheduler);
10.7 +
10.8 + gmyth_debug ("[%s] channel: %s", __FUNCTION__, channel->str);
10.9
10.10 if (scheduler->msqlquery == NULL) {
10.11 g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
10.12 @@ -564,7 +566,7 @@
10.13 proginfo->playgroup = g_string_new (msql_row[21]);
10.14 proginfo->recpriority = (gint) g_ascii_strtoull (msql_row[22], NULL, 10);
10.15
10.16 - proginfo->pathname = g_string_new (msql_row[25]);
10.17 + proginfo->pathname = g_string_new (g_strdup(msql_row[25]));
10.18
10.19 gmyth_debug ("One program info loaded from mysql database\n");
10.20 }
11.1 --- a/gmyth/src/gmyth_socket.c Sat Mar 10 15:01:25 2007 +0000
11.2 +++ b/gmyth/src/gmyth_socket.c Mon Mar 19 17:11:23 2007 +0000
11.3 @@ -951,23 +951,20 @@
11.4 GIOCondition io_cond;
11.5
11.6 /* verify if the input (read) buffer is ready to receive data */
11.7 -
11.8 g_mutex_lock( gmyth_socket->mutex );
11.9 - //g_static_rw_lock_reader_lock (&rwlock);
11.10
11.11 - //buffer = g_new0 (gchar, MYTH_PROTOCOL_FIELD_SIZE);
11.12 buffer = g_strnfill (MYTH_PROTOCOL_FIELD_SIZE, ' ');
11.13 - if ( NULL == gmyth_socket->sd_io_ch )
11.14 - {
11.15 - gmyth_socket_connect( gmyth_socket, gmyth_socket->hostname, gmyth_socket->port );
11.16 - }
11.17 + if ( NULL == gmyth_socket->sd_io_ch ) {
11.18 + gmyth_socket_connect( gmyth_socket, gmyth_socket->hostname, gmyth_socket->port );
11.19 + }
11.20
11.21 - io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
11.22 -/*
11.23 - if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) )
11.24 - gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd );
11.25 - */
11.26 - if ( gmyth_socket->sd_io_ch->is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 )*/ )
11.27 + io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
11.28 + /*
11.29 + if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) )
11.30 + gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd );
11.31 + */
11.32 +
11.33 + if ( gmyth_socket->sd_io_ch->is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 )*/ )
11.34 io_status = g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer, MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, &error);
11.35 else
11.36 return g_string_new("");
11.37 @@ -975,68 +972,68 @@
11.38 /* verify if the input (read) buffer is ready to receive data */
11.39 io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
11.40
11.41 - //if ( ( io_cond & G_IO_IN ) == 0 )
11.42 - // return NULL;
11.43 + //if ( ( io_cond & G_IO_IN ) == 0 )
11.44 + // return NULL;
11.45
11.46 gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read );
11.47
11.48 if( (io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0) ) {
11.49 - g_debug ("[%s] Error in mythprotocol response from backend\n", __FUNCTION__);
11.50 - str = NULL;
11.51 - //return NULL;
11.52 + g_debug ("[%s] Error in mythprotocol response from backend\n", __FUNCTION__);
11.53 + str = NULL;
11.54 + //return NULL;
11.55 } else if ( buffer != NULL && strlen(buffer) > 0 ) {
11.56
11.57 - //io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
11.58 - /* verify if the input (read) buffer is ready to receive data */
11.59 - //io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
11.60 + //io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
11.61 + /* verify if the input (read) buffer is ready to receive data */
11.62 + //io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
11.63
11.64 - //if ( ( io_cond & G_IO_IN ) != 0 ) {
11.65 + //if ( ( io_cond & G_IO_IN ) != 0 ) {
11.66 //gchar *buffer_aux = NULL;
11.67
11.68 - /* removes trailing whitespace */
11.69 - //buffer_aux = g_strstrip (buffer);
11.70 - len = (gint)g_ascii_strtoull ( g_strstrip (buffer), NULL, 10 );
11.71 + /* removes trailing whitespace */
11.72 + //buffer_aux = g_strstrip (buffer);
11.73 + len = (gint)g_ascii_strtoull ( g_strstrip (buffer), NULL, 10 );
11.74
11.75 - if (buffer != NULL) {
11.76 - g_free (buffer);
11.77 - buffer = NULL;
11.78 - }
11.79 + if (buffer != NULL) {
11.80 + g_free (buffer);
11.81 + buffer = NULL;
11.82 + }
11.83
11.84 - /*
11.85 - if (buffer_aux != NULL) {
11.86 - g_free (buffer_aux);
11.87 - buffer_aux = NULL;
11.88 - }
11.89 - */
11.90 + /*
11.91 + if (buffer_aux != NULL) {
11.92 + g_free (buffer_aux);
11.93 + buffer_aux = NULL;
11.94 + }
11.95 + */
11.96
11.97 - buffer = g_new0 (gchar, len+1);
11.98 + buffer = g_new0 (gchar, len+1);
11.99
11.100 - bytes_read = 0;
11.101 - if ( !( gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL) )
11.102 - return NULL;
11.103 - if ( gmyth_socket->sd_io_ch->is_readable )
11.104 - io_status = g_io_channel_read_chars( gmyth_socket->sd_io_ch, buffer, len, &bytes_read, &error);
11.105 - else
11.106 - return g_string_new("");
11.107 + bytes_read = 0;
11.108 + if ( !( gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL) )
11.109 + return NULL;
11.110 +
11.111 + if ( gmyth_socket->sd_io_ch->is_readable )
11.112 + io_status = g_io_channel_read_chars( gmyth_socket->sd_io_ch, buffer, len, &bytes_read, &error);
11.113 + else
11.114 + return g_string_new("");
11.115
11.116 - buffer[bytes_read] = '\0';
11.117 + buffer[bytes_read] = '\0';
11.118 //}
11.119 }
11.120
11.121 g_mutex_unlock( gmyth_socket->mutex );
11.122 //g_static_rw_lock_reader_unlock (&rwlock);
11.123
11.124 - gmyth_debug ("Response received from backend: {%s}\n", buffer);
11.125 -
11.126 + gmyth_debug ("Response received from backend: ----- {%s}\n", buffer);
11.127 if ( ( bytes_read != len ) || ( io_status == G_IO_STATUS_ERROR ) )
11.128 - str = NULL;
11.129 + str = NULL;
11.130 else
11.131 - str = g_string_new (buffer);
11.132 + str = g_string_new (buffer);
11.133
11.134 if ( error != NULL ) {
11.135 - g_debug( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message );
11.136 - str = NULL;
11.137 - g_error_free (error);
11.138 + g_debug( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message );
11.139 + str = NULL;
11.140 + g_error_free (error);
11.141 }
11.142
11.143 g_free (buffer);
12.1 --- a/gmyth/src/gmyth_stringlist.c Sat Mar 10 15:01:25 2007 +0000
12.2 +++ b/gmyth/src/gmyth_stringlist.c Mon Mar 19 17:11:23 2007 +0000
12.3 @@ -62,15 +62,13 @@
12.4 static void
12.5 gmyth_string_list_dispose (GObject *object)
12.6 {
12.7 - GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
12.8 + GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
12.9
12.10 - if (gmyth_string_list->glist)
12.11 - gmyth_string_list_clear_all(gmyth_string_list);
12.12 + //if (gmyth_string_list)
12.13 + // gmyth_string_list_clear_all(gmyth_string_list);
12.14
12.15 - if ( gmyth_string_list->glist != NULL )
12.16 - g_list_free( gmyth_string_list->glist );
12.17
12.18 - G_OBJECT_CLASS (gmyth_string_list_parent_class)->dispose (object);
12.19 + G_OBJECT_CLASS (gmyth_string_list_parent_class)->dispose (object);
12.20 }
12.21
12.22 static void
12.23 @@ -105,13 +103,13 @@
12.24 GString*
12.25 gmyth_string_list_append_int ( GMythStringList *strlist, const gint value )
12.26 {
12.27 - GString *tmp_str = g_string_new ("");
12.28 + GString *value_str = g_string_new ("");
12.29
12.30 - g_string_printf (tmp_str, "%d", value);
12.31 + g_string_printf (value_str, "%d", value);
12.32
12.33 - gmyth_string_list_append_string (strlist, tmp_str);
12.34 + strlist->glist = g_list_append (strlist->glist, value_str);
12.35
12.36 - return tmp_str;
12.37 + return value_str;
12.38 }
12.39
12.40 /** Appends a guint64 to the string list.
12.41 @@ -136,7 +134,6 @@
12.42
12.43 gmyth_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
12.44
12.45 - //gmyth_string_list_append_string (strlist, tmp_str1);
12.46 strlist->glist = g_list_append( strlist->glist, tmp_str1 );
12.47
12.48 /* low order part of guint64 value */
12.49 @@ -146,8 +143,6 @@
12.50
12.51 strlist->glist = g_list_append( strlist->glist, tmp_str2 );
12.52
12.53 - //gmyth_string_list_append_string (strlist, tmp_str2);
12.54 -
12.55 return tmp_str2;
12.56 }
12.57
12.58 @@ -173,7 +168,6 @@
12.59
12.60 gmyth_debug( "[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
12.61
12.62 - //gmyth_string_list_append_string (strlist, tmp_str1);
12.63 strlist->glist = g_list_append( strlist->glist, tmp_str1 );
12.64
12.65 /* low order part of gint64 value */
12.66 @@ -205,7 +199,7 @@
12.67 if ( NULL == tmp_str )
12.68 return NULL;
12.69
12.70 - gmyth_string_list_append_string (strlist, tmp_str);
12.71 + strlist->glist = g_list_append (strlist->glist, tmp_str);
12.72
12.73 return tmp_str;
12.74 }
12.75 @@ -220,11 +214,15 @@
12.76 GString*
12.77 gmyth_string_list_append_string ( GMythStringList *strlist, GString *value )
12.78 {
12.79 - g_return_val_if_fail( strlist != NULL, NULL );
12.80 + g_return_val_if_fail (strlist != NULL, NULL );
12.81
12.82 - strlist->glist = g_list_append (strlist->glist, value);
12.83 + if (value != NULL) {
12.84 + strlist->glist = g_list_append (strlist->glist, g_string_new (value->str));
12.85 + } else {
12.86 + strlist->glist = g_list_append (strlist->glist, NULL);
12.87 + }
12.88
12.89 - return value;
12.90 + return value;
12.91 }
12.92
12.93 /** Gets an integer value from the string list at the given position.
12.94 @@ -340,7 +338,7 @@
12.95 }
12.96
12.97
12.98 -/** Gets a string from the string list at the given position.
12.99 +/** Gets a string from the string list at the given position. The GString must be deallocated.
12.100 *
12.101 * @param strlist The GMythStringList instance.
12.102 * @param index the string position in the list, starting with zero.
12.103 @@ -349,24 +347,26 @@
12.104 GString*
12.105 gmyth_string_list_get_string ( GMythStringList *strlist, const gint index )
12.106 {
12.107 - if (!strlist || !(strlist->glist)) {
12.108 - g_warning ("%s received Null arguments", __FUNCTION__);
12.109 - return NULL;
12.110 - }
12.111 + GString *ret;
12.112
12.113 - return (GString *) g_list_nth_data (strlist->glist, index);
12.114 + if (!strlist || !(strlist->glist)) {
12.115 + g_warning ("%s received Null arguments", __FUNCTION__);
12.116 + return NULL;
12.117 + }
12.118 +
12.119 + ret = (GString *) g_list_nth_data (strlist->glist, index);
12.120 +
12.121 + return g_string_new (ret->str);
12.122 }
12.123
12.124
12.125 -#if 0
12.126 static void
12.127 gmyth_string_list_clear_element( GString *str_elem, void *data_aux )
12.128 {
12.129 - if ( str_elem != NULL ) {
12.130 - g_string_free( str_elem, TRUE );
12.131 - }
12.132 + if ( str_elem != NULL ) {
12.133 + g_string_free( str_elem, TRUE );
12.134 + }
12.135 }
12.136 -#endif
12.137
12.138 /** Removes all strings from the string list.
12.139 *
12.140 @@ -375,11 +375,11 @@
12.141 void
12.142 gmyth_string_list_clear_all ( GMythStringList *strlist )
12.143 {
12.144 - if ( strlist != NULL && strlist->glist ) {
12.145 - //g_list_foreach( strlist->glist, (GFunc)gmyth_string_list_clear_element, NULL );
12.146 - g_list_free (strlist->glist);
12.147 - strlist->glist = NULL;
12.148 - }
12.149 + if ( strlist != NULL && strlist->glist ) {
12.150 + g_list_foreach( strlist->glist, (GFunc)gmyth_string_list_clear_element, NULL );
12.151 + g_list_free (strlist->glist);
12.152 + strlist->glist = NULL;
12.153 + }
12.154 }
12.155
12.156 /** Retrieves the number of elements in the string list.
12.157 @@ -390,8 +390,8 @@
12.158 gint
12.159 gmyth_string_list_length ( GMythStringList *strlist )
12.160 {
12.161 - if ( !(strlist != NULL && strlist->glist != NULL) )
12.162 - return 0;
12.163 + if ( !(strlist != NULL && strlist->glist != NULL) )
12.164 + return 0;
12.165
12.166 - return g_list_length (strlist->glist);
12.167 + return g_list_length (strlist->glist);
12.168 }
13.1 --- a/gmyth/src/gmyth_transcoder.c Sat Mar 10 15:01:25 2007 +0000
13.2 +++ b/gmyth/src/gmyth_transcoder.c Mon Mar 19 17:11:23 2007 +0000
13.3 @@ -97,8 +97,10 @@
13.4 GMythTranscoder *transcoder = GMYTH_TRANSCODER\
13.5 (g_object_new(GMYTH_TRANSCODER_TYPE, NULL));
13.6
13.7 - g_object_ref (backend_info);
13.8 - transcoder->backend_info = backend_info;
13.9 + if (backend_info != NULL) {
13.10 + g_object_ref (backend_info);
13.11 + transcoder->backend_info = backend_info;
13.12 + }
13.13
13.14 return transcoder;
13.15 }
13.16 @@ -214,8 +216,13 @@
13.17 gmyth_transcoder_start (GMythTranscoder* trans)
13.18 {
13.19 g_return_val_if_fail (trans != NULL, FALSE);
13.20 + g_return_val_if_fail (trans->backend_info != NULL, FALSE);
13.21 + g_return_val_if_fail (trans->filename != NULL, FALSE);
13.22
13.23 if (trans->started == FALSE) { // not started yet
13.24 + if (!gmyth_util_file_exists (trans->backend_info, trans->filename)) {
13.25 + gmyth_debug ("File %s does not exist", trans->filename);
13.26 + }
13.27 trans->started = gmyth_jobqueue_add_job(trans, "JOB_TRANSCODE");
13.28 if (trans->started == FALSE)
13.29 g_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename);
13.30 @@ -230,7 +237,8 @@
13.31 gmyth_transcoder_pause (GMythTranscoder* trans)
13.32 {
13.33 g_return_val_if_fail (trans != NULL, FALSE);
13.34 -
13.35 + g_return_val_if_fail (trans->started == TRUE, FALSE);
13.36 +
13.37 return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE");
13.38 }
13.39
13.40 @@ -246,6 +254,9 @@
13.41 gmyth_transcoder_cancel (GMythTranscoder* trans)
13.42 {
13.43 g_return_val_if_fail (trans != NULL, FALSE);
13.44 + g_return_val_if_fail (trans->started == TRUE, FALSE);
13.45 +
13.46 + trans->started = FALSE;
13.47
13.48 return gmyth_jobqueue_change_cmd (trans, "STOP", "JOB_TRANSCODE");
13.49 }
14.1 --- a/gmyth/src/gmyth_uri.c Sat Mar 10 15:01:25 2007 +0000
14.2 +++ b/gmyth/src/gmyth_uri.c Mon Mar 19 17:11:23 2007 +0000
14.3 @@ -106,6 +106,12 @@
14.4 gmyth_uri->query = NULL;
14.5 }
14.6
14.7 + if ( gmyth_uri->uri != NULL ) {
14.8 + g_string_free( gmyth_uri->uri, TRUE );
14.9 + gmyth_uri->uri = NULL;
14.10 + }
14.11 +
14.12 +
14.13 G_OBJECT_CLASS (gmyth_uri_parent_class)->dispose (object);
14.14 }
14.15
14.16 @@ -136,11 +142,11 @@
14.17 * @return a new instance of GMythURI.
14.18 */
14.19 GMythURI *
14.20 -gmyth_uri_new_with_value (const gchar *value)
14.21 +gmyth_uri_new_with_value (const gchar *uri_str)
14.22 {
14.23 GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL));
14.24
14.25 - gmyth_uri_parser_setup_and_new (gmyth_uri, value);
14.26 + gmyth_uri_parser_setup_and_new (gmyth_uri, uri_str);
14.27
14.28 return gmyth_uri;
14.29 }
14.30 @@ -226,7 +232,7 @@
14.31 */
14.32
14.33 uriLen = strlen(value);
14.34 - uri->uri = g_string_new( value );
14.35 + uri->uri = g_string_new( g_strdup (value) );
14.36
14.37 currIdx = 0;
14.38
15.1 --- a/gmyth/src/gmyth_util.c Sat Mar 10 15:01:25 2007 +0000
15.2 +++ b/gmyth/src/gmyth_util.c Mon Mar 19 17:11:23 2007 +0000
15.3 @@ -430,6 +430,11 @@
15.4 GMythSocket *socket;
15.5 gboolean res;
15.6
15.7 + gmyth_debug ("Check if file %s exists", filename);
15.8 +
15.9 + g_return_val_if_fail (backend_info != NULL, FALSE);
15.10 + g_return_val_if_fail (filename != NULL, FALSE);
15.11 +
15.12 socket = gmyth_socket_new ();
15.13 res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
15.14 backend_info->port, TRUE);
15.15 @@ -449,9 +454,8 @@
15.16 gmyth_socket_sendreceive_stringlist (socket, slist);
15.17
15.18 res = (gmyth_string_list_get_int (slist, 0) == 1);
15.19 -
15.20 +
15.21 g_object_unref (program);
15.22 -
15.23 g_object_unref (slist);
15.24
15.25 gmyth_socket_close_connection (socket);