# HG changeset patch # User rosfran # Date 1179946241 -3600 # Node ID 2f28edb4d80464a59d36da039f307e95f91c23ac # Parent 9ade4c5e5db8a153fe35ac68d08f2df868a6959c [svn r707] Fixed the wrong commentary indentation. diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/Makefile.am --- a/gmyth/src/Makefile.am Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/Makefile.am Wed May 23 19:50:41 2007 +0100 @@ -100,10 +100,10 @@ if HAVE_INDENT indent: @for src_file in $(libgmyth_la_SOURCES); do \ - ./gst-indent.sh $$src_file; \ + ./gmyth-indent.sh $$src_file; \ done; \ for inc_file in $(libgmyth_include_HEADERS); do \ - ./gst-indent.sh $$inc_file; \ + ./gmyth-indent.sh $$inc_file; \ done; endif diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth.h --- a/gmyth/src/gmyth.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth.h Wed May 23 19:50:41 2007 +0100 @@ -7,22 +7,22 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Renato Filho * - *//* - * - * 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 - */ + *//* + * + * 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 + */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_backendinfo.c --- a/gmyth/src/gmyth_backendinfo.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_backendinfo.c Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * @author Hallyson Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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" @@ -35,25 +34,25 @@ #include "gmyth_uri.h" #include "gmyth_debug.h" -static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass); -static void gmyth_backend_info_init (GMythBackendInfo * object); +static void gmyth_backend_info_class_init ( GMythBackendInfoClass * klass ); +static void gmyth_backend_info_init ( GMythBackendInfo * object ); -static void gmyth_backend_info_dispose (GObject * object); -static void gmyth_backend_info_finalize (GObject * object); +static void gmyth_backend_info_dispose ( GObject * object ); +static void gmyth_backend_info_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT) - static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass) +G_DEFINE_TYPE ( GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT ) + static void gmyth_backend_info_class_init ( GMythBackendInfoClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_backend_info_dispose; gobject_class->finalize = gmyth_backend_info_finalize; } static void -gmyth_backend_info_init (GMythBackendInfo * backend_info) +gmyth_backend_info_init ( GMythBackendInfo * backend_info ) { backend_info->hostname = NULL; backend_info->username = NULL; @@ -64,14 +63,14 @@ } static void -gmyth_backend_info_dispose (GObject * object) +gmyth_backend_info_dispose ( GObject * object ) { - GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO (object); + GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO ( object ); - g_free (backend_info->hostname); - g_free (backend_info->username); - g_free (backend_info->password); - g_free (backend_info->db_name); + g_free ( backend_info->hostname ); + g_free ( backend_info->username ); + g_free ( backend_info->password ); + g_free ( backend_info->db_name ); backend_info->hostname = NULL; backend_info->username = NULL; @@ -80,15 +79,15 @@ backend_info->port = -1; backend_info->status_port = -1; - G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_backend_info_parent_class )->dispose ( object ); } static void -gmyth_backend_info_finalize (GObject * object) +gmyth_backend_info_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_backend_info_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_backend_info_parent_class )->finalize ( object ); } /** @@ -97,10 +96,10 @@ * @return a new instance of GMythBackendInfo. */ GMythBackendInfo * -gmyth_backend_info_new () +gmyth_backend_info_new ( ) { GMythBackendInfo *backend_info = - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL)); + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) ); return backend_info; } @@ -118,17 +117,18 @@ * @return a new instance of GMythBackendInfo. */ GMythBackendInfo * -gmyth_backend_info_new_full (const gchar * hostname, const gchar * username, - const gchar * password, const gchar * db_name, gint port) +gmyth_backend_info_new_full ( const gchar * hostname, const gchar * username, + const gchar * password, const gchar * db_name, + gint port ) { GMythBackendInfo *backend_info = - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL)); + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) ); - gmyth_backend_info_set_hostname (backend_info, hostname); - gmyth_backend_info_set_username (backend_info, username); - gmyth_backend_info_set_password (backend_info, password); - gmyth_backend_info_set_db_name (backend_info, db_name); - gmyth_backend_info_set_port (backend_info, port); + gmyth_backend_info_set_hostname ( backend_info, hostname ); + gmyth_backend_info_set_username ( backend_info, username ); + gmyth_backend_info_set_password ( backend_info, password ); + gmyth_backend_info_set_db_name ( backend_info, db_name ); + gmyth_backend_info_set_port ( backend_info, port ); return backend_info; } @@ -142,134 +142,149 @@ * @return a new instance of GMythBackendInfo. */ GMythBackendInfo * -gmyth_backend_info_new_with_uri (const gchar * uri_str) +gmyth_backend_info_new_with_uri ( const gchar * uri_str ) { GMythBackendInfo *backend_info = - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL)); + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) ); - GMythURI *uri = gmyth_uri_new_with_value (uri_str); + GMythURI *uri = gmyth_uri_new_with_value ( uri_str ); - gchar **path_parts = g_strsplit (gmyth_uri_get_path (uri), "&", -1); + gchar **path_parts = g_strsplit ( gmyth_uri_get_path ( uri ), "&", -1 ); - gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri)); - gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user (uri)); - gmyth_backend_info_set_password (backend_info, - gmyth_uri_get_password (uri)); + gmyth_backend_info_set_hostname ( backend_info, + gmyth_uri_get_host ( uri ) ); + gmyth_backend_info_set_username ( backend_info, + gmyth_uri_get_user ( uri ) ); + gmyth_backend_info_set_password ( backend_info, + gmyth_uri_get_password ( uri ) ); /* gets the path info to database name, from the URI, and removes the trash chars */ - gmyth_backend_info_set_db_name (backend_info, path_parts != NULL && - strlen (path_parts[0]) > 0 ? - g_strstrip (g_strdelimit - (path_parts[0], "/?", ' ')) : gmyth_uri_get_path (uri)); + gmyth_backend_info_set_db_name ( backend_info, path_parts != NULL && + strlen ( path_parts[0] ) > 0 ? + g_strstrip ( g_strdelimit + ( path_parts[0], "/?", + ' ' ) ) : + gmyth_uri_get_path ( uri ) ); - gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port (uri)); + gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port ( uri ) ); - g_object_unref (uri); - g_strfreev (path_parts); + g_object_unref ( uri ); + g_strfreev ( path_parts ); return backend_info; } void -gmyth_backend_info_set_hostname (GMythBackendInfo * backend_info, - const gchar * hostname) +gmyth_backend_info_set_hostname ( GMythBackendInfo * backend_info, + const gchar * hostname ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - if (NULL == hostname || strlen (hostname) <= 0) { - gmyth_debug ("Error trying to set a hostname equals to NULL."); - } else { - backend_info->hostname = g_strdup (hostname); + if ( NULL == hostname || strlen ( hostname ) <= 0 ) + { + gmyth_debug ( "Error trying to set a hostname equals to NULL." ); + } + else + { + backend_info->hostname = g_strdup ( hostname ); } } void -gmyth_backend_info_set_username (GMythBackendInfo * backend_info, - const gchar * username) +gmyth_backend_info_set_username ( GMythBackendInfo * backend_info, + const gchar * username ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - backend_info->username = g_strdup (username); + backend_info->username = g_strdup ( username ); } void -gmyth_backend_info_set_password (GMythBackendInfo * backend_info, - const gchar * password) +gmyth_backend_info_set_password ( GMythBackendInfo * backend_info, + const gchar * password ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - backend_info->password = g_strdup (password); + backend_info->password = g_strdup ( password ); } void -gmyth_backend_info_set_db_name (GMythBackendInfo * backend_info, - const gchar * db_name) +gmyth_backend_info_set_db_name ( GMythBackendInfo * backend_info, + const gchar * db_name ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - backend_info->db_name = g_strdup (db_name); + backend_info->db_name = g_strdup ( db_name ); } void -gmyth_backend_info_set_port (GMythBackendInfo * backend_info, gint port) +gmyth_backend_info_set_port ( GMythBackendInfo * backend_info, gint port ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - if (port <= 0) { - gmyth_debug ("Error trying to set a port less than 0."); - } else { + if ( port <= 0 ) + { + gmyth_debug ( "Error trying to set a port less than 0." ); + } + else + { backend_info->port = port; } } void -gmyth_backend_info_set_status_port (GMythBackendInfo * backend_info, gint port) +gmyth_backend_info_set_status_port ( GMythBackendInfo * backend_info, + gint port ) { - g_return_if_fail (backend_info != NULL); + g_return_if_fail ( backend_info != NULL ); - if (port <= 0) { - gmyth_debug ("Error trying to set the status port to less than zero."); - } else { + if ( port <= 0 ) + { + gmyth_debug + ( "Error trying to set the status port to less than zero." ); + } + else + { backend_info->status_port = port; } } const gchar * -gmyth_backend_info_get_hostname (GMythBackendInfo * backend_info) +gmyth_backend_info_get_hostname ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, NULL); + g_return_val_if_fail ( backend_info != NULL, NULL ); return backend_info->hostname; } const gchar * -gmyth_backend_info_get_username (GMythBackendInfo * backend_info) +gmyth_backend_info_get_username ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, NULL); + g_return_val_if_fail ( backend_info != NULL, NULL ); return backend_info->username; } const gchar * -gmyth_backend_info_get_password (GMythBackendInfo * backend_info) +gmyth_backend_info_get_password ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, NULL); + g_return_val_if_fail ( backend_info != NULL, NULL ); return backend_info->password; } const gchar * -gmyth_backend_info_get_db_name (GMythBackendInfo * backend_info) +gmyth_backend_info_get_db_name ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, NULL); + g_return_val_if_fail ( backend_info != NULL, NULL ); return backend_info->db_name; } gint -gmyth_backend_info_get_port (GMythBackendInfo * backend_info) +gmyth_backend_info_get_port ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, -1); + g_return_val_if_fail ( backend_info != NULL, -1 ); return backend_info->port; } @@ -283,48 +298,52 @@ * @return an instance of GMythURI, created from a GMythBackendInfo. */ GMythURI * -gmyth_backend_info_get_uri (GMythBackendInfo * backend_info) +gmyth_backend_info_get_uri ( GMythBackendInfo * backend_info ) { GMythURI *uri = NULL; gchar *uri_str = NULL; gchar *user_info = NULL; gchar *db_data = NULL; - if ((backend_info->username != NULL && strlen (backend_info->username) > 0)) + if ( ( backend_info->username != NULL + && strlen ( backend_info->username ) > 0 ) ) user_info = - g_strdup_printf ("%s:%s@", backend_info->username, - backend_info->password); + g_strdup_printf ( "%s:%s@", backend_info->username, + backend_info->password ); - if (backend_info->db_name != NULL && strlen (backend_info->db_name) > 0) { - if ((g_strrstr (backend_info->db_name, "_") != NULL)) - db_data = g_strdup (backend_info->db_name); + if ( backend_info->db_name != NULL && strlen ( backend_info->db_name ) > 0 ) + { + if ( ( g_strrstr ( backend_info->db_name, "_" ) != NULL ) ) + db_data = g_strdup ( backend_info->db_name ); else - db_data = g_strdup_printf ("?%s&", backend_info->db_name); + db_data = g_strdup_printf ( "?%s&", backend_info->db_name ); } //else if ( ( ( g_strrstr( backend_info->path, "livetv" ) != NULL ) || // ( g_strrstr( backend_info->path, "/?" ) != NULL ) ) - uri_str = g_strdup_printf ("myth://%s%s:%d/%s", user_info != NULL - && strlen (user_info) > 0 ? user_info : "", - backend_info->hostname, backend_info->port, - db_data != NULL && strlen (db_data) > 0 ? db_data : ""); - uri = gmyth_uri_new_with_value (uri_str); + uri_str = g_strdup_printf ( "myth://%s%s:%d/%s", user_info != NULL + && strlen ( user_info ) > 0 ? user_info : "", + backend_info->hostname, backend_info->port, + db_data != NULL + && strlen ( db_data ) > 0 ? db_data : "" ); + uri = gmyth_uri_new_with_value ( uri_str ); - if (user_info != NULL) - g_free (user_info); + if ( user_info != NULL ) + g_free ( user_info ); - if (db_data != NULL) - g_free (db_data); + if ( db_data != NULL ) + g_free ( db_data ); - g_free (uri_str); + g_free ( uri_str ); return uri; } gboolean -gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info) +gmyth_backend_info_is_local_file ( GMythBackendInfo * backend_info ) { - g_return_val_if_fail (backend_info != NULL, FALSE); + g_return_val_if_fail ( backend_info != NULL, FALSE ); - return gmyth_uri_is_local_file (gmyth_backend_info_get_uri (backend_info)); + return + gmyth_uri_is_local_file ( gmyth_backend_info_get_uri ( backend_info ) ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_backendinfo.h --- a/gmyth/src/gmyth_backendinfo.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_backendinfo.h Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * @author Hallyson Melo * @author Rosfran Borges * - *//* - * - * 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 - */ +* +* 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_BACKEND_INFO_H__ #define __GMYTH_BACKEND_INFO_H__ @@ -45,62 +44,67 @@ typedef struct _GMythBackendInfoClass GMythBackendInfoClass; struct _GMythBackendInfoClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythBackendInfo -{ - GObject parent; + { + GObject parent; /** The backend hostname or ip address. */ - gchar *hostname; + gchar *hostname; /** The username to connect to the mysql server. */ - gchar *username; + gchar *username; /** The password to connect to the mysql server. */ - gchar *password; + gchar *password; /** The mythtv's mysql database name. */ - gchar *db_name; + gchar *db_name; /** The backend port. */ - gint port; + gint port; /** The backend status port for http connection */ - gint status_port; - //gchar *path; + gint status_port; + //gchar *path; - //GMythURI* uri; -}; + //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); +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); +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); +GMythURI *gmyth_backend_info_get_uri ( GMythBackendInfo * backend_info ); -gboolean gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info); +gboolean gmyth_backend_info_is_local_file ( GMythBackendInfo * backend_info ); G_END_DECLS #endif /* __GMYTH_BACKEND_INFO_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_common.c --- a/gmyth/src/gmyth_common.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_common.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * @author Leonardo Sobral Cunha * @author Rosfran Borges * - *//* - * - * 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 - */ +* +* 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" @@ -34,23 +33,23 @@ #include "gmyth_debug.h" #include "gmyth_util.h" -static void free_channel_data (gpointer data, gpointer user_data); -static void free_program_data (gpointer data, gpointer user_data); +static void free_channel_data ( gpointer data, gpointer user_data ); +static void free_program_data ( gpointer data, gpointer user_data ); -/** - * Frees the memory allocated to the GMythChannelInfo objects inside list. - * The list memory is also released by g_list_free(). If LIST is NULL it - * simply returns. - * - * @param list the GList containing a list of GMythChannelInfo to free. - */ + /** + * Frees the memory allocated to the GMythChannelInfo objects inside list. + * The list memory is also released by g_list_free(). If LIST is NULL it + * simply returns. + * + * @param list the GList containing a list of GMythChannelInfo to free. + */ void -gmyth_free_channel_list (GList * list) +gmyth_free_channel_list ( GList * list ) { - g_return_if_fail (list != NULL); + g_return_if_fail ( list != NULL ); - g_list_foreach (list, free_channel_data, NULL); - g_list_free (list); + g_list_foreach ( list, free_channel_data, NULL ); + g_list_free ( list ); } /** @@ -61,29 +60,29 @@ * @param list the GList containing a list of GMythProgramInfo to free. */ void -gmyth_free_program_list (GList * list) +gmyth_free_program_list ( GList * list ) { - g_return_if_fail (list != NULL); + g_return_if_fail ( list != NULL ); - g_list_foreach (list, free_program_data, NULL); - g_list_free (list); + g_list_foreach ( list, free_program_data, NULL ); + g_list_free ( list ); } void -gmyth_channel_info_free (GMythChannelInfo * channel) +gmyth_channel_info_free ( GMythChannelInfo * channel ) { - g_return_if_fail (channel != NULL); + g_return_if_fail ( channel != NULL ); - if (channel->channel_num) - g_string_free (channel->channel_num, TRUE); + if ( channel->channel_num ) + g_string_free ( channel->channel_num, TRUE ); - if (channel->channel_name) - g_string_free (channel->channel_name, TRUE); + if ( channel->channel_name ) + g_string_free ( channel->channel_name, TRUE ); - if (channel->channel_icon) - g_string_free (channel->channel_icon, TRUE); + if ( channel->channel_icon ) + g_string_free ( channel->channel_icon, TRUE ); - g_free (channel); + g_free ( channel ); } /** @@ -91,16 +90,18 @@ * @param channel_info the GMythChannelInfo instance */ void -gmyth_channel_info_print (GMythChannelInfo * channel_info) +gmyth_channel_info_print ( GMythChannelInfo * channel_info ) { #ifdef GMYTH_USE_DEBUG - if (channel_info != NULL) { - g_return_if_fail (channel_info->channel_name != NULL); - g_return_if_fail (channel_info->channel_num != NULL); + if ( channel_info != NULL ) + { + g_return_if_fail ( channel_info->channel_name != NULL ); + g_return_if_fail ( channel_info->channel_num != NULL ); - gmyth_debug ("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n", - channel_info->channel_name->str, - channel_info->channel_num->str, channel_info->channel_ID); + gmyth_debug ( "ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n", + channel_info->channel_name->str, + channel_info->channel_num->str, + channel_info->channel_ID ); } #endif @@ -111,42 +112,42 @@ * @param channel_info the GMythProgramInfo instance */ void -gmyth_program_info_print (GMythProgramInfo * program_info) +gmyth_program_info_print ( GMythProgramInfo * program_info ) { #ifdef GMYTH_USE_DEBUG - g_return_if_fail (program_info); + g_return_if_fail ( program_info ); - gmyth_debug ("ProgramInfo\n\tTitle = %s\n\t" - "Description = %s\n\t" - "Start time= %s\t" - "End time = %s\n" - "Path name = %s\n" - "File size = %lld\n", - program_info->title ? program_info->title->str : "NULL", - program_info->description ? program_info->description-> - str : "NULL", - gmyth_util_time_to_string_from_time_val (program_info-> - startts), - gmyth_util_time_to_string_from_time_val (program_info-> - endts), - program_info->pathname ? program_info->pathname->str : "NULL", - program_info->filesize); + gmyth_debug ( "ProgramInfo\n\tTitle = %s\n\t" + "Description = %s\n\t" + "Start time= %s\t" + "End time = %s\n" + "Path name = %s\n" + "File size = %lld\n", + program_info->title ? program_info->title->str : "NULL", + program_info->description ? program_info->description-> + str : "NULL", + gmyth_util_time_to_string_from_time_val ( program_info-> + startts ), + gmyth_util_time_to_string_from_time_val ( program_info-> + endts ), + program_info->pathname ? program_info->pathname->str : "NULL", + program_info->filesize ); #endif } static void -free_channel_data (gpointer data, gpointer user_data) +free_channel_data ( gpointer data, gpointer user_data ) { /* Frees the GMythChannelInfo structure */ - GMythChannelInfo *channel = (GMythChannelInfo *) data; + GMythChannelInfo *channel = ( GMythChannelInfo * ) data; - gmyth_channel_info_free (channel); + gmyth_channel_info_free ( channel ); } static void -free_program_data (gpointer data, gpointer user_data) +free_program_data ( gpointer data, gpointer user_data ) { - g_return_if_fail (data != NULL); + g_return_if_fail ( data != NULL ); - g_object_unref ((GMythProgramInfo *) data); + g_object_unref ( ( GMythProgramInfo * ) data ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_common.h --- a/gmyth/src/gmyth_common.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_common.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * @author Leonardo Sobral Cunha * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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_COMMON_H_ #define GMYTH_COMMON_H_ @@ -40,29 +39,29 @@ * stored in the backend database. */ typedef struct -{ - /** The channel ID in backend database */ - gint channel_ID; + { + /** The channel ID in backend database */ + gint channel_ID; - /** The channel number */ - GString *channel_num; + /** The channel number */ + GString *channel_num; - /** The channel name in backend database */ - GString *channel_name; + /** The channel name in backend database */ + GString *channel_name; - /** The channel icon path in the backend database */ - GString *channel_icon; + /** The channel icon path in the backend database */ + GString *channel_icon; -} GMythChannelInfo; + } GMythChannelInfo; -void gmyth_free_channel_list (GList * list); -void gmyth_free_program_list (GList * list); +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_free ( GMythChannelInfo * channel_info ); -void gmyth_channel_info_print (GMythChannelInfo * channel_info); -void gmyth_program_info_print (GMythProgramInfo * program_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 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_debug.c --- a/gmyth/src/gmyth_debug.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_debug.c Wed May 23 19:50:41 2007 +0100 @@ -7,22 +7,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Renato Filho * - *//* - * - * 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 - */ + * + * 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" @@ -31,24 +30,25 @@ #include "gmyth_debug.h" void -gmyth_debug_real (const char *func, - const char *file, const int line, gboolean newline, const char *format, ...) +gmyth_debug_real ( const char *func, + const char *file, const int line, gboolean newline, + const char *format, ... ) { va_list args; char buffer[1025]; char str_time[255]; time_t the_time; - va_start (args, format); + va_start ( args, format ); - g_vsnprintf (buffer, 1024, format, args); + g_vsnprintf ( buffer, 1024, format, args ); - va_end (args); + va_end ( args ); - time (&the_time); - strftime (str_time, 254, "%H:%M:%S", localtime (&the_time)); + time ( &the_time ); + strftime ( str_time, 254, "%H:%M:%S", localtime ( &the_time ) ); - g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : - "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self (), func, - file, line, buffer); + g_printerr ( newline ? "(%s) [%p] [%s] %s:%d: %s\n" : + "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self ( ), func, + file, line, buffer ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_debug.h --- a/gmyth/src/gmyth_debug.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_debug.h Wed May 23 19:50:41 2007 +0100 @@ -7,22 +7,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Renato Filho * - *//* - * - * 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 - */ +* +* 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_DEBUG_H__ #define __GMYTH_DEBUG_H__ @@ -38,9 +37,10 @@ #define gmyth_debug(...) #endif void -gmyth_debug_real (const char *func, - const char *file, int line, gboolean newline, const char *format, ...) -G_GNUC_PRINTF (5, 6); +gmyth_debug_real ( const char *func, + const char *file, int line, gboolean newline, + const char *format, ... ) +G_GNUC_PRINTF ( 5, 6 ); G_END_DECLS #endif diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_epg.c --- a/gmyth/src/gmyth_epg.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_epg.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * 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 - */ +* +* 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" @@ -41,46 +40,47 @@ #include "gmyth_file_transfer.h" #include "gmyth_debug.h" -static void gmyth_epg_class_init (GMythEPGClass * klass); -static void gmyth_epg_init (GMythEPG * object); +static void gmyth_epg_class_init ( GMythEPGClass * klass ); +static void gmyth_epg_init ( GMythEPG * object ); -static void gmyth_epg_dispose (GObject * object); -static void gmyth_epg_finalize (GObject * object); +static void gmyth_epg_dispose ( GObject * object ); +static void gmyth_epg_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythEPG, gmyth_epg, G_TYPE_OBJECT) - static void gmyth_epg_class_init (GMythEPGClass * klass) +G_DEFINE_TYPE ( GMythEPG, gmyth_epg, G_TYPE_OBJECT ) + static void gmyth_epg_class_init ( GMythEPGClass * klass ) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass ); gobject_class->dispose = gmyth_epg_dispose; gobject_class->finalize = gmyth_epg_finalize; } static void -gmyth_epg_init (GMythEPG * gmyth_epg) +gmyth_epg_init ( GMythEPG * gmyth_epg ) { } static void -gmyth_epg_dispose (GObject * object) +gmyth_epg_dispose ( GObject * object ) { - GMythEPG *gmyth_epg = GMYTH_EPG (object); + GMythEPG *gmyth_epg = GMYTH_EPG ( object ); - if (gmyth_epg->sqlquery != NULL) { - g_object_unref (gmyth_epg->sqlquery); + if ( gmyth_epg->sqlquery != NULL ) + { + g_object_unref ( gmyth_epg->sqlquery ); gmyth_epg->sqlquery = NULL; } - G_OBJECT_CLASS (gmyth_epg_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_epg_parent_class )->dispose ( object ); } static void -gmyth_epg_finalize (GObject * object) +gmyth_epg_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_epg_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_epg_parent_class )->finalize ( object ); } /** @@ -89,9 +89,9 @@ * @return a new instance of GMythEPG. */ GMythEPG * -gmyth_epg_new (void) +gmyth_epg_new ( void ) { - GMythEPG *epg = GMYTH_EPG (g_object_new (GMYTH_EPG_TYPE, NULL)); + GMythEPG *epg = GMYTH_EPG ( g_object_new ( GMYTH_EPG_TYPE, NULL ) ); return epg; } @@ -103,22 +103,24 @@ * @return true if connection was success, false if failed. */ gboolean -gmyth_epg_connect (GMythEPG * gmyth_epg, GMythBackendInfo * backend_info) +gmyth_epg_connect ( GMythEPG * gmyth_epg, GMythBackendInfo * backend_info ) { - g_return_val_if_fail (gmyth_epg != NULL, FALSE); + g_return_val_if_fail ( gmyth_epg != NULL, FALSE ); - if (gmyth_epg->sqlquery == NULL) { - gmyth_debug ("[%s] Creating gmyth_query", __FUNCTION__); - gmyth_epg->sqlquery = gmyth_query_new (); + if ( gmyth_epg->sqlquery == NULL ) + { + gmyth_debug ( "[%s] Creating gmyth_query", __FUNCTION__ ); + gmyth_epg->sqlquery = gmyth_query_new ( ); } - if (!gmyth_query_connect (gmyth_epg->sqlquery, backend_info)) { - gmyth_debug ("[%s] Error while connecting to db", __FUNCTION__); + if ( !gmyth_query_connect ( gmyth_epg->sqlquery, backend_info ) ) + { + gmyth_debug ( "[%s] Error while connecting to db", __FUNCTION__ ); return FALSE; } gmyth_epg->backend_info = backend_info; - g_object_ref (backend_info); + g_object_ref ( backend_info ); return TRUE; } @@ -129,18 +131,20 @@ * @return true if disconnection was success, false if failed. */ gboolean -gmyth_epg_disconnect (GMythEPG * gmyth_epg) +gmyth_epg_disconnect ( GMythEPG * gmyth_epg ) { - g_return_val_if_fail (gmyth_epg != NULL, FALSE); + g_return_val_if_fail ( gmyth_epg != NULL, FALSE ); - if (gmyth_epg->sqlquery != NULL) { - gmyth_query_disconnect (gmyth_epg->sqlquery); - g_object_unref (gmyth_epg->sqlquery); + if ( gmyth_epg->sqlquery != NULL ) + { + gmyth_query_disconnect ( gmyth_epg->sqlquery ); + g_object_unref ( gmyth_epg->sqlquery ); gmyth_epg->sqlquery = NULL; } - if (gmyth_epg->backend_info != NULL) { - g_object_unref (gmyth_epg->backend_info); + if ( gmyth_epg->backend_info != NULL ) + { + g_object_unref ( gmyth_epg->backend_info ); gmyth_epg->backend_info = NULL; } @@ -154,77 +158,85 @@ * @return The amount of channels retrieved from database, or -1 if error. */ gint -gmyth_epg_get_channel_list (GMythEPG * gmyth_epg, GList ** glist_ptr) +gmyth_epg_get_channel_list ( GMythEPG * gmyth_epg, GList ** glist_ptr ) { MYSQL_RES *msql_res; - g_return_val_if_fail (gmyth_epg != NULL, -1); + g_return_val_if_fail ( gmyth_epg != NULL, -1 ); - msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, - "SELECT chanid, channum, name, icon FROM channel;"); + msql_res = gmyth_query_process_statement ( gmyth_epg->sqlquery, + "SELECT chanid, channum, name, icon FROM channel;" ); - (*glist_ptr) = NULL; + ( *glist_ptr ) = NULL; - if (msql_res == NULL) { - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__); + if ( msql_res == NULL ) + { + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ ); return -1; - } else { + } + else + { MYSQL_ROW row; GMythChannelInfo *channel_info; - while ((row = mysql_fetch_row (msql_res)) != NULL) { + while ( ( row = mysql_fetch_row ( msql_res ) ) != NULL ) + { - channel_info = g_new0 (GMythChannelInfo, 1); + channel_info = g_new0 ( GMythChannelInfo, 1 ); channel_info->channel_ID = - (gint) g_ascii_strtoull (row[0], NULL, 10); - channel_info->channel_num = g_string_new (row[1]); - channel_info->channel_name = g_string_new (row[2]); - channel_info->channel_icon = g_string_new (row[3]); + ( gint ) g_ascii_strtoull ( row[0], NULL, 10 ); + channel_info->channel_num = g_string_new ( row[1] ); + channel_info->channel_name = g_string_new ( row[2] ); + channel_info->channel_icon = g_string_new ( row[3] ); #ifdef GMYTH_USE_DEBUG - gmyth_channel_info_print (channel_info); + gmyth_channel_info_print ( channel_info ); #endif - (*glist_ptr) = g_list_append ((*glist_ptr), channel_info); + ( *glist_ptr ) = g_list_append ( ( *glist_ptr ), channel_info ); } } - mysql_free_result (msql_res); + mysql_free_result ( msql_res ); - return (!(*glist_ptr)) ? 0 : g_list_length (*glist_ptr); + return ( !( *glist_ptr ) ) ? 0 : g_list_length ( *glist_ptr ); } GMythChannelInfo * -gmyth_epg_get_channel_info (GMythEPG * gmyth_epg, gint channel_id) +gmyth_epg_get_channel_info ( GMythEPG * gmyth_epg, gint channel_id ) { GMythChannelInfo *channel_info = NULL; MYSQL_RES *msql_res; gchar *query_str; - g_return_val_if_fail (gmyth_epg != NULL, NULL); + g_return_val_if_fail ( gmyth_epg != NULL, NULL ); query_str = g_strdup_printf - ("SELECT channum, name, icon FROM channel WHERE chanid=%d;", - channel_id); - msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, query_str); + ( "SELECT channum, name, icon FROM channel WHERE chanid=%d;", + channel_id ); + msql_res = gmyth_query_process_statement ( gmyth_epg->sqlquery, query_str ); - if (msql_res == NULL) { - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__); + if ( msql_res == NULL ) + { + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ ); return NULL; - } else { + } + else + { MYSQL_ROW row; - if ((row = mysql_fetch_row (msql_res)) != NULL) { + if ( ( row = mysql_fetch_row ( msql_res ) ) != NULL ) + { - channel_info = g_new0 (GMythChannelInfo, 1); + channel_info = g_new0 ( GMythChannelInfo, 1 ); channel_info->channel_ID = channel_id; - channel_info->channel_num = g_string_new (row[0]); - channel_info->channel_name = g_string_new (row[1]); - channel_info->channel_icon = g_string_new (row[2]); + channel_info->channel_num = g_string_new ( row[0] ); + channel_info->channel_name = g_string_new ( row[1] ); + channel_info->channel_icon = g_string_new ( row[2] ); #ifdef GMYTH_USE_DEBUG - gmyth_channel_info_print (channel_info); + gmyth_channel_info_print ( channel_info ); #endif } } - mysql_free_result (msql_res); + mysql_free_result ( msql_res ); return channel_info; } @@ -240,130 +252,138 @@ * @return The amount of channels retrieved from database, or -1 if error. */ gint -gmyth_epg_get_program_list (GMythEPG * gmyth_epg, GList ** proglist, - const gint chan_num, GTimeVal * starttime, GTimeVal * endtime) +gmyth_epg_get_program_list ( GMythEPG * gmyth_epg, GList ** proglist, + const gint chan_num, GTimeVal * starttime, + GTimeVal * endtime ) { - gchar *startts = gmyth_util_time_to_string_from_time_val (starttime); - gchar *endts = gmyth_util_time_to_string_from_time_val (endtime); + gchar *startts = gmyth_util_time_to_string_from_time_val ( starttime ); + gchar *endts = gmyth_util_time_to_string_from_time_val ( endtime ); MYSQL_ROW row; GString *querystr; - assert (gmyth_epg); + assert ( gmyth_epg ); querystr = g_string_new - ("SELECT DISTINCT program.chanid, program.starttime, program.endtime, " - " program.title, program.subtitle, program.description, " - " program.category, channel.channum, channel.callsign, " - " channel.name, program.previouslyshown, channel.commfree, " - " channel.outputfilters, program.seriesid, program.programid, " - " program.airdate, program.stars, program.originalairdate, " - " program.category_type, oldrecstatus.recordid, " - " oldrecstatus.rectype, oldrecstatus.recstatus, " - " oldrecstatus.findid " "FROM program " - "LEFT JOIN channel ON program.chanid = channel.chanid " - "LEFT JOIN oldrecorded AS oldrecstatus ON " - " program.title = oldrecstatus.title AND " - " channel.callsign = oldrecstatus.station AND " - " program.starttime = oldrecstatus.starttime "); + ( "SELECT DISTINCT program.chanid, program.starttime, program.endtime, " + " program.title, program.subtitle, program.description, " + " program.category, channel.channum, channel.callsign, " + " channel.name, program.previouslyshown, channel.commfree, " + " channel.outputfilters, program.seriesid, program.programid, " + " program.airdate, program.stars, program.originalairdate, " + " program.category_type, oldrecstatus.recordid, " + " oldrecstatus.rectype, oldrecstatus.recstatus, " + " oldrecstatus.findid " "FROM program " + "LEFT JOIN channel ON program.chanid = channel.chanid " + "LEFT JOIN oldrecorded AS oldrecstatus ON " + " program.title = oldrecstatus.title AND " + " channel.callsign = oldrecstatus.station AND " + " program.starttime = oldrecstatus.starttime " ); - g_string_append_printf (querystr, - "WHERE program.chanid = %d " - " AND program.endtime >= '%s' " - " AND program.starttime <= '%s' " - " AND program.manualid = 0 ", chan_num, startts, endts); + g_string_append_printf ( querystr, + "WHERE program.chanid = %d " + " AND program.endtime >= '%s' " + " AND program.starttime <= '%s' " + " AND program.manualid = 0 ", chan_num, startts, + endts ); - if (!g_strrstr (querystr->str, " GROUP BY ")) - querystr = g_string_append (querystr, - " GROUP BY program.starttime, channel.channum, " - " channel.callsign, program.title "); + if ( !g_strrstr ( querystr->str, " GROUP BY " ) ) + querystr = g_string_append ( querystr, + " GROUP BY program.starttime, channel.channum, " + " channel.callsign, program.title " ); - if (!g_strrstr (querystr->str, " LIMIT ")) - querystr = g_string_append (querystr, " LIMIT 1000 "); + if ( !g_strrstr ( querystr->str, " LIMIT " ) ) + querystr = g_string_append ( querystr, " LIMIT 1000 " ); MYSQL_RES *res_set = - gmyth_query_process_statement (gmyth_epg->sqlquery, querystr->str); + gmyth_query_process_statement ( gmyth_epg->sqlquery, querystr->str ); - if (res_set == NULL) { - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__); + if ( res_set == NULL ) + { + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ ); return -1; } - (*proglist) = NULL; - while ((row = mysql_fetch_row (res_set)) != NULL) { + ( *proglist ) = NULL; + while ( ( row = mysql_fetch_row ( res_set ) ) != NULL ) + { - GMythProgramInfo *p = gmyth_program_info_new (); + GMythProgramInfo *p = gmyth_program_info_new ( ); - p->chanid = g_string_new (row[0]); + p->chanid = g_string_new ( row[0] ); - p->startts = gmyth_util_string_to_time_val (row[1]); - p->endts = gmyth_util_string_to_time_val (row[2]); + p->startts = gmyth_util_string_to_time_val ( row[1] ); + p->endts = gmyth_util_string_to_time_val ( row[2] ); - p->recstartts = g_new0 (GTimeVal, 1); + p->recstartts = g_new0 ( GTimeVal, 1 ); p->recstartts->tv_sec = p->startts->tv_sec; p->recstartts->tv_usec = p->startts->tv_usec; - p->recendts = g_new0 (GTimeVal, 1); + p->recendts = g_new0 ( GTimeVal, 1 ); p->recendts->tv_sec = p->endts->tv_sec; p->recendts->tv_usec = p->endts->tv_usec; - p->lastmodified = g_new0 (GTimeVal, 1); + p->lastmodified = g_new0 ( GTimeVal, 1 ); p->lastmodified->tv_sec = p->startts->tv_sec; p->lastmodified->tv_usec = p->startts->tv_usec; - p->title = g_string_new (row[3]); - p->subtitle = g_string_new (row[4]); - p->description = g_string_new (row[5]); - p->category = g_string_new (row[6]); - p->chanstr = g_string_new (row[7]); - p->chansign = g_string_new (row[8]); - p->channame = g_string_new (row[9]); - p->repeat = g_ascii_strtoull (row[10], NULL, 10); - p->chancommfree = g_ascii_strtoull (row[11], NULL, 10); - p->chanOutputFilters = g_string_new (row[12]); - p->seriesid = g_string_new (row[13]); - p->programid = g_string_new (row[14]); - p->year = g_string_new (row[15]); - p->stars = g_ascii_strtod (row[16], NULL); + p->title = g_string_new ( row[3] ); + p->subtitle = g_string_new ( row[4] ); + p->description = g_string_new ( row[5] ); + p->category = g_string_new ( row[6] ); + p->chanstr = g_string_new ( row[7] ); + p->chansign = g_string_new ( row[8] ); + p->channame = g_string_new ( row[9] ); + p->repeat = g_ascii_strtoull ( row[10], NULL, 10 ); + p->chancommfree = g_ascii_strtoull ( row[11], NULL, 10 ); + p->chanOutputFilters = g_string_new ( row[12] ); + p->seriesid = g_string_new ( row[13] ); + p->programid = g_string_new ( row[14] ); + p->year = g_string_new ( row[15] ); + p->stars = g_ascii_strtod ( row[16], NULL ); - if (!row[17] || !strcmp (row[17], "")) { + if ( !row[17] || !strcmp ( row[17], "" ) ) + { p->originalAirDate = 0; p->hasAirDate = FALSE; - } else { - p->originalAirDate = gmyth_util_string_to_time_val (row[17]); + } + else + { + p->originalAirDate = gmyth_util_string_to_time_val ( row[17] ); p->hasAirDate = TRUE; } - p->catType = g_string_new (row[18]); + p->catType = g_string_new ( row[18] ); - *proglist = g_list_append ((*proglist), p); + *proglist = g_list_append ( ( *proglist ), p ); #ifdef GMYTH_USE_DEBUG - gmyth_program_info_print (p); + gmyth_program_info_print ( p ); #endif } /* deallocate */ - mysql_free_result (res_set); - g_string_free (querystr, TRUE); + mysql_free_result ( res_set ); + g_string_free ( querystr, TRUE ); return TRUE; } gboolean -gmyth_epg_channel_has_icon (GMythEPG * gmyth_epg, - GMythChannelInfo * channel_info) +gmyth_epg_channel_has_icon ( GMythEPG * gmyth_epg, + GMythChannelInfo * channel_info ) { gboolean res = FALSE; - g_return_val_if_fail (gmyth_epg != NULL, FALSE); - g_return_val_if_fail (channel_info != NULL, FALSE); + g_return_val_if_fail ( gmyth_epg != NULL, FALSE ); + g_return_val_if_fail ( channel_info != NULL, FALSE ); - if (channel_info->channel_icon != NULL) { + if ( channel_info->channel_icon != NULL ) + { res = - gmyth_util_file_exists (gmyth_epg->backend_info, - channel_info->channel_icon->str); + gmyth_util_file_exists ( gmyth_epg->backend_info, + channel_info->channel_icon->str ); } return res; @@ -376,47 +396,55 @@ * @return TRUE if success, FALSE if any error happens. */ gboolean -gmyth_epg_channel_get_icon (GMythEPG * gmyth_epg, - GMythChannelInfo * channel_info, guint8 ** data, guint * length) +gmyth_epg_channel_get_icon ( GMythEPG * gmyth_epg, + GMythChannelInfo * channel_info, guint8 ** data, + guint * length ) { gboolean res = FALSE; - g_return_val_if_fail (gmyth_epg != NULL, FALSE); - g_return_val_if_fail (channel_info != NULL, FALSE); + g_return_val_if_fail ( gmyth_epg != NULL, FALSE ); + g_return_val_if_fail ( channel_info != NULL, FALSE ); - if (gmyth_epg_channel_has_icon (gmyth_epg, channel_info)) { + if ( gmyth_epg_channel_has_icon ( gmyth_epg, channel_info ) ) + { GMythFileTransfer *transfer = - gmyth_file_transfer_new (gmyth_epg->backend_info); + gmyth_file_transfer_new ( gmyth_epg->backend_info ); GMythFileReadResult gmyth_res; GByteArray *icon_data; guint64 icon_length = 0; res = - gmyth_file_transfer_open (transfer, - channel_info->channel_icon->str); - if (!res) { - gmyth_debug ("Channel icon could not be opened"); + gmyth_file_transfer_open ( transfer, + channel_info->channel_icon->str ); + if ( !res ) + { + gmyth_debug ( "Channel icon could not be opened" ); return FALSE; } - icon_length = gmyth_file_transfer_get_filesize (transfer); - if (icon_length <= 0) { - gmyth_debug ("Channel icon file size is zero or negative"); + icon_length = gmyth_file_transfer_get_filesize ( transfer ); + if ( icon_length <= 0 ) + { + gmyth_debug ( "Channel icon file size is zero or negative" ); return FALSE; } - icon_data = g_byte_array_new (); + icon_data = g_byte_array_new ( ); gmyth_res = - gmyth_file_transfer_read (transfer, icon_data, icon_length, FALSE); - if (gmyth_res == GMYTH_FILE_READ_EOF) { + gmyth_file_transfer_read ( transfer, icon_data, icon_length, + FALSE ); + if ( gmyth_res == GMYTH_FILE_READ_EOF ) + { *length = icon_length; *data = icon_data->data; - g_byte_array_free (icon_data, FALSE); + g_byte_array_free ( icon_data, FALSE ); res = TRUE; - } else { + } + else + { *length = 0; *data = NULL; - g_byte_array_free (icon_data, TRUE); + g_byte_array_free ( icon_data, TRUE ); } } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_epg.h --- a/gmyth/src/gmyth_epg.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_epg.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * 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 - */ +* +* 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_EPG_H_ #define GMYTH_EPG_H_ @@ -45,41 +44,43 @@ typedef struct _GMythEPGClass GMythEPGClass; struct _GMythEPGClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythEPG -{ - GObject parent; + { + GObject parent; - GMythQuery *sqlquery; - GMythBackendInfo *backend_info; -}; + GMythQuery *sqlquery; + GMythBackendInfo *backend_info; + }; -GType gmyth_epg_get_type (void); +GType gmyth_epg_get_type ( void ); -GMythEPG *gmyth_epg_new (void); +GMythEPG *gmyth_epg_new ( void ); -gboolean gmyth_epg_connect (GMythEPG * gmyth_epg, - GMythBackendInfo * backend_info); -gboolean gmyth_epg_disconnect (GMythEPG * gmyth_epg); +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); +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); +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); +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 ); #endif /*GMYTH_EPG_H_ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file.c --- a/gmyth/src/gmyth_file.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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" @@ -51,50 +50,51 @@ #include #define GMYTH_FILE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TYPE, GMythFilePrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TYPE, GMythFilePrivate)) struct _GMythFilePrivate -{ - gboolean disposed; - gint64 offset; - guint64 filesize; + { + gboolean disposed; + gint64 offset; + guint64 filesize; - GMythBackendInfo *backend_info; + GMythBackendInfo *backend_info; - /* Myth URI structure */ - gchar *filename; + /* Myth URI structure */ + gchar *filename; - gint file_id; -}; + gint file_id; + }; enum -{ - PROP_GMYTH_FILE_DUMMY, - PROP_GMYTH_FILE_FILENAME, - PROP_GMYTH_FILE_OFFSET, - PROP_GMYTH_FILE_FILESIZE, - PROP_GMYTH_FILE_BACKEND_INFO, - PROP_GMYTH_FILE_FILEID -}; + { + PROP_GMYTH_FILE_DUMMY, + PROP_GMYTH_FILE_FILENAME, + PROP_GMYTH_FILE_OFFSET, + PROP_GMYTH_FILE_FILESIZE, + PROP_GMYTH_FILE_BACKEND_INFO, + PROP_GMYTH_FILE_FILEID + }; -static void gmyth_file_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec); -static void gmyth_file_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec); +static void gmyth_file_set_property ( GObject * object, guint prop_id, + const GValue * value, + GParamSpec * pspec ); +static void gmyth_file_get_property ( GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec ); -static void gmyth_file_class_init (GMythFileClass * klass); -static void gmyth_file_init (GMythFile * object); -static void gmyth_file_dispose (GObject * object); -static void gmyth_file_finalize (GObject * object); +static void gmyth_file_class_init ( GMythFileClass * klass ); +static void gmyth_file_init ( GMythFile * object ); +static void gmyth_file_dispose ( GObject * object ); +static void gmyth_file_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythFile, gmyth_file, G_TYPE_OBJECT) - static void gmyth_file_class_init (GMythFileClass * klass) +G_DEFINE_TYPE ( GMythFile, gmyth_file, G_TYPE_OBJECT ) + static void gmyth_file_class_init ( GMythFileClass * klass ) { GObjectClass *gobject_class; GMythFileClass *gtransfer_class; - gobject_class = (GObjectClass *) klass; - gtransfer_class = (GMythFileClass *) gobject_class; + gobject_class = ( GObjectClass * ) klass; + gtransfer_class = ( GMythFileClass * ) gobject_class; gobject_class->dispose = gmyth_file_dispose; gobject_class->finalize = gmyth_file_finalize; @@ -103,67 +103,73 @@ gobject_class->get_property = gmyth_file_get_property; g_object_class_install_property - (gobject_class, PROP_GMYTH_FILE_FILENAME, - g_param_spec_string ("filename", "filename", - "The file name.", - "", - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + ( gobject_class, PROP_GMYTH_FILE_FILENAME, + g_param_spec_string ( "filename", "filename", + "The file name.", + "", + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB | G_PARAM_READABLE | + G_PARAM_WRITABLE ) ); g_object_class_install_property - (gobject_class, PROP_GMYTH_FILE_OFFSET, - g_param_spec_int64 ("file-offset", "file-offset", - "The offset (position) of this file", 0, - G_MAXINT64, 0, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + ( gobject_class, PROP_GMYTH_FILE_OFFSET, + g_param_spec_int64 ( "file-offset", "file-offset", + "The offset (position) of this file", 0, + G_MAXINT64, 0, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB | G_PARAM_READABLE | + G_PARAM_WRITABLE ) ); g_object_class_install_property - (gobject_class, PROP_GMYTH_FILE_FILESIZE, - g_param_spec_uint64 ("file-size", "file-size", - "The file size in bytes", - 0, G_MAXUINT64, 0, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + ( gobject_class, PROP_GMYTH_FILE_FILESIZE, + g_param_spec_uint64 ( "file-size", "file-size", + "The file size in bytes", + 0, G_MAXUINT64, 0, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB | G_PARAM_READABLE | + G_PARAM_WRITABLE ) ); g_object_class_install_property - (gobject_class, PROP_GMYTH_FILE_BACKEND_INFO, - g_param_spec_object ("backend-info", "backend-info", - "The Backend Information about the remote server", - G_TYPE_OBJECT, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + ( gobject_class, PROP_GMYTH_FILE_BACKEND_INFO, + g_param_spec_object ( "backend-info", "backend-info", + "The Backend Information about the remote server", + G_TYPE_OBJECT, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB | G_PARAM_READABLE | + G_PARAM_WRITABLE ) ); g_object_class_install_property - (gobject_class, PROP_GMYTH_FILE_FILEID, - g_param_spec_int ("file-id", "file-id", - "The file ID", 0, G_MAXINT, 0, - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE)); + ( gobject_class, PROP_GMYTH_FILE_FILEID, + g_param_spec_int ( "file-id", "file-id", + "The file ID", 0, G_MAXINT, 0, + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB | G_PARAM_READABLE | + G_PARAM_WRITABLE ) ); - g_type_class_add_private (gobject_class, sizeof (GMythFilePrivate)); + g_type_class_add_private ( gobject_class, sizeof ( GMythFilePrivate ) ); } static void -gmyth_file_init (GMythFile * file) +gmyth_file_init ( GMythFile * file ) { - g_return_if_fail (file != NULL); + g_return_if_fail ( file != NULL ); - file->priv = GMYTH_FILE_GET_PRIVATE (file); + file->priv = GMYTH_FILE_GET_PRIVATE ( file ); } static void -gmyth_file_dispose (GObject * object) +gmyth_file_dispose ( GObject * object ) { GMythFilePrivate *priv; - GMythFile *file = GMYTH_FILE (object); + GMythFile *file = GMYTH_FILE ( object ); - g_return_if_fail (file != NULL); + g_return_if_fail ( file != NULL ); - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); - if (priv->disposed) { + if ( priv->disposed ) + { /* If dispose did already run, return. */ return; } @@ -171,25 +177,27 @@ /* Make sure dispose does not run twice. */ priv->disposed = TRUE; - if (priv->backend_info != NULL) { - g_object_unref (priv->backend_info); + if ( priv->backend_info != NULL ) + { + g_object_unref ( priv->backend_info ); priv->backend_info = NULL; } - if (priv->filename != NULL) { - g_free (priv->filename); + if ( priv->filename != NULL ) + { + g_free ( priv->filename ); priv->filename = NULL; } - G_OBJECT_CLASS (gmyth_file_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_file_parent_class )->dispose ( object ); } static void -gmyth_file_finalize (GObject * object) +gmyth_file_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_file_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_file_parent_class )->finalize ( object ); } /** @@ -201,49 +209,51 @@ * @return a new instance of the File Transfer. */ GMythFile * -gmyth_file_new (GMythBackendInfo * backend_info) +gmyth_file_new ( GMythBackendInfo * backend_info ) { GMythFile *file = NULL; - g_return_val_if_fail (backend_info != NULL, NULL); + g_return_val_if_fail ( backend_info != NULL, NULL ); - GParameter *__params = g_new0 (GParameter, 1); + GParameter *__params = g_new0 ( GParameter, 1 ); GParameter *__params_it = __params; - (__params_it->name = - "backend-info", g_value_init (&__params_it->value, G_TYPE_OBJECT), - g_value_set_object (&__params_it->value, backend_info), __params_it++); - file = g_object_newv (GMYTH_FILE_TYPE, __params_it - __params, __params); + ( __params_it->name = + "backend-info", g_value_init ( &__params_it->value, G_TYPE_OBJECT ), + g_value_set_object ( &__params_it->value, backend_info ), __params_it++ ); + file = g_object_newv ( GMYTH_FILE_TYPE, __params_it - __params, __params ); return file; } gchar * -gmyth_file_get_file_name (GMythFile * file) +gmyth_file_get_file_name ( GMythFile * file ) { - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file); + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file ); - g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail ( file != NULL, NULL ); return priv->filename; } void -gmyth_file_set_file_name (GMythFile * file, const gchar * filename) +gmyth_file_set_file_name ( GMythFile * file, const gchar * filename ) { - g_return_if_fail (file != NULL); - g_return_if_fail (filename != NULL); + g_return_if_fail ( file != NULL ); + g_return_if_fail ( filename != NULL ); gchar *__temp2 = NULL; const gchar *__temp1 = NULL; - file->priv->filename = (__temp2 = (__temp1 = filename, (__temp1 == NULL ? - NULL : - g_strdup - (__temp1))), - (file->priv->filename == - NULL ? NULL : (file->priv->filename = - (g_free (file->priv->filename), NULL))), __temp2); + file->priv->filename = ( __temp2 = ( __temp1 = filename, ( __temp1 == NULL ? + NULL : + g_strdup + ( __temp1 ) ) ), + ( file->priv->filename == + NULL ? NULL : ( file->priv->filename = + ( g_free + ( file->priv->filename ), + NULL ) ) ), __temp2 ); } /** @@ -254,12 +264,12 @@ * @return a new instance of the File Transfer. */ GMythFile * -gmyth_file_new_with_uri (const gchar * uri_str) +gmyth_file_new_with_uri ( const gchar * uri_str ) { - GMythFile *file = GMYTH_FILE (g_object_new (GMYTH_FILE_TYPE, NULL)); - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file); + GMythFile *file = GMYTH_FILE ( g_object_new ( GMYTH_FILE_TYPE, NULL ) ); + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file ); - priv->backend_info = gmyth_backend_info_new_with_uri (uri_str); + priv->backend_info = gmyth_backend_info_new_with_uri ( uri_str ); return file; } @@ -272,21 +282,22 @@ * @return true, if the connection opening had been done successfully. */ gboolean -gmyth_file_setup (GMythFile * file, const gchar * filename) +gmyth_file_setup ( GMythFile * file, const gchar * filename ) { gboolean ret = TRUE; GMythFilePrivate *priv; - g_return_val_if_fail (file != NULL, FALSE); - g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE); + g_return_val_if_fail ( file != NULL, FALSE ); + g_return_val_if_fail ( filename != NULL && strlen ( filename ) > 0, FALSE ); - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); - if (priv->filename != NULL) { - gmyth_file_close (file); + if ( priv->filename != NULL ) + { + gmyth_file_close ( file ); } - priv->filename = g_strdup (filename); + priv->filename = g_strdup ( filename ); return ret; } @@ -297,14 +308,15 @@ * @param file The actual File Transfer instance. */ void -gmyth_file_close (GMythFile * file) +gmyth_file_close ( GMythFile * file ) { GMythFilePrivate *priv; - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); - if (priv->filename) { - g_free (priv->filename); + if ( priv->filename ) + { + g_free ( priv->filename ); priv->filename = NULL; } @@ -318,13 +330,13 @@ * @return The actual file size in bytes. */ guint64 -gmyth_file_get_filesize (GMythFile * file) +gmyth_file_get_filesize ( GMythFile * file ) { GMythFilePrivate *priv; - g_return_val_if_fail (file != NULL, 0); + g_return_val_if_fail ( file != NULL, 0 ); - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); return priv->filesize; } @@ -335,11 +347,11 @@ * @param filesize The actual File Transfer size, in bytes. */ void -gmyth_file_set_filesize (GMythFile * file, guint64 filesize) +gmyth_file_set_filesize ( GMythFile * file, guint64 filesize ) { GMythFilePrivate *priv; - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); priv->filesize = filesize; } @@ -352,9 +364,9 @@ * @return The actual file offset in bytes. */ gint64 -gmyth_file_get_offset (GMythFile * file) +gmyth_file_get_offset ( GMythFile * file ) { - g_return_val_if_fail (file != NULL, 0); + g_return_val_if_fail ( file != NULL, 0 ); return file->priv->offset; } @@ -366,125 +378,135 @@ * @param filesize The actual File offset, in bytes. */ void -gmyth_file_set_offset (GMythFile * file, gint64 offset) +gmyth_file_set_offset ( GMythFile * file, gint64 offset ) { GMythFilePrivate *priv; - priv = GMYTH_FILE_GET_PRIVATE (file); + priv = GMYTH_FILE_GET_PRIVATE ( file ); priv->offset = offset; } gchar * -gmyth_file_get_uri (GMythFile * file) +gmyth_file_get_uri ( GMythFile * file ) { - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file); + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file ); gchar *uri = NULL; - g_return_val_if_fail (file != NULL, NULL); + g_return_val_if_fail ( file != NULL, NULL ); - if (g_strstr_len (priv->filename, strlen (priv->filename), "://") != NULL) - uri = g_strdup (priv->filename); + if ( g_strstr_len ( priv->filename, strlen ( priv->filename ), "://" ) != + NULL ) + uri = g_strdup ( priv->filename ); else uri = - g_strdup_printf ("myth://%s:%d/%s", - gmyth_backend_info_get_hostname (priv-> - backend_info), - gmyth_backend_info_get_port (priv->backend_info), priv->filename); + g_strdup_printf ( "myth://%s:%d/%s", + gmyth_backend_info_get_hostname ( priv-> + backend_info ), + gmyth_backend_info_get_port ( priv-> + backend_info ), + priv->filename ); return uri; } static void -gmyth_file_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) +gmyth_file_set_property ( GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec ) { - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object)); + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE ( object ) ); - switch (prop_id) { - case PROP_GMYTH_FILE_FILENAME: + switch ( prop_id ) + { + case PROP_GMYTH_FILE_FILENAME: { - if (!g_value_get_string (value)) { + if ( !g_value_get_string ( value ) ) + { break; } - if (priv->filename != NULL) { - g_free (priv->filename); + if ( priv->filename != NULL ) + { + g_free ( priv->filename ); priv->filename = NULL; } - priv->filename = g_value_dup_string (value); - gmyth_debug ("Changed the filename to [%s]!", priv->filename); + priv->filename = g_value_dup_string ( value ); + gmyth_debug ( "Changed the filename to [%s]!", priv->filename ); break; } - case PROP_GMYTH_FILE_OFFSET: + case PROP_GMYTH_FILE_OFFSET: { - priv->offset = g_value_get_int64 (value); + priv->offset = g_value_get_int64 ( value ); break; } - case PROP_GMYTH_FILE_FILESIZE: + case PROP_GMYTH_FILE_FILESIZE: { - priv->filesize = g_value_get_uint64 (value); + priv->filesize = g_value_get_uint64 ( value ); break; } - case PROP_GMYTH_FILE_BACKEND_INFO: + case PROP_GMYTH_FILE_BACKEND_INFO: { - if (!g_value_get_object (value)) { + if ( !g_value_get_object ( value ) ) + { break; } - if (priv->backend_info != NULL) { - g_object_unref (priv->backend_info); + if ( priv->backend_info != NULL ) + { + g_object_unref ( priv->backend_info ); priv->backend_info = NULL; } - priv->backend_info = g_value_get_object (value); - gmyth_debug ("Changed the backend info to [%s]!", - gmyth_backend_info_get_hostname (priv->backend_info)); + priv->backend_info = g_value_get_object ( value ); + gmyth_debug ( "Changed the backend info to [%s]!", + gmyth_backend_info_get_hostname ( priv-> + backend_info ) ); break; } - case PROP_GMYTH_FILE_FILEID: + case PROP_GMYTH_FILE_FILEID: { - priv->file_id = g_value_get_int (value); + priv->file_id = g_value_get_int ( value ); break; } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID ( object, prop_id, pspec ); + break; } } static void -gmyth_file_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) +gmyth_file_get_property ( GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec ) { - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object)); + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE ( object ) ); - switch (prop_id) { - case PROP_GMYTH_FILE_FILENAME: + switch ( prop_id ) + { + case PROP_GMYTH_FILE_FILENAME: { - gmyth_debug ("Got the filename to [%s]!", priv->filename); - g_value_set_string (value, priv->filename); + gmyth_debug ( "Got the filename to [%s]!", priv->filename ); + g_value_set_string ( value, priv->filename ); break; } - case PROP_GMYTH_FILE_OFFSET: + case PROP_GMYTH_FILE_OFFSET: { - g_value_set_int64 (value, priv->offset); + g_value_set_int64 ( value, priv->offset ); break; } - case PROP_GMYTH_FILE_FILESIZE: + case PROP_GMYTH_FILE_FILESIZE: { - g_value_set_uint64 (value, priv->filesize); + g_value_set_uint64 ( value, priv->filesize ); break; } - case PROP_GMYTH_FILE_BACKEND_INFO: - g_value_set_object (value, priv->backend_info); - break; - case PROP_GMYTH_FILE_FILEID: - g_value_set_int (value, priv->file_id); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + case PROP_GMYTH_FILE_BACKEND_INFO: + g_value_set_object ( value, priv->backend_info ); + break; + case PROP_GMYTH_FILE_FILEID: + g_value_set_int ( value, priv->file_id ); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID ( object, prop_id, pspec ); + break; } } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file.h --- a/gmyth/src/gmyth_file.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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_FILE_H__ #define __GMYTH_FILE_H__ @@ -50,43 +49,43 @@ #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 -{ - GMYTH_FILE_READ_OK = 0, - GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1, - GMYTH_FILE_READ_ERROR = 2, - GMYTH_FILE_READ_EOF = 3 -} GMythFileReadResult; + { + GMYTH_FILE_READ_OK = 0, + GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1, + GMYTH_FILE_READ_ERROR = 2, + GMYTH_FILE_READ_EOF = 3 + } GMythFileReadResult; typedef struct _GMythFile GMythFile; typedef struct _GMythFileClass GMythFileClass; typedef struct _GMythFilePrivate GMythFilePrivate; struct _GMythFile -{ - GObject parent; - GMythFilePrivate *priv; -}; + { + GObject parent; + GMythFilePrivate *priv; + }; struct _GMythFileClass -{ - GObjectClass parent_class; -}; + { + 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); +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); +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); +gint64 gmyth_file_get_offset ( GMythFile * file ); +void gmyth_file_set_offset ( GMythFile * file, gint64 offset ); -gchar *gmyth_file_get_uri (GMythFile * file); +gchar *gmyth_file_get_uri ( GMythFile * file ); G_END_DECLS #endif /* __GMYTH_FILE_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file_local.c --- a/gmyth/src/gmyth_file_local.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file_local.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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" @@ -51,70 +50,72 @@ #include #define GMYTH_FILE_LOCAL_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalPrivate)) struct _GMythFileLocalPrivate -{ + { - gboolean disposed; + gboolean disposed; - GMutex *mutex; + GMutex *mutex; - gint fd; + gint fd; - GIOChannel *file_io; + GIOChannel *file_io; -}; + }; -static void gmyth_file_local_class_init (GMythFileLocalClass * klass); -static void gmyth_file_local_init (GMythFileLocal * object); -static void gmyth_file_local_dispose (GObject * object); -static void gmyth_file_local_finalize (GObject * object); +static void gmyth_file_local_class_init ( GMythFileLocalClass * klass ); +static void gmyth_file_local_init ( GMythFileLocal * object ); +static void gmyth_file_local_dispose ( GObject * object ); +static void gmyth_file_local_finalize ( GObject * object ); -static gboolean _control_acquire_context (GMythFileLocal * file_local, - gboolean do_wait); +static gboolean _control_acquire_context ( GMythFileLocal * file_local, + gboolean do_wait ); -static gboolean _control_release_context (GMythFileLocal * file_local); +static gboolean _control_release_context ( GMythFileLocal * file_local ); -G_DEFINE_TYPE (GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE) - static void gmyth_file_local_class_init (GMythFileLocalClass * klass) +G_DEFINE_TYPE ( GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE ) + static void gmyth_file_local_class_init ( GMythFileLocalClass * klass ) { GObjectClass *gobject_class; GMythFileLocalClass *gtransfer_class; - gobject_class = (GObjectClass *) klass; - gtransfer_class = (GMythFileLocalClass *) gobject_class; + gobject_class = ( GObjectClass * ) klass; + gtransfer_class = ( GMythFileLocalClass * ) gobject_class; gobject_class->dispose = gmyth_file_local_dispose; gobject_class->finalize = gmyth_file_local_finalize; - g_type_class_add_private (gobject_class, sizeof (GMythFileLocalPrivate)); + g_type_class_add_private ( gobject_class, + sizeof ( GMythFileLocalPrivate ) ); } static void -gmyth_file_local_init (GMythFileLocal * file_local) +gmyth_file_local_init ( GMythFileLocal * file_local ) { GMythFileLocalPrivate *priv; - g_return_if_fail (file_local != NULL); + g_return_if_fail ( file_local != NULL ); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - priv->mutex = g_mutex_new (); + priv->mutex = g_mutex_new ( ); } static void -gmyth_file_local_dispose (GObject * object) +gmyth_file_local_dispose ( GObject * object ) { GMythFileLocalPrivate *priv; - GMythFileLocal *file_local = GMYTH_FILE_LOCAL (object); + GMythFileLocal *file_local = GMYTH_FILE_LOCAL ( object ); - g_return_if_fail (file_local != NULL); + g_return_if_fail ( file_local != NULL ); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - if (priv->disposed) { + if ( priv->disposed ) + { /* If dispose did already run, return. */ return; } @@ -122,25 +123,27 @@ /* Make sure dispose does not run twice. */ priv->disposed = TRUE; - if (priv->mutex != NULL) { - g_mutex_free (priv->mutex); + if ( priv->mutex != NULL ) + { + g_mutex_free ( priv->mutex ); priv->mutex = NULL; } - if (priv->file_io != NULL) { - g_io_channel_unref (priv->file_io); + if ( priv->file_io != NULL ) + { + g_io_channel_unref ( priv->file_io ); priv->file_io = NULL; } - G_OBJECT_CLASS (gmyth_file_local_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_file_local_parent_class )->dispose ( object ); } static void -gmyth_file_local_finalize (GObject * object) +gmyth_file_local_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_file_local_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_file_local_parent_class )->finalize ( object ); } /** @@ -152,12 +155,13 @@ * @return a new instance of the File Transfer. */ GMythFileLocal * -gmyth_file_local_new (GMythBackendInfo * backend_info) +gmyth_file_local_new ( GMythBackendInfo * backend_info ) { GMythFileLocal *file_local = - GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL)); + GMYTH_FILE_LOCAL ( g_object_new ( GMYTH_FILE_LOCAL_TYPE, NULL ) ); - g_object_set (GMYTH_FILE (file_local), "backend-info", &backend_info, NULL); + g_object_set ( GMYTH_FILE ( file_local ), "backend-info", &backend_info, + NULL ); return file_local; } @@ -170,34 +174,34 @@ * @return a new instance of the File Transfer. */ GMythFileLocal * -gmyth_file_local_new_with_uri (const gchar * uri_str) +gmyth_file_local_new_with_uri ( const gchar * uri_str ) { GMythFileLocal *file_local = - GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL)); - GMythURI *uri = gmyth_uri_new_with_value (uri_str); + GMYTH_FILE_LOCAL ( g_object_new ( GMYTH_FILE_LOCAL_TYPE, NULL ) ); + GMythURI *uri = gmyth_uri_new_with_value ( uri_str ); - gmyth_debug ("GMythURI path segment = %s", gmyth_uri_get_path (uri)); + gmyth_debug ( "GMythURI path segment = %s", gmyth_uri_get_path ( uri ) ); - g_object_set (GMYTH_FILE (file_local), - "backend-info", gmyth_backend_info_new_with_uri (uri_str), - "filename", g_strdup (gmyth_uri_get_path (uri)), NULL); + g_object_set ( GMYTH_FILE ( file_local ), + "backend-info", gmyth_backend_info_new_with_uri ( uri_str ), + "filename", g_strdup ( gmyth_uri_get_path ( uri ) ), NULL ); - g_object_unref (uri); + g_object_unref ( uri ); return file_local; } gchar * -gmyth_file_local_get_file_name (GMythFileLocal * file_local) +gmyth_file_local_get_file_name ( GMythFileLocal * file_local ) { - return gmyth_file_get_file_name (GMYTH_FILE (file_local)); + return gmyth_file_get_file_name ( GMYTH_FILE ( file_local ) ); } void -gmyth_file_local_set_file_name (GMythFileLocal * file_local, - const gchar * filename) +gmyth_file_local_set_file_name ( GMythFileLocal * file_local, + const gchar * filename ) { - gmyth_file_set_file_name (GMYTH_FILE (file_local), filename); + gmyth_file_set_file_name ( GMYTH_FILE ( file_local ), filename ); } /** @@ -208,24 +212,25 @@ * @return true, if the connection opening had been done successfully. */ gboolean -gmyth_file_local_open (GMythFileLocal * file_local) +gmyth_file_local_open ( GMythFileLocal * file_local ) { gboolean ret = TRUE; GMythFileLocalPrivate *priv; gchar *file_name_uri = NULL; - g_return_val_if_fail (file_local != NULL, FALSE); + g_return_val_if_fail ( file_local != NULL, FALSE ); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); - file_name_uri = gmyth_file_local_get_file_name (file_local); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); + file_name_uri = gmyth_file_local_get_file_name ( file_local ); - if (file_name_uri != NULL) { + if ( file_name_uri != NULL ) + { priv->file_io = - g_io_channel_new_file (g_strdup (file_name_uri), "r+", NULL); - g_free (file_name_uri); + g_io_channel_new_file ( g_strdup ( file_name_uri ), "r+", NULL ); + g_free ( file_name_uri ); } - if (priv->file_io < 0) + if ( priv->file_io < 0 ) ret = FALSE; return ret; @@ -237,9 +242,9 @@ * @param file_local The actual File Transfer instance. */ void -gmyth_file_local_close (GMythFileLocal * file_local) +gmyth_file_local_close ( GMythFileLocal * file_local ) { - g_return_if_fail (file_local != NULL); + g_return_if_fail ( file_local != NULL ); } /** @@ -251,15 +256,15 @@ * @return true, if the acquire had been got. */ static gboolean -_control_acquire_context (GMythFileLocal * file_local, gboolean do_wait) +_control_acquire_context ( GMythFileLocal * file_local, gboolean do_wait ) { gboolean ret = TRUE; GMythFileLocalPrivate *priv; - g_return_val_if_fail (file_local != NULL, FALSE); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + g_return_val_if_fail ( file_local != NULL, FALSE ); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - g_mutex_lock (priv->mutex); + g_mutex_lock ( priv->mutex ); return ret; } @@ -271,15 +276,15 @@ * @return true, if the local file read/write permissions had been releaseds. */ static gboolean -_control_release_context (GMythFileLocal * file_local) +_control_release_context ( GMythFileLocal * file_local ) { gboolean ret = TRUE; GMythFileLocalPrivate *priv; - g_return_val_if_fail (file_local != NULL, FALSE); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + g_return_val_if_fail ( file_local != NULL, FALSE ); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - g_mutex_unlock (priv->mutex); + g_mutex_unlock ( priv->mutex ); return ret; } @@ -298,8 +303,8 @@ * or the error code. */ GMythFileReadResult -gmyth_file_local_read (GMythFileLocal * file_local, GByteArray * data, - gint size, gboolean read_unlimited) +gmyth_file_local_read ( GMythFileLocal * file_local, GByteArray * data, + gint size, gboolean read_unlimited ) { gsize bytes_read = 0; gint64 total_read = 0; @@ -311,69 +316,78 @@ GIOCondition io_cond; GIOStatus io_status = G_IO_STATUS_NORMAL; - g_return_val_if_fail (file_local != NULL, FALSE); - g_return_val_if_fail (data != NULL, GMYTH_FILE_READ_ERROR); + g_return_val_if_fail ( file_local != NULL, FALSE ); + g_return_val_if_fail ( data != NULL, GMYTH_FILE_READ_ERROR ); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - io_status = g_io_channel_set_encoding (priv->file_io, NULL, &error); - if (io_status == G_IO_STATUS_NORMAL) - gmyth_debug ("Setting encoding to binary file data stream.\n"); + io_status = g_io_channel_set_encoding ( priv->file_io, NULL, &error ); + if ( io_status == G_IO_STATUS_NORMAL ) + gmyth_debug ( "Setting encoding to binary file data stream.\n" ); - io_cond = g_io_channel_get_buffer_condition (priv->file_io); + io_cond = g_io_channel_get_buffer_condition ( priv->file_io ); - _control_acquire_context (file_local, TRUE); + _control_acquire_context ( file_local, TRUE ); - if (size > 0) { - gchar *data_buffer = g_new0 (gchar, size); + if ( size > 0 ) + { + gchar *data_buffer = g_new0 ( gchar, size ); - io_status = g_io_channel_read_chars (priv->file_io, - data_buffer, (gsize) size, &bytes_read, &error); + io_status = g_io_channel_read_chars ( priv->file_io, + data_buffer, ( gsize ) size, + &bytes_read, &error ); - if (io_status != G_IO_STATUS_NORMAL) { - gmyth_debug ("Error on io_channel"); - g_free (data_buffer); + if ( io_status != G_IO_STATUS_NORMAL ) + { + gmyth_debug ( "Error on io_channel" ); + g_free ( data_buffer ); retval = GMYTH_FILE_READ_ERROR; goto error; } /* append new data to the increasing byte array */ data = - g_byte_array_append (data, (const guint8 *) data_buffer, - bytes_read); + g_byte_array_append ( data, ( const guint8 * ) data_buffer, + bytes_read ); total_read += bytes_read; - if (!read_unlimited && (gmyth_file_local_get_filesize (file_local) > 0) - && (gmyth_file_local_get_offset (file_local) == - gmyth_file_local_get_filesize (file_local))) { + if ( !read_unlimited + && ( gmyth_file_local_get_filesize ( file_local ) > 0 ) + && ( gmyth_file_local_get_offset ( file_local ) == + gmyth_file_local_get_filesize ( file_local ) ) ) + { retval = GMYTH_FILE_READ_EOF; goto error; } - g_free (data_buffer); - } else { + g_free ( data_buffer ); + } + else + { retval = GMYTH_FILE_READ_ERROR; } error: - _control_release_context (file_local); + _control_release_context ( file_local ); - if (error != NULL) { - gmyth_debug ("Cleaning-up ERROR: [msg = %s, code = %d]\n", - error->message, error->code); - g_error_free (error); + if ( error != NULL ) + { + gmyth_debug ( "Cleaning-up ERROR: [msg = %s, code = %d]\n", + error->message, error->code ); + g_error_free ( error ); } - if (total_read > 0) - gmyth_file_local_set_offset (file_local, - (gmyth_file_local_get_offset (file_local) + total_read)); + if ( total_read > 0 ) + gmyth_file_local_set_offset ( file_local, + ( gmyth_file_local_get_offset + ( file_local ) + total_read ) ); return retval; } gint64 -gmyth_file_local_seek (GMythFileLocal * file_local, gint64 pos, - GSeekType whence) +gmyth_file_local_seek ( GMythFileLocal * file_local, gint64 pos, + GSeekType whence ) { GMythFileLocalPrivate *priv; @@ -381,13 +395,14 @@ GIOStatus io_status = G_IO_STATUS_NORMAL; - g_return_val_if_fail (file_local != NULL, -1); + g_return_val_if_fail ( file_local != NULL, -1 ); - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local); + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local ); - io_status = g_io_channel_seek_position (priv->file_io, pos, whence, &error); + io_status = + g_io_channel_seek_position ( priv->file_io, pos, whence, &error ); - if (io_status == G_IO_STATUS_ERROR) + if ( io_status == G_IO_STATUS_ERROR ) pos = -1; return pos; @@ -402,11 +417,11 @@ * @return The actual file_local size in bytes. */ guint64 -gmyth_file_local_get_filesize (GMythFileLocal * file_local) +gmyth_file_local_get_filesize ( GMythFileLocal * file_local ) { - g_return_val_if_fail (file_local != NULL, 0); + g_return_val_if_fail ( file_local != NULL, 0 ); - return gmyth_file_get_filesize (GMYTH_FILE (file_local)); + return gmyth_file_get_filesize ( GMYTH_FILE ( file_local ) ); } /** @@ -416,11 +431,11 @@ * @param filesize The actual File Transfer size, in bytes. */ void -gmyth_file_local_set_filesize (GMythFileLocal * file_local, guint64 filesize) +gmyth_file_local_set_filesize ( GMythFileLocal * file_local, guint64 filesize ) { - g_return_if_fail (file_local != NULL); + g_return_if_fail ( file_local != NULL ); - gmyth_file_set_filesize (GMYTH_FILE (file_local), filesize); + gmyth_file_set_filesize ( GMYTH_FILE ( file_local ), filesize ); } /** @@ -431,11 +446,11 @@ * @return The actual file offset in bytes. */ gint64 -gmyth_file_local_get_offset (GMythFileLocal * file_local) +gmyth_file_local_get_offset ( GMythFileLocal * file_local ) { - g_return_val_if_fail (file_local != NULL, 0); + g_return_val_if_fail ( file_local != NULL, 0 ); - return gmyth_file_get_offset (GMYTH_FILE (file_local)); + return gmyth_file_get_offset ( GMYTH_FILE ( file_local ) ); } /** @@ -445,9 +460,9 @@ * @param offset The actual File Local offset, in bytes. */ void -gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset) +gmyth_file_local_set_offset ( GMythFileLocal * file_local, gint64 offset ) { - g_return_if_fail (file_local != NULL); + g_return_if_fail ( file_local != NULL ); - gmyth_file_set_offset (GMYTH_FILE (file_local), offset); + gmyth_file_set_offset ( GMYTH_FILE ( file_local ), offset ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file_local.h --- a/gmyth/src/gmyth_file_local.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file_local.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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_FILE_LOCAL_H__ #define __GMYTH_FILE_LOCAL_H__ @@ -55,38 +54,38 @@ typedef struct _GMythFileLocalPrivate GMythFileLocalPrivate; struct _GMythFileLocal -{ - GMythFile parent; -}; + { + GMythFile parent; + }; struct _GMythFileLocalClass -{ - GMythFileClass parent_class; -}; + { + GMythFileClass parent_class; + }; -GType gmyth_file_local_get_type (void); -GMythFileLocal *gmyth_file_local_new (GMythBackendInfo * backend_info); -GMythFileLocal *gmyth_file_local_new_with_uri (const gchar * uri); -gchar *gmyth_file_local_get_file_name (GMythFileLocal * file_local); -void gmyth_file_local_set_file_name (GMythFileLocal * file_local, - const gchar * filename); -gboolean gmyth_file_local_open (GMythFileLocal * file_local); -void gmyth_file_local_close (GMythFileLocal * file_local); -gboolean gmyth_file_local_is_open (GMythFileLocal * file_local); +GType gmyth_file_local_get_type ( void ); +GMythFileLocal *gmyth_file_local_new ( GMythBackendInfo * backend_info ); +GMythFileLocal *gmyth_file_local_new_with_uri ( const gchar * uri ); +gchar *gmyth_file_local_get_file_name ( GMythFileLocal * file_local ); +void gmyth_file_local_set_file_name ( GMythFileLocal * file_local, + const gchar * filename ); +gboolean gmyth_file_local_open ( GMythFileLocal * file_local ); +void gmyth_file_local_close ( GMythFileLocal * file_local ); +gboolean gmyth_file_local_is_open ( GMythFileLocal * file_local ); GMythFileReadResult -gmyth_file_local_read (GMythFileLocal * file_local, - GByteArray * data, gint size, gboolean read_unlimited); +gmyth_file_local_read ( GMythFileLocal * file_local, + GByteArray * data, gint size, gboolean read_unlimited ); -gint64 gmyth_file_local_seek (GMythFileLocal * file_local, - gint64 pos, GSeekType whence); +gint64 gmyth_file_local_seek ( GMythFileLocal * file_local, + gint64 pos, GSeekType whence ); -guint64 gmyth_file_local_get_filesize (GMythFileLocal * file_local); -void gmyth_file_local_set_filesize (GMythFileLocal * file, guint64 filesize); +guint64 gmyth_file_local_get_filesize ( GMythFileLocal * file_local ); +void gmyth_file_local_set_filesize ( GMythFileLocal * file, guint64 filesize ); -gint64 gmyth_file_local_get_offset (GMythFileLocal * file_local); -void gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset); +gint64 gmyth_file_local_get_offset ( GMythFileLocal * file_local ); +void gmyth_file_local_set_offset ( GMythFileLocal * file_local, gint64 offset ); G_END_DECLS #endif /* __GMYTH_FILE_LOCAL_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file_transfer.c Wed May 23 19:50:41 2007 +0100 @@ -9,27 +9,26 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - * - * GStreamer MythTV plug-in properties: - * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv] - * - path (qurl - remote file to be opened) - * - port number * - */ + * + * 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 + * + * GStreamer MythTV plug-in properties: + * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv] + * - path (qurl - remote file to be opened) + * - port number * + */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -59,96 +58,101 @@ #define GMYTH_FILE_TRANSFER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferPrivate)) + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferPrivate)) enum myth_sock_types -{ - GMYTH_PLAYBACK_TYPE = 0, - GMYTH_MONITOR_TYPE, - GMYTH_FILETRANSFER_TYPE, - GMYTH_RINGBUFFER_TYPE -}; + { + GMYTH_PLAYBACK_TYPE = 0, + GMYTH_MONITOR_TYPE, + GMYTH_FILETRANSFER_TYPE, + GMYTH_RINGBUFFER_TYPE + }; struct _GMythFileTransferPrivate -{ - GMythRecorder *recorder; + { + GMythRecorder *recorder; - gboolean do_next_program_chain; - gboolean disposed; - gboolean livetv_wait; + gboolean do_next_program_chain; + gboolean disposed; + gboolean livetv_wait; - /* MythTV version number */ - gint mythtv_version; + /* MythTV version number */ + gint mythtv_version; - /* socket descriptors */ - GMythSocket *control_sock; - GMythSocket *sock; - GMutex *mutex; - gint file_id; -}; + /* socket descriptors */ + GMythSocket *control_sock; + GMythSocket *sock; + GMutex *mutex; + gint file_id; + }; -static void gmyth_file_transfer_class_init (GMythFileTransferClass * klass); -static void gmyth_file_transfer_init (GMythFileTransfer * object); -static void gmyth_file_transfer_dispose (GObject * object); -static void gmyth_file_transfer_finalize (GObject * object); -static void _file_transfer_program_info_changed (GMythFileTransfer * transfer, - gint msg_code, gpointer livetv_recorder); -static gboolean _connect_to_backend (GMythFileTransfer * transfer); -static gboolean _control_acquire_context (GMythFileTransfer * transfer, - gboolean do_wait); -static gboolean _control_release_context (GMythFileTransfer * transfer); +static void gmyth_file_transfer_class_init ( GMythFileTransferClass * klass ); +static void gmyth_file_transfer_init ( GMythFileTransfer * object ); +static void gmyth_file_transfer_dispose ( GObject * object ); +static void gmyth_file_transfer_finalize ( GObject * object ); +static void _file_transfer_program_info_changed ( GMythFileTransfer * transfer, + gint msg_code, + gpointer livetv_recorder ); +static gboolean _connect_to_backend ( GMythFileTransfer * transfer ); +static gboolean _control_acquire_context ( GMythFileTransfer * transfer, + gboolean do_wait ); +static gboolean _control_release_context ( GMythFileTransfer * transfer ); -G_DEFINE_TYPE (GMythFileTransfer, gmyth_file_transfer, GMYTH_FILE_TYPE) - static void gmyth_file_transfer_class_init (GMythFileTransferClass * klass) +G_DEFINE_TYPE ( GMythFileTransfer, gmyth_file_transfer, GMYTH_FILE_TYPE ) + static void gmyth_file_transfer_class_init ( GMythFileTransferClass * + klass ) { GObjectClass *gobject_class; GMythFileTransferClass *gtransfer_class; - gobject_class = (GObjectClass *) klass; - gtransfer_class = (GMythFileTransferClass *) gobject_class; + gobject_class = ( GObjectClass * ) klass; + gtransfer_class = ( GMythFileTransferClass * ) gobject_class; gobject_class->dispose = gmyth_file_transfer_dispose; gobject_class->finalize = gmyth_file_transfer_finalize; - g_type_class_add_private (gobject_class, sizeof (GMythFileTransferPrivate)); + g_type_class_add_private ( gobject_class, + sizeof ( GMythFileTransferPrivate ) ); gtransfer_class->program_info_changed_handler = _file_transfer_program_info_changed; gtransfer_class->program_info_changed_handler_signal_id = - g_signal_new ("program-info-changed", - G_TYPE_FROM_CLASS (gtransfer_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, 0, NULL, NULL, - gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_POINTER); + g_signal_new ( "program-info-changed", + G_TYPE_FROM_CLASS ( gtransfer_class ), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | + G_SIGNAL_NO_HOOKS, 0, NULL, NULL, + gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2, + G_TYPE_INT, G_TYPE_POINTER ); } static void -gmyth_file_transfer_init (GMythFileTransfer * transfer) +gmyth_file_transfer_init ( GMythFileTransfer * transfer ) { - g_return_if_fail (transfer != NULL); + g_return_if_fail ( transfer != NULL ); - transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); - transfer->priv->mutex = g_mutex_new (); + transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); + transfer->priv->mutex = g_mutex_new ( ); - g_signal_connect (G_OBJECT (transfer), "program-info-changed", - (GCallback) (GMYTH_FILE_TRANSFER_GET_CLASS - (transfer)->program_info_changed_handler), NULL); + g_signal_connect ( G_OBJECT ( transfer ), "program-info-changed", + ( GCallback ) ( GMYTH_FILE_TRANSFER_GET_CLASS + ( transfer )-> + program_info_changed_handler ), NULL ); } static void -gmyth_file_transfer_dispose (GObject * object) +gmyth_file_transfer_dispose ( GObject * object ) { GMythFileTransferPrivate *priv; - GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (object); + GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER ( object ); - g_return_if_fail (transfer != NULL); + g_return_if_fail ( transfer != NULL ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - if (priv->disposed) { + if ( priv->disposed ) + { /* If dispose did already run, return. */ return; } @@ -156,35 +160,39 @@ /* Make sure dispose does not run twice. */ priv->disposed = TRUE; - if (priv->mutex != NULL) { - g_mutex_free (priv->mutex); + if ( priv->mutex != NULL ) + { + g_mutex_free ( priv->mutex ); priv->mutex = NULL; } - if (priv->control_sock != NULL) { - g_object_unref (priv->control_sock); + if ( priv->control_sock != NULL ) + { + g_object_unref ( priv->control_sock ); priv->control_sock = NULL; } - if (priv->sock != NULL) { - g_object_unref (priv->sock); + if ( priv->sock != NULL ) + { + g_object_unref ( priv->sock ); priv->sock = NULL; } - if (priv->recorder != NULL) { - g_object_unref (priv->recorder); + if ( priv->recorder != NULL ) + { + g_object_unref ( priv->recorder ); priv->recorder = NULL; } - G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_file_transfer_parent_class )->dispose ( object ); } static void -gmyth_file_transfer_finalize (GObject * object) +gmyth_file_transfer_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_file_transfer_parent_class )->finalize ( object ); } /** @@ -196,16 +204,16 @@ * @return a new instance of the File Transfer. */ GMythFileTransfer * -gmyth_file_transfer_new (GMythBackendInfo * backend_info) +gmyth_file_transfer_new ( GMythBackendInfo * backend_info ) { - GMythFileTransfer *transfer = g_object_new (GMYTH_FILE_TRANSFER_TYPE, - "backend-info", backend_info, - NULL); + GMythFileTransfer *transfer = g_object_new ( GMYTH_FILE_TRANSFER_TYPE, + "backend-info", backend_info, + NULL ); //GValue val = {0,}; //backend_info = g_object_ref( backend_info ); - gmyth_debug ("Creating FileTransfer BackendInfo hostname = %s", - gmyth_backend_info_get_hostname (backend_info)); + gmyth_debug ( "Creating FileTransfer BackendInfo hostname = %s", + gmyth_backend_info_get_hostname ( backend_info ) ); //GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri (uri_str); //g_value_init (&val, G_TYPE_OBJECT); //g_value_set_object (&val, backend_info); @@ -215,11 +223,11 @@ } gchar * -gmyth_file_transfer_get_file_name (GMythFileTransfer * transfer) +gmyth_file_transfer_get_file_name ( GMythFileTransfer * transfer ) { gchar *filename; - g_object_get (G_OBJECT (transfer), "filename", &filename, NULL); + g_object_get ( G_OBJECT ( transfer ), "filename", &filename, NULL ); return filename; } @@ -232,16 +240,16 @@ * @return a new instance of the File Transfer. */ GMythFileTransfer * -gmyth_file_transfer_new_with_uri (const gchar * uri_str) +gmyth_file_transfer_new_with_uri ( const gchar * uri_str ) { GMythFileTransfer *transfer = - GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL)); - gmyth_debug ("URI str = %s", uri_str); + GMYTH_FILE_TRANSFER ( g_object_new ( GMYTH_FILE_TRANSFER_TYPE, NULL ) ); + gmyth_debug ( "URI str = %s", uri_str ); //GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri (uri_str); GValue val = { 0, }; - g_value_init (&val, G_TYPE_OBJECT); - g_value_set_object (&val, gmyth_backend_info_new_with_uri (uri_str)); - g_object_set (G_OBJECT (transfer), "backend-info", &val, NULL); + g_value_init ( &val, G_TYPE_OBJECT ); + g_value_set_object ( &val, gmyth_backend_info_new_with_uri ( uri_str ) ); + g_object_set ( G_OBJECT ( transfer ), "backend-info", &val, NULL ); return transfer; } @@ -255,64 +263,75 @@ * @return true, if the connection opening had been done successfully. */ gboolean -gmyth_file_transfer_open (GMythFileTransfer * transfer, const gchar * filename) +gmyth_file_transfer_open ( GMythFileTransfer * transfer, + const gchar * filename ) { gboolean ret = TRUE; GMythFileTransferPrivate *priv; - g_return_val_if_fail (transfer != NULL, FALSE); - g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE); + g_return_val_if_fail ( transfer != NULL, FALSE ); + g_return_val_if_fail ( filename != NULL && strlen ( filename ) > 0, FALSE ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - gmyth_debug ("Opening the FileTransfer... (%s)", filename); + gmyth_debug ( "Opening the FileTransfer... (%s)", filename ); - g_object_set (GMYTH_FILE (transfer), "filename", filename, NULL); + g_object_set ( GMYTH_FILE ( transfer ), "filename", filename, NULL ); /* configure the control socket */ - if (TRUE /*priv->control_sock == NULL */ ) { - if (!_connect_to_backend (transfer)) { - gmyth_debug ("Connection to backend failed (Control Socket)."); + if ( TRUE /*priv->control_sock == NULL */ ) + { + if ( !_connect_to_backend ( transfer ) ) + { + gmyth_debug ( "Connection to backend failed (Control Socket)." ); ret = FALSE; } - if (priv->do_next_program_chain) { + if ( priv->do_next_program_chain ) + { priv->do_next_program_chain = FALSE; // fixme gmyth_debug - ("New file available before the current file was opened"); + ( "New file available before the current file was opened" ); GMythProgramInfo *prog_info = - gmyth_recorder_get_current_program_info (priv->recorder); + gmyth_recorder_get_current_program_info ( priv->recorder ); - if (prog_info != NULL && prog_info->pathname != NULL - && strlen (prog_info->pathname->str) > 0 - && g_ascii_strcasecmp (prog_info->pathname->str, - gmyth_file_get_file_name (GMYTH_FILE (transfer))) - != 0) + if ( prog_info != NULL && prog_info->pathname != NULL + && strlen ( prog_info->pathname->str ) > 0 + && g_ascii_strcasecmp ( prog_info->pathname->str, + gmyth_file_get_file_name ( GMYTH_FILE + ( transfer ) ) ) + != 0 ) ret = - gmyth_file_transfer_open (transfer, - g_strrstr (prog_info->pathname->str, "/")); + gmyth_file_transfer_open ( transfer, + g_strrstr ( prog_info->pathname-> + str, "/" ) ); - if (prog_info != NULL) - g_object_unref (prog_info); + if ( prog_info != NULL ) + g_object_unref ( prog_info ); - if (!ret) - gmyth_debug ("Cannot change to the next program info!"); + if ( !ret ) + gmyth_debug ( "Cannot change to the next program info!" ); else - gmyth_debug ("OK!!! MOVED to the next program info [%s]!", - gmyth_file_get_file_name (GMYTH_FILE (transfer))); + gmyth_debug ( "OK!!! MOVED to the next program info [%s]!", + gmyth_file_get_file_name ( GMYTH_FILE + ( transfer ) ) ); - } else { - gmyth_debug ("XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX"); + } + else + { + gmyth_debug ( "XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX" ); gmyth_debug - ("None new file found. We continue with the same file opened before"); + ( "None new file found. We continue with the same file opened before" ); } - } else { - gmyth_debug ("Remote transfer control socket already created."); + } + else + { + gmyth_debug ( "Remote transfer control socket already created." ); } - gmyth_debug ("Got file with size = %lld.\n", - gmyth_file_get_filesize (GMYTH_FILE (transfer))); + gmyth_debug ( "Got file with size = %lld.\n", + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) ); return ret; } @@ -325,7 +344,7 @@ * @return true, if the connection had been configured successfully. */ static gboolean -_connect_to_backend (GMythFileTransfer * transfer) +_connect_to_backend ( GMythFileTransfer * transfer ) { GString *base_str = NULL; GString *hostname = NULL; @@ -334,93 +353,100 @@ GMythFileTransferPrivate *priv; GMythBackendInfo *backend_info; - g_return_val_if_fail (transfer != NULL, FALSE); + g_return_val_if_fail ( transfer != NULL, FALSE ); - g_object_get (GMYTH_FILE (transfer), "backend-info", &backend_info, NULL); + g_object_get ( GMYTH_FILE ( transfer ), "backend-info", &backend_info, + NULL ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); - _control_acquire_context (transfer, TRUE); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); + _control_acquire_context ( transfer, TRUE ); /* Creates the control socket */ - if (priv->control_sock != NULL) { - g_object_unref (priv->control_sock); + if ( priv->control_sock != NULL ) + { + g_object_unref ( priv->control_sock ); priv->control_sock = NULL; } - base_str = g_string_new (""); + base_str = g_string_new ( "" ); - priv->control_sock = gmyth_socket_new (); + priv->control_sock = gmyth_socket_new ( ); // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version - if (!gmyth_socket_connect_to_backend (priv->control_sock, - backend_info->hostname, backend_info->port, TRUE)) { + if ( !gmyth_socket_connect_to_backend ( priv->control_sock, + backend_info->hostname, + backend_info->port, TRUE ) ) + { - g_object_unref (priv->control_sock); + g_object_unref ( priv->control_sock ); priv->control_sock = NULL; return FALSE; } /* Creates the data socket */ - if (priv->sock != NULL) { - g_object_unref (priv->sock); + if ( priv->sock != NULL ) + { + g_object_unref ( priv->sock ); priv->sock = NULL; } - priv->sock = gmyth_socket_new (); - gmyth_socket_connect (priv->sock, backend_info->hostname, - backend_info->port); - gmyth_debug ("Connecting file transfer... (%s, %d)", - backend_info->hostname, backend_info->port); + priv->sock = gmyth_socket_new ( ); + gmyth_socket_connect ( priv->sock, backend_info->hostname, + backend_info->port ); + gmyth_debug ( "Connecting file transfer... (%s, %d)", + backend_info->hostname, backend_info->port ); - strlist = gmyth_string_list_new (); - hostname = gmyth_socket_get_local_hostname (); - gmyth_debug ("[%s] MythTV version (from backend) = %d.\n", __FUNCTION__, - priv->control_sock->mythtv_version); - if (priv->control_sock->mythtv_version > 26) - g_string_printf (base_str, "ANN FileTransfer %s 1 -1", hostname->str); + strlist = gmyth_string_list_new ( ); + hostname = gmyth_socket_get_local_hostname ( ); + gmyth_debug ( "[%s] MythTV version (from backend) = %d.\n", __FUNCTION__, + priv->control_sock->mythtv_version ); + if ( priv->control_sock->mythtv_version > 26 ) + g_string_printf ( base_str, "ANN FileTransfer %s 1 -1", hostname->str ); else - g_string_printf (base_str, "ANN FileTransfer %s", hostname->str); + g_string_printf ( base_str, "ANN FileTransfer %s", hostname->str ); - gmyth_string_list_append_string (strlist, base_str); - gmyth_string_list_append_char_array (strlist, - gmyth_file_get_file_name (GMYTH_FILE (transfer))); + gmyth_string_list_append_string ( strlist, base_str ); + gmyth_string_list_append_char_array ( strlist, + gmyth_file_get_file_name ( GMYTH_FILE + ( transfer ) ) ); - gmyth_socket_write_stringlist (priv->sock, strlist); + gmyth_socket_write_stringlist ( priv->sock, strlist ); /* MONITOR Handler - DVB TV Chain update messages!!! */ - gmyth_socket_read_stringlist (priv->sock, strlist); + gmyth_socket_read_stringlist ( priv->sock, strlist ); /* file identification used in future file transfer requests to backend */ - priv->file_id = gmyth_string_list_get_int (strlist, 1); + priv->file_id = gmyth_string_list_get_int ( strlist, 1 ); /* Myth URI stream file size - decoded using two 8-bytes sequences (64 bits/long long types) */ - gmyth_file_set_filesize (GMYTH_FILE (transfer), - gmyth_string_list_get_int64 (strlist, 2)); + gmyth_file_set_filesize ( GMYTH_FILE ( transfer ), + gmyth_string_list_get_int64 ( strlist, 2 ) ); - gmyth_debug ("***** Received: recordernum = %d, filesize = %" - G_GUINT64_FORMAT "\n", priv->file_id, - gmyth_file_get_filesize (GMYTH_FILE (transfer))); + gmyth_debug ( "***** Received: recordernum = %d, filesize = %" + G_GUINT64_FORMAT "\n", priv->file_id, + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) ); - if (gmyth_file_get_filesize (GMYTH_FILE (transfer)) < 0) { + if ( gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) < 0 ) + { gmyth_debug - ("Got filesize equals to %llu is lesser than 0 [invalid stream file]\n", - gmyth_file_get_filesize (GMYTH_FILE (transfer))); - g_object_unref (priv->sock); + ( "Got filesize equals to %llu is lesser than 0 [invalid stream file]\n", + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) ); + g_object_unref ( priv->sock ); priv->sock = NULL; ret = FALSE; } - _control_release_context (transfer); + _control_release_context ( transfer ); - if (strlist != NULL) - g_object_unref (strlist); + if ( strlist != NULL ) + g_object_unref ( strlist ); - if (base_str != NULL) - g_string_free (base_str, TRUE); + if ( base_str != NULL ) + g_string_free ( base_str, TRUE ); - if (hostname != NULL) - g_string_free (hostname, TRUE); + if ( hostname != NULL ) + g_string_free ( hostname, TRUE ); return ret; } @@ -434,13 +460,15 @@ * @param live_tv A pointer to the LiveTV instance. * */ void -gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer * - transfer, gint msg_code, gpointer live_tv_recorder) +gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer * + transfer, gint msg_code, + gpointer + live_tv_recorder ) { - gmyth_debug ("Calling signal handler... [FILE_TRANSFER]"); + gmyth_debug ( "Calling signal handler... [FILE_TRANSFER]" ); - g_signal_emit (transfer, GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id, 0, /* details */ - msg_code, live_tv_recorder); + g_signal_emit ( transfer, GMYTH_FILE_TRANSFER_GET_CLASS ( transfer )->program_info_changed_handler_signal_id, 0, /* details */ + msg_code, live_tv_recorder ); } @@ -452,36 +480,36 @@ * @return true, if the File Transfer connection is opened. */ gboolean -gmyth_file_transfer_is_open (GMythFileTransfer * transfer) +gmyth_file_transfer_is_open ( GMythFileTransfer * transfer ) { GMythStringList *strlist; GMythFileTransferPrivate *priv; GString *query; - g_return_val_if_fail (transfer != NULL, FALSE); + g_return_val_if_fail ( transfer != NULL, FALSE ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); - g_return_val_if_fail (priv->control_sock != NULL, FALSE); - g_return_val_if_fail (priv->sock != NULL, FALSE); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); + g_return_val_if_fail ( priv->control_sock != NULL, FALSE ); + g_return_val_if_fail ( priv->sock != NULL, FALSE ); - _control_acquire_context (transfer, TRUE); + _control_acquire_context ( transfer, TRUE ); - strlist = gmyth_string_list_new (); - query = g_string_new (GMYTHTV_QUERY_HEADER); - g_string_append_printf (query, "%d", priv->file_id); + strlist = gmyth_string_list_new ( ); + query = g_string_new ( GMYTHTV_QUERY_HEADER ); + g_string_append_printf ( query, "%d", priv->file_id ); - gmyth_string_list_append_string (strlist, query); - gmyth_string_list_append_char_array (strlist, "IS_OPEN"); + gmyth_string_list_append_string ( strlist, query ); + gmyth_string_list_append_char_array ( strlist, "IS_OPEN" ); - gmyth_socket_write_stringlist (priv->control_sock, strlist); - gmyth_socket_read_stringlist (priv->control_sock, strlist); + gmyth_socket_write_stringlist ( priv->control_sock, strlist ); + gmyth_socket_read_stringlist ( priv->control_sock, strlist ); - _control_release_context (transfer); + _control_release_context ( transfer ); - g_string_free (query, TRUE); - g_object_unref (strlist); + g_string_free ( query, TRUE ); + g_object_unref ( strlist ); - return (strlist != NULL && gmyth_string_list_get_int (strlist, 0) == 1); + return ( strlist != NULL && gmyth_string_list_get_int ( strlist, 0 ) == 1 ); } /** @@ -490,47 +518,51 @@ * @param transfer The actual File Transfer instance. */ void -gmyth_file_transfer_close (GMythFileTransfer * transfer) +gmyth_file_transfer_close ( GMythFileTransfer * transfer ) { GMythStringList *strlist; GMythFileTransferPrivate *priv; GString *query; - g_return_if_fail (transfer != NULL); + g_return_if_fail ( transfer != NULL ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - if (priv->control_sock == NULL) + if ( priv->control_sock == NULL ) return; - _control_acquire_context (transfer, TRUE); + _control_acquire_context ( transfer, TRUE ); - strlist = gmyth_string_list_new (); - query = g_string_new (GMYTHTV_QUERY_HEADER); - g_string_append_printf (query, "%d", priv->file_id); + strlist = gmyth_string_list_new ( ); + query = g_string_new ( GMYTHTV_QUERY_HEADER ); + g_string_append_printf ( query, "%d", priv->file_id ); - gmyth_string_list_append_string (strlist, query); - gmyth_string_list_append_char_array (strlist, "DONE"); + gmyth_string_list_append_string ( strlist, query ); + gmyth_string_list_append_char_array ( strlist, "DONE" ); - if (gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist) <= 0) { + if ( gmyth_socket_sendreceive_stringlist ( priv->control_sock, strlist ) <= + 0 ) + { // fixme: time out??? - gmyth_debug ("Remote file timeout.\n"); + gmyth_debug ( "Remote file timeout.\n" ); } - g_string_free (query, TRUE); - g_object_unref (strlist); + g_string_free ( query, TRUE ); + g_object_unref ( strlist ); - if (priv->sock) { - g_object_unref (priv->sock); + if ( priv->sock ) + { + g_object_unref ( priv->sock ); priv->sock = NULL; } - if (priv->control_sock) { - g_object_unref (priv->control_sock); + if ( priv->control_sock ) + { + g_object_unref ( priv->control_sock ); priv->control_sock = NULL; } - _control_release_context (transfer); + _control_release_context ( transfer ); } /** @@ -543,47 +575,48 @@ * @return The actual position on the remote file (after seek has been done). */ gint64 -gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos, - gint whence) +gmyth_file_transfer_seek ( GMythFileTransfer * transfer, guint64 pos, + gint whence ) { - GMythStringList *strlist = gmyth_string_list_new (); + GMythStringList *strlist = gmyth_string_list_new ( ); GMythFileTransferPrivate *priv; GString *query; - g_return_val_if_fail (transfer != NULL, FALSE); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + g_return_val_if_fail ( transfer != NULL, FALSE ); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - g_return_val_if_fail (priv->sock != NULL, -1); - g_return_val_if_fail (priv->control_sock != NULL, -1); + g_return_val_if_fail ( priv->sock != NULL, -1 ); + g_return_val_if_fail ( priv->control_sock != NULL, -1 ); - strlist = gmyth_string_list_new (); - query = g_string_new (GMYTHTV_QUERY_HEADER); - g_string_append_printf (query, "%d", priv->file_id); + strlist = gmyth_string_list_new ( ); + query = g_string_new ( GMYTHTV_QUERY_HEADER ); + g_string_append_printf ( query, "%d", priv->file_id ); /* myth_control_acquire_context( transfer, TRUE ); */ - gmyth_string_list_append_string (strlist, query); - gmyth_string_list_append_char_array (strlist, "SEEK"); - gmyth_string_list_append_uint64 (strlist, pos); + gmyth_string_list_append_string ( strlist, query ); + gmyth_string_list_append_char_array ( strlist, "SEEK" ); + gmyth_string_list_append_uint64 ( strlist, pos ); - gmyth_string_list_append_int (strlist, whence); + gmyth_string_list_append_int ( strlist, whence ); - if (pos > 0) - gmyth_string_list_append_uint64 (strlist, pos); + if ( pos > 0 ) + gmyth_string_list_append_uint64 ( strlist, pos ); else - gmyth_string_list_append_uint64 (strlist, - gmyth_file_get_offset (GMYTH_FILE (transfer))); + gmyth_string_list_append_uint64 ( strlist, + gmyth_file_get_offset ( GMYTH_FILE + ( transfer ) ) ); - gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist); + gmyth_socket_sendreceive_stringlist ( priv->control_sock, strlist ); - gint64 retval = gmyth_string_list_get_int64 (strlist, 0); + gint64 retval = gmyth_string_list_get_int64 ( strlist, 0 ); - gmyth_file_set_offset (GMYTH_FILE (transfer), retval); - gmyth_debug ("Got reading position pointer from the streaming = %lld\n", - retval); + gmyth_file_set_offset ( GMYTH_FILE ( transfer ), retval ); + gmyth_debug ( "Got reading position pointer from the streaming = %lld\n", + retval ); - g_object_unref (strlist); - g_string_free (query, TRUE); + g_object_unref ( strlist ); + g_string_free ( query, TRUE ); /* myth_control_release_context( transfer ); */ @@ -599,15 +632,15 @@ * @return true, if the acquire had been got. */ static gboolean -_control_acquire_context (GMythFileTransfer * transfer, gboolean do_wait) +_control_acquire_context ( GMythFileTransfer * transfer, gboolean do_wait ) { gboolean ret = TRUE; GMythFileTransferPrivate *priv; - g_return_val_if_fail (transfer != NULL, FALSE); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + g_return_val_if_fail ( transfer != NULL, FALSE ); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - g_mutex_lock (priv->mutex); + g_mutex_lock ( priv->mutex ); return ret; } @@ -619,15 +652,15 @@ * @return true, if the socket read/write permissions had been releaseds. */ static gboolean -_control_release_context (GMythFileTransfer * transfer) +_control_release_context ( GMythFileTransfer * transfer ) { gboolean ret = TRUE; GMythFileTransferPrivate *priv; - g_return_val_if_fail (transfer != NULL, FALSE); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + g_return_val_if_fail ( transfer != NULL, FALSE ); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - g_mutex_unlock (priv->mutex); + g_mutex_unlock ( priv->mutex ); return ret; } @@ -646,8 +679,8 @@ * or the error code. */ GMythFileReadResult -gmyth_file_transfer_read (GMythFileTransfer * transfer, GByteArray * data, - gint size, gboolean read_unlimited) +gmyth_file_transfer_read ( GMythFileTransfer * transfer, GByteArray * data, + gint size, gboolean read_unlimited ) { gint bytes_sent = 0; gsize bytes_read = 0; @@ -670,194 +703,221 @@ gboolean ret = TRUE; GString *query; - g_return_val_if_fail (transfer != NULL, FALSE); - g_return_val_if_fail (data != NULL, GMYTH_FILE_READ_ERROR); + g_return_val_if_fail ( transfer != NULL, FALSE ); + g_return_val_if_fail ( data != NULL, GMYTH_FILE_READ_ERROR ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - strlist = gmyth_string_list_new (); + strlist = gmyth_string_list_new ( ); io_channel = priv->sock->sd_io_ch; io_channel_control = priv->control_sock->sd_io_ch; - io_status = g_io_channel_set_encoding (io_channel, NULL, &error); - if (io_status == G_IO_STATUS_NORMAL) - gmyth_debug ("[%s] Setting encoding to binary data socket).\n", - __FUNCTION__); + io_status = g_io_channel_set_encoding ( io_channel, NULL, &error ); + if ( io_status == G_IO_STATUS_NORMAL ) + gmyth_debug ( "[%s] Setting encoding to binary data socket).\n", + __FUNCTION__ ); - io_cond = g_io_channel_get_buffer_condition (io_channel); + io_cond = g_io_channel_get_buffer_condition ( io_channel ); - io_cond_control = g_io_channel_get_buffer_condition (io_channel); - if (priv->sock == NULL || (io_status == G_IO_STATUS_ERROR)) { - g_printerr ("gmyth_file_transfer_read(): Called with no raw socket.\n"); + io_cond_control = g_io_channel_get_buffer_condition ( io_channel ); + if ( priv->sock == NULL || ( io_status == G_IO_STATUS_ERROR ) ) + { + g_printerr + ( "gmyth_file_transfer_read(): Called with no raw socket.\n" ); return GMYTH_FILE_READ_ERROR; } - if (priv->control_sock == NULL || (io_status_control == G_IO_STATUS_ERROR)) { + if ( priv->control_sock == NULL + || ( io_status_control == G_IO_STATUS_ERROR ) ) + { g_printerr - ("gmyth_file_transfer_read(): Called with no control socket.\n"); + ( "gmyth_file_transfer_read(): Called with no control socket.\n" ); return GMYTH_FILE_READ_ERROR; } - query = g_string_new (GMYTHTV_QUERY_HEADER); - g_string_append_printf (query, "%d", priv->file_id); - gmyth_debug ("[%s] Transfer_query = %s\n", __FUNCTION__, query->str); + query = g_string_new ( GMYTHTV_QUERY_HEADER ); + g_string_append_printf ( query, "%d", priv->file_id ); + gmyth_debug ( "[%s] Transfer_query = %s\n", __FUNCTION__, query->str ); - _control_acquire_context (transfer, TRUE); + _control_acquire_context ( transfer, TRUE ); //Do Read - gmyth_string_list_append_char_array (strlist, query->str); - gmyth_string_list_append_char_array (strlist, "REQUEST_BLOCK"); - gmyth_string_list_append_int (strlist, size - total_read); + gmyth_string_list_append_char_array ( strlist, query->str ); + gmyth_string_list_append_char_array ( strlist, "REQUEST_BLOCK" ); + gmyth_string_list_append_int ( strlist, size - total_read ); guint iter_count = 3; - do { + do + { bytes_sent = 0; // Request the block to the backend - gmyth_socket_write_stringlist (priv->control_sock, strlist); + gmyth_socket_write_stringlist ( priv->control_sock, strlist ); - if (ret_strlist != NULL) - g_object_unref (ret_strlist); + if ( ret_strlist != NULL ) + g_object_unref ( ret_strlist ); - ret_strlist = gmyth_string_list_new (); + ret_strlist = gmyth_string_list_new ( ); // Receives the backand answer - gmyth_socket_read_stringlist (priv->control_sock, ret_strlist); + gmyth_socket_read_stringlist ( priv->control_sock, ret_strlist ); - if (ret_strlist != NULL && gmyth_string_list_length (ret_strlist) > 0) { - bytes_sent = gmyth_string_list_get_int (ret_strlist, 0); // -1 on backend error - gmyth_debug ("[%s] got SENT buffer message = %d\n", __FUNCTION__, - bytes_sent); + if ( ret_strlist != NULL + && gmyth_string_list_length ( ret_strlist ) > 0 ) + { + bytes_sent = gmyth_string_list_get_int ( ret_strlist, 0 ); // -1 on backend error + gmyth_debug ( "[%s] got SENT buffer message = %d\n", __FUNCTION__, + bytes_sent ); } - if (read_unlimited && (bytes_sent == 0)) { - g_usleep (300); + if ( read_unlimited && ( bytes_sent == 0 ) ) + { + g_usleep ( 300 ); } --iter_count; } - while (read_unlimited && (bytes_sent == 0) && iter_count > 0); + while ( read_unlimited && ( bytes_sent == 0 ) && iter_count > 0 ); - if (bytes_sent > 0) { - gchar *data_buffer = g_new0 (gchar, bytes_sent); + if ( bytes_sent > 0 ) + { + gchar *data_buffer = g_new0 ( gchar, bytes_sent ); - io_status = g_io_channel_read_chars (io_channel, - data_buffer, (gsize) bytes_sent, &bytes_read, &error); + io_status = g_io_channel_read_chars ( io_channel, + data_buffer, ( gsize ) bytes_sent, + &bytes_read, &error ); - if (io_status != G_IO_STATUS_NORMAL) { - gmyth_debug ("Error on io_channel"); - g_free (data_buffer); - g_object_unref (strlist); + if ( io_status != G_IO_STATUS_NORMAL ) + { + gmyth_debug ( "Error on io_channel" ); + g_free ( data_buffer ); + g_object_unref ( strlist ); retval = GMYTH_FILE_READ_ERROR; goto error; } /* append new data to the increasing byte array */ data = - g_byte_array_append (data, (const guint8 *) data_buffer, - bytes_read); - gmyth_file_set_offset (GMYTH_FILE (transfer), - gmyth_file_get_offset (GMYTH_FILE (transfer)) + bytes_read); + g_byte_array_append ( data, ( const guint8 * ) data_buffer, + bytes_read ); + gmyth_file_set_offset ( GMYTH_FILE ( transfer ), + gmyth_file_get_offset ( GMYTH_FILE + ( transfer ) ) + + bytes_read ); - if (!read_unlimited - && (gmyth_file_get_filesize (GMYTH_FILE (transfer)) > 0) - && (gmyth_file_get_offset (GMYTH_FILE (transfer)) == - gmyth_file_get_filesize (GMYTH_FILE (transfer)))) { + if ( !read_unlimited + && ( gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) > 0 ) + && ( gmyth_file_get_offset ( GMYTH_FILE ( transfer ) ) == + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) ) ) + { retval = GMYTH_FILE_READ_EOF; goto error; } - g_free (data_buffer); - } else { + g_free ( data_buffer ); + } + else + { retval = GMYTH_FILE_READ_ERROR; } - if (strlist != NULL) { - g_object_unref (strlist); + if ( strlist != NULL ) + { + g_object_unref ( strlist ); strlist = NULL; } - if (ret_strlist != NULL) { - g_object_unref (ret_strlist); + if ( ret_strlist != NULL ) + { + g_object_unref ( ret_strlist ); ret_strlist = NULL; } - if (read_unlimited && (bytes_sent == 0)) { - gmyth_debug ("Trying to move to the next program chain..."); - if (priv->recorder != NULL && priv->do_next_program_chain) { + if ( read_unlimited && ( bytes_sent == 0 ) ) + { + gmyth_debug ( "Trying to move to the next program chain..." ); + if ( priv->recorder != NULL && priv->do_next_program_chain ) + { priv->do_next_program_chain = FALSE; retval = GMYTH_FILE_READ_NEXT_PROG_CHAIN; GMythProgramInfo *prog_info = - gmyth_recorder_get_current_program_info (priv->recorder); + gmyth_recorder_get_current_program_info ( priv->recorder ); - if (prog_info != NULL && prog_info->pathname != NULL - && strlen (prog_info->pathname->str) > 0 - && g_ascii_strcasecmp (prog_info->pathname->str, - gmyth_file_get_file_name (GMYTH_FILE (transfer))) - != 0) + if ( prog_info != NULL && prog_info->pathname != NULL + && strlen ( prog_info->pathname->str ) > 0 + && g_ascii_strcasecmp ( prog_info->pathname->str, + gmyth_file_get_file_name ( GMYTH_FILE + ( transfer ) ) ) + != 0 ) /* releasing context got at this function starting... */ - _control_release_context (transfer); + _control_release_context ( transfer ); ret = - gmyth_file_transfer_open (transfer, - g_strrstr (prog_info->pathname->str, "/")); - _control_acquire_context (transfer, TRUE); + gmyth_file_transfer_open ( transfer, + g_strrstr ( prog_info->pathname->str, + "/" ) ); + _control_acquire_context ( transfer, TRUE ); /* acquiring context released at this function stopping... */ - if (prog_info != NULL) - g_object_unref (prog_info); + if ( prog_info != NULL ) + g_object_unref ( prog_info ); - if (!ret) - gmyth_debug ("Cannot change to the next program info!"); + if ( !ret ) + gmyth_debug ( "Cannot change to the next program info!" ); else - gmyth_debug ("OK!!! MOVED to the next program info [%s]!", - gmyth_file_get_file_name (GMYTH_FILE (transfer))); + gmyth_debug ( "OK!!! MOVED to the next program info [%s]!", + gmyth_file_get_file_name ( GMYTH_FILE + ( transfer ) ) ); } } /* if */ error: - _control_release_context (transfer); - g_string_free (query, TRUE); + _control_release_context ( transfer ); + g_string_free ( query, TRUE ); - if (error != NULL) { - gmyth_debug ("Cleaning-up ERROR: %s [msg = %s, code = %d]\n", - __FUNCTION__, error->message, error->code); - g_error_free (error); + if ( error != NULL ) + { + gmyth_debug ( "Cleaning-up ERROR: %s [msg = %s, code = %d]\n", + __FUNCTION__, error->message, error->code ); + g_error_free ( error ); } - if (total_read > 0) - gmyth_file_set_offset (GMYTH_FILE (transfer), - gmyth_file_get_offset (GMYTH_FILE (transfer)) + total_read); + if ( total_read > 0 ) + gmyth_file_set_offset ( GMYTH_FILE ( transfer ), + gmyth_file_get_offset ( GMYTH_FILE + ( transfer ) ) + + total_read ); return retval; } static void -_file_transfer_program_info_changed (GMythFileTransfer * transfer, - gint msg_code, gpointer livetv_recorder) +_file_transfer_program_info_changed ( GMythFileTransfer * transfer, + gint msg_code, gpointer livetv_recorder ) { GMythRecorder *recorder; GMythFileTransferPrivate *priv; - g_return_if_fail (transfer != NULL); + g_return_if_fail ( transfer != NULL ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - recorder = GMYTH_RECORDER (livetv_recorder); + recorder = GMYTH_RECORDER ( livetv_recorder ); gmyth_debug - ("Program info changed! ( file transfer orig. = %p, ptr. = [%s] )", - transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]"); + ( "Program info changed! ( file transfer orig. = %p, ptr. = [%s] )", + transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]" ); - if (NULL != recorder) { + if ( NULL != recorder ) + { gmyth_debug - ("YES, the requested program info movement on the LiveTV transfer is authentical!"); + ( "YES, the requested program info movement on the LiveTV transfer is authentical!" ); } - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); - g_object_ref (recorder); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); + g_object_ref ( recorder ); priv->recorder = recorder; priv->do_next_program_chain = TRUE; } @@ -872,40 +932,41 @@ * @return true, if the acquire had been got. */ gboolean -gmyth_file_transfer_settimeout (GMythFileTransfer * transfer, gboolean fast) +gmyth_file_transfer_settimeout ( GMythFileTransfer * transfer, gboolean fast ) { GMythFileTransferPrivate *priv; GMythStringList *strlist = NULL; - g_return_val_if_fail (transfer != NULL, FALSE); + g_return_val_if_fail ( transfer != NULL, FALSE ); - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer); + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer ); - g_return_val_if_fail (priv->sock != NULL, FALSE); - g_return_val_if_fail (priv->control_sock != NULL, FALSE); + g_return_val_if_fail ( priv->sock != NULL, FALSE ); + g_return_val_if_fail ( priv->control_sock != NULL, FALSE ); - _control_acquire_context (transfer, TRUE); + _control_acquire_context ( transfer, TRUE ); - strlist = gmyth_string_list_new (); - gmyth_string_list_append_char_array (strlist, GMYTHTV_QUERY_HEADER); - gmyth_string_list_append_char_array (strlist, "SET_TIMEOUT"); - gmyth_string_list_append_int (strlist, fast); + strlist = gmyth_string_list_new ( ); + gmyth_string_list_append_char_array ( strlist, GMYTHTV_QUERY_HEADER ); + gmyth_string_list_append_char_array ( strlist, "SET_TIMEOUT" ); + gmyth_string_list_append_int ( strlist, fast ); - gint strlist_len = gmyth_socket_sendreceive_stringlist (priv->control_sock, - strlist); + gint strlist_len = gmyth_socket_sendreceive_stringlist ( priv->control_sock, + strlist ); - if (strlist_len > 0) - gmyth_debug ("Yes, timeout was changed: %s.", - gmyth_string_list_get_char_array (strlist, 0)); + if ( strlist_len > 0 ) + gmyth_debug ( "Yes, timeout was changed: %s.", + gmyth_string_list_get_char_array ( strlist, 0 ) ); else - gmyth_debug ("Timeout cannot be changed!"); + gmyth_debug ( "Timeout cannot be changed!" ); - _control_release_context (transfer); + _control_release_context ( transfer ); - gmyth_debug ("%s setting timeout flag of this file transfer = %s\n", - strlist_len > 0 ? "Yes," : "NOT", fast ? "FAST" : "NOT FAST"); + gmyth_debug ( "%s setting timeout flag of this file transfer = %s\n", + strlist_len > 0 ? "Yes," : "NOT", + fast ? "FAST" : "NOT FAST" ); - g_object_unref (strlist); + g_object_unref ( strlist ); return TRUE; } @@ -918,13 +979,13 @@ * @return The actual file size in bytes. */ guint64 -gmyth_file_transfer_get_filesize (GMythFileTransfer * transfer) +gmyth_file_transfer_get_filesize ( GMythFileTransfer * transfer ) { guint64 filesize; - g_return_val_if_fail (transfer != NULL, 0); + g_return_val_if_fail ( transfer != NULL, 0 ); - g_object_get (GMYTH_FILE (transfer), "file-size", &filesize, NULL); + g_object_get ( GMYTH_FILE ( transfer ), "file-size", &filesize, NULL ); return filesize; } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_file_transfer.h --- a/gmyth/src/gmyth_file_transfer.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_file_transfer.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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_FILE_TRANSFER_H__ #define __GMYTH_FILE_TRANSFER_H__ @@ -56,43 +55,48 @@ typedef struct _GMythFileTransferPrivate GMythFileTransferPrivate; struct _GMythFileTransfer -{ - GMythFile parent; - GMythFileTransferPrivate *priv; -}; + { + GMythFile parent; + GMythFileTransferPrivate *priv; + }; struct _GMythFileTransferClass -{ - GMythFileClass parent_class; + { + GMythFileClass parent_class; - /* callbacks */ - guint program_info_changed_handler_signal_id; + /* callbacks */ + guint program_info_changed_handler_signal_id; - /* signal default handlers */ - void (*program_info_changed_handler) (GMythFileTransfer * transfer, - gint msg_code, gpointer livetv_recorder); -}; + /* signal default handlers */ + void ( *program_info_changed_handler ) ( GMythFileTransfer * transfer, + gint msg_code, + gpointer livetv_recorder ); + }; -GType gmyth_file_transfer_get_type (void); -GMythFileTransfer *gmyth_file_transfer_new (GMythBackendInfo * backend_info); -gchar *gmyth_file_transfer_get_file_name (GMythFileTransfer * transfer); -gboolean gmyth_file_transfer_open (GMythFileTransfer * transfer, - const gchar * filename); -void gmyth_file_transfer_close (GMythFileTransfer * transfer); -gboolean gmyth_file_transfer_is_open (GMythFileTransfer * transfer); +GType gmyth_file_transfer_get_type ( void ); +GMythFileTransfer *gmyth_file_transfer_new ( GMythBackendInfo * backend_info ); +gchar *gmyth_file_transfer_get_file_name ( GMythFileTransfer * transfer ); +gboolean gmyth_file_transfer_open ( GMythFileTransfer * transfer, + const gchar * filename ); +void gmyth_file_transfer_close ( GMythFileTransfer * transfer ); +gboolean gmyth_file_transfer_is_open ( GMythFileTransfer * transfer ); GMythFileReadResult -gmyth_file_transfer_read (GMythFileTransfer * transfer, - GByteArray * data, gint size, gboolean read_unlimited); -gint64 gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos, - gint whence); -gboolean gmyth_file_transfer_settimeout (GMythFileTransfer * transfer, - gboolean fast); -guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer * transfer); +gmyth_file_transfer_read ( GMythFileTransfer * transfer, + GByteArray * data, gint size, + gboolean read_unlimited ); +gint64 gmyth_file_transfer_seek ( GMythFileTransfer * transfer, guint64 pos, + gint whence ); +gboolean gmyth_file_transfer_settimeout ( GMythFileTransfer * transfer, + gboolean fast ); +guint64 gmyth_file_transfer_get_filesize ( GMythFileTransfer * transfer ); -void gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer * - transfer, gint msg_code, gpointer live_tv_recorder); +void gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer * + transfer, + gint msg_code, + gpointer + live_tv_recorder ); G_END_DECLS #endif /* __GMYTH_FILE_TRANSFER_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_http.c --- a/gmyth/src/gmyth_http.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_http.c Wed May 23 19:50:41 2007 +0100 @@ -40,33 +40,35 @@ #include "gmyth_socket.h" xmlXPathObjectPtr -getnodeset (xmlDocPtr doc, xmlChar * xpath) +getnodeset ( xmlDocPtr doc, xmlChar * xpath ) { xmlXPathContextPtr context; xmlXPathObjectPtr result; - context = xmlXPathNewContext (doc); - result = xmlXPathEvalExpression (xpath, context); + context = xmlXPathNewContext ( doc ); + result = xmlXPathEvalExpression ( xpath, context ); - if (xmlXPathNodeSetIsEmpty (result->nodesetval)) { - g_fprintf (stderr, "Error: No result at XPath\n"); + if ( xmlXPathNodeSetIsEmpty ( result->nodesetval ) ) + { + g_fprintf ( stderr, "Error: No result at XPath\n" ); return NULL; } - xmlXPathFreeContext (context); + xmlXPathFreeContext ( context ); return result; } xmlDocPtr -XMLParse (const char *content, int length) +XMLParse ( const char *content, int length ) { xmlDocPtr doc; /* the resulting document tree */ - doc = xmlReadMemory (content, length, NULL, NULL, 0); - if (doc == NULL) { - g_fprintf (stderr, "Error: Failed to parse XML document\n"); + doc = xmlReadMemory ( content, length, NULL, NULL, 0 ); + if ( doc == NULL ) + { + g_fprintf ( stderr, "Error: Failed to parse XML document\n" ); return NULL; } @@ -74,11 +76,11 @@ } xmlXPathObjectPtr -getXPath (xmlChar * xpath, xmlDocPtr doc) +getXPath ( xmlChar * xpath, xmlDocPtr doc ) { xmlXPathObjectPtr result; - result = getnodeset (doc, xpath); + result = getnodeset ( doc, xpath ); return result; } @@ -89,40 +91,43 @@ * @return A GSList containing a list of all the programs */ GSList * -get_Program_List (xmlNodePtr node) +get_Program_List ( xmlNodePtr node ) { GSList *program_list = NULL; - while (node != NULL) { - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { - GMythProgram *program = (GMythProgram *) - g_malloc (sizeof (struct _GMythProgram)); + while ( node != NULL ) + { + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 ) + { + GMythProgram *program = ( GMythProgram * ) + g_malloc ( sizeof ( struct _GMythProgram ) ); - program->title = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) "title")); + program->title = g_strdup ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) "title" ) ); - program->subtitle = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "subtitle")); + program->subtitle = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "subtitle" ) ); - program->catType = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "catType")); + program->catType = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "catType" ) ); - program->category = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "category")); + program->category = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "category" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"), - "%d", &(program->repeat)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "repeat" ), + "%d", &( program->repeat ) ); program->startTime = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "startTime")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "startTime" ) ); program->endTime = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "endTime")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "endTime" ) ); - program_list = g_slist_append (program_list, program); + program_list = g_slist_append ( program_list, program ); } node = node->next; @@ -138,33 +143,35 @@ * @return The epg from "param" updated */ void -get_Channel_List (xmlNodePtr node, GMythEpg * epg) +get_Channel_List ( xmlNodePtr node, GMythEpg * epg ) { epg->channelList = NULL; - while (node != NULL) { + while ( node != NULL ) + { - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { - GMythChannel *channel = (GMythChannel *) g_malloc - (sizeof (struct _GMythChannel)); + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 ) + { + GMythChannel *channel = ( GMythChannel * ) g_malloc + ( sizeof ( struct _GMythChannel ) ); - channel->channelName = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "channelName")); + channel->channelName = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "channelName" ) ); - channel->chanNum = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "chanNum")); + channel->chanNum = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "chanNum" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"), - "%d", &(channel->chanId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanId" ), + "%d", &( channel->chanId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"), - "%d", &(channel->callSign)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "callSign" ), + "%d", &( channel->callSign ) ); - channel->programList = get_Program_List (node->children); + channel->programList = get_Program_List ( node->children ); - epg->channelList = g_slist_append (epg->channelList, channel); + epg->channelList = g_slist_append ( epg->channelList, channel ); } @@ -179,44 +186,44 @@ * @return The epg from "param" updated */ void -get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg * epg) +get_ProgramGuide_Properties ( xmlNodePtr nodeTab, GMythEpg * epg ) { xmlNode *ptr = nodeTab->children->next->children; - epg->startTime = gmyth_util_string_to_time_val ((char *) ptr->content); + epg->startTime = gmyth_util_string_to_time_val ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - epg->endTime = gmyth_util_string_to_time_val ((char *) ptr->content); + epg->endTime = gmyth_util_string_to_time_val ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->startChanId)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->startChanId ) ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->endChanId)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->endChanId ) ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->numOfChannels)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->numOfChannels ) ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->details)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->details ) ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->totalCount)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->totalCount ) ); ptr = ptr->parent->next->next->children; - epg->asOf = gmyth_util_string_to_time_val ((char *) ptr->content); + epg->asOf = gmyth_util_string_to_time_val ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - epg->version = g_strdup ((char *) ptr->content); + epg->version = g_strdup ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(epg->protoVer)); + sscanf ( ( char * ) ptr->content, "%d", &( epg->protoVer ) ); ptr = ptr->parent->next->next->children; // go to Channel section and retrieve Channels and Programs - if (epg->numOfChannels > 0) - get_Channel_List (ptr, epg); + if ( epg->numOfChannels > 0 ) + get_Channel_List ( ptr, epg ); else epg->channelList = NULL; } @@ -227,7 +234,7 @@ * @return The epg */ void -getEpg (xmlDocPtr doc, GMythEpg * epg) +getEpg ( xmlDocPtr doc, GMythEpg * epg ) { xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; @@ -235,19 +242,22 @@ int i; - result = getXPath ((xmlChar *) "/*", doc); + result = getXPath ( ( xmlChar * ) "/*", doc ); - if (result) { + if ( result ) + { nodeset = result->nodesetval; - for (i = 0; i < nodeset->nodeNr; i++) { - keyword = (xmlChar *) nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp - ((char *) keyword, "GetProgramGuideResponse") == 0) { - get_ProgramGuide_Properties (nodeset->nodeTab[i], epg); + for ( i = 0; i < nodeset->nodeNr; i++ ) + { + keyword = ( xmlChar * ) nodeset->nodeTab[i]->name; + if ( g_ascii_strcasecmp + ( ( char * ) keyword, "GetProgramGuideResponse" ) == 0 ) + { + get_ProgramGuide_Properties ( nodeset->nodeTab[i], epg ); break; } } - xmlXPathFreeObject (result); + xmlXPathFreeObject ( result ); } } @@ -260,9 +270,10 @@ * @return The epg */ GMythEpg -gmyth_http_retrieve_epg (GMythBackendInfo * backend_info, - GTimeVal * StartTime, GTimeVal * EndTime, - gint StartChanId, gint NumOfChannels, gchar * Details) +gmyth_http_retrieve_epg ( GMythBackendInfo * backend_info, + GTimeVal * StartTime, GTimeVal * EndTime, + gint StartChanId, gint NumOfChannels, + gchar * Details ) { GMythEpg epg; MemoryStruct chunk; @@ -272,28 +283,31 @@ gchar *starttime; - starttime = (gchar *) xmlURIEscapeStr ((const xmlChar *) - gmyth_util_time_to_mythformat_from_time_val (StartTime), NULL); + starttime = ( gchar * ) xmlURIEscapeStr ( ( const xmlChar * ) + gmyth_util_time_to_mythformat_from_time_val + ( StartTime ), NULL ); gchar *endtime; - endtime = (gchar *) xmlURIEscapeStr ((const xmlChar *) - gmyth_util_time_to_mythformat_from_time_val (EndTime), NULL); + endtime = ( gchar * ) xmlURIEscapeStr ( ( const xmlChar * ) + gmyth_util_time_to_mythformat_from_time_val + ( EndTime ), NULL ); - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, - "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" - "&NumOfChannels=%d&Details=%s", starttime, endtime, - StartChanId, NumOfChannels, Details); - gmyth_debug ("HTTP Request command = %s\n", command->str); + g_string_printf ( command, + "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" + "&NumOfChannels=%d&Details=%s", starttime, endtime, + StartChanId, NumOfChannels, Details ); + gmyth_debug ( "HTTP Request command = %s\n", command->str ); - chunk = gmyth_http_request (backend_info, command); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + chunk = gmyth_http_request ( backend_info, command ); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - getEpg (doc, &epg); - free (chunk.memory); + getEpg ( doc, &epg ); + free ( chunk.memory ); } return epg; @@ -301,50 +315,51 @@ GMythRecorded_Recording -retrieve_recorded_recording (xmlNodePtr node) +retrieve_recorded_recording ( xmlNodePtr node ) { GMythRecorded_Recording recording; - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 ) + { - sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupInType"), - "%d", &(recording.dupInType)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "dupInType" ), + "%d", &( recording.dupInType ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupMethod"), - "%d", &(recording.dupMethod)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "dupMethod" ), + "%d", &( recording.dupMethod ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recStatus"), - "%d", &(recording.recStatus)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recStatus" ), + "%d", &( recording.recStatus ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "encoderId"), - "%d", &(recording.encoderId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "encoderId" ), + "%d", &( recording.encoderId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recordId"), - "%d", &(recording.recordId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recordId" ), + "%d", &( recording.recordId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recType"), - "%d", &(recording.recType)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recType" ), + "%d", &( recording.recType ) ); - recording.playGroup = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "playGroup")); + recording.playGroup = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "playGroup" ) ); - recording.recGroup = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "recGroup")); + recording.recGroup = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "recGroup" ) ); - recording.recProfile = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "recProfile")); + recording.recProfile = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "recProfile" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recPriority"), - "%d", &(recording.recPriority)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recPriority" ), + "%d", &( recording.recPriority ) ); recording.recStartTs = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "recStartTs")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recStartTs" ) ); recording.recEndTs = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "recEndTs")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recEndTs" ) ); } return recording; @@ -352,37 +367,38 @@ GMythRecorded_Channel -retrieve_recorded_channel (xmlNodePtr node) +retrieve_recorded_channel ( xmlNodePtr node ) { GMythRecorded_Channel channel; - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 ) + { - channel.chanFilters = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "chanFilters")); + channel.chanFilters = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "chanFilters" ) ); - channel.channelName = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "channelName")); + channel.channelName = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "channelName" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanNum"), - "%d", &(channel.chanNum)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanNum" ), + "%d", &( channel.chanNum ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "sourceId"), - "%d", &(channel.sourceId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "sourceId" ), + "%d", &( channel.sourceId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "commFree"), - "%d", &(channel.commFree)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "commFree" ), + "%d", &( channel.commFree ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "inputId"), - "%d", &(channel.inputId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "inputId" ), + "%d", &( channel.inputId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"), - "%d", &(channel.chanId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanId" ), + "%d", &( channel.chanId ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"), - "%d", &(channel.callSign)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "callSign" ), + "%d", &( channel.callSign ) ); } return channel; @@ -397,77 +413,84 @@ * @return list with all the recorded programs */ GSList * -get_Recorded_Programs (xmlNodePtr node) +get_Recorded_Programs ( xmlNodePtr node ) { GSList *programList = NULL; - while (node != NULL) { + while ( node != NULL ) + { - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 ) + { - GMythRecorded_Program *program = (GMythRecorded_Program *) - g_malloc (sizeof (struct _GMythRecorded_Program)); + GMythRecorded_Program *program = ( GMythRecorded_Program * ) + g_malloc ( sizeof ( struct _GMythRecorded_Program ) ); - sscanf ((char *) - xmlGetProp (node, (xmlChar *) "programFlags"), "%d", - &(program->programFlags)); + sscanf ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) "programFlags" ), "%d", + &( program->programFlags ) ); - program->title = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) "title")); + program->title = g_strdup ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) "title" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "programId"), - "%d", &(program->programId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "programId" ), + "%d", &( program->programId ) ); - program->catType = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "catType")); + program->catType = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "catType" ) ); - program->category = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "category")); + program->category = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "category" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "seriesId"), - "%d", &(program->seriesId)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "seriesId" ), + "%d", &( program->seriesId ) ); program->startTime = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "startTime")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "startTime" ) ); program->endTime = gmyth_util_string_to_time_val - ((char *) xmlGetProp (node, (xmlChar *) "endTime")); + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "endTime" ) ); - program->lastModified = gmyth_util_string_to_time_val ((char *) - xmlGetProp (node, (xmlChar *) "lastModified")); + program->lastModified = gmyth_util_string_to_time_val ( ( char * ) + xmlGetProp + ( node, + ( xmlChar + * ) + "lastModified" ) ); /* TODO: FIX ME at gmyth_util program->asOf = gmyth_util_string_to_time_val\ ((char *)xmlGetProp(node, (xmlChar *)"airdate")); */ - program->subTitle = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "subTitle")); + program->subTitle = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "subTitle" ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "stars"), - "%d", &(program->stars)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "stars" ), + "%d", &( program->stars ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"), - "%d", &(program->repeat)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "repeat" ), + "%d", &( program->repeat ) ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) "fileSize"), - "%d", &(program->repeat)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "fileSize" ), + "%d", &( program->repeat ) ); - program->hostname = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "hostname")); + program->hostname = g_strdup ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) + "hostname" ) ); - program->channel = retrieve_recorded_channel (node->children); + program->channel = retrieve_recorded_channel ( node->children ); // Skip the \n program->recording = - retrieve_recorded_recording (node->children->next->next); + retrieve_recorded_recording ( node->children->next->next ); // add to the list - programList = g_slist_append (programList, program); + programList = g_slist_append ( programList, program ); } node = node->next; @@ -483,25 +506,25 @@ * @return "recorded" from "param" updated */ void -get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded * recorded) +get_Recorded_Properties ( xmlNodePtr nodeTab, GMythRecorded * recorded ) { xmlNode *ptr = nodeTab->children->next->children; - sscanf ((char *) ptr->content, "%d", &(recorded->totalCount)); + sscanf ( ( char * ) ptr->content, "%d", &( recorded->totalCount ) ); ptr = ptr->parent->next->next->children; - recorded->asOf = gmyth_util_string_to_time_val ((char *) ptr->content); + recorded->asOf = gmyth_util_string_to_time_val ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - recorded->version = g_strdup ((char *) ptr->content); + recorded->version = g_strdup ( ( char * ) ptr->content ); ptr = ptr->parent->next->next->children; - sscanf ((char *) ptr->content, "%d", &(recorded->protoVer)); + sscanf ( ( char * ) ptr->content, "%d", &( recorded->protoVer ) ); ptr = ptr->parent->next->next->children; - if (recorded->totalCount > 0) - recorded->programList = get_Recorded_Programs (ptr->children); + if ( recorded->totalCount > 0 ) + recorded->programList = get_Recorded_Programs ( ptr->children ); } @@ -512,7 +535,7 @@ * @return The recorded var updated */ void -getRecorded (xmlDocPtr doc, GMythRecorded * recorded) +getRecorded ( xmlDocPtr doc, GMythRecorded * recorded ) { xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; @@ -520,19 +543,22 @@ int i; - result = getXPath ((xmlChar *) "/*", doc); + result = getXPath ( ( xmlChar * ) "/*", doc ); - if (result) { + if ( result ) + { nodeset = result->nodesetval; - for (i = 0; i < nodeset->nodeNr; i++) { - keyword = (xmlChar *) nodeset->nodeTab[i]->name; - if (g_ascii_strcasecmp - ((char *) keyword, "GetRecordedResponse") == 0) { - get_Recorded_Properties (nodeset->nodeTab[i], recorded); + for ( i = 0; i < nodeset->nodeNr; i++ ) + { + keyword = ( xmlChar * ) nodeset->nodeTab[i]->name; + if ( g_ascii_strcasecmp + ( ( char * ) keyword, "GetRecordedResponse" ) == 0 ) + { + get_Recorded_Properties ( nodeset->nodeTab[i], recorded ); break; } } - xmlXPathFreeObject (result); + xmlXPathFreeObject ( result ); } } @@ -542,7 +568,7 @@ * */ GMythRecorded -gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info) +gmyth_http_retrieve_recorded ( GMythBackendInfo * backend_info ) { GMythRecorded recorded; MemoryStruct chunk; @@ -550,16 +576,17 @@ chunk.memory = NULL; chunk.size = 0; - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, "GetRecorded"); + g_string_printf ( command, "GetRecorded" ); - chunk = gmyth_http_request (backend_info, command); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + chunk = gmyth_http_request ( backend_info, command ); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - getRecorded (doc, &recorded); - free (chunk.memory); + getRecorded ( doc, &recorded ); + free ( chunk.memory ); } return recorded; @@ -571,8 +598,8 @@ * */ gint -gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info, - gint chanid, GTimeVal * start) +gmyth_http_retrieve_job_status ( GMythBackendInfo * backend_info, + gint chanid, GTimeVal * start ) { gint status = 0; gint count = 0; @@ -588,43 +615,52 @@ chunk.memory = NULL; chunk.size = 0; - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, "GetStatus"); + g_string_printf ( command, "GetStatus" ); - chunk = gmyth_http_request (backend_info, command); + chunk = gmyth_http_request ( backend_info, command ); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - result = getXPath ((xmlChar *) "/Status/JobQueue", doc); - if (result) { + result = getXPath ( ( xmlChar * ) "/Status/JobQueue", doc ); + if ( result ) + { nodeset = result->nodesetval; node = nodeset->nodeTab[0]; - sscanf ((char *) xmlGetProp (node, (xmlChar *) "count"), - "%d", &count); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "count" ), + "%d", &count ); - if (count > 0) { + if ( count > 0 ) + { // Get the first child node = node->children->next; - for (i = 0; i < count; i++) { + for ( i = 0; i < count; i++ ) + { - sscanf ((char *) - xmlGetProp (node, (xmlChar *) "chanId"), "%d", - &temp_chanid); + sscanf ( ( char * ) + xmlGetProp ( node, ( xmlChar * ) "chanId" ), "%d", + &temp_chanid ); - if (chanid == temp_chanid) { - temp_start = gmyth_util_string_to_time_val ((char *) - xmlGetProp (node, (xmlChar *) - "startTime")); + if ( chanid == temp_chanid ) + { + temp_start = gmyth_util_string_to_time_val ( ( char * ) + xmlGetProp + ( node, + ( xmlChar + * ) + "startTime" ) ); - if ((temp_start->tv_sec == start->tv_sec) && - (temp_start->tv_usec == start->tv_usec)) - sscanf ((char *) - xmlGetProp (node, - (xmlChar *) "status"), "%d", &status); + if ( ( temp_start->tv_sec == start->tv_sec ) && + ( temp_start->tv_usec == start->tv_usec ) ) + sscanf ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) "status" ), + "%d", &status ); } // Escape "text" node node = node->next->next; @@ -633,8 +669,8 @@ } - xmlXPathFreeObject (result); - free (chunk.memory); + xmlXPathFreeObject ( result ); + free ( chunk.memory ); } @@ -651,8 +687,8 @@ * @return the value of the key */ gchar * -gmyth_http_retrieve_setting (GMythBackendInfo * backend_info, - gchar * key, gchar * hostname) +gmyth_http_retrieve_setting ( GMythBackendInfo * backend_info, + gchar * key, gchar * hostname ) { xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; @@ -663,29 +699,32 @@ chunk.memory = NULL; chunk.size = 0; - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, "GetSetting?Key=%s&HostName=%s&Default=NULL", - key, hostname); + g_string_printf ( command, "GetSetting?Key=%s&HostName=%s&Default=NULL", + key, hostname ); - chunk = gmyth_http_request (backend_info, command); + chunk = gmyth_http_request ( backend_info, command ); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - result = getXPath ((xmlChar *) "/GetSettingResponse/Values/*", doc); + result = getXPath ( ( xmlChar * ) "/GetSettingResponse/Values/*", doc ); - if (result) { + if ( result ) + { nodeset = result->nodesetval; - keyword = (xmlChar *) nodeset->nodeTab[0]->name; - if (g_ascii_strcasecmp ((char *) keyword, "Value") == 0) { + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name; + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Value" ) == 0 ) + { // Here we have the value - value = (gchar *) nodeset->nodeTab[0]->children->content; + value = ( gchar * ) nodeset->nodeTab[0]->children->content; } - xmlXPathFreeObject (result); + xmlXPathFreeObject ( result ); } - free (chunk.memory); + free ( chunk.memory ); } return value; @@ -698,7 +737,7 @@ * @return 0 if OK */ gint -rec_profile_common (GMythBackendInfo * backend_info, GString * command) +rec_profile_common ( GMythBackendInfo * backend_info, GString * command ) { xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; @@ -710,24 +749,26 @@ int ret = -1; - chunk = gmyth_http_request (backend_info, command); + chunk = gmyth_http_request ( backend_info, command ); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - result = getXPath ((xmlChar *) "/*", doc); + result = getXPath ( ( xmlChar * ) "/*", doc ); - if (result) { + if ( result ) + { nodeset = result->nodesetval; - keyword = (xmlChar *) nodeset->nodeTab[0]->name; + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name; - if (g_ascii_strcasecmp ((char *) keyword, "Success") == 0) + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Success" ) == 0 ) ret = 0; - xmlXPathFreeObject (result); + xmlXPathFreeObject ( result ); } - free (chunk.memory); + free ( chunk.memory ); } return ret; @@ -741,15 +782,15 @@ * @return 0 if OK */ gint -gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id) +gmyth_http_del_rec_profile ( GMythBackendInfo * backend_info, gint id ) { - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, "delRecProfiles?id=%d", id); + g_string_printf ( command, "delRecProfiles?id=%d", id ); - return rec_profile_common (backend_info, command); + return rec_profile_common ( backend_info, command ); } /** Function to create recording profiles @@ -762,67 +803,69 @@ * @return 0 if OK */ gint -gmyth_http_create_rec_profile (GMythBackendInfo * backend_info, - GMythRecProfile * profile) +gmyth_http_create_rec_profile ( GMythBackendInfo * backend_info, + GMythRecProfile * profile ) { - if (profile->name != NULL && profile->group != NULL && - profile->vcodec && profile->acodec && profile->options != NULL) { - GString *command = g_string_new (""); + if ( profile->name != NULL && profile->group != NULL && + profile->vcodec && profile->acodec && profile->options != NULL ) + { + GString *command = g_string_new ( "" ); - g_string_printf (command, "createRecProfiles?profilename=%s&" - "groupname=%s&vcodec=%s&acodec=%s&" - "transcodelossless=%d&transcoderesize=%d&" - "width=%d&height=%d&rtjpegquality=%d&" - "rtjpeglumafilter=%d&rtjpegchromafilter=%d&" - "mpeg4bitrate=%d&mpeg4maxquality=%d&" - "mpeg4minquality=%d&mpeg4qualdiff=%d&" - "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&" - "mpeg4option4mv=%d&mpeg4optionidct=%d&" - "mpeg4optionime=%d&hardwaremjpegquality=%d&" - "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&" - "mpeg2streamtype=%s&mpeg2aspectratio=%s&" - "mpeg2bitrate=%d&mpeg2maxbitrate=%d&" - "samplerate=%d&mp3quality=%d&" - "volume=%d&mpeg2audtype=%s&" - "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&" - "mpeg2audvolume=%d", - profile->name, profile->group, - profile->vcodec, profile->acodec, - profile->options->transcodelossless, - profile->options->transcoderesize, - profile->options->width, - profile->options->height, - profile->options->rtjpegquality, - profile->options->rtjpeglumafilter, - profile->options->rtjpegchromafilter, - profile->options->mpeg4bitrate, - profile->options->mpeg4maxquality, - profile->options->mpeg4minquality, - profile->options->mpeg4qualdiff, - profile->options->mpeg4scalebitrate, - profile->options->mpeg4optionvhq, - profile->options->mpeg4option4mv, - profile->options->mpeg4optionidct, - profile->options->mpeg4optionime, - profile->options->hardwaremjpegquality, - profile->options->hardwaremjpeghdecimation, - profile->options->hardwaremjpegvdecimation, - profile->options->mpeg2streamtype, - profile->options->mpeg2aspectratio, - profile->options->mpeg2bitrate, - profile->options->mpeg2maxbitrate, - profile->options->samplerate, - profile->options->mp3quality, - profile->options->volume, - profile->options->mpeg2audtype, - profile->options->mpeg2audbitratel1, - profile->options->mpeg2audbitratel2, - profile->options->mpeg2audvolume); + g_string_printf ( command, "createRecProfiles?profilename=%s&" + "groupname=%s&vcodec=%s&acodec=%s&" + "transcodelossless=%d&transcoderesize=%d&" + "width=%d&height=%d&rtjpegquality=%d&" + "rtjpeglumafilter=%d&rtjpegchromafilter=%d&" + "mpeg4bitrate=%d&mpeg4maxquality=%d&" + "mpeg4minquality=%d&mpeg4qualdiff=%d&" + "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&" + "mpeg4option4mv=%d&mpeg4optionidct=%d&" + "mpeg4optionime=%d&hardwaremjpegquality=%d&" + "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&" + "mpeg2streamtype=%s&mpeg2aspectratio=%s&" + "mpeg2bitrate=%d&mpeg2maxbitrate=%d&" + "samplerate=%d&mp3quality=%d&" + "volume=%d&mpeg2audtype=%s&" + "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&" + "mpeg2audvolume=%d", + profile->name, profile->group, + profile->vcodec, profile->acodec, + profile->options->transcodelossless, + profile->options->transcoderesize, + profile->options->width, + profile->options->height, + profile->options->rtjpegquality, + profile->options->rtjpeglumafilter, + profile->options->rtjpegchromafilter, + profile->options->mpeg4bitrate, + profile->options->mpeg4maxquality, + profile->options->mpeg4minquality, + profile->options->mpeg4qualdiff, + profile->options->mpeg4scalebitrate, + profile->options->mpeg4optionvhq, + profile->options->mpeg4option4mv, + profile->options->mpeg4optionidct, + profile->options->mpeg4optionime, + profile->options->hardwaremjpegquality, + profile->options->hardwaremjpeghdecimation, + profile->options->hardwaremjpegvdecimation, + profile->options->mpeg2streamtype, + profile->options->mpeg2aspectratio, + profile->options->mpeg2bitrate, + profile->options->mpeg2maxbitrate, + profile->options->samplerate, + profile->options->mp3quality, + profile->options->volume, + profile->options->mpeg2audtype, + profile->options->mpeg2audbitratel1, + profile->options->mpeg2audbitratel2, + profile->options->mpeg2audvolume ); - return rec_profile_common (backend_info, command); - } else + return rec_profile_common ( backend_info, command ); + } + else return -1; } @@ -833,8 +876,8 @@ * @return the list of profiles */ GSList * -gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info, - gchar * groupname) +gmyth_http_retrieve_rec_profiles ( GMythBackendInfo * backend_info, + gchar * groupname ) { xmlXPathObjectPtr result; xmlNodeSetPtr nodeset; @@ -845,56 +888,66 @@ chunk.memory = NULL; chunk.size = 0; - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); - g_string_printf (command, "GetRecProfiles?groupname=%s", groupname); + g_string_printf ( command, "GetRecProfiles?groupname=%s", groupname ); - chunk = gmyth_http_request (backend_info, command); + chunk = gmyth_http_request ( backend_info, command ); - if (chunk.memory != NULL) { - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory)); + if ( chunk.memory != NULL ) + { + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) ); - result = getXPath ((xmlChar *) "/*", doc); + result = getXPath ( ( xmlChar * ) "/*", doc ); - if (result) { + if ( result ) + { nodeset = result->nodesetval; - keyword = (xmlChar *) nodeset->nodeTab[0]->name; + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name; - if (g_ascii_strcasecmp ((char *) keyword, "Profiles") == 0) { + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Profiles" ) == 0 ) + { xmlNodePtr node = nodeset->nodeTab[0]->children->next; GMythRecProfile *profile; - while (node != NULL) { - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) { - profile = gmyth_recprofile_new (); + while ( node != NULL ) + { + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != + 0 ) + { + profile = gmyth_recprofile_new ( ); - sscanf ((char *) xmlGetProp (node, (xmlChar *) - "id"), "%d", &(profile->id)); + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) + "id" ), "%d", + &( profile->id ) ); - profile->name = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "name")); + profile->name = g_strdup ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) + "name" ) ); - profile->vcodec = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "vcodec")); + profile->vcodec = g_strdup ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) + "vcodec" ) ); - profile->acodec = g_strdup ((char *) - xmlGetProp (node, (xmlChar *) - "acodec")); + profile->acodec = g_strdup ( ( char * ) + xmlGetProp ( node, + ( xmlChar * ) + "acodec" ) ); - profile->group = g_strdup (groupname); + profile->group = g_strdup ( groupname ); - profiles = g_slist_append (profiles, profile); + profiles = g_slist_append ( profiles, profile ); } node = node->next; } } - xmlXPathFreeObject (result); + xmlXPathFreeObject ( result ); } - free (chunk.memory); + free ( chunk.memory ); } return profiles; @@ -904,25 +957,27 @@ /* Aux functions got from libcurl */ void * -myrealloc (void *ptr, size_t size) +myrealloc ( void *ptr, size_t size ) { /* There might be a realloc() out there that doesn't like reallocing NULL pointers, so we take care of it here */ - if (ptr) - return realloc (ptr, size); + if ( ptr ) + return realloc ( ptr, size ); else - return malloc (size); + return malloc ( size ); } size_t -WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data) +WriteMemoryCallback ( void *ptr, size_t size, size_t nmemb, void *data ) { size_t realsize = size * nmemb; - MemoryStruct *mem = (struct _MemoryStruct *) data; + MemoryStruct *mem = ( struct _MemoryStruct * ) data; - mem->memory = (char *) myrealloc (mem->memory, mem->size + realsize + 1); - if (mem->memory) { - memcpy (&(mem->memory[mem->size]), ptr, realsize); + mem->memory = + ( char * ) myrealloc ( mem->memory, mem->size + realsize + 1 ); + if ( mem->memory ) + { + memcpy ( &( mem->memory[mem->size] ), ptr, realsize ); mem->size += realsize; mem->memory[mem->size] = 0; } @@ -937,24 +992,26 @@ * NULL if there is no response. */ MemoryStruct -gmyth_http_request (GMythBackendInfo * backend_info, GString * command) +gmyth_http_request ( GMythBackendInfo * backend_info, GString * command ) { LIBXML_TEST_VERSION - size_t size = strlen (backend_info->hostname) + - strlen (command->str) + 20; + size_t size = strlen ( backend_info->hostname ) + + strlen ( command->str ) + 20; - gchar *URL = (gchar *) g_malloc (sizeof (gchar) * size); - gchar *mid = (gchar *) g_malloc (sizeof (gchar) * 6); + gchar *URL = ( gchar * ) g_malloc ( sizeof ( gchar ) * size ); + gchar *mid = ( gchar * ) g_malloc ( sizeof ( gchar ) * 6 ); mid = ""; - if (g_ascii_strcasecmp (command->str, "GetStatus") && - g_ascii_strcasecmp (command->str, "GetStatusHTML")) { + if ( g_ascii_strcasecmp ( command->str, "GetStatus" ) && + g_ascii_strcasecmp ( command->str, "GetStatusHTML" ) ) + { mid = "Myth/"; } - g_snprintf (URL, size, "http://%s:%d/%s%s", - backend_info->hostname, backend_info->status_port, mid, command->str); + g_snprintf ( URL, size, "http://%s:%d/%s%s", + backend_info->hostname, backend_info->status_port, mid, + command->str ); CURL *curl_handle; @@ -963,32 +1020,33 @@ chunk.memory = NULL; /* we expect realloc(NULL, size) to work */ chunk.size = 0; /* no data at this point */ - curl_global_init (CURL_GLOBAL_ALL); + curl_global_init ( CURL_GLOBAL_ALL ); /* init the curl session */ - curl_handle = curl_easy_init (); + curl_handle = curl_easy_init ( ); /* specify URL to get */ - curl_easy_setopt (curl_handle, CURLOPT_URL, URL); + curl_easy_setopt ( curl_handle, CURLOPT_URL, URL ); /* send all data to this function */ - curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); + curl_easy_setopt ( curl_handle, CURLOPT_WRITEFUNCTION, + WriteMemoryCallback ); /* we pass our 'chunk' struct to the callback function */ - curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, (void *) &chunk); + curl_easy_setopt ( curl_handle, CURLOPT_WRITEDATA, ( void * ) &chunk ); /* some servers don't like requests that are made without a user-agent field, so we provide one */ - curl_easy_setopt (curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); + curl_easy_setopt ( curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0" ); /* set timeout */ - curl_easy_setopt (curl_handle, CURLOPT_CONNECTTIMEOUT, 20); + curl_easy_setopt ( curl_handle, CURLOPT_CONNECTTIMEOUT, 20 ); /* get it! */ - curl_easy_perform (curl_handle); + curl_easy_perform ( curl_handle ); /* cleanup curl stuff */ - curl_easy_cleanup (curl_handle); + curl_easy_cleanup ( curl_handle ); return chunk; } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_http.h --- a/gmyth/src/gmyth_http.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_http.h Wed May 23 19:50:41 2007 +0100 @@ -74,130 +74,131 @@ typedef struct _MemoryStruct MemoryStruct; struct _MemoryStruct -{ - char *memory; - size_t size; -}; + { + char *memory; + size_t size; + }; struct _GMythProgram -{ - gchar *title; - gchar *subtitle; - gchar *catType; - gchar *category; - gint repeat; - GTimeVal *startTime; - GTimeVal *endTime; -}; + { + gchar *title; + gchar *subtitle; + gchar *catType; + gchar *category; + gint repeat; + GTimeVal *startTime; + GTimeVal *endTime; + }; struct _GMythChannel -{ - gchar *channelName; - gchar *chanNum; - gint chanId; - gint callSign; - GSList *programList; -}; + { + gchar *channelName; + gchar *chanNum; + gint chanId; + gint callSign; + GSList *programList; + }; struct _GMythEpg -{ - gint startChanId; - gint endChanId; - gchar *version; - gint protoVer; - gint totalCount; - gint numOfChannels; - GTimeVal *asOf; - GTimeVal *startTime; - GTimeVal *endTime; - gint details; - GSList *channelList; -}; + { + gint startChanId; + gint endChanId; + gchar *version; + gint protoVer; + gint totalCount; + gint numOfChannels; + GTimeVal *asOf; + GTimeVal *startTime; + GTimeVal *endTime; + gint details; + GSList *channelList; + }; struct _GMythRecorded_Recording -{ - gint dupInType; - gint dupMethod; - gchar *playGroup; - gchar *recGroup; - gchar *recProfile; - gint recPriority; - gint recStatus; - gint encoderId; - gint recordId; - gint recType; - GTimeVal *recStartTs; - GTimeVal *recEndTs; -}; + { + gint dupInType; + gint dupMethod; + gchar *playGroup; + gchar *recGroup; + gchar *recProfile; + gint recPriority; + gint recStatus; + gint encoderId; + gint recordId; + gint recType; + GTimeVal *recStartTs; + GTimeVal *recEndTs; + }; struct _GMythRecorded_Channel -{ - gchar *chanFilters; - gchar *channelName; - gint chanNum; - gint sourceId; - gint commFree; - gint inputId; - gint chanId; - gint callSign; -}; + { + gchar *chanFilters; + gchar *channelName; + gint chanNum; + gint sourceId; + gint commFree; + gint inputId; + gint chanId; + gint callSign; + }; struct _GMythRecorded_Program -{ - gint programFlags; - gchar *title; - gint programId; - gchar *catType; - gchar *category; - gint seriesId; - GTimeVal *startTime; - GTimeVal *endTime; - GTimeVal *airdate; //? - GTimeVal *lastModified; - gchar *subTitle; - gint stars; - gint repeat; - gint fileSize; - gchar *hostname; - GMythRecorded_Channel channel; - GMythRecorded_Recording recording; -}; + { + gint programFlags; + gchar *title; + gint programId; + gchar *catType; + gchar *category; + gint seriesId; + GTimeVal *startTime; + GTimeVal *endTime; + GTimeVal *airdate; //? + GTimeVal *lastModified; + gchar *subTitle; + gint stars; + gint repeat; + gint fileSize; + gchar *hostname; + GMythRecorded_Channel channel; + GMythRecorded_Recording recording; + }; struct _GMythRecorded -{ - gchar *version; - gint protoVer; - gint totalCount; - GTimeVal *asOf; - GSList *programList; -}; + { + gchar *version; + gint protoVer; + gint totalCount; + GTimeVal *asOf; + GSList *programList; + }; -gint gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info, - gint chanid, GTimeVal * start); +gint gmyth_http_retrieve_job_status ( GMythBackendInfo * backend_info, + gint chanid, GTimeVal * start ); -gchar *gmyth_http_retrieve_setting (GMythBackendInfo * backend_info, - gchar * key, gchar * hostname); +gchar *gmyth_http_retrieve_setting ( GMythBackendInfo * backend_info, + gchar * key, gchar * hostname ); -GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo * backend_info, - GTimeVal * StartTime, GTimeVal * EndTime, - gint StartChanId, gint NumOfChannels, gchar * Details); +GMythEpg gmyth_http_retrieve_epg ( GMythBackendInfo * backend_info, + GTimeVal * StartTime, GTimeVal * EndTime, + gint StartChanId, gint NumOfChannels, + gchar * Details ); -GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info); +GMythRecorded gmyth_http_retrieve_recorded ( GMythBackendInfo * backend_info ); -GSList *gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info, - gchar * groupname); +GSList *gmyth_http_retrieve_rec_profiles ( GMythBackendInfo * backend_info, + gchar * groupname ); -gint gmyth_http_create_rec_profile (GMythBackendInfo * backend_info, - GMythRecProfile * profile); +gint gmyth_http_create_rec_profile ( GMythBackendInfo * backend_info, + GMythRecProfile * profile ); -gint gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id); +gint gmyth_http_del_rec_profile ( GMythBackendInfo * backend_info, gint id ); -MemoryStruct gmyth_http_request (GMythBackendInfo * backend_info, - GString * command); +MemoryStruct gmyth_http_request ( GMythBackendInfo * backend_info, + GString * command ); G_END_DECLS #endif /* __GMYTH_HTTP_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_jobqueue.c --- a/gmyth/src/gmyth_jobqueue.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_jobqueue.c Wed May 23 19:50:41 2007 +0100 @@ -40,18 +40,22 @@ * */ static GMythSocket * -backend_connect (GMythBackendInfo * backend_info) +backend_connect ( GMythBackendInfo * backend_info ) { - GMythSocket *socket = gmyth_socket_new (); + GMythSocket *socket = gmyth_socket_new ( ); - if (gmyth_socket_connect_to_backend (socket, - gmyth_backend_info_get_hostname - (backend_info), - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { - gmyth_debug ("Backend socket connection success"); + if ( gmyth_socket_connect_to_backend ( socket, + gmyth_backend_info_get_hostname + ( backend_info ), + gmyth_backend_info_get_port + ( backend_info ), TRUE ) == TRUE ) + { + gmyth_debug ( "Backend socket connection success" ); return socket; - } else { - gmyth_debug ("Connection failed"); + } + else + { + gmyth_debug ( "Connection failed" ); return NULL; } } @@ -69,31 +73,31 @@ * */ static gchar * -send_command (GMythSocket * socket, gchar * action, - gchar * job, gint chanid, gchar * starttime, gchar * options) +send_command ( GMythSocket * socket, gchar * action, + gchar * job, gint chanid, gchar * starttime, gchar * options ) { - GString *command = g_string_new (""); + GString *command = g_string_new ( "" ); GString *ret_str; gchar *ret; - GMythStringList *retlist = gmyth_string_list_new (); + GMythStringList *retlist = gmyth_string_list_new ( ); - g_string_printf (command, "JOBQUEUE %s %s %d %s %s", action, job, - chanid, starttime, options); + g_string_printf ( command, "JOBQUEUE %s %s %d %s %s", action, job, + chanid, starttime, options ); - gmyth_string_list_append_string (retlist, command); - gmyth_socket_write_stringlist (socket, retlist); + gmyth_string_list_append_string ( retlist, command ); + gmyth_socket_write_stringlist ( socket, retlist ); // receive answer - gmyth_socket_read_stringlist (socket, retlist); - ret_str = gmyth_string_list_get_string (retlist, 0); + gmyth_socket_read_stringlist ( socket, retlist ); + ret_str = gmyth_string_list_get_string ( retlist, 0 ); //ret = ret_str->str; - ret = g_string_free (ret_str, FALSE); - g_string_free (command, TRUE); + ret = g_string_free ( ret_str, FALSE ); + g_string_free ( command, TRUE ); - gmyth_string_list_clear_all (retlist); - g_object_unref (retlist); + gmyth_string_list_clear_all ( retlist ); + g_object_unref ( retlist ); return ret; } @@ -107,12 +111,15 @@ * */ static gboolean -test_result (gchar * ret, gchar * value) +test_result ( gchar * ret, gchar * value ) { - if (g_ascii_strcasecmp (ret, value) == 0) { + if ( g_ascii_strcasecmp ( ret, value ) == 0 ) + { return TRUE; - } else { - gmyth_debug ("JobQueue Error: %s", ret); + } + else + { + gmyth_debug ( "JobQueue Error: %s", ret ); return FALSE; } } @@ -125,40 +132,44 @@ * */ gboolean -gmyth_jobqueue_add_job (GMythTranscoder * transcode, gchar * job) +gmyth_jobqueue_add_job ( GMythTranscoder * transcode, gchar * job ) { - GMythSocket *socket = backend_connect (transcode->backend_info); + GMythSocket *socket = backend_connect ( transcode->backend_info ); gboolean res = FALSE; - if (socket != NULL) { - GString *options = g_string_new (""); + if ( socket != NULL ) + { + GString *options = g_string_new ( "" ); gchar *ret = NULL; - if (g_ascii_strcasecmp (job, "JOB_TRANSCODE") == 0) { - if (transcode->cutlist) - g_string_append (options, " JOB_USE_CUTLIST"); + if ( g_ascii_strcasecmp ( job, "JOB_TRANSCODE" ) == 0 ) + { + if ( transcode->cutlist ) + g_string_append ( options, " JOB_USE_CUTLIST" ); - if (transcode->output) - g_string_append_printf (options, " JOB_OUTPUT %s", - transcode->output_filename); + if ( transcode->output ) + g_string_append_printf ( options, " JOB_OUTPUT %s", + transcode->output_filename ); - if (transcode->profile != NULL) - g_string_append_printf (options, " %s", transcode->profile); + if ( transcode->profile != NULL ) + g_string_append_printf ( options, " %s", transcode->profile ); } - ret = send_command (socket, "ADD", job, transcode->chanid, - transcode->starttime, options->str); - res = test_result (ret, "JOBQUEUE_OK"); - gmyth_socket_close_connection (socket); + ret = send_command ( socket, "ADD", job, transcode->chanid, + transcode->starttime, options->str ); + res = test_result ( ret, "JOBQUEUE_OK" ); + gmyth_socket_close_connection ( socket ); - g_object_unref (socket); + g_object_unref ( socket ); - g_string_free (options, TRUE); + g_string_free ( options, TRUE ); - if (ret) - g_free (ret); + if ( ret ) + g_free ( ret ); - } else { - gmyth_debug ("JobQueue Connection Failed"); + } + else + { + gmyth_debug ( "JobQueue Connection Failed" ); } return res; @@ -173,26 +184,29 @@ * */ gboolean -gmyth_jobqueue_change_cmd (GMythTranscoder * transcode, gchar * action, - gchar * job) +gmyth_jobqueue_change_cmd ( GMythTranscoder * transcode, gchar * action, + gchar * job ) { - GMythSocket *socket = backend_connect (transcode->backend_info); + GMythSocket *socket = backend_connect ( transcode->backend_info ); gboolean res = FALSE; - if (socket != NULL) { - gchar *ret = send_command (socket, action, job, - transcode->chanid, - transcode->starttime, ""); + if ( socket != NULL ) + { + gchar *ret = send_command ( socket, action, job, + transcode->chanid, + transcode->starttime, "" ); - res = test_result (ret, "JOBQUEUE_CHANGED_CMD_OK"); + res = test_result ( ret, "JOBQUEUE_CHANGED_CMD_OK" ); - gmyth_socket_close_connection (socket); - g_object_unref (socket); + gmyth_socket_close_connection ( socket ); + g_object_unref ( socket ); - g_free (ret); + g_free ( ret ); - } else { - gmyth_debug ("JobQueue Connection Failed"); + } + else + { + gmyth_debug ( "JobQueue Connection Failed" ); } return res; diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_jobqueue.h --- a/gmyth/src/gmyth_jobqueue.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_jobqueue.h Wed May 23 19:50:41 2007 +0100 @@ -43,9 +43,10 @@ #include "gmyth_util.h" G_BEGIN_DECLS - gboolean gmyth_jobqueue_add_job (GMythTranscoder * transcoder, gchar * job); -gboolean gmyth_jobqueue_change_cmd (GMythTranscoder * transcoder, - gchar * action, gchar * job); + gboolean gmyth_jobqueue_add_job ( GMythTranscoder * transcoder, + gchar * job ); +gboolean gmyth_jobqueue_change_cmd ( GMythTranscoder * transcoder, + gchar * action, gchar * job ); G_END_DECLS #endif /* __GMYTH_JOBQUEUE_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Wed May 23 19:50:41 2007 +0100 @@ -8,22 +8,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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" @@ -56,113 +55,113 @@ #define GMYTHTV_TRANSFER_MAX_WAITS 100 -G_DEFINE_TYPE (GMythLiveTV, gmyth_livetv, G_TYPE_OBJECT) - static void gmyth_livetv_class_init (GMythLiveTVClass * klass) + G_DEFINE_TYPE (GMythLiveTV, gmyth_livetv, G_TYPE_OBJECT) +static void gmyth_livetv_class_init (GMythLiveTVClass * klass) { - GObjectClass *gobject_class; + GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = (GObjectClass *) klass; - gobject_class->dispose = gmyth_livetv_dispose; - gobject_class->finalize = gmyth_livetv_finalize; + gobject_class->dispose = gmyth_livetv_dispose; + gobject_class->finalize = gmyth_livetv_finalize; } -static void + static void gmyth_livetv_init (GMythLiveTV * livetv) { - livetv->monitor = NULL; - livetv->backend_info = NULL; - livetv->local_hostname = NULL; - livetv->file = NULL; - livetv->setup_done = FALSE; + livetv->monitor = NULL; + livetv->backend_info = NULL; + livetv->local_hostname = NULL; + livetv->file = NULL; + livetv->setup_done = FALSE; - livetv->socket = NULL; - livetv->recorder = NULL; - livetv->tvchain = NULL; - livetv->proginfo = NULL; - livetv->uri = NULL; + livetv->socket = NULL; + livetv->recorder = NULL; + livetv->tvchain = NULL; + livetv->proginfo = NULL; + livetv->uri = NULL; - livetv->mutex = g_mutex_new (); + livetv->mutex = g_mutex_new (); } -static void + static void gmyth_livetv_dispose (GObject * object) { - GMythLiveTV *livetv = GMYTH_LIVETV (object); + GMythLiveTV *livetv = GMYTH_LIVETV (object); - if (livetv->disposed) { - /* If dispose did already run, return. */ - return; - } + if (livetv->disposed) { + /* If dispose did already run, return. */ + return; + } - /* Make sure dispose does not run twice. */ - livetv->disposed = TRUE; + /* Make sure dispose does not run twice. */ + livetv->disposed = TRUE; - if (livetv->monitor != NULL) { - g_object_unref (livetv->monitor); - livetv->monitor = NULL; - } + if (livetv->monitor != NULL) { + g_object_unref (livetv->monitor); + livetv->monitor = NULL; + } - if (livetv->file != NULL) { - g_object_unref (livetv->file); - livetv->file = NULL; - } + if (livetv->file != NULL) { + g_object_unref (livetv->file); + livetv->file = NULL; + } - if (livetv->recorder != NULL) { - //gmyth_recorder_close(livetv->recorder); - g_object_unref (livetv->recorder); - livetv->recorder = NULL; - } + if (livetv->recorder != NULL) { + //gmyth_recorder_close(livetv->recorder); + g_object_unref (livetv->recorder); + livetv->recorder = NULL; + } - if (livetv->socket != NULL) { - g_object_unref (livetv->socket); - livetv->socket = NULL; - } + if (livetv->socket != NULL) { + g_object_unref (livetv->socket); + livetv->socket = NULL; + } - if (livetv->tvchain != NULL) { - g_object_unref (livetv->tvchain); - livetv->tvchain = NULL; - } + if (livetv->tvchain != NULL) { + g_object_unref (livetv->tvchain); + livetv->tvchain = NULL; + } - if (livetv->proginfo != NULL) { - g_object_unref (livetv->proginfo); - livetv->proginfo = NULL; - } + if (livetv->proginfo != NULL) { + g_object_unref (livetv->proginfo); + livetv->proginfo = NULL; + } - if (livetv->backend_info != NULL) { - g_object_unref (livetv->backend_info); - livetv->backend_info = NULL; - } + if (livetv->backend_info != NULL) { + g_object_unref (livetv->backend_info); + livetv->backend_info = NULL; + } - if (livetv->uri != NULL) { - g_object_unref (livetv->uri); - livetv->uri = NULL; - } + if (livetv->uri != NULL) { + g_object_unref (livetv->uri); + livetv->uri = NULL; + } - if (livetv->mutex != NULL) { - g_mutex_free (livetv->mutex); - livetv->mutex = NULL; - } + if (livetv->mutex != NULL) { + g_mutex_free (livetv->mutex); + livetv->mutex = NULL; + } - if (livetv->local_hostname != NULL) { - g_string_free (livetv->local_hostname, TRUE); - livetv->local_hostname = NULL; - } + if (livetv->local_hostname != NULL) { + g_string_free (livetv->local_hostname, TRUE); + livetv->local_hostname = NULL; + } - G_OBJECT_CLASS (gmyth_livetv_parent_class)->dispose (object); + G_OBJECT_CLASS (gmyth_livetv_parent_class)->dispose (object); } -static void + static void gmyth_livetv_finalize (GObject * object) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_livetv_parent_class)->finalize (object); + G_OBJECT_CLASS (gmyth_livetv_parent_class)->finalize (object); } /** @@ -170,15 +169,15 @@ * * @return a newly allocated GMythLiveTV instance */ -GMythLiveTV * + GMythLiveTV * gmyth_livetv_new (GMythBackendInfo * backend_info) { - GMythLiveTV *livetv = GMYTH_LIVETV (g_object_new (GMYTH_LIVETV_TYPE, NULL)); + GMythLiveTV *livetv = GMYTH_LIVETV (g_object_new (GMYTH_LIVETV_TYPE, NULL)); - livetv->backend_info = backend_info; - g_object_ref (livetv->backend_info); + livetv->backend_info = backend_info; + g_object_ref (livetv->backend_info); - return livetv; + return livetv; } /** @@ -191,96 +190,96 @@ * @param message the message's string description * @param user_data pointer to the GMythLiveTV instance */ -static void + static void gmyth_livetv_monitor_signal_handler (GMythMonitorHandler * monitor, - gint msg_code, gchar * message, gpointer user_data) + gint msg_code, gchar * message, gpointer user_data) { - GMythLiveTV *live_tv = GMYTH_LIVETV (user_data); + GMythLiveTV *live_tv = GMYTH_LIVETV (user_data); - gmyth_debug - ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", - message, msg_code, live_tv != NULL ? "" : "NULL", - user_data != NULL ? "" : "NULL"); + gmyth_debug + ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", + message, msg_code, live_tv != NULL ? "" : "NULL", + user_data != NULL ? "" : "NULL"); - if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file)) { - gmyth_debug ("LiveTV_obj is equals to NULL!!!"); - return; - } + if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file)) { + gmyth_debug ("LiveTV_obj is equals to NULL!!!"); + return; + } - switch (msg_code) { + switch (msg_code) { - case GMYTH_BACKEND_PROGRAM_INFO_CHANGED: - { - gmyth_debug - ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new " - "TV Chain ID is the same as the old one...\n", message); - if (g_ascii_strcasecmp - (message, - (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) { - gmyth_debug - ("OK!!! MOVED to the next program chain [actual == %s]!", - (gmyth_tvchain_get_id (live_tv->tvchain))->str); - /* advertises the FileTransfer about the program info changed */ - if (live_tv->file != NULL) { - gmyth_debug - ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]"); + case GMYTH_BACKEND_PROGRAM_INFO_CHANGED: + { + gmyth_debug + ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new " + "TV Chain ID is the same as the old one...\n", message); + if (g_ascii_strcasecmp + (message, + (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) { + gmyth_debug + ("OK!!! MOVED to the next program chain [actual == %s]!", + (gmyth_tvchain_get_id (live_tv->tvchain))->str); + /* advertises the FileTransfer about the program info changed */ + if (live_tv->file != NULL) { + gmyth_debug + ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]"); - gmyth_file_transfer_emit_program_info_changed_signal - (GMYTH_FILE_TRANSFER (live_tv->file), msg_code, - (gpointer) (live_tv->recorder)); + gmyth_file_transfer_emit_program_info_changed_signal + (GMYTH_FILE_TRANSFER (live_tv->file), msg_code, + (gpointer) (live_tv->recorder)); - /* gmyth_livetv_monitor_handler_stop( live_tv ); */ - } else - gmyth_debug - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); - } - break; - } - case GMYTH_BACKEND_DONE_RECORDING: - { - gmyth_debug - ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new " - "TV Chain ID is the same as the old one...\n", message); - if (g_ascii_strcasecmp - (message, - (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) { - gmyth_debug - ("OK!!! MOVED to the next program chain [actual == %s]!", - (gmyth_tvchain_get_id (live_tv->tvchain))->str); - /* advertises the FileTransfer about the program info changed */ - if (live_tv->file != NULL) { - gmyth_debug - ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]"); + /* gmyth_livetv_monitor_handler_stop( live_tv ); */ + } else + gmyth_debug + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); + } + break; + } + case GMYTH_BACKEND_DONE_RECORDING: + { + gmyth_debug + ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new " + "TV Chain ID is the same as the old one...\n", message); + if (g_ascii_strcasecmp + (message, + (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) { + gmyth_debug + ("OK!!! MOVED to the next program chain [actual == %s]!", + (gmyth_tvchain_get_id (live_tv->tvchain))->str); + /* advertises the FileTransfer about the program info changed */ + if (live_tv->file != NULL) { + gmyth_debug + ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]"); - gmyth_file_transfer_emit_program_info_changed_signal - (GMYTH_FILE_TRANSFER (live_tv->file), msg_code, - (gpointer) (live_tv->recorder)); + gmyth_file_transfer_emit_program_info_changed_signal + (GMYTH_FILE_TRANSFER (live_tv->file), msg_code, + (gpointer) (live_tv->recorder)); - } else - gmyth_debug - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); - } - break; - } - case GMYTH_BACKEND_STOP_LIVETV: - { - gmyth_debug - ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the " - "LiveTV...\n", message); - /* stops the LiveTV */ - if (live_tv != NULL) { - gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]"); + } else + gmyth_debug + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); + } + break; + } + case GMYTH_BACKEND_STOP_LIVETV: + { + gmyth_debug + ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the " + "LiveTV...\n", message); + /* stops the LiveTV */ + if (live_tv != NULL) { + gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]"); - g_object_unref (live_tv); - } else - gmyth_debug - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); + g_object_unref (live_tv); + } else + gmyth_debug + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); - break; - } - default: - break; - } /* switch (Monitor Handler messages) */ + break; + } + default: + break; + } /* switch (Monitor Handler messages) */ } @@ -293,43 +292,43 @@ * @return true if the Monitor Handler start-up process * had been concluded succcesfully */ -gboolean + gboolean gmyth_livetv_monitor_handler_start (GMythLiveTV * livetv) { - gboolean res = TRUE; + gboolean res = TRUE; - if (livetv->monitor != NULL) { - g_object_unref (livetv->monitor); - livetv->monitor = NULL; - } + if (livetv->monitor != NULL) { + g_object_unref (livetv->monitor); + livetv->monitor = NULL; + } - livetv->monitor = gmyth_monitor_handler_new (); + livetv->monitor = gmyth_monitor_handler_new (); - res = - gmyth_monitor_handler_open (livetv->monitor, - livetv->backend_info->hostname, livetv->backend_info->port); + res = + gmyth_monitor_handler_open (livetv->monitor, + livetv->backend_info->hostname, livetv->backend_info->port); - if (res == TRUE) { - gmyth_debug - ("Connect MythTV Monitor event socket! Trying to start the message handler..."); + if (res == TRUE) { + gmyth_debug + ("Connect MythTV Monitor event socket! Trying to start the message handler..."); - res = gmyth_monitor_handler_start (livetv->monitor); + res = gmyth_monitor_handler_start (livetv->monitor); - if (res) { - gmyth_debug - ("MythTV Monitor event socket connected and listening!"); - g_signal_connect (G_OBJECT (livetv->monitor), - "backend-events-handler", (GCallback) - gmyth_livetv_monitor_signal_handler, livetv); - } else { - gmyth_debug - ("Problems when trying to start MythTV Monitor event socket!"); - goto error; - } - } + if (res) { + gmyth_debug + ("MythTV Monitor event socket connected and listening!"); + g_signal_connect (G_OBJECT (livetv->monitor), + "backend-events-handler", (GCallback) + gmyth_livetv_monitor_signal_handler, livetv); + } else { + gmyth_debug + ("Problems when trying to start MythTV Monitor event socket!"); + goto error; + } + } - error: - return res; +error: + return res; } @@ -342,26 +341,26 @@ * @return true if the Monitor Handler shutdown process * had been concluded succcesfully */ -void + void gmyth_livetv_monitor_handler_stop (GMythLiveTV * livetv) { - if (livetv->monitor != NULL) { - g_object_unref (livetv->monitor); - livetv->monitor = NULL; - } + if (livetv->monitor != NULL) { + g_object_unref (livetv->monitor); + livetv->monitor = NULL; + } } #if 0 -static gchar * + static gchar * gmyth_livetv_create_remote_url (GMythLiveTV * livetv) { - gchar *uri = g_strdup (""); + gchar *uri = g_strdup (""); - gmyth_backend_info_get_remote_h - //gmyth_backend(livetv->backend_info) - return uri; + gmyth_backend_info_get_remote_h + //gmyth_backend(livetv->backend_info) + return uri; } #endif @@ -377,272 +376,272 @@ * @return true if the LiveTV's recorder instance configuration * had been concluded succcesfully */ -static gboolean + static gboolean gmyth_livetv_setup_recorder_channel_name (GMythLiveTV * livetv, gchar * channel) { - gboolean res = TRUE; + gboolean res = TRUE; - g_return_val_if_fail (livetv != NULL, FALSE); + g_return_val_if_fail (livetv != NULL, FALSE); - if (NULL == livetv->socket) { - livetv->socket = gmyth_socket_new (); + if (NULL == livetv->socket) { + livetv->socket = gmyth_socket_new (); - /* FIME: Implement this at gmyth_socket */ - res = - gmyth_socket_connect_to_backend (livetv->socket, - livetv->backend_info->hostname, livetv->backend_info->port, TRUE); - if (!res) { - gmyth_debug ("[%s] LiveTV can not connect to backend", - __FUNCTION__); - res = FALSE; - goto error; - } - } + /* FIME: Implement this at gmyth_socket */ + res = + gmyth_socket_connect_to_backend (livetv->socket, + livetv->backend_info->hostname, livetv->backend_info->port, TRUE); + if (!res) { + gmyth_debug ("[%s] LiveTV can not connect to backend", + __FUNCTION__); + res = FALSE; + goto error; + } + } - g_mutex_lock (livetv->mutex); + g_mutex_lock (livetv->mutex); - livetv->is_livetv = TRUE; + livetv->is_livetv = TRUE; - livetv->local_hostname = gmyth_socket_get_local_hostname (); + livetv->local_hostname = gmyth_socket_get_local_hostname (); - if (livetv->local_hostname == NULL) { - g_warning ("livetv could not retrieve the local hostname"); - res = FALSE; - goto error; - } else { - gmyth_debug ("Local hostname: %s", livetv->local_hostname->str); - } + if (livetv->local_hostname == NULL) { + g_warning ("livetv could not retrieve the local hostname"); + res = FALSE; + goto error; + } else { + gmyth_debug ("Local hostname: %s", livetv->local_hostname->str); + } - if (livetv->recorder != NULL) { - g_object_unref (livetv->recorder); - livetv->recorder = NULL; - } + if (livetv->recorder != NULL) { + g_object_unref (livetv->recorder); + livetv->recorder = NULL; + } - if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0) { - gmyth_debug ("No free remote encoder available."); - res = FALSE; - goto error; - } + if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0) { + gmyth_debug ("No free remote encoder available."); + res = FALSE; + goto error; + } - /* Gets the recorder num */ - livetv->recorder = remote_request_next_free_recorder (livetv->socket, -1); - gmyth_socket_close_connection (livetv->socket); + /* Gets the recorder num */ + livetv->recorder = remote_request_next_free_recorder (livetv->socket, -1); + gmyth_socket_close_connection (livetv->socket); - if (NULL == livetv->recorder) { - gmyth_debug ("[%s] None remote encoder available", __FUNCTION__); - res = FALSE; - goto error; - } + if (NULL == livetv->recorder) { + gmyth_debug ("[%s] None remote encoder available", __FUNCTION__); + res = FALSE; + goto error; + } - /* Init remote encoder. Opens its control socket. */ - res = gmyth_recorder_setup (livetv->recorder); - if (!res) { - gmyth_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__); - res = FALSE; - goto error; - } + /* Init remote encoder. Opens its control socket. */ + res = gmyth_recorder_setup (livetv->recorder); + if (!res) { + gmyth_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__); + res = FALSE; + goto error; + } - /* Creates livetv chain handler */ - livetv->tvchain = gmyth_tvchain_new (); - gmyth_tvchain_initialize (livetv->tvchain, livetv->backend_info); + /* Creates livetv chain handler */ + livetv->tvchain = gmyth_tvchain_new (); + gmyth_tvchain_initialize (livetv->tvchain, livetv->backend_info); - if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL) { - res = FALSE; - goto error; - } - // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) - res = gmyth_recorder_spawntv (livetv->recorder, - gmyth_tvchain_get_id (livetv->tvchain)); - if (!res) { - gmyth_debug ("[%s] Fail while spawn tv\n", __FUNCTION__); - res = FALSE; - goto error; - } + if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL) { + res = FALSE; + goto error; + } + // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly) + res = gmyth_recorder_spawntv (livetv->recorder, + gmyth_tvchain_get_id (livetv->tvchain)); + if (!res) { + gmyth_debug ("[%s] Fail while spawn tv\n", __FUNCTION__); + res = FALSE; + goto error; + } - if (res == TRUE) { - /* loop finished, set the max tries variable to zero again... */ - gint wait_to_transfer = 0; + if (res == TRUE) { + /* loop finished, set the max tries variable to zero again... */ + gint wait_to_transfer = 0; - while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && - (gmyth_recorder_is_recording (livetv->recorder) == FALSE)) - g_usleep (300); + while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && + (gmyth_recorder_is_recording (livetv->recorder) == FALSE)) + g_usleep (300); - if (channel != NULL) { - /* Pauses remote encoder. */ - res = gmyth_recorder_pause_recording (livetv->recorder); - if (!res) { - gmyth_debug ("[%s] Fail while pausing remote encoder\n", - __FUNCTION__); - res = FALSE; - goto error; - } + if (channel != NULL) { + /* Pauses remote encoder. */ + res = gmyth_recorder_pause_recording (livetv->recorder); + if (!res) { + gmyth_debug ("[%s] Fail while pausing remote encoder\n", + __FUNCTION__); + res = FALSE; + goto error; + } - if (gmyth_recorder_check_channel_name (livetv->recorder, channel)) { - if (gmyth_recorder_set_channel_name (livetv->recorder, channel)) { - gmyth_debug ("Channel changed!!! [%s].\n", channel); - } - } + if (gmyth_recorder_check_channel_name (livetv->recorder, channel)) { + if (gmyth_recorder_set_channel_name (livetv->recorder, channel)) { + gmyth_debug ("Channel changed!!! [%s].\n", channel); + } + } - } - /* if - changes the channel number */ - /* sleep (5); */ - /* FIXME: this is evil (tpm) */ - } + } + /* if - changes the channel number */ + /* sleep (5); */ + /* FIXME: this is evil (tpm) */ + } - /* DEBUG message */ - GMythProgramInfo *prog_info = - gmyth_recorder_get_current_program_info (livetv->recorder); + /* DEBUG message */ + GMythProgramInfo *prog_info = + gmyth_recorder_get_current_program_info (livetv->recorder); - if (NULL == prog_info) { - gmyth_debug ("ProgramInfo is equals to NULL!!!"); + if (NULL == prog_info) { + gmyth_debug ("ProgramInfo is equals to NULL!!!"); - gint i; - gchar *channame = NULL; + gint i; + gchar *channame = NULL; - gmyth_debug ("Problem getting current proginfo!\n"); + gmyth_debug ("Problem getting current proginfo!\n"); - /* - * mythbackend must not be tuned in to a channel, so keep - * changing channels until we find a valid one, or until - * we decide to give up. - */ - for (i = 1; i < 1000; i++) { - if (channame != NULL) - g_free (channame); - channame = g_strdup_printf ("%d", i); - if (gmyth_recorder_set_channel_name (livetv->recorder, channame) - < 0) { - continue; - } - prog_info = - gmyth_recorder_get_next_program_info (livetv->recorder, - BROWSE_DIRECTION_UP); - gmyth_program_info_print (prog_info); - if (prog_info != NULL) - break; - } + /* + * mythbackend must not be tuned in to a channel, so keep + * changing channels until we find a valid one, or until + * we decide to give up. + */ + for (i = 1; i < 1000; i++) { + if (channame != NULL) + g_free (channame); + channame = g_strdup_printf ("%d", i); + if (gmyth_recorder_set_channel_name (livetv->recorder, channame) + < 0) { + continue; + } + prog_info = + gmyth_recorder_get_next_program_info (livetv->recorder, + BROWSE_DIRECTION_UP); + gmyth_program_info_print (prog_info); + if (prog_info != NULL) + break; + } - } + } - /* if - Program Info */ - /* prints program info data text */ - gmyth_debug ("New ProgramInfo...\n"); - gmyth_program_info_print (prog_info); + /* if - Program Info */ + /* prints program info data text */ + gmyth_debug ("New ProgramInfo...\n"); + gmyth_program_info_print (prog_info); - /* check if the program chain could be obtained from the MythTV protocol message */ - if (prog_info != NULL) { - gmyth_backend_info_set_username (livetv->tvchain->backend_info, - "mythtv"); - gmyth_backend_info_set_password (livetv->tvchain->backend_info, - "mythtv"); - gmyth_backend_info_set_db_name (livetv->tvchain->backend_info, - "mythconverg"); - GList *prog_list = - gmyth_tvchain_get_program_info_from_channel (livetv->tvchain, - channel); - GMythProgramInfo *ch_prog = NULL; + /* check if the program chain could be obtained from the MythTV protocol message */ + if (prog_info != NULL) { + gmyth_backend_info_set_username (livetv->tvchain->backend_info, + "mythtv"); + gmyth_backend_info_set_password (livetv->tvchain->backend_info, + "mythtv"); + gmyth_backend_info_set_db_name (livetv->tvchain->backend_info, + "mythconverg"); + GList *prog_list = + gmyth_tvchain_get_program_info_from_channel (livetv->tvchain, + channel); + GMythProgramInfo *ch_prog = NULL; - if (prog_list != NULL && g_list_length (prog_list) > 0) { - ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0); - gmyth_debug ("Channel program info (from a list with size = %d)!", - g_list_length (prog_list)); - gmyth_program_info_print (ch_prog); - } + if (prog_list != NULL && g_list_length (prog_list) > 0) { + ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0); + gmyth_debug ("Channel program info (from a list with size = %d)!", + g_list_length (prog_list)); + gmyth_program_info_print (ch_prog); + } - gmyth_debug ("Program Info: %s\n", - gmyth_program_info_to_string (prog_info)); - livetv->proginfo = prog_info; - /* testing change channel */ - //gmyth_recorder_spawntv_no_tvchain( livetv->recorder ); - } else { + gmyth_debug ("Program Info: %s\n", + gmyth_program_info_to_string (prog_info)); + livetv->proginfo = prog_info; + /* testing change channel */ + //gmyth_recorder_spawntv_no_tvchain( livetv->recorder ); + } else { - /* check for the program info in the TV program chain could be obtained - from the MythTV MySQL database */ + /* check for the program info in the TV program chain could be obtained + from the MythTV MySQL database */ - /* Reload all TV chain from Mysql database. */ - gmyth_tvchain_reload_all (livetv->tvchain); + /* Reload all TV chain from Mysql database. */ + gmyth_tvchain_reload_all (livetv->tvchain); - if (livetv->tvchain == NULL) { - res = FALSE; - goto error; - } + if (livetv->tvchain == NULL) { + res = FALSE; + goto error; + } - /* Get program info from database using chanid and starttime */ - livetv->proginfo = - gmyth_tvchain_get_program_at (livetv->tvchain, - tvchain_curr_index++); - if (livetv->proginfo == NULL) { - gmyth_debug ("LiveTV not successfully started.\n"); - res = FALSE; - goto error; - } else { - res = TRUE; - gmyth_debug - ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", - livetv->proginfo->pathname->str); - } + /* Get program info from database using chanid and starttime */ + livetv->proginfo = + gmyth_tvchain_get_program_at (livetv->tvchain, + tvchain_curr_index++); + if (livetv->proginfo == NULL) { + gmyth_debug ("LiveTV not successfully started.\n"); + res = FALSE; + goto error; + } else { + res = TRUE; + gmyth_debug + ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", + livetv->proginfo->pathname->str); + } - } + } - livetv->uri = - (GMythURI *) gmyth_backend_info_get_uri (livetv->backend_info); + livetv->uri = + (GMythURI *) gmyth_backend_info_get_uri (livetv->backend_info); - g_mutex_unlock (livetv->mutex); + g_mutex_unlock (livetv->mutex); - if (!gmyth_livetv_monitor_handler_start (livetv)) { - res = FALSE; - gmyth_debug ("LiveTV MONITOR handler error on setup!"); - goto error; - } + if (!gmyth_livetv_monitor_handler_start (livetv)) { + res = FALSE; + gmyth_debug ("LiveTV MONITOR handler error on setup!"); + goto error; + } - livetv->setup_done = TRUE; + livetv->setup_done = TRUE; - return res; + return res; - error: - g_mutex_unlock (livetv->mutex); +error: + g_mutex_unlock (livetv->mutex); - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - res = FALSE; + res = FALSE; - if (livetv->local_hostname != NULL) { - g_string_free (livetv->local_hostname, TRUE); - livetv->local_hostname = NULL; - } + if (livetv->local_hostname != NULL) { + g_string_free (livetv->local_hostname, TRUE); + livetv->local_hostname = NULL; + } - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - if (livetv->recorder != NULL) { - g_object_unref (livetv->recorder); - livetv->recorder = NULL; - } + if (livetv->recorder != NULL) { + g_object_unref (livetv->recorder); + livetv->recorder = NULL; + } - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - if (livetv->tvchain != NULL) { - g_object_unref (livetv->tvchain); - livetv->tvchain = NULL; - } + if (livetv->tvchain != NULL) { + g_object_unref (livetv->tvchain); + livetv->tvchain = NULL; + } - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - if (livetv->proginfo != NULL) { - g_object_unref (livetv->proginfo); - livetv->proginfo = NULL; - } + if (livetv->proginfo != NULL) { + g_object_unref (livetv->proginfo); + livetv->proginfo = NULL; + } - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - if (livetv->monitor != NULL) { - g_object_unref (livetv->monitor); - livetv->monitor = NULL; - } + if (livetv->monitor != NULL) { + g_object_unref (livetv->monitor); + livetv->monitor = NULL; + } - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__); - return res; + return res; } @@ -658,12 +657,12 @@ * @return true if the LiveTV's recorder instance configuration * had been concluded succcesfully */ -static gboolean + static gboolean gmyth_livetv_setup_recorder (GMythLiveTV * livetv, gint channel) { - return gmyth_livetv_setup_recorder_channel_name (livetv, - (channel != -1) ? g_strdup_printf ("%d", channel) - : NULL); + return gmyth_livetv_setup_recorder_channel_name (livetv, + (channel != -1) ? g_strdup_printf ("%d", channel) + : NULL); } /** @@ -678,10 +677,10 @@ * @return true if the LiveTV's recorder instance configuration * had been concluded succcesfully */ -gboolean + gboolean gmyth_livetv_channel_setup (GMythLiveTV * livetv, gint channel) { - return gmyth_livetv_setup_recorder (livetv, channel); + return gmyth_livetv_setup_recorder (livetv, channel); } /** @@ -696,10 +695,10 @@ * @return true if the LiveTV's recorder instance configuration * had been concluded succcesfully */ -gboolean + gboolean gmyth_livetv_channel_name_setup (GMythLiveTV * livetv, gchar * channel) { - return gmyth_livetv_setup_recorder_channel_name (livetv, channel); + return gmyth_livetv_setup_recorder_channel_name (livetv, channel); } /** @@ -713,10 +712,10 @@ * @return true if the LiveTV's recorder instance configuration * had been concluded succcesfully */ -gboolean + gboolean gmyth_livetv_setup (GMythLiveTV * livetv) { - return gmyth_livetv_setup_recorder (livetv, -1); + return gmyth_livetv_setup_recorder (livetv, -1); } /** @@ -726,72 +725,72 @@ * * @return true if the next program info could be got */ -gboolean + gboolean gmyth_livetv_next_program_chain (GMythLiveTV * livetv) { - gboolean res = TRUE; - GMythProgramInfo *prog_info = NULL; + gboolean res = TRUE; + GMythProgramInfo *prog_info = NULL; - if (!livetv->setup_done) { - gmyth_debug ("Call the setup function first!"); - goto error; - } + if (!livetv->setup_done) { + gmyth_debug ("Call the setup function first!"); + goto error; + } - gmyth_debug ("Current ProgramInfo...\n"); - prog_info = gmyth_recorder_get_current_program_info (livetv->recorder); + gmyth_debug ("Current ProgramInfo...\n"); + prog_info = gmyth_recorder_get_current_program_info (livetv->recorder); - if (prog_info != NULL) { - livetv->proginfo = prog_info; - } else { - gmyth_debug - ("ProgramInfo equals to NULL!!! Getting the next program info..."); - prog_info = - gmyth_recorder_get_next_program_info (livetv->recorder, - BROWSE_DIRECTION_RIGHT); - livetv->proginfo = prog_info; - } - /* prints program info data text */ - gmyth_program_info_print (prog_info); + if (prog_info != NULL) { + livetv->proginfo = prog_info; + } else { + gmyth_debug + ("ProgramInfo equals to NULL!!! Getting the next program info..."); + prog_info = + gmyth_recorder_get_next_program_info (livetv->recorder, + BROWSE_DIRECTION_RIGHT); + livetv->proginfo = prog_info; + } + /* prints program info data text */ + gmyth_program_info_print (prog_info); - if (prog_info != NULL) { - res = TRUE; - livetv->proginfo = prog_info; - gmyth_debug - ("GMythLiveTV: All requests to backend to start TV were OK, program info changed."); - } else { - gmyth_debug - ("[%s] LiveTV not successfully started on the next program chain.\n", - __FUNCTION__); - goto error; - } + if (prog_info != NULL) { + res = TRUE; + livetv->proginfo = prog_info; + gmyth_debug + ("GMythLiveTV: All requests to backend to start TV were OK, program info changed."); + } else { + gmyth_debug + ("[%s] LiveTV not successfully started on the next program chain.\n", + __FUNCTION__); + goto error; + } - livetv->setup_done = TRUE; + livetv->setup_done = TRUE; - return res; + return res; - error: - gmyth_debug ("ERROR running LiveTV setup.\n"); +error: + gmyth_debug ("ERROR running LiveTV setup.\n"); - res = FALSE; + res = FALSE; - g_string_free (livetv->local_hostname, TRUE); + g_string_free (livetv->local_hostname, TRUE); - if (livetv->recorder != NULL) { - g_object_unref (livetv->recorder); - livetv->recorder = NULL; - } + if (livetv->recorder != NULL) { + g_object_unref (livetv->recorder); + livetv->recorder = NULL; + } - if (livetv->tvchain != NULL) { - g_object_unref (livetv->tvchain); - livetv->tvchain = NULL; - } + if (livetv->tvchain != NULL) { + g_object_unref (livetv->tvchain); + livetv->tvchain = NULL; + } - if (livetv->proginfo != NULL) { - g_object_unref (livetv->proginfo); - livetv->proginfo = NULL; - } + if (livetv->proginfo != NULL) { + g_object_unref (livetv->proginfo); + livetv->proginfo = NULL; + } - return res; + return res; } /** @@ -803,85 +802,85 @@ * @return the actual GMythFileTransfer instance, generated using the * data got from the actual program info. */ -GMythFile * + GMythFile * gmyth_livetv_create_file_transfer (GMythLiveTV * livetv) { - //GMythURI* uri = NULL; + //GMythURI* uri = NULL; - if (NULL == livetv) - goto done; + if (NULL == livetv) + goto done; - if (!livetv->setup_done) { - gmyth_debug - ("Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!"); - goto done; - } + if (!livetv->setup_done) { + gmyth_debug + ("Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!"); + goto done; + } - if (livetv->proginfo != NULL) - gmyth_debug ("URI path (from program info) = %s.\n", - livetv->proginfo->pathname->str); - else - gmyth_debug ("URI path (from URI) = %s.\n", livetv->uri->uri->str); + if (livetv->proginfo != NULL) + gmyth_debug ("URI path (from program info) = %s.\n", + livetv->proginfo->pathname->str); + else + gmyth_debug ("URI path (from URI) = %s.\n", livetv->uri->uri->str); - g_mutex_lock (livetv->mutex); + g_mutex_lock (livetv->mutex); - if (livetv->file != NULL) { - /*gmyth_file_transfer_close( livetv->file ); */ - g_object_unref (livetv->file); - livetv->file = NULL; - } + if (livetv->file != NULL) { + /*gmyth_file_transfer_close( livetv->file ); */ + g_object_unref (livetv->file); + livetv->file = NULL; + } - if (livetv->uri != NULL) { - gmyth_debug - ("URI is not NULL, creating from the ProgramInfo pathname... (%s)", - livetv->proginfo->pathname->str); - livetv->uri->path = g_string_erase (livetv->uri->path, 0, -1); - livetv->uri->path = - g_string_new (g_strrstr (livetv->proginfo->pathname->str, "/")); - } else { - gmyth_debug - ("URI is NULL, creating from the ProgramInfo pathname... (%s)", - livetv->proginfo->pathname->str); - livetv->uri = - gmyth_uri_new_with_value (livetv->proginfo->pathname->str); - } + if (livetv->uri != NULL) { + gmyth_debug + ("URI is not NULL, creating from the ProgramInfo pathname... (%s)", + livetv->proginfo->pathname->str); + livetv->uri->path = g_string_erase (livetv->uri->path, 0, -1); + livetv->uri->path = + g_string_new (g_strrstr (livetv->proginfo->pathname->str, "/")); + } else { + gmyth_debug + ("URI is NULL, creating from the ProgramInfo pathname... (%s)", + livetv->proginfo->pathname->str); + livetv->uri = + gmyth_uri_new_with_value (livetv->proginfo->pathname->str); + } - if (NULL == livetv->uri) { - gmyth_debug ("Couldn't parse the URI to start LiveTV! [ uri = %s ]", - livetv->proginfo->pathname->str); - goto done; - } + if (NULL == livetv->uri) { + gmyth_debug ("Couldn't parse the URI to start LiveTV! [ uri = %s ]", + livetv->proginfo->pathname->str); + goto done; + } - if (gmyth_uri_is_local_file (livetv->uri)) - livetv->file = GMYTH_FILE (gmyth_file_local_new (livetv->backend_info)); - else { - livetv->file = - GMYTH_FILE (gmyth_file_transfer_new (livetv->backend_info)); - /* gmyth_file_transfer_settimeout( GMYTH_FILE_TRANSFER(livetv->file), TRUE ); */ - } + if (gmyth_uri_is_local_file (livetv->uri)) + livetv->file = GMYTH_FILE (gmyth_file_local_new (livetv->backend_info)); + else { + livetv->file = + GMYTH_FILE (gmyth_file_transfer_new (livetv->backend_info)); + /* gmyth_file_transfer_settimeout( GMYTH_FILE_TRANSFER(livetv->file), TRUE ); */ + } - if (NULL == livetv->file) { - gmyth_debug - ("Error: couldn't create the FileTransfer from LiveTV source!"); - goto done; - } + if (NULL == livetv->file) { + gmyth_debug + ("Error: couldn't create the FileTransfer from LiveTV source!"); + goto done; + } - g_object_ref (livetv->file); + g_object_ref (livetv->file); - g_mutex_unlock (livetv->mutex); + g_mutex_unlock (livetv->mutex); - /* Do some locking procedure with the Monitor Handler messages... */ + /* Do some locking procedure with the Monitor Handler messages... */ - done: - /* - if ( uri != NULL ) - { - g_object_unref( uri ); - uri = NULL; - } - */ +done: + /* + if ( uri != NULL ) + { + g_object_unref( uri ); + uri = NULL; + } + */ - return livetv->file; + return livetv->file; } @@ -890,35 +889,35 @@ * * @param live_tv the GMythLiveTV instance */ -void + void gmyth_livetv_stop_playing (GMythLiveTV * livetv) { - gmyth_debug ("Stopping the LiveTV...\n"); + gmyth_debug ("Stopping the LiveTV...\n"); - if (livetv->is_livetv) { - if (!gmyth_recorder_stop_livetv (livetv->recorder)) { - gmyth_debug ("[%s] Error while stoping remote encoder", - __FUNCTION__); - } + if (livetv->is_livetv) { + if (!gmyth_recorder_stop_livetv (livetv->recorder)) { + gmyth_debug ("[%s] Error while stoping remote encoder", + __FUNCTION__); + } - if (!gmyth_recorder_finish_recording (livetv->recorder)) { - gmyth_debug - ("[%s] Error while finishing recording on remote encoder", - __FUNCTION__); - } - } + if (!gmyth_recorder_finish_recording (livetv->recorder)) { + gmyth_debug + ("[%s] Error while finishing recording on remote encoder", + __FUNCTION__); + } + } } -gboolean + gboolean gmyth_livetv_is_playing (GMythLiveTV * livetv) { - return TRUE; + return TRUE; } -void + void gmyth_livetv_start_playing (GMythLiveTV * livetv) { - // TODO + // TODO } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_livetv.h --- a/gmyth/src/gmyth_livetv.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_livetv.h Wed May 23 19:50:41 2007 +0100 @@ -8,22 +8,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ +* +* 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_LIVETV_H_ #define GMYTH_LIVETV_H_ @@ -49,55 +48,55 @@ typedef struct _GMythLiveTVClass GMythLiveTVClass; struct _GMythLiveTVClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ -}; + /* callbacks */ + }; struct _GMythLiveTV -{ - GObject parent; + { + GObject parent; - GMythSocket *socket; + GMythSocket *socket; - GString *local_hostname; + GString *local_hostname; - GMythBackendInfo *backend_info; + GMythBackendInfo *backend_info; - GMythRecorder *recorder; - GMythTVChain *tvchain; - GMythProgramInfo *proginfo; + GMythRecorder *recorder; + GMythTVChain *tvchain; + GMythProgramInfo *proginfo; - GMythFile *file; + GMythFile *file; - GMythMonitorHandler *monitor; - GMythURI *uri; + GMythMonitorHandler *monitor; + GMythURI *uri; - gboolean is_livetv; - gboolean setup_done; + gboolean is_livetv; + gboolean setup_done; - GMutex *mutex; - gboolean disposed; -}; + GMutex *mutex; + gboolean disposed; + }; -GType gmyth_livetv_get_type (void); +GType gmyth_livetv_get_type ( void ); -GMythLiveTV *gmyth_livetv_new (GMythBackendInfo * backend_info); +GMythLiveTV *gmyth_livetv_new ( GMythBackendInfo * backend_info ); -void gmyth_livetv_start_playing (GMythLiveTV * livetv); -void gmyth_livetv_stop_playing (GMythLiveTV * livetv); +void gmyth_livetv_start_playing ( GMythLiveTV * livetv ); +void gmyth_livetv_stop_playing ( GMythLiveTV * livetv ); -gboolean gmyth_livetv_setup (GMythLiveTV * livetv); -gboolean gmyth_livetv_channel_setup (GMythLiveTV * livetv, gint channel); -gboolean gmyth_livetv_channel_name_setup (GMythLiveTV * livetv, - gchar * channel); -gboolean gmyth_livetv_next_program_chain (GMythLiveTV * livetv); +gboolean gmyth_livetv_setup ( GMythLiveTV * livetv ); +gboolean gmyth_livetv_channel_setup ( GMythLiveTV * livetv, gint channel ); +gboolean gmyth_livetv_channel_name_setup ( GMythLiveTV * livetv, + gchar * channel ); +gboolean gmyth_livetv_next_program_chain ( GMythLiveTV * livetv ); -GMythFile *gmyth_livetv_create_file_transfer (GMythLiveTV * livetv); +GMythFile *gmyth_livetv_create_file_transfer ( GMythLiveTV * livetv ); -gboolean gmyth_livetv_monitor_handler_start (GMythLiveTV * livetv); -void gmyth_livetv_monitor_handler_stop (GMythLiveTV * livetv); +gboolean gmyth_livetv_monitor_handler_start ( GMythLiveTV * livetv ); +void gmyth_livetv_monitor_handler_stop ( GMythLiveTV * livetv ); G_END_DECLS #endif /*GMYTH_LIVETV_H_ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_monitor_handler.c Wed May 23 19:50:41 2007 +0100 @@ -9,27 +9,26 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - * - * GStreamer MythTV plug-in properties: - * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv] - * - path (qurl - remote file to be opened) - * - port number * - */ + * + * 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 + * + * GStreamer MythTV plug-in properties: + * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv] + * - path (qurl - remote file to be opened) + * - port number * + */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -69,45 +68,47 @@ #define GMYTHTV_ENABLE_DEBUG 1 #endif -gpointer gmyth_monitor_handler_listener (gpointer data); +gpointer gmyth_monitor_handler_listener ( gpointer data ); -static void gmyth_monitor_handler_default_listener (GMythMonitorHandler * - monitor, gint msg_code, gchar * message); +static void gmyth_monitor_handler_default_listener ( GMythMonitorHandler * + monitor, gint msg_code, + gchar * message ); -static void gmyth_monitor_handler_class_init (GMythMonitorHandlerClass * klass); -static void gmyth_monitor_handler_init (GMythMonitorHandler * object); +static void gmyth_monitor_handler_class_init ( GMythMonitorHandlerClass * + klass ); +static void gmyth_monitor_handler_init ( GMythMonitorHandler * object ); -static void gmyth_monitor_handler_dispose (GObject * object); -static void gmyth_monitor_handler_finalize (GObject * object); +static void gmyth_monitor_handler_dispose ( GObject * object ); +static void gmyth_monitor_handler_finalize ( GObject * object ); -static gboolean gmyth_connect_to_backend_monitor (GMythMonitorHandler * - monitor); +static gboolean gmyth_connect_to_backend_monitor ( GMythMonitorHandler * + monitor ); -static gboolean gmyth_monitor_handler_setup (GMythMonitorHandler * monitor, - GIOChannel * channel); +static gboolean gmyth_monitor_handler_setup ( GMythMonitorHandler * monitor, + GIOChannel * channel ); -void gmyth_monitor_handler_close (GMythMonitorHandler * monitor); +void gmyth_monitor_handler_close ( GMythMonitorHandler * monitor ); -G_DEFINE_TYPE (GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT) +G_DEFINE_TYPE ( GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT ) static void - gmyth_monitor_handler_class_init (GMythMonitorHandlerClass * klass) + gmyth_monitor_handler_class_init ( GMythMonitorHandlerClass * klass ) { GObjectClass *gobject_class; GMythMonitorHandlerClass *gmonitor_class; - gobject_class = (GObjectClass *) klass; - gmonitor_class = (GMythMonitorHandlerClass *) gobject_class; + gobject_class = ( GObjectClass * ) klass; + gmonitor_class = ( GMythMonitorHandlerClass * ) gobject_class; gobject_class->dispose = gmyth_monitor_handler_dispose; gobject_class->finalize = gmyth_monitor_handler_finalize; gmonitor_class->backend_events_handler_signal_id = - g_signal_new ("backend-events-handler", - G_TYPE_FROM_CLASS (gmonitor_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | - G_SIGNAL_NO_HOOKS, 0, NULL, NULL, - gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_STRING); + g_signal_new ( "backend-events-handler", + G_TYPE_FROM_CLASS ( gmonitor_class ), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | + G_SIGNAL_NO_HOOKS, 0, NULL, NULL, + gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, + G_TYPE_INT, G_TYPE_STRING ); gmonitor_class->backend_events_handler = gmyth_monitor_handler_default_listener; @@ -115,9 +116,9 @@ } static void -gmyth_monitor_handler_init (GMythMonitorHandler * monitor) +gmyth_monitor_handler_init ( GMythMonitorHandler * monitor ) { - g_return_if_fail (monitor != NULL); + g_return_if_fail ( monitor != NULL ); monitor->event_sock = NULL; monitor->hostname = NULL; @@ -129,7 +130,7 @@ /* monitor->backend_msgs = g_hash_table_new( g_int_hash, g_int_equal ); */ /* it is used for signalizing the event socket consumer thread */ - monitor->mutex = g_mutex_new (); + monitor->mutex = g_mutex_new ( ); monitor->th = NULL; @@ -137,43 +138,48 @@ } static void -gmyth_monitor_handler_dispose (GObject * object) +gmyth_monitor_handler_dispose ( GObject * object ) { - GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object); + GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER ( object ); - gmyth_monitor_handler_close (monitor); + gmyth_monitor_handler_close ( monitor ); monitor->allow_msgs_listener = FALSE; - if (monitor->th != NULL) { - gboolean *ret = (gboolean *) g_thread_join (monitor->th); + if ( monitor->th != NULL ) + { + gboolean *ret = ( gboolean * ) g_thread_join ( monitor->th ); - if (*ret == FALSE) - gmyth_debug ("Error closing GThread listener socket!"); + if ( *ret == FALSE ) + gmyth_debug ( "Error closing GThread listener socket!" ); else - gmyth_debug ("Closed GThread listener socket."); + gmyth_debug ( "Closed GThread listener socket." ); //g_object_unref( monitor->th ); } /* mutex to control access to the event socket consumer thread */ - if (monitor->mutex != NULL) { + if ( monitor->mutex != NULL ) + { //g_mutex_unlock( monitor->mutex ); - g_mutex_free (monitor->mutex); + g_mutex_free ( monitor->mutex ); monitor->mutex = NULL; } - if (monitor->event_sock != NULL) { - g_object_unref (monitor->event_sock); + if ( monitor->event_sock != NULL ) + { + g_object_unref ( monitor->event_sock ); monitor->event_sock = NULL; } - if (monitor->hostname != NULL) { - g_free (monitor->hostname); + if ( monitor->hostname != NULL ) + { + g_free ( monitor->hostname ); monitor->hostname = NULL; } - if (monitor->backend_msgs != NULL) { - g_hash_table_destroy (monitor->backend_msgs); + if ( monitor->backend_msgs != NULL ) + { + g_hash_table_destroy ( monitor->backend_msgs ); monitor->backend_msgs = NULL; } @@ -185,15 +191,15 @@ } */ - G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_monitor_handler_parent_class )->dispose ( object ); } static void -gmyth_monitor_handler_finalize (GObject * object) +gmyth_monitor_handler_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_monitor_handler_parent_class )->finalize ( object ); } /** @@ -202,11 +208,11 @@ * @return a new instance of the Monitor Handler. */ GMythMonitorHandler * -gmyth_monitor_handler_new (void) +gmyth_monitor_handler_new ( void ) { GMythMonitorHandler *monitor = - GMYTH_MONITOR_HANDLER (g_object_new - (GMYTH_MONITOR_HANDLER_TYPE, FALSE)); + GMYTH_MONITOR_HANDLER ( g_object_new + ( GMYTH_MONITOR_HANDLER_TYPE, FALSE ) ); return monitor; } @@ -220,12 +226,12 @@ * @return true, if the access to IO Watcher was acquired. */ static gboolean -myth_control_acquire_context (GMythMonitorHandler * monitor, gboolean do_wait) +myth_control_acquire_context ( GMythMonitorHandler * monitor, gboolean do_wait ) { gboolean ret = TRUE; - g_mutex_lock (monitor->mutex); + g_mutex_lock ( monitor->mutex ); return ret; @@ -239,32 +245,34 @@ * @return true, if the access to IO Watcher was released. */ static gboolean -myth_control_release_context (GMythMonitorHandler * monitor) +myth_control_release_context ( GMythMonitorHandler * monitor ) { gboolean ret = TRUE; - g_mutex_unlock (monitor->mutex); + g_mutex_unlock ( monitor->mutex ); return ret; } void -gmyth_monitor_handler_close (GMythMonitorHandler * monitor) +gmyth_monitor_handler_close ( GMythMonitorHandler * monitor ) { monitor->allow_msgs_listener = FALSE; #if 0 - if (monitor->monitor_th != NULL) { - g_thread_pool_free (monitor->monitor_th, TRUE, FALSE); + if ( monitor->monitor_th != NULL ) + { + g_thread_pool_free ( monitor->monitor_th, TRUE, FALSE ); //g_thread_exit( monitor->monitor_th ); /*if ( monitor->monitor_th != NULL ) g_object_unref( monitor->monitor_th ); */ monitor->monitor_th = NULL; } - if (monitor->event_sock != NULL) { - gmyth_socket_close_connection (monitor->event_sock); + if ( monitor->event_sock != NULL ) + { + gmyth_socket_close_connection ( monitor->event_sock ); } #endif @@ -281,42 +289,50 @@ * @return true, if the connection was successfully opened. */ gboolean -gmyth_monitor_handler_open (GMythMonitorHandler * monitor, - const gchar * hostname, gint port) +gmyth_monitor_handler_open ( GMythMonitorHandler * monitor, + const gchar * hostname, gint port ) { gboolean ret = TRUE; - g_return_val_if_fail (hostname != NULL, FALSE); + g_return_val_if_fail ( hostname != NULL, FALSE ); - if (monitor->hostname != NULL) { - g_free (monitor->hostname); + if ( monitor->hostname != NULL ) + { + g_free ( monitor->hostname ); monitor->hostname = NULL; } - monitor->hostname = g_strdup (hostname); + monitor->hostname = g_strdup ( hostname ); monitor->port = port; - gmyth_debug ("Monitor event socket --- hostname: %s, port %d\n", - monitor->hostname, monitor->port); + gmyth_debug ( "Monitor event socket --- hostname: %s, port %d\n", + monitor->hostname, monitor->port ); - if (NULL != monitor->event_sock) { - g_object_unref (monitor->event_sock); + if ( NULL != monitor->event_sock ) + { + g_object_unref ( monitor->event_sock ); monitor->event_sock = NULL; } /* configure the event socket */ - if (NULL == monitor->event_sock) { - if (!gmyth_connect_to_backend_monitor (monitor)) { - gmyth_debug ("Connection to backend failed (Event Socket)!"); + if ( NULL == monitor->event_sock ) + { + if ( !gmyth_connect_to_backend_monitor ( monitor ) ) + { + gmyth_debug ( "Connection to backend failed (Event Socket)!" ); ret = FALSE; - } else { + } + else + { gmyth_debug - ("Remote monitor event socket had been succesfully created. (io_fd == %d)\n", - g_io_channel_unix_get_fd (monitor->event_sock->sd_io_ch)); + ( "Remote monitor event socket had been succesfully created. (io_fd == %d)\n", + g_io_channel_unix_get_fd ( monitor->event_sock->sd_io_ch ) ); } - } else { + } + else + { gmyth_debug - ("ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n"); + ( "ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n" ); } return ret; @@ -334,48 +350,61 @@ * @return The backend status message code ID. */ static gint -gmyth_monitor_handler_is_backend_message (GMythMonitorHandler * monitor, - GMythStringList * strlist, gchar ** back_msg_action) +gmyth_monitor_handler_is_backend_message ( GMythMonitorHandler * monitor, + GMythStringList * strlist, + gchar ** back_msg_action ) { gint msg_type = GMYTH_BACKEND_NO_MESSAGE; GString *back_msg = NULL; - if (gmyth_string_list_length (strlist) > 0) { + if ( gmyth_string_list_length ( strlist ) > 0 ) + { - back_msg = gmyth_string_list_get_string (strlist, 0); - if (back_msg != NULL && back_msg->str != NULL && - strstr (back_msg->str, "BACKEND") != NULL) { - gmyth_debug ("MONITOR HANDLER - Received backend message = %s", - back_msg->str); - *back_msg_action = gmyth_string_list_get_char_array (strlist, 1); + back_msg = gmyth_string_list_get_string ( strlist, 0 ); + if ( back_msg != NULL && back_msg->str != NULL && + strstr ( back_msg->str, "BACKEND" ) != NULL ) + { + gmyth_debug ( "MONITOR HANDLER - Received backend message = %s", + back_msg->str ); + *back_msg_action = gmyth_string_list_get_char_array ( strlist, 1 ); - if (back_msg_action != NULL) { + if ( back_msg_action != NULL ) + { - if (g_strstr_len - (*back_msg_action, strlen (*back_msg_action), - "LIVETV_CHAIN") - || g_strstr_len (*back_msg_action, - strlen (*back_msg_action), "RECORDING_LIST_CHANGE") - || g_strstr_len (*back_msg_action, - strlen (*back_msg_action), "SCHEDULE_CHANGE") - || g_strstr_len (*back_msg_action, - strlen (*back_msg_action), "LIVETV_WATCH")) { + if ( g_strstr_len + ( *back_msg_action, strlen ( *back_msg_action ), + "LIVETV_CHAIN" ) + || g_strstr_len ( *back_msg_action, + strlen ( *back_msg_action ), + "RECORDING_LIST_CHANGE" ) + || g_strstr_len ( *back_msg_action, + strlen ( *back_msg_action ), + "SCHEDULE_CHANGE" ) + || g_strstr_len ( *back_msg_action, + strlen ( *back_msg_action ), + "LIVETV_WATCH" ) ) + { gmyth_debug - ("MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", - *back_msg_action); + ( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", + *back_msg_action ); msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED; - } else if (g_strstr_len - (*back_msg_action, strlen (*back_msg_action), - "DONE_RECORDING")) { + } + else if ( g_strstr_len + ( *back_msg_action, strlen ( *back_msg_action ), + "DONE_RECORDING" ) ) + { gmyth_debug - ("MONITOR: message type == GMYTH_BACKEND_DONE_RECORDING, msg = %s", - *back_msg_action); + ( "MONITOR: message type == GMYTH_BACKEND_DONE_RECORDING, msg = %s", + *back_msg_action ); msg_type = GMYTH_BACKEND_DONE_RECORDING; - } else if (g_strstr_len - (*back_msg_action, strlen (*back_msg_action), "QUIT")) { + } + else if ( g_strstr_len + ( *back_msg_action, strlen ( *back_msg_action ), + "QUIT" ) ) + { gmyth_debug - ("MONITOR: message type == GMYTH_BACKEND_STOP_LIVETV, msg = %s", - *back_msg_action); + ( "MONITOR: message type == GMYTH_BACKEND_STOP_LIVETV, msg = %s", + *back_msg_action ); msg_type = GMYTH_BACKEND_STOP_LIVETV; } @@ -386,14 +415,16 @@ /* if */ } /* if */ - if (back_msg != NULL) { - g_string_free (back_msg, TRUE); + if ( back_msg != NULL ) + { + g_string_free ( back_msg, TRUE ); back_msg = NULL; } - } /* if - Does Monitor got any message from backend? */ - else { - *back_msg_action = g_strdup (""); + } /* if - Does Monitor got any message from backend? */ + else + { + *back_msg_action = g_strdup ( "" ); } return msg_type; @@ -401,18 +432,18 @@ } static void -gmyth_monitor_handler_default_listener (GMythMonitorHandler * monitor, - gint msg_code, gchar * message) +gmyth_monitor_handler_default_listener ( GMythMonitorHandler * monitor, + gint msg_code, gchar * message ) { //assert( message!= NULL ); - gmyth_debug ("DEFAULT Signal handler ( msg = %s, code = %d )\n", - message, msg_code); + gmyth_debug ( "DEFAULT Signal handler ( msg = %s, code = %d )\n", + message, msg_code ); } static void -gmyth_monitor_handler_print (GString * str, gpointer ptr) +gmyth_monitor_handler_print ( GString * str, gpointer ptr ) { - gmyth_debug ("Backend message event: %s --- ", str->str); + gmyth_debug ( "Backend message event: %s --- ", str->str ); } /** @@ -425,104 +456,114 @@ * successfully read. */ gpointer -gmyth_monitor_handler_listener (gpointer data) +gmyth_monitor_handler_listener ( gpointer data ) { - GMythMonitorHandler *monitor = (GMythMonitorHandler *) data; + GMythMonitorHandler *monitor = ( GMythMonitorHandler * ) data; guint recv = 0; - gboolean *ret = g_new0 (gboolean, 1); + gboolean *ret = g_new0 ( gboolean, 1 ); gsize len = 0; GIOChannel *io_channel = monitor->event_sock->sd_io_ch; - GIOCondition io_cond = g_io_channel_get_buffer_condition (io_channel); + GIOCondition io_cond = g_io_channel_get_buffer_condition ( io_channel ); static guint count = 0; *ret = TRUE; - gmyth_debug ("Entering MONITOR handler listener..."); + gmyth_debug ( "Entering MONITOR handler listener..." ); - myth_control_acquire_context (monitor, TRUE); + myth_control_acquire_context ( monitor, TRUE ); - if ((io_cond & G_IO_HUP) != 0) { + if ( ( io_cond & G_IO_HUP ) != 0 ) + { *ret = FALSE; goto clean_up; } GMythStringList *strlist = NULL; - if (NULL == io_channel) { - gmyth_debug ("Monitor socket is NULL! (GIOChannel)"); + if ( NULL == io_channel ) + { + gmyth_debug ( "Monitor socket is NULL! (GIOChannel)" ); *ret = FALSE; goto clean_up; } - while (monitor->allow_msgs_listener) { + while ( monitor->allow_msgs_listener ) + { ++count; - gmyth_debug ("%d - Listening on Monitor socket...!\n", count); + gmyth_debug ( "%d - Listening on Monitor socket...!\n", count ); - do { + do + { gint bytes_sent = 0; - strlist = gmyth_string_list_new (); + strlist = gmyth_string_list_new ( ); - if (monitor->event_sock != NULL) { + if ( monitor->event_sock != NULL ) + { len = - gmyth_socket_read_stringlist (monitor->event_sock, strlist); + gmyth_socket_read_stringlist ( monitor->event_sock, + strlist ); - if ((len > 0) && strlist != NULL - && gmyth_string_list_length (strlist) > 0) { - bytes_sent = gmyth_string_list_get_int (strlist, 0); // -1 on backend error + if ( ( len > 0 ) && strlist != NULL + && gmyth_string_list_length ( strlist ) > 0 ) + { + bytes_sent = gmyth_string_list_get_int ( strlist, 0 ); // -1 on backend error gmyth_debug - ("[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n", - __FUNCTION__, len); + ( "[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n", + __FUNCTION__, len ); recv += len; /* debug purpose: prints out all the string list elements */ - g_list_foreach (strlist->glist, - (GFunc) gmyth_monitor_handler_print, NULL); + g_list_foreach ( strlist->glist, + ( GFunc ) gmyth_monitor_handler_print, + NULL ); - gchar *back_msg_action = g_new0 (gchar, 1); + gchar *back_msg_action = g_new0 ( gchar, 1 ); gint msg_type = - gmyth_monitor_handler_is_backend_message (monitor, - strlist, - &back_msg_action); + gmyth_monitor_handler_is_backend_message ( monitor, + strlist, + &back_msg_action ); - if (monitor != NULL && msg_type != GMYTH_BACKEND_NO_MESSAGE) - g_signal_emit (monitor, GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id, 0, /* details */ - msg_type, back_msg_action); + if ( monitor != NULL + && msg_type != GMYTH_BACKEND_NO_MESSAGE ) + g_signal_emit ( monitor, GMYTH_MONITOR_HANDLER_GET_CLASS ( monitor )->backend_events_handler_signal_id, 0, /* details */ + msg_type, back_msg_action ); - if (back_msg_action != NULL) - g_free (back_msg_action); + if ( back_msg_action != NULL ) + g_free ( back_msg_action ); } } - if (strlist != NULL) { - g_object_unref (strlist); + if ( strlist != NULL ) + { + g_object_unref ( strlist ); strlist = NULL; } - io_cond = g_io_channel_get_buffer_condition (io_channel); + io_cond = g_io_channel_get_buffer_condition ( io_channel ); - g_usleep (500); + g_usleep ( 500 ); } - while (recv <= 0 && ((io_cond & G_IO_HUP) == 0)); + while ( recv <= 0 && ( ( io_cond & G_IO_HUP ) == 0 ) ); - gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv); + gmyth_debug ( "\tMONITOR EVENT: Read %d bytes\n", recv ); } /* main GThread while */ clean_up: - myth_control_release_context (monitor); + myth_control_release_context ( monitor ); - g_thread_exit (ret); + g_thread_exit ( ret ); - return (gpointer) ret; + return ( gpointer ) ret; } @@ -535,16 +576,18 @@ * @return true, if the socket was successfully opened. */ static gboolean -gmyth_connect_to_backend_monitor (GMythMonitorHandler * monitor) +gmyth_connect_to_backend_monitor ( GMythMonitorHandler * monitor ) { gboolean ret = TRUE; - monitor->event_sock = gmyth_socket_new (); + monitor->event_sock = gmyth_socket_new ( ); /* Connects the socket, send Mythtv ANN Monitor and verify Mythtv protocol version */ - if (!gmyth_socket_connect_to_backend_events (monitor->event_sock, - monitor->hostname, monitor->port, FALSE)) { - g_object_unref (monitor->event_sock); + if ( !gmyth_socket_connect_to_backend_events ( monitor->event_sock, + monitor->hostname, + monitor->port, FALSE ) ) + { + g_object_unref ( monitor->event_sock ); monitor->event_sock = NULL; ret = FALSE; } @@ -563,27 +606,31 @@ * GMythMonitorHandler could be configured. */ static gboolean -gmyth_monitor_handler_setup (GMythMonitorHandler * monitor, - GIOChannel * channel) +gmyth_monitor_handler_setup ( GMythMonitorHandler * monitor, + GIOChannel * channel ) { gboolean ret = TRUE; - if (channel != NULL) { + if ( channel != NULL ) + { monitor->allow_msgs_listener = TRUE; monitor->th = - g_thread_create ((GThreadFunc) gmyth_monitor_handler_listener, - monitor, TRUE, NULL); - gmyth_debug ("MONITOR GThread created!"); - } else { + g_thread_create ( ( GThreadFunc ) gmyth_monitor_handler_listener, + monitor, TRUE, NULL ); + gmyth_debug ( "MONITOR GThread created!" ); + } + else + { ret = FALSE; goto cleanup; } - if (NULL == monitor->th) { + if ( NULL == monitor->th ) + { gmyth_debug - ("[%s] Error adding GThread listener function to the IO control channel!\n", - __FUNCTION__); + ( "[%s] Error adding GThread listener function to the IO control channel!\n", + __FUNCTION__ ); ret = FALSE; goto cleanup; } @@ -601,30 +648,35 @@ * @return true, if the MonitorHandler was started. */ gboolean -gmyth_monitor_handler_start (GMythMonitorHandler * monitor) +gmyth_monitor_handler_start ( GMythMonitorHandler * monitor ) { gboolean ret = TRUE; - if (!(ret = g_thread_supported ())) { - gmyth_debug ("Thread system wasn't initialized, starting NOW!!!"); - g_thread_init (NULL); + if ( !( ret = g_thread_supported ( ) ) ) + { + gmyth_debug ( "Thread system wasn't initialized, starting NOW!!!" ); + g_thread_init ( NULL ); } - ret = gmyth_monitor_handler_setup (monitor, monitor->event_sock->sd_io_ch); - if (ret) { + ret = + gmyth_monitor_handler_setup ( monitor, monitor->event_sock->sd_io_ch ); + if ( ret ) + { gmyth_debug - ("\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n", - __FUNCTION__, g_thread_self ()); - } else { + ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n", + __FUNCTION__, g_thread_self ( ) ); + } + else + { gmyth_debug - ("\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n", - __FUNCTION__, g_thread_self ()); + ( "\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n", + __FUNCTION__, g_thread_self ( ) ); ret = FALSE; } gmyth_debug - ("[%s] Watch listener function over the IO control channel? %s!!!\n", - __FUNCTION__, (ret == TRUE ? "YES" : "NO")); + ( "[%s] Watch listener function over the IO control channel? %s!!!\n", + __FUNCTION__, ( ret == TRUE ? "YES" : "NO" ) ); return ret; } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_monitor_handler.h --- a/gmyth/src/gmyth_monitor_handler.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_monitor_handler.h Wed May 23 19:50:41 2007 +0100 @@ -1,4 +1,3 @@ -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */ /** * GMyth Library * @@ -10,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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_MONITOR_HANDLER_H__ #define __GMYTH_MONITOR_HANDLER_H__ @@ -52,66 +50,66 @@ #define GMYTH_MONITOR_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass)) #define GMYTHTV_MONITOR_HANDLER_READ_ERROR -314 enum -{ - GMYTH_BACKEND_NO_MESSAGE = 0, - GMYTH_BACKEND_PROGRAM_INFO_CHANGED, - GMYTH_BACKEND_DONE_RECORDING, - GMYTH_BACKEND_STOP_LIVETV -}; + { + GMYTH_BACKEND_NO_MESSAGE = 0, + GMYTH_BACKEND_PROGRAM_INFO_CHANGED, + GMYTH_BACKEND_DONE_RECORDING, + GMYTH_BACKEND_STOP_LIVETV + }; typedef struct _GMythMonitorHandler GMythMonitorHandler; typedef struct _GMythMonitorHandlerClass GMythMonitorHandlerClass; struct _GMythMonitorHandlerClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - guint backend_events_handler_signal_id; + /* callbacks */ + guint backend_events_handler_signal_id; - /* signal default handlers */ - void (*backend_events_handler) (GMythMonitorHandler * monitor, - gint msg_code, gchar * message); -}; + /* signal default handlers */ + void ( *backend_events_handler ) ( GMythMonitorHandler * monitor, + gint msg_code, gchar * message ); + }; struct _GMythMonitorHandler -{ - GObject parent; + { + GObject parent; - /* MythTV version number */ - gint mythtv_version; + /* MythTV version number */ + gint mythtv_version; - /* socket descriptors */ - GMythSocket *event_sock; + /* socket descriptors */ + GMythSocket *event_sock; - gpointer (*gmyth_monitor_handler_listener) (gpointer data); + gpointer ( *gmyth_monitor_handler_listener ) ( gpointer data ); - gchar *hostname; - gint port; + gchar *hostname; + gint port; - gint64 actual_index; + gint64 actual_index; - gboolean allow_msgs_listener; + gboolean allow_msgs_listener; - /* stores the messages coming from the backend */ - GHashTable *backend_msgs; + /* stores the messages coming from the backend */ + GHashTable *backend_msgs; - GMutex *mutex; + GMutex *mutex; - GThread *th; + GThread *th; -}; + }; -GType gmyth_monitor_handler_get_type (void); +GType gmyth_monitor_handler_get_type ( void ); -GMythMonitorHandler *gmyth_monitor_handler_new (void); +GMythMonitorHandler *gmyth_monitor_handler_new ( void ); -gboolean gmyth_monitor_handler_open (GMythMonitorHandler * monitor, - const gchar * hostname, gint port); +gboolean gmyth_monitor_handler_open ( GMythMonitorHandler * monitor, + const gchar * hostname, gint port ); -gboolean gmyth_monitor_handler_start (GMythMonitorHandler * monitor); +gboolean gmyth_monitor_handler_start ( GMythMonitorHandler * monitor ); -void gmyth_monitor_handler_close (GMythMonitorHandler * monitor); +void gmyth_monitor_handler_close ( GMythMonitorHandler * monitor ); G_END_DECLS #endif /* __GMYTH_MONITOR_HANDLER_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_programinfo.c Wed May 23 19:50:41 2007 +0100 @@ -10,23 +10,22 @@ * @author Rosfran Borges * @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 - * - */ + * + * 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" @@ -40,30 +39,30 @@ #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_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); +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 const gchar *gmyth_program_info_non_null_value (const GString * - str); +G_DEFINE_TYPE ( GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT ) + static const gchar *gmyth_program_info_non_null_value ( const GString * + str ); - static void gmyth_program_info_class_init (GMythProgramInfoClass * klass) + static void gmyth_program_info_class_init ( GMythProgramInfoClass * klass ) { - GObjectClass *gobject_class = G_OBJECT_CLASS (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_init ( GMythProgramInfo * gmyth_program_info ) { gmyth_program_info->chancommfree = 0; - /** A flag informing if the program has video or not. */ + /** A flag informing if the program has video or not. */ gmyth_program_info->isVideo = FALSE; gmyth_program_info->lenMins = 0; @@ -97,144 +96,163 @@ gmyth_program_info->recpriority = 0; - /** The file size of the recorded program.*/ + /** The file size of the recorded program.*/ gmyth_program_info->filesize = -1; } static void -gmyth_program_info_dispose (GObject * object) +gmyth_program_info_dispose ( GObject * object ) { - GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO (object); + GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO ( object ); - if (gmyth_program_info->chanid != NULL) { - g_string_free (gmyth_program_info->chanid, TRUE); + if ( gmyth_program_info->chanid != NULL ) + { + g_string_free ( gmyth_program_info->chanid, TRUE ); gmyth_program_info->chanid = NULL; } /** The program start time. */ - g_free (gmyth_program_info->startts); + g_free ( gmyth_program_info->startts ); /** The program end time. */ - g_free (gmyth_program_info->endts); + g_free ( gmyth_program_info->endts ); /** The recording schedule start time. */ - g_free (gmyth_program_info->recstartts); + g_free ( gmyth_program_info->recstartts ); /** The recording schedule end time */ - g_free (gmyth_program_info->recendts); + g_free ( gmyth_program_info->recendts ); /** The program title. */ - if (gmyth_program_info->title != NULL) { - g_string_free (gmyth_program_info->title, TRUE); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + if ( gmyth_program_info->year != NULL ) + { + g_string_free ( gmyth_program_info->year, TRUE ); gmyth_program_info->year = NULL; } - g_free (gmyth_program_info->originalAirDate); + g_free ( gmyth_program_info->originalAirDate ); - g_free (gmyth_program_info->lastmodified); + g_free ( gmyth_program_info->lastmodified ); - g_free (gmyth_program_info->lastInUseTime); + g_free ( gmyth_program_info->lastInUseTime ); - if (gmyth_program_info->schedulerid != NULL) { - g_string_free (gmyth_program_info->schedulerid, TRUE); + 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); + 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); + 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); + 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); + 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); + G_OBJECT_CLASS ( gmyth_program_info_parent_class )->dispose ( object ); } static void -gmyth_program_info_finalize (GObject * object) +gmyth_program_info_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_program_info_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_program_info_parent_class )->finalize ( object ); } /** @@ -243,10 +261,10 @@ * @return a new instance of GMythProgramInfo. */ GMythProgramInfo * -gmyth_program_info_new (void) +gmyth_program_info_new ( void ) { GMythProgramInfo *program_info = - GMYTH_PROGRAM_INFO (g_object_new (GMYTH_PROGRAM_INFO_TYPE, NULL)); + GMYTH_PROGRAM_INFO ( g_object_new ( GMYTH_PROGRAM_INFO_TYPE, NULL ) ); return program_info; } @@ -262,66 +280,66 @@ * @return a GMythStringList with the program info fields. */ GMythStringList * -gmyth_program_info_to_string_list (GMythProgramInfo * prog, - GMythStringList * slist) +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); + 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 */ - gmyth_string_list_append_int64 (slist, 0); /* 9 */ + 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 */ + gmyth_string_list_append_int64 ( slist, 0 ); /* 9 */ // fixme //gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */ //gmyth_string_list_append_int (slist, 0); /* 10 */ - if (prog->startts) - gmyth_string_list_append_int (slist, prog->startts->tv_sec); /* 11 *///DATETIME_TO_LIST(startts) + 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); + 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) + 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, 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_char_array (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 */ + 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_char_array ( 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; } @@ -335,69 +353,70 @@ * @return a GMythProgramInfo representing the string list got from network. */ GMythProgramInfo * -gmyth_program_info_from_string_list_from_pos (GMythStringList * slist, - guint pos) +gmyth_program_info_from_string_list_from_pos ( GMythStringList * slist, + guint pos ) { - GMythProgramInfo *prog = gmyth_program_info_new (); + GMythProgramInfo *prog = gmyth_program_info_new ( ); - g_return_val_if_fail (slist != NULL && - gmyth_string_list_get_string (slist, pos) != NULL, NULL); + g_return_val_if_fail ( slist != NULL && + gmyth_string_list_get_string ( slist, pos ) != NULL, + NULL ); - prog->title = gmyth_string_list_get_string (slist, pos); - prog->subtitle = gmyth_string_list_get_string (slist, pos + 1); - prog->description = gmyth_string_list_get_string (slist, pos + 2); - prog->category = gmyth_string_list_get_string (slist, pos + 3); - prog->chanid = gmyth_string_list_get_string (slist, pos + 4); - prog->channame = gmyth_string_list_get_string (slist, pos + 5); - prog->chanstr = gmyth_string_list_get_string (slist, pos + 6); - prog->chansign = gmyth_string_list_get_string (slist, pos + 7); - prog->pathname = gmyth_string_list_get_string (slist, pos + 8); + prog->title = gmyth_string_list_get_string ( slist, pos ); + prog->subtitle = gmyth_string_list_get_string ( slist, pos + 1 ); + prog->description = gmyth_string_list_get_string ( slist, pos + 2 ); + prog->category = gmyth_string_list_get_string ( slist, pos + 3 ); + prog->chanid = gmyth_string_list_get_string ( slist, pos + 4 ); + prog->channame = gmyth_string_list_get_string ( slist, pos + 5 ); + prog->chanstr = gmyth_string_list_get_string ( slist, pos + 6 ); + prog->chansign = gmyth_string_list_get_string ( slist, pos + 7 ); + prog->pathname = gmyth_string_list_get_string ( slist, pos + 8 ); - prog->filesize = gmyth_string_list_get_int64 (slist, pos + 9); + prog->filesize = gmyth_string_list_get_int64 ( slist, pos + 9 ); - gmyth_debug ("Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", - gmyth_program_info_non_null_value (prog->title), - gmyth_program_info_non_null_value (prog->subtitle), - gmyth_program_info_non_null_value (prog->description), - gmyth_program_info_non_null_value (prog->category), - gmyth_program_info_non_null_value (prog->chanid), - gmyth_program_info_non_null_value (prog->channame), - gmyth_program_info_non_null_value (prog->chanstr), - gmyth_program_info_non_null_value (prog->chansign), - gmyth_program_info_non_null_value (prog->pathname), - gmyth_string_list_get_int (slist, pos + 11)); + gmyth_debug ( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", + gmyth_program_info_non_null_value ( prog->title ), + gmyth_program_info_non_null_value ( prog->subtitle ), + gmyth_program_info_non_null_value ( prog->description ), + gmyth_program_info_non_null_value ( prog->category ), + gmyth_program_info_non_null_value ( prog->chanid ), + gmyth_program_info_non_null_value ( prog->channame ), + gmyth_program_info_non_null_value ( prog->chanstr ), + gmyth_program_info_non_null_value ( prog->chansign ), + gmyth_program_info_non_null_value ( prog->pathname ), + gmyth_string_list_get_int ( slist, pos + 11 ) ); - prog->startts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 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, pos + 12)))->str); //DATETIME_TO_LIST(endts) - prog->duplicate = gmyth_string_list_get_int (slist, pos + 13); - prog->shareable = gmyth_string_list_get_int (slist, pos + 14); - prog->findid = gmyth_string_list_get_int (slist, pos + 15); - prog->hostname = gmyth_string_list_get_string (slist, pos + 16); - prog->sourceid = gmyth_string_list_get_int (slist, pos + 17); - prog->cardid = gmyth_string_list_get_int (slist, pos + 18); - prog->inputid = gmyth_string_list_get_int (slist, pos + 19); - prog->recpriority = gmyth_string_list_get_int (slist, pos + 20); - prog->reactivate = gmyth_string_list_get_int (slist, pos + 21); - prog->recordid = gmyth_string_list_get_int (slist, pos + 22); - gmyth_string_list_get_int (slist, pos + 23); - gmyth_string_list_get_int (slist, pos + 24); - gmyth_string_list_get_int (slist, pos + 25); - prog->recstartts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 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, pos + 27)))->str); //DATETIME_TO_LIST(recendts) - prog->repeat = gmyth_string_list_get_int (slist, pos + 28); - prog->programflags = gmyth_string_list_get_int (slist, pos + 29); - prog->recgroup = gmyth_string_list_get_string (slist, pos + 30); //prog->(recgroup != "") ? recgroup : "Default") - prog->chancommfree = gmyth_string_list_get_int (slist, pos + 31); - prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos + 32); - prog->seriesid = gmyth_string_list_get_string (slist, pos + 33); - prog->programid = gmyth_string_list_get_string (slist, pos + 34); - gmyth_string_list_get_string (slist, pos + 35); - prog->lastmodified = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 36)))->str); //DATETIME_TO_LIST(lastmodified) - gmyth_string_list_get_int (slist, pos + 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, pos + 38)))->str); //DATETIME_TO_LIST(QDateTime(originalAirDate)) - prog->hasAirDate = gmyth_string_list_get_int (slist, pos + 39); - prog->playgroup = gmyth_string_list_get_string (slist, pos + 40); //prog->(playgroup != "") ? playgroup : "Default") - prog->recpriority2 = gmyth_string_list_get_int (slist, pos + 41); + prog->startts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 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, pos + 12 ) ) )->str ); //DATETIME_TO_LIST(endts) + prog->duplicate = gmyth_string_list_get_int ( slist, pos + 13 ); + prog->shareable = gmyth_string_list_get_int ( slist, pos + 14 ); + prog->findid = gmyth_string_list_get_int ( slist, pos + 15 ); + prog->hostname = gmyth_string_list_get_string ( slist, pos + 16 ); + prog->sourceid = gmyth_string_list_get_int ( slist, pos + 17 ); + prog->cardid = gmyth_string_list_get_int ( slist, pos + 18 ); + prog->inputid = gmyth_string_list_get_int ( slist, pos + 19 ); + prog->recpriority = gmyth_string_list_get_int ( slist, pos + 20 ); + prog->reactivate = gmyth_string_list_get_int ( slist, pos + 21 ); + prog->recordid = gmyth_string_list_get_int ( slist, pos + 22 ); + gmyth_string_list_get_int ( slist, pos + 23 ); + gmyth_string_list_get_int ( slist, pos + 24 ); + gmyth_string_list_get_int ( slist, pos + 25 ); + prog->recstartts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 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, pos + 27 ) ) )->str ); //DATETIME_TO_LIST(recendts) + prog->repeat = gmyth_string_list_get_int ( slist, pos + 28 ); + prog->programflags = gmyth_string_list_get_int ( slist, pos + 29 ); + prog->recgroup = gmyth_string_list_get_string ( slist, pos + 30 ); //prog->(recgroup != "") ? recgroup : "Default") + prog->chancommfree = gmyth_string_list_get_int ( slist, pos + 31 ); + prog->chanOutputFilters = gmyth_string_list_get_string ( slist, pos + 32 ); + prog->seriesid = gmyth_string_list_get_string ( slist, pos + 33 ); + prog->programid = gmyth_string_list_get_string ( slist, pos + 34 ); + gmyth_string_list_get_string ( slist, pos + 35 ); + prog->lastmodified = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 36 ) ) )->str ); //DATETIME_TO_LIST(lastmodified) + gmyth_string_list_get_int ( slist, pos + 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, pos + 38 ) ) )->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate)) + prog->hasAirDate = gmyth_string_list_get_int ( slist, pos + 39 ); + prog->playgroup = gmyth_string_list_get_string ( slist, pos + 40 ); //prog->(playgroup != "") ? playgroup : "Default") + prog->recpriority2 = gmyth_string_list_get_int ( slist, pos + 41 ); return prog; } @@ -410,13 +429,13 @@ * @return a GMythProgramInfo representing the string list got from network. */ GMythProgramInfo * -gmyth_program_info_from_string_list (GMythStringList * slist) +gmyth_program_info_from_string_list ( GMythStringList * slist ) { GMythProgramInfo *prog = NULL; - g_return_val_if_fail (slist != NULL, NULL); + g_return_val_if_fail ( slist != NULL, NULL ); - prog = gmyth_program_info_from_string_list_from_pos (slist, 0); + prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 ); return prog; } @@ -429,11 +448,11 @@ * @return a GMythProgramInfo representing the string list got from network. */ GMythProgramInfo * -gmyth_program_info_from_string_list_next_prog (GMythStringList * slist) +gmyth_program_info_from_string_list_next_prog ( GMythStringList * slist ) { - GMythProgramInfo *prog = gmyth_program_info_new (); + GMythProgramInfo *prog = gmyth_program_info_new ( ); - g_return_val_if_fail (slist != NULL, NULL); + g_return_val_if_fail ( slist != NULL, NULL ); /* {Home Improvement[]:[]No, No, Godot[]:[] @@ -443,37 +462,37 @@ /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] } */ - 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->startts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 4)); //DATETIME_TO_LIST(startts) - prog->endts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 5)); //DATETIME_TO_LIST(endts) - prog->channame = gmyth_string_list_get_string (slist, 6); - prog->chansign = gmyth_string_list_get_string (slist, 7); - prog->chanstr = gmyth_string_list_get_string (slist, 8); - prog->chanid = gmyth_string_list_get_string (slist, 9); - prog->filesize = gmyth_string_list_get_int64 (slist, 10); + 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->startts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 4 ) ); //DATETIME_TO_LIST(startts) + prog->endts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 5 ) ); //DATETIME_TO_LIST(endts) + prog->channame = gmyth_string_list_get_string ( slist, 6 ); + prog->chansign = gmyth_string_list_get_string ( slist, 7 ); + prog->chanstr = gmyth_string_list_get_string ( slist, 8 ); + prog->chanid = gmyth_string_list_get_string ( slist, 9 ); + prog->filesize = gmyth_string_list_get_int64 ( slist, 10 ); - gmyth_debug ("NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n", - gmyth_program_info_non_null_value (prog->title), - gmyth_program_info_non_null_value (prog->subtitle), - gmyth_program_info_non_null_value (prog->description), - gmyth_program_info_non_null_value (prog->category), - gmyth_program_info_non_null_value (prog->chanid), - gmyth_program_info_non_null_value (prog->channame), - gmyth_program_info_non_null_value (prog->chanstr), - gmyth_program_info_non_null_value (prog->chansign), - gmyth_program_info_non_null_value (prog->pathname)); + gmyth_debug ( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n", + gmyth_program_info_non_null_value ( prog->title ), + gmyth_program_info_non_null_value ( prog->subtitle ), + gmyth_program_info_non_null_value ( prog->description ), + gmyth_program_info_non_null_value ( prog->category ), + gmyth_program_info_non_null_value ( prog->chanid ), + gmyth_program_info_non_null_value ( prog->channame ), + gmyth_program_info_non_null_value ( prog->chanstr ), + gmyth_program_info_non_null_value ( prog->chansign ), + gmyth_program_info_non_null_value ( prog->pathname ) ); return prog; } static const gchar * -gmyth_program_info_non_null_value (const GString * str) +gmyth_program_info_non_null_value ( const GString * str ) { - return (str != NULL && str->str != NULL - && strlen (str->str) > 0 ? str->str : " "); + return ( str != NULL && str->str != NULL + && strlen ( str->str ) > 0 ? str->str : " " ); } /** @@ -484,44 +503,45 @@ * @return a string representing the program info. */ const gchar * -gmyth_program_info_to_string (const GMythProgramInfo * prog) +gmyth_program_info_to_string ( const GMythProgramInfo * prog ) { return g_strdup_printf - ("Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, " - "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n" - "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, " - "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n" - "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, " - "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n" - "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, " - "Play Group: %s.\n", - gmyth_program_info_non_null_value (prog->title), - gmyth_program_info_non_null_value (prog->subtitle), - gmyth_program_info_non_null_value (prog->description), - gmyth_program_info_non_null_value (prog->category), - gmyth_program_info_non_null_value (prog->chanid), - gmyth_program_info_non_null_value (prog->channame), - gmyth_program_info_non_null_value (prog->chanstr), - gmyth_program_info_non_null_value (prog->chansign), - gmyth_program_info_non_null_value (prog->pathname), prog->filesize, - gmyth_util_time_to_string_from_time_val (prog->startts), - gmyth_util_time_to_string_from_time_val (prog->endts), - prog->duplicate, prog->shareable, prog->findid, - gmyth_program_info_non_null_value (prog->hostname), prog->sourceid, - prog->cardid, prog->inputid, prog->recpriority, prog->reactivate, - prog->recordid, - gmyth_util_time_to_string_from_time_val (prog->recstartts), - gmyth_util_time_to_string_from_time_val (prog->recendts), - prog->repeat, prog->programflags, - gmyth_program_info_non_null_value (prog->recgroup), - prog->chancommfree, - gmyth_program_info_non_null_value (prog->chanOutputFilters), - gmyth_program_info_non_null_value (prog->seriesid), - gmyth_program_info_non_null_value (prog->programid), - gmyth_util_time_to_string_from_time_val (prog->lastmodified), - gmyth_util_time_to_string_from_time_val (prog->originalAirDate), - prog->hasAirDate, gmyth_program_info_non_null_value (prog->playgroup)); + ( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, " + "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n" + "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, " + "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n" + "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, " + "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n" + "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, " + "Play Group: %s.\n", + gmyth_program_info_non_null_value ( prog->title ), + gmyth_program_info_non_null_value ( prog->subtitle ), + gmyth_program_info_non_null_value ( prog->description ), + gmyth_program_info_non_null_value ( prog->category ), + gmyth_program_info_non_null_value ( prog->chanid ), + gmyth_program_info_non_null_value ( prog->channame ), + gmyth_program_info_non_null_value ( prog->chanstr ), + gmyth_program_info_non_null_value ( prog->chansign ), + gmyth_program_info_non_null_value ( prog->pathname ), prog->filesize, + gmyth_util_time_to_string_from_time_val ( prog->startts ), + gmyth_util_time_to_string_from_time_val ( prog->endts ), + prog->duplicate, prog->shareable, prog->findid, + gmyth_program_info_non_null_value ( prog->hostname ), prog->sourceid, + prog->cardid, prog->inputid, prog->recpriority, prog->reactivate, + prog->recordid, + gmyth_util_time_to_string_from_time_val ( prog->recstartts ), + gmyth_util_time_to_string_from_time_val ( prog->recendts ), + prog->repeat, prog->programflags, + gmyth_program_info_non_null_value ( prog->recgroup ), + prog->chancommfree, + gmyth_program_info_non_null_value ( prog->chanOutputFilters ), + gmyth_program_info_non_null_value ( prog->seriesid ), + gmyth_program_info_non_null_value ( prog->programid ), + gmyth_util_time_to_string_from_time_val ( prog->lastmodified ), + gmyth_util_time_to_string_from_time_val ( prog->originalAirDate ), + prog->hasAirDate, + gmyth_program_info_non_null_value ( prog->playgroup ) ); } /** @@ -533,15 +553,15 @@ * @return true, if the program infos are equals. */ gboolean -gmyth_program_info_is_equals (const GMythProgramInfo * prog1, - const GMythProgramInfo * prog2) +gmyth_program_info_is_equals ( const GMythProgramInfo * prog1, + const GMythProgramInfo * prog2 ) { - if ((strcmp (gmyth_program_info_non_null_value (prog1->title), - gmyth_program_info_non_null_value (prog2->title)) == 0) - || - (strcmp - (gmyth_program_info_non_null_value (prog1->pathname), - gmyth_program_info_non_null_value (prog2->pathname)) == 0)) + if ( ( strcmp ( gmyth_program_info_non_null_value ( prog1->title ), + gmyth_program_info_non_null_value ( prog2->title ) ) == 0 ) + || + ( strcmp + ( gmyth_program_info_non_null_value ( prog1->pathname ), + gmyth_program_info_non_null_value ( prog2->pathname ) ) == 0 ) ) return TRUE; else return FALSE; diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_programinfo.h Wed May 23 19:50:41 2007 +0100 @@ -10,23 +10,22 @@ * @author Rosfran Borges * @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 - * - */ + * + * 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 @@ -47,11 +46,11 @@ typedef struct _GMythProgramInfoClass GMythProgramInfoClass; struct _GMythProgramInfoClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ -}; + /* callbacks */ + }; /** * The GMythProgramInfo structure represents a program information @@ -59,113 +58,115 @@ * a program scheduled to be recorded, or a program already recorded. */ struct _GMythProgramInfo -{ - GObject parent; + { + GObject parent; /** The channel unique ID. */ - GString *chanid; + GString *chanid; /** The program start time. */ - GTimeVal *startts; + GTimeVal *startts; /** The program end time. */ - GTimeVal *endts; + GTimeVal *endts; /** The recording schedule start time. */ - GTimeVal *recstartts; + GTimeVal *recstartts; /** The recording schedule end time */ - GTimeVal *recendts; + GTimeVal *recendts; /** The program title. */ - GString *title; + GString *title; /** The program subtitle. */ - GString *subtitle; + GString *subtitle; /** The program description. */ - GString *description; + GString *description; /** The program category. */ - GString *category; + GString *category; - GString *chanstr; - GString *chansign; + GString *chanstr; + GString *chansign; /** The associated channel name. */ - GString *channame; - gint chancommfree; - GString *chanOutputFilters; + GString *channame; + gint chancommfree; + GString *chanOutputFilters; - GString *seriesid; + GString *seriesid; /** The program unique id. */ - GString *programid; - GString *catType; + GString *programid; + GString *catType; - GString *sortTitle; + GString *sortTitle; - /** A flag informing if the program has video or not. */ - gboolean isVideo; - gint lenMins; + /** A flag informing if the program has video or not. */ + gboolean isVideo; + gint lenMins; - GString *year; - gdouble stars; - gint repeat; + GString *year; + gdouble stars; + gint repeat; - GTimeVal *originalAirDate; - GTimeVal *lastmodified; - GTimeVal *lastInUseTime; + GTimeVal *originalAirDate; + GTimeVal *lastmodified; + GTimeVal *lastInUseTime; - gboolean hasAirDate; + gboolean hasAirDate; - gint spread; - gint startCol; + gint spread; + gint startCol; - gint recpriority2; - gint reactivate; + gint recpriority2; + gint reactivate; - gint recordid; - gint parentid; + gint recordid; + gint parentid; /** The backend video source id associated to this program.*/ - gint sourceid; + gint sourceid; /** the backend input id associated to this program.*/ - gint inputid; + gint inputid; /** The backend card id associated to this program.*/ - gint cardid; - gboolean shareable; - gboolean duplicate; + gint cardid; + gboolean shareable; + gboolean duplicate; - GString *schedulerid; - gint findid; + GString *schedulerid; + gint findid; - gint programflags; - gint transcoder; + gint programflags; + gint transcoder; - GString *recgroup; - GString *playgroup; - gint recpriority; + GString *recgroup; + GString *playgroup; + gint recpriority; - /** The file size of the recorded program.*/ - gint64 filesize; + /** The file size of the recorded program.*/ + gint64 filesize; /** The file name of the recorded program.*/ - GString *pathname; - GString *hostname; -}; + GString *pathname; + GString *hostname; + }; -GType gmyth_program_info_type (void); +GType gmyth_program_info_type ( void ); -GMythProgramInfo *gmyth_program_info_new (void); +GMythProgramInfo *gmyth_program_info_new ( void ); -GMythStringList *gmyth_program_info_to_string_list (GMythProgramInfo * prog, - GMythStringList * slist); +GMythStringList *gmyth_program_info_to_string_list ( GMythProgramInfo * prog, + GMythStringList * slist ); -GMythProgramInfo *gmyth_program_info_from_string_list_from_pos (GMythStringList - * slist, guint pos); +GMythProgramInfo *gmyth_program_info_from_string_list_from_pos ( GMythStringList + * slist, + guint pos ); -GMythProgramInfo *gmyth_program_info_from_string_list (GMythStringList * slist); +GMythProgramInfo *gmyth_program_info_from_string_list ( GMythStringList * + slist ); GMythProgramInfo - * gmyth_program_info_from_string_list_next_prog (GMythStringList * slist); + * gmyth_program_info_from_string_list_next_prog ( GMythStringList * slist ); -const gchar *gmyth_program_info_to_string (const GMythProgramInfo * prog); +const gchar *gmyth_program_info_to_string ( const GMythProgramInfo * prog ); -gboolean gmyth_program_info_is_equals (const GMythProgramInfo * prog1, - const GMythProgramInfo * prog2); +gboolean gmyth_program_info_is_equals ( const GMythProgramInfo * prog1, + const GMythProgramInfo * prog2 ); G_END_DECLS #endif /*_GMYTH_PROGRAMINFO_H*/ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_query.c --- a/gmyth/src/gmyth_query.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_query.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * 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 - */ + * + * 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" @@ -37,60 +36,62 @@ #include "gmyth_query.h" #include "gmyth_debug.h" -static void gmyth_query_class_init (GMythQueryClass * klass); -static void gmyth_query_init (GMythQuery * object); +static void gmyth_query_class_init ( GMythQueryClass * klass ); +static void gmyth_query_init ( GMythQuery * object ); -static void gmyth_query_dispose (GObject * object); -static void gmyth_query_finalize (GObject * object); +static void gmyth_query_dispose ( GObject * object ); +static void gmyth_query_finalize ( GObject * object ); -static void gmyth_query_print_error (MYSQL * conn, char *message); +static void gmyth_query_print_error ( MYSQL * conn, char *message ); -G_DEFINE_TYPE (GMythQuery, gmyth_query, G_TYPE_OBJECT) - static void gmyth_query_class_init (GMythQueryClass * klass) +G_DEFINE_TYPE ( GMythQuery, gmyth_query, G_TYPE_OBJECT ) + static void gmyth_query_class_init ( GMythQueryClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_query_dispose; gobject_class->finalize = gmyth_query_finalize; } static void -gmyth_query_init (GMythQuery * gmyth_query) +gmyth_query_init ( GMythQuery * gmyth_query ) { gmyth_query->backend_info = NULL; /* initialize connection handler */ - gmyth_query->conn = mysql_init (NULL); + gmyth_query->conn = mysql_init ( NULL ); - if (!(gmyth_query->conn)) - g_warning ("[%s] MSQL structure not initialized", __FUNCTION__); + if ( !( gmyth_query->conn ) ) + g_warning ( "[%s] MSQL structure not initialized", __FUNCTION__ ); } static void -gmyth_query_dispose (GObject * object) +gmyth_query_dispose ( GObject * object ) { - GMythQuery *gmyth_query = GMYTH_QUERY (object); + GMythQuery *gmyth_query = GMYTH_QUERY ( object ); - if (gmyth_query->conn != NULL) { - gmyth_query_disconnect (gmyth_query); + if ( gmyth_query->conn != NULL ) + { + gmyth_query_disconnect ( gmyth_query ); } - if (gmyth_query->backend_info) { - g_object_unref (gmyth_query->backend_info); + if ( gmyth_query->backend_info ) + { + g_object_unref ( gmyth_query->backend_info ); gmyth_query->backend_info = NULL; } - G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_query_parent_class )->dispose ( object ); } static void -gmyth_query_finalize (GObject * object) +gmyth_query_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_query_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_query_parent_class )->finalize ( object ); } /** Creates a new instance of GMythQuery. @@ -98,30 +99,34 @@ * @return a new instance of GMythQuery. */ GMythQuery * -gmyth_query_new () +gmyth_query_new ( ) { - GMythQuery *sql_query = GMYTH_QUERY (g_object_new (GMYTH_QUERY_TYPE, NULL)); + GMythQuery *sql_query = + GMYTH_QUERY ( g_object_new ( GMYTH_QUERY_TYPE, NULL ) ); return sql_query; } gboolean -gmyth_query_connect_with_timeout (GMythQuery * gmyth_query, - GMythBackendInfo * backend_info, guint timeout) +gmyth_query_connect_with_timeout ( GMythQuery * gmyth_query, + GMythBackendInfo * backend_info, + guint timeout ) { - assert (gmyth_query); + assert ( gmyth_query ); - if (gmyth_query->conn == NULL) { - gmyth_query->conn = mysql_init (NULL); + if ( gmyth_query->conn == NULL ) + { + gmyth_query->conn = mysql_init ( NULL ); } - if (timeout != 0) { + if ( timeout != 0 ) + { /* sets connection timeout */ - mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT, - (gchar *) & timeout); + mysql_options ( gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT, + ( gchar * ) & timeout ); } - return gmyth_query_connect (gmyth_query, backend_info); + return gmyth_query_connect ( gmyth_query, backend_info ); } /** Connects to the Mysql database in the backend. The backend address @@ -131,42 +136,47 @@ * @return true if connection was success, false if failed. */ gboolean -gmyth_query_connect (GMythQuery * gmyth_query, GMythBackendInfo * backend_info) +gmyth_query_connect ( GMythQuery * gmyth_query, + GMythBackendInfo * backend_info ) { - assert (gmyth_query); - g_return_val_if_fail (backend_info != NULL, FALSE); - g_return_val_if_fail (backend_info->hostname != NULL, FALSE); - g_return_val_if_fail (backend_info->username != NULL, FALSE); - g_return_val_if_fail (backend_info->password != NULL, FALSE); - g_return_val_if_fail (backend_info->db_name != NULL, FALSE); + assert ( gmyth_query ); + g_return_val_if_fail ( backend_info != NULL, FALSE ); + g_return_val_if_fail ( backend_info->hostname != NULL, FALSE ); + g_return_val_if_fail ( backend_info->username != NULL, FALSE ); + g_return_val_if_fail ( backend_info->password != NULL, FALSE ); + g_return_val_if_fail ( backend_info->db_name != NULL, FALSE ); - if (gmyth_query->backend_info != NULL) { - g_object_unref (gmyth_query->backend_info); + if ( gmyth_query->backend_info != NULL ) + { + g_object_unref ( gmyth_query->backend_info ); } - gmyth_query->backend_info = g_object_ref (backend_info); + gmyth_query->backend_info = g_object_ref ( backend_info ); - if (gmyth_query->conn == NULL) { - gmyth_query->conn = mysql_init (NULL); + if ( gmyth_query->conn == NULL ) + { + gmyth_query->conn = mysql_init ( NULL ); } /* connect to server */ - if (mysql_real_connect (gmyth_query->conn, - gmyth_query->backend_info->hostname, - gmyth_query->backend_info->username, - gmyth_query->backend_info->password, - gmyth_query->backend_info->db_name, 0, NULL, 0) == NULL) { - gmyth_query_print_error (gmyth_query->conn, - "mysql_real_connect() failed"); + if ( mysql_real_connect ( gmyth_query->conn, + gmyth_query->backend_info->hostname, + gmyth_query->backend_info->username, + gmyth_query->backend_info->password, + gmyth_query->backend_info->db_name, 0, NULL, + 0 ) == NULL ) + { + gmyth_query_print_error ( gmyth_query->conn, + "mysql_real_connect() failed" ); return FALSE; } gmyth_debug - ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, " - "password = %s, db name = %s)", __FUNCTION__, - gmyth_query->backend_info->hostname, - gmyth_query->backend_info->username, - gmyth_query->backend_info->password, - gmyth_query->backend_info->db_name); + ( "[%s] Connection to Mysql server succeeded! (host = %s, user = %s, " + "password = %s, db name = %s)", __FUNCTION__, + gmyth_query->backend_info->hostname, + gmyth_query->backend_info->username, + gmyth_query->backend_info->password, + gmyth_query->backend_info->db_name ); return TRUE; } @@ -177,31 +187,34 @@ * @return true if disconnection was success, false if failed. */ gboolean -gmyth_query_disconnect (GMythQuery * gmyth_query) +gmyth_query_disconnect ( GMythQuery * gmyth_query ) { - g_return_val_if_fail (gmyth_query != NULL, FALSE); - g_return_val_if_fail (gmyth_query->conn != NULL, FALSE); + g_return_val_if_fail ( gmyth_query != NULL, FALSE ); + g_return_val_if_fail ( gmyth_query->conn != NULL, FALSE ); /* TODO: Check how to return error */ - gmyth_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__); + gmyth_debug ( "[%s] Closing gmyth_query->conn", __FUNCTION__ ); - mysql_close (gmyth_query->conn); + mysql_close ( gmyth_query->conn ); gmyth_query->conn = NULL; return TRUE; } static void -gmyth_query_print_error (MYSQL * conn, char *message) +gmyth_query_print_error ( MYSQL * conn, char *message ) { - gmyth_debug ("%s", message); + gmyth_debug ( "%s", message ); - if (conn != NULL) { + if ( conn != NULL ) + { #if MYSQL_VERSION_ID >= 40101 - gmyth_debug ("Error %u (%s): %s\n", - mysql_errno (conn), mysql_sqlstate (conn), mysql_error (conn)); + gmyth_debug ( "Error %u (%s): %s\n", + mysql_errno ( conn ), mysql_sqlstate ( conn ), + mysql_error ( conn ) ); #else - gmyth_debug ("Error %u: %s\n", mysql_errno (conn), mysql_error (conn)); + gmyth_debug ( "Error %u: %s\n", mysql_errno ( conn ), + mysql_error ( conn ) ); #endif } } @@ -217,46 +230,48 @@ * @return the MYSQL_RES result pointer or NULL if any error happens. */ MYSQL_RES * -gmyth_query_process_statement (GMythQuery * gmyth_query, char *stmt_str) +gmyth_query_process_statement ( GMythQuery * gmyth_query, char *stmt_str ) { - assert (gmyth_query); + assert ( gmyth_query ); - gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); + gmyth_debug ( "[%s] Running mysql query %s", __FUNCTION__, stmt_str ); - if (gmyth_query == NULL) + if ( gmyth_query == NULL ) return NULL; /* the statement failed */ - if (mysql_query (gmyth_query->conn, stmt_str) != 0) { - gmyth_query_print_error (gmyth_query->conn, - "Could not execute statement"); + if ( mysql_query ( gmyth_query->conn, stmt_str ) != 0 ) + { + gmyth_query_print_error ( gmyth_query->conn, + "Could not execute statement" ); return NULL; } /* the statement succeeded; determine whether it returned data */ - return mysql_store_result (gmyth_query->conn); + return mysql_store_result ( gmyth_query->conn ); } MYSQL_RES * -gmyth_query_process_statement_with_increment (GMythQuery * gmyth_query, - char *stmt_str, gulong * id) +gmyth_query_process_statement_with_increment ( GMythQuery * gmyth_query, + char *stmt_str, gulong * id ) { - assert (gmyth_query); + assert ( gmyth_query ); - gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str); + gmyth_debug ( "[%s] Running mysql query %s", __FUNCTION__, stmt_str ); - if (gmyth_query == NULL) + if ( gmyth_query == NULL ) return NULL; /* the statement failed */ - if (mysql_query (gmyth_query->conn, stmt_str) != 0) { - gmyth_query_print_error (gmyth_query->conn, - "Could not execute statement"); + if ( mysql_query ( gmyth_query->conn, stmt_str ) != 0 ) + { + gmyth_query_print_error ( gmyth_query->conn, + "Could not execute statement" ); return NULL; } - *id = (my_ulonglong) mysql_insert_id (gmyth_query->conn); + *id = ( my_ulonglong ) mysql_insert_id ( gmyth_query->conn ); /* the statement succeeded; determine whether it returned data */ - return mysql_store_result (gmyth_query->conn); + return mysql_store_result ( gmyth_query->conn ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_query.h --- a/gmyth/src/gmyth_query.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_query.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * 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 - */ + * + * 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_QUERY_H__ #define __GMYTH_QUERY_H__ @@ -47,37 +46,40 @@ typedef struct _GMythQueryClass GMythQueryClass; struct _GMythQueryClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythQuery -{ - GObject parent; + { + GObject parent; - GMythBackendInfo *backend_info; + GMythBackendInfo *backend_info; - /* pointer to connection handler */ - MYSQL *conn; -}; + /* pointer to connection handler */ + MYSQL *conn; + }; -GType gmyth_query_get_type (void); +GType gmyth_query_get_type ( void ); -GMythQuery *gmyth_query_new (void); -MYSQL_RES *gmyth_query_process_statement (GMythQuery * gmyth_query, - gchar * stmt_str); -MYSQL_RES *gmyth_query_process_statement_with_increment (GMythQuery * - gmyth_query, char *stmt_str, gulong * id); +GMythQuery *gmyth_query_new ( void ); +MYSQL_RES *gmyth_query_process_statement ( GMythQuery * gmyth_query, + gchar * stmt_str ); +MYSQL_RES *gmyth_query_process_statement_with_increment ( GMythQuery * + gmyth_query, + char *stmt_str, + gulong * id ); -gboolean gmyth_query_connect (GMythQuery * gmyth_query, - GMythBackendInfo * backend_info); -gboolean gmyth_query_connect_with_timeout (GMythQuery * gmyth_query, - GMythBackendInfo * backend_info, guint timeout); -gboolean gmyth_query_disconnect (GMythQuery * gmyth_query); +gboolean gmyth_query_connect ( GMythQuery * gmyth_query, + GMythBackendInfo * backend_info ); +gboolean gmyth_query_connect_with_timeout ( GMythQuery * gmyth_query, + GMythBackendInfo * backend_info, + guint timeout ); +gboolean gmyth_query_disconnect ( GMythQuery * gmyth_query ); G_END_DECLS #endif /* __GMYTH_QUERY_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_recorder.c Wed May 23 19:50:41 2007 +0100 @@ -11,22 +11,21 @@ * @author Hallyson Luiz de Morais Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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" @@ -43,74 +42,77 @@ #define GMYTHTV_RECORDER_HEADER "QUERY_RECORDER" -static void gmyth_recorder_class_init (GMythRecorderClass * klass); -static void gmyth_recorder_init (GMythRecorder * object); +static void gmyth_recorder_class_init ( GMythRecorderClass * klass ); +static void gmyth_recorder_init ( GMythRecorder * object ); -static void gmyth_recorder_dispose (GObject * object); -static void gmyth_recorder_finalize (GObject * object); +static void gmyth_recorder_dispose ( GObject * object ); +static void gmyth_recorder_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythRecorder, gmyth_recorder, G_TYPE_OBJECT) - static void gmyth_recorder_class_init (GMythRecorderClass * klass) +G_DEFINE_TYPE ( GMythRecorder, gmyth_recorder, G_TYPE_OBJECT ) + static void gmyth_recorder_class_init ( GMythRecorderClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_recorder_dispose; gobject_class->finalize = gmyth_recorder_finalize; } static void -gmyth_recorder_init (GMythRecorder * gmyth_remote_encoder) +gmyth_recorder_init ( GMythRecorder * gmyth_remote_encoder ) { } static void -gmyth_recorder_dispose (GObject * object) +gmyth_recorder_dispose ( GObject * object ) { - GMythRecorder *recorder = GMYTH_RECORDER (object); + GMythRecorder *recorder = GMYTH_RECORDER ( object ); - gmyth_recorder_close (recorder); + gmyth_recorder_close ( recorder ); - if (recorder->mutex != NULL) { - g_mutex_free (recorder->mutex); + if ( recorder->mutex != NULL ) + { + g_mutex_free ( recorder->mutex ); recorder->mutex = NULL; } - if (recorder->myth_socket != NULL) { - g_object_unref (recorder->myth_socket); + if ( recorder->myth_socket != NULL ) + { + g_object_unref ( recorder->myth_socket ); recorder->myth_socket = NULL; } - if (recorder->progs_info_list != NULL) - gmyth_free_program_list (recorder->progs_info_list); + if ( recorder->progs_info_list != NULL ) + gmyth_free_program_list ( recorder->progs_info_list ); - if (recorder->hostname != NULL) - g_string_free (recorder->hostname, TRUE); + if ( recorder->hostname != NULL ) + g_string_free ( recorder->hostname, TRUE ); - G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_recorder_parent_class )->dispose ( object ); } static void -gmyth_recorder_finalize (GObject * object) +gmyth_recorder_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_recorder_parent_class )->finalize ( object ); } void -gmyth_recorder_close (GMythRecorder * recorder) +gmyth_recorder_close ( GMythRecorder * recorder ) { - if (recorder != NULL && recorder->recorder_num != -1) { - g_mutex_lock (recorder->mutex); + if ( recorder != NULL && recorder->recorder_num != -1 ) + { + g_mutex_lock ( recorder->mutex ); - gmyth_recorder_stop_playing (recorder); - gmyth_recorder_stop_livetv (recorder); - gmyth_recorder_finish_recording (recorder); - gmyth_recorder_free_tuner (recorder); + gmyth_recorder_stop_playing ( recorder ); + gmyth_recorder_stop_livetv ( recorder ); + gmyth_recorder_finish_recording ( recorder ); + gmyth_recorder_free_tuner ( recorder ); - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); } } @@ -119,16 +121,16 @@ * @return a new instance of GMythRecorder. */ GMythRecorder * -gmyth_recorder_new (int num, GString * hostname, gshort port) +gmyth_recorder_new ( int num, GString * hostname, gshort port ) { GMythRecorder *encoder = - GMYTH_RECORDER (g_object_new (GMYTH_RECORDER_TYPE, FALSE)); + GMYTH_RECORDER ( g_object_new ( GMYTH_RECORDER_TYPE, FALSE ) ); encoder->recorder_num = num; - encoder->hostname = g_string_new (hostname->str); + encoder->hostname = g_string_new ( hostname->str ); encoder->port = port; - encoder->mutex = g_mutex_new (); + encoder->mutex = g_mutex_new ( ); encoder->progs_info_list = NULL; @@ -142,22 +144,27 @@ * @return TRUE if successfull, FALSE if any error happens. */ gboolean -gmyth_recorder_setup (GMythRecorder * recorder) +gmyth_recorder_setup ( GMythRecorder * recorder ) { - assert (recorder); - gmyth_debug ("[%s] Creating socket and connecting to backend", - __FUNCTION__); + assert ( recorder ); + gmyth_debug ( "[%s] Creating socket and connecting to backend", + __FUNCTION__ ); - if (recorder->myth_socket == NULL) { - recorder->myth_socket = gmyth_socket_new (); + if ( recorder->myth_socket == NULL ) + { + recorder->myth_socket = gmyth_socket_new ( ); - if (!gmyth_socket_connect_to_backend (recorder->myth_socket, - recorder->hostname->str, recorder->port, TRUE)) { - gmyth_debug ("GMythRemoteEncoder: Connection to backend failed"); + if ( !gmyth_socket_connect_to_backend ( recorder->myth_socket, + recorder->hostname->str, + recorder->port, TRUE ) ) + { + gmyth_debug ( "GMythRemoteEncoder: Connection to backend failed" ); return FALSE; } - } else { - gmyth_debug ("Remote encoder socket already created\n"); + } + else + { + gmyth_debug ( "Remote encoder socket already created\n" ); } return TRUE; @@ -171,52 +178,54 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_spawntv (GMythRecorder * recorder, GString * tvchain_id) +gmyth_recorder_spawntv ( GMythRecorder * recorder, GString * tvchain_id ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, - tvchain_id->str); + gmyth_debug ( "[%s] Spawntv with tvchain_id = %s", __FUNCTION__, + tvchain_id->str ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "SPAWN_LIVETV"); + gmyth_string_list_append_char_array ( str_list, "SPAWN_LIVETV" ); - gmyth_string_list_append_string (str_list, tvchain_id); - gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0) + gmyth_string_list_append_string ( str_list, tvchain_id ); + gmyth_string_list_append_int ( str_list, 0 ); // PIP = FALSE (0) - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, - tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -230,48 +239,50 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder) +gmyth_recorder_spawntv_no_tvchain ( GMythRecorder * recorder ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__); + gmyth_debug ( "[%s] Spawntv, no TV chain!", __FUNCTION__ ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "SPAWN_LIVETV"); + gmyth_string_list_append_char_array ( str_list, "SPAWN_LIVETV" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, - tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -282,37 +293,38 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_stop_livetv (GMythRecorder * recorder) +gmyth_recorder_stop_livetv ( GMythRecorder * recorder ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s]", __FUNCTION__); + gmyth_debug ( "[%s]", __FUNCTION__ ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "STOP_LIVETV"); + gmyth_string_list_append_char_array ( str_list, "STOP_LIVETV" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] Stop livetv request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -324,49 +336,51 @@ * @return TRUE if success, FALSE if any error happens. */ gboolean -gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder) +gmyth_recorder_send_frontend_ready_command ( GMythRecorder * recorder ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, - recorder->recorder_num); + gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, + recorder->recorder_num ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "FRONTEND_READY"); + gmyth_string_list_append_char_array ( str_list, "FRONTEND_READY" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { + if ( tmp_str == NULL ) + { gmyth_debug - ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", - __FUNCTION__, tmp_str->str); + ( "[%s] FRONTEND_READY command request couldn't returns, reason: %s", + __FUNCTION__, tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] FRONTEND_READY request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -379,50 +393,53 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_check_channel_name (GMythRecorder * recorder, gchar * channel) +gmyth_recorder_check_channel_name ( GMythRecorder * recorder, gchar * channel ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel); + gmyth_debug ( "[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, + channel ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "CHECK_CHANNEL"); + gmyth_string_list_append_char_array ( str_list, "CHECK_CHANNEL" ); - gmyth_string_list_append_char_array (str_list, channel); + gmyth_string_list_append_char_array ( str_list, channel ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, - tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 - || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0) { - gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) == 0 + || g_ascii_strncasecmp ( tmp_str->str, "0", 1 ) == 0 ) + { + gmyth_debug ( "[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -435,10 +452,10 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel) +gmyth_recorder_check_channel ( GMythRecorder * recorder, gint channel ) { - return gmyth_recorder_check_channel_name (recorder, g_strdup_printf ("%d", - channel)); + return gmyth_recorder_check_channel_name ( recorder, g_strdup_printf ( "%d", + channel ) ); } /** Send a SET_CHANNEL command request to the backend, to start streaming on another @@ -449,49 +466,51 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel) +gmyth_recorder_set_channel ( GMythRecorder * recorder, gint channel ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel); + gmyth_debug ( "[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "SET_CHANNEL"); + gmyth_string_list_append_char_array ( str_list, "SET_CHANNEL" ); - gmyth_string_list_append_int (str_list, channel); + gmyth_string_list_append_int ( str_list, channel ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, - tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] SET_CHANNEL request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] SET_CHANNEL request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -504,52 +523,54 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_set_channel_name (GMythRecorder * recorder, - const gchar * channel) +gmyth_recorder_set_channel_name ( GMythRecorder * recorder, + const gchar * channel ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, - channel); + gmyth_debug ( "[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, + channel ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "SET_CHANNEL"); - gmyth_string_list_append_char_array (str_list, channel); + gmyth_string_list_append_char_array ( str_list, "SET_CHANNEL" ); + gmyth_string_list_append_char_array ( str_list, channel ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!", - __FUNCTION__); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] SET_CHANNEL name request returned NULL!", + __FUNCTION__ ); ret = FALSE; goto cleanup; } - if (tmp_str != NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) - /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */ - ) { - g_warning ("[%s] SET_CHANNEL name request returned not ok", - __FUNCTION__); + if ( tmp_str != NULL && g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) + /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */ + ) + { + g_warning ( "[%s] SET_CHANNEL name request returned not ok", + __FUNCTION__ ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -570,51 +591,54 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_change_channel (GMythRecorder * recorder, - const GMythRecorderChannelChangeDirection direction) +gmyth_recorder_change_channel ( GMythRecorder * recorder, + const GMythRecorderChannelChangeDirection + direction ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", - __FUNCTION__, direction); + gmyth_debug ( "[%s] CHANGE_CHANNEL to the channel direction = %u", + __FUNCTION__, direction ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "CHANGE_CHANNEL"); - gmyth_string_list_append_int (str_list, direction); + gmyth_string_list_append_char_array ( str_list, "CHANGE_CHANNEL" ); + gmyth_string_list_append_int ( str_list, direction ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", - __FUNCTION__, tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] CHANGE_CHANNEL name request returned %s", + __FUNCTION__, tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) - || g_ascii_strtoull (tmp_str->str, NULL, 10) == 0) { - gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", - __FUNCTION__, tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) + || g_ascii_strtoull ( tmp_str->str, NULL, 10 ) == 0 ) + { + gmyth_debug ( "[%s] CHANGE_CHANNEL name request returned %s", + __FUNCTION__, tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } @@ -627,23 +651,25 @@ * @return a GList* instance with all the channel names. */ GList * -gmyth_recorder_get_channel_list (GMythRecorder * recorder) +gmyth_recorder_get_channel_list ( GMythRecorder * recorder ) { GList *channel_list = NULL; gchar *channel = NULL; guint i; - for (i = 0; i < 1000; i++) { - channel = g_strdup_printf ("%u", i); + for ( i = 0; i < 1000; i++ ) + { + channel = g_strdup_printf ( "%u", i ); - if (gmyth_recorder_check_channel_name (recorder, channel)) { - channel_list = g_list_append (channel_list, g_strdup (channel)); + if ( gmyth_recorder_check_channel_name ( recorder, channel ) ) + { + channel_list = g_list_append ( channel_list, g_strdup ( channel ) ); } } /* for - channel list */ - g_free (channel); + g_free ( channel ); return channel_list; @@ -656,65 +682,70 @@ * @return true if success, false if any error happens. */ gboolean -gmyth_recorder_pause_recording (GMythRecorder * recorder) +gmyth_recorder_pause_recording ( GMythRecorder * recorder ) { GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gboolean ret = TRUE; - gmyth_debug ("[%s] PAUSE", __FUNCTION__); + gmyth_debug ( "[%s] PAUSE", __FUNCTION__ ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); - g_string_free (tmp_str, TRUE); + gmyth_string_list_append_string ( str_list, tmp_str ); + g_string_free ( tmp_str, TRUE ); - gmyth_string_list_append_char_array (str_list, "PAUSE"); + gmyth_string_list_append_char_array ( str_list, "PAUSE" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - tmp_str = gmyth_string_list_get_string (str_list, 0); + tmp_str = gmyth_string_list_get_string ( str_list, 0 ); - if (tmp_str == NULL) { - gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, - tmp_str->str); + if ( tmp_str == NULL ) + { + gmyth_debug ( "[%s] PAUSE name request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) { - gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, - tmp_str->str); + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) ) + { + gmyth_debug ( "[%s] PAUSE name request returned %s", __FUNCTION__, + tmp_str->str ); ret = FALSE; goto cleanup; } cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return ret; } static gboolean -gmyth_recorder_find_if_program_exists (GMythRecorder * recorder, - GMythProgramInfo * prog) +gmyth_recorder_find_if_program_exists ( GMythRecorder * recorder, + GMythProgramInfo * prog ) { GList *lst = NULL; - g_return_val_if_fail (recorder != NULL - && recorder->progs_info_list != NULL, FALSE); + g_return_val_if_fail ( recorder != NULL + && recorder->progs_info_list != NULL, FALSE ); - for (lst = recorder->progs_info_list; lst != NULL; lst = g_list_next (lst)) { - gmyth_debug ("Got program info from list = [%s]", - gmyth_program_info_to_string ((GMythProgramInfo *) - lst->data)); - if (gmyth_program_info_is_equals (prog, (GMythProgramInfo *) lst->data)) + for ( lst = recorder->progs_info_list; lst != NULL; + lst = g_list_next ( lst ) ) + { + gmyth_debug ( "Got program info from list = [%s]", + gmyth_program_info_to_string ( ( GMythProgramInfo * ) + lst->data ) ); + if ( gmyth_program_info_is_equals + ( prog, ( GMythProgramInfo * ) lst->data ) ) return TRUE; } @@ -728,56 +759,60 @@ * @return The actual program info. */ GMythProgramInfo * -gmyth_recorder_get_current_program_info (GMythRecorder * recorder) +gmyth_recorder_get_current_program_info ( GMythRecorder * recorder ) { GMythStringList *str_list = NULL; GMythProgramInfo *program_info = NULL; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string ( str_list, tmp_str ); - if (recorder->myth_socket->mythtv_version >= 26) - gmyth_string_list_append_char_array (str_list, "GET_CURRENT_RECORDING"); + if ( recorder->myth_socket->mythtv_version >= 26 ) + gmyth_string_list_append_char_array ( str_list, + "GET_CURRENT_RECORDING" ); else - gmyth_string_list_append_char_array (str_list, "GET_PROGRAM_INFO"); + gmyth_string_list_append_char_array ( str_list, "GET_PROGRAM_INFO" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list == NULL) { + if ( str_list == NULL ) + { gmyth_debug - ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", - __FUNCTION__); + ( "[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!", + __FUNCTION__ ); goto cleanup; } - program_info = gmyth_program_info_from_string_list (str_list); + program_info = gmyth_program_info_from_string_list ( str_list ); - if (NULL == program_info || NULL == program_info->pathname - || program_info->pathname->len <= 0) { + if ( NULL == program_info || NULL == program_info->pathname + || program_info->pathname->len <= 0 ) + { gmyth_debug - ("GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!"); + ( "GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!" ); - if (program_info) - g_object_unref (program_info); + if ( program_info ) + g_object_unref ( program_info ); program_info = NULL; goto cleanup; } - if (!gmyth_recorder_find_if_program_exists (recorder, program_info)) - recorder->progs_info_list = g_list_append (recorder->progs_info_list, - g_object_ref (program_info)); + if ( !gmyth_recorder_find_if_program_exists ( recorder, program_info ) ) + recorder->progs_info_list = g_list_append ( recorder->progs_info_list, + g_object_ref + ( program_info ) ); cleanup: - g_mutex_unlock (recorder->mutex); - g_string_free (tmp_str, TRUE); - g_object_unref (str_list); + g_mutex_unlock ( recorder->mutex ); + g_string_free ( tmp_str, TRUE ); + g_object_unref ( str_list ); return program_info; } @@ -789,73 +824,82 @@ * @return The GMythRecorder instance. */ GMythRecorder * -gmyth_recorder_get_recorder_from_num (gint rec_id) +gmyth_recorder_get_recorder_from_num ( gint rec_id ) { GMythRecorder *recorder = NULL; GMythStringList *str_list; - GString *tmp_str = g_string_new ("GET_RECORDER_FROM_NUM"); + GString *tmp_str = g_string_new ( "GET_RECORDER_FROM_NUM" ); gint command_size = 0; gchar *recorder_host = NULL; gint recorder_port; - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */ - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - gmyth_string_list_append_string (str_list, tmp_str); + gmyth_string_list_append_string ( str_list, tmp_str ); - gmyth_string_list_append_int (str_list, rec_id); + gmyth_string_list_append_int ( str_list, rec_id ); - command_size = gmyth_socket_sendreceive_stringlist (recorder->myth_socket, - str_list); + command_size = gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, + str_list ); - if (str_list == NULL) { + if ( str_list == NULL ) + { gmyth_debug - ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", - __FUNCTION__, rec_id); + ( "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", + __FUNCTION__, rec_id ); return NULL; } - if (command_size > 0) { - recorder_host = gmyth_string_list_get_char_array (str_list, 0); - recorder_port = gmyth_string_list_get_int (str_list, 1); + if ( command_size > 0 ) + { + recorder_host = gmyth_string_list_get_char_array ( str_list, 0 ); + recorder_port = gmyth_string_list_get_int ( str_list, 1 ); - if (g_strstr_len (recorder_host, strlen (recorder_host), "nohost") - != NULL) { + if ( g_strstr_len ( recorder_host, strlen ( recorder_host ), "nohost" ) + != NULL ) + { gmyth_debug - ("No available recorder with the recorder ID number %d!", - rec_id); - } else { + ( "No available recorder with the recorder ID number %d!", + rec_id ); + } + else + { - recorder = gmyth_recorder_new (rec_id, - g_string_new (recorder_host), (gshort) recorder_port); + recorder = gmyth_recorder_new ( rec_id, + g_string_new ( recorder_host ), + ( gshort ) recorder_port ); - if (NULL == recorder) { + if ( NULL == recorder ) + { gmyth_debug - ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", - __FUNCTION__, rec_id); - g_object_unref (recorder); + ( "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!", + __FUNCTION__, rec_id ); + g_object_unref ( recorder ); return NULL; } } - } else { + } + else + { gmyth_debug - ("Cannot find a valuable recorder with the recorder ID number %d, backend server error!", - rec_id); + ( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", + rec_id ); } - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - g_object_unref (str_list); + g_object_unref ( str_list ); - g_string_free (tmp_str, TRUE); + g_string_free ( tmp_str, TRUE ); - g_free (recorder_host); + g_free ( recorder_host ); return recorder; @@ -871,66 +915,75 @@ * @return The GMythProgramInfo next program info instance. */ GMythProgramInfo * -gmyth_recorder_get_next_program_info (GMythRecorder * recorder, - const GMythRecorderBrowseDirection direction) +gmyth_recorder_get_next_program_info ( GMythRecorder * recorder, + const GMythRecorderBrowseDirection + direction ) { GMythProgramInfo *actual_proginfo = NULL; GMythProgramInfo *program_info = NULL; GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); gchar *date = NULL; struct tm *tm = NULL; time_t t; - actual_proginfo = gmyth_recorder_get_current_program_info (recorder); + actual_proginfo = gmyth_recorder_get_current_program_info ( recorder ); - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); - t = time (NULL); - tm = localtime (&t); - date = g_strdup_printf ("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900, - tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + t = time ( NULL ); + tm = localtime ( &t ); + date = g_strdup_printf ( "%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900, + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, + tm->tm_min, tm->tm_sec ); - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO"); - gmyth_string_list_append_string (str_list, actual_proginfo->channame); - gmyth_string_list_append_string (str_list, actual_proginfo->chanid); - gmyth_string_list_append_int (str_list, direction); - gmyth_string_list_append_char_array (str_list, date); + gmyth_string_list_append_string ( str_list, tmp_str ); + gmyth_string_list_append_char_array ( str_list, "GET_NEXT_PROGRAM_INFO" ); + gmyth_string_list_append_string ( str_list, actual_proginfo->channame ); + gmyth_string_list_append_string ( str_list, actual_proginfo->chanid ); + gmyth_string_list_append_int ( str_list, direction ); + gmyth_string_list_append_char_array ( str_list, date ); - if (gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list) - > 0) { + if ( gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ) + > 0 ) + { - if (str_list == NULL) { + if ( str_list == NULL ) + { gmyth_debug - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", - __FUNCTION__); + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", + __FUNCTION__ ); goto done; } - program_info = gmyth_program_info_from_string_list_next_prog (str_list); + program_info = + gmyth_program_info_from_string_list_next_prog ( str_list ); - if (NULL == program_info) { + if ( NULL == program_info ) + { gmyth_debug - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", - __FUNCTION__); - g_object_unref (program_info); + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", + __FUNCTION__ ); + g_object_unref ( program_info ); goto done; } if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) && */ - (program_info->chansign != NULL - && strlen (program_info->chansign->str) > 0)) { - gmyth_debug ("OK!!! Got the next program info... [%s].", - program_info->chansign->str); - } else { + ( program_info->chansign != NULL + && strlen ( program_info->chansign->str ) > 0 ) ) + { + gmyth_debug ( "OK!!! Got the next program info... [%s].", + program_info->chansign->str ); + } + else + { gmyth_debug - ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!"); - g_object_unref (program_info); + ( "GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" ); + g_object_unref ( program_info ); program_info = NULL; } @@ -938,19 +991,19 @@ /* if */ done: - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - if (actual_proginfo != NULL) - g_object_unref (actual_proginfo); + if ( actual_proginfo != NULL ) + g_object_unref ( actual_proginfo ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - if (tmp_str != NULL) - g_string_free (tmp_str, TRUE); + if ( tmp_str != NULL ) + g_string_free ( tmp_str, TRUE ); - if (date != NULL) - g_free (date); + if ( date != NULL ) + g_free ( date ); //if ( tm != NULL) // g_free (tm); @@ -965,13 +1018,13 @@ * @return The GMythProgramInfo next program info instance. */ GMythProgramInfo * -gmyth_recorder_get_program_info_from_channel_name (GMythRecorder * recorder, - const gchar * channel) +gmyth_recorder_get_program_info_from_channel_name ( GMythRecorder * recorder, + const gchar * channel ) { //GMythProgramInfo* actual_proginfo= NULL; GMythProgramInfo *program_info = NULL; GMythStringList *str_list; - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER ); /* gchar *date = NULL; @@ -981,11 +1034,11 @@ actual_proginfo = gmyth_recorder_get_current_program_info(recorder); */ - str_list = gmyth_string_list_new (); + str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (tmp_str, " %d", recorder->recorder_num); + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); /* t = time(NULL); @@ -994,63 +1047,70 @@ tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); */ - gmyth_string_list_append_string (str_list, tmp_str); - gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO"); - gmyth_string_list_append_char_array (str_list, channel); - gmyth_string_list_append_char_array (str_list, "0"); - gmyth_string_list_append_int (str_list, BROWSE_DIRECTION_UP); - gmyth_string_list_append_char_array (str_list, "0"); + gmyth_string_list_append_string ( str_list, tmp_str ); + gmyth_string_list_append_char_array ( str_list, "GET_NEXT_PROGRAM_INFO" ); + gmyth_string_list_append_char_array ( str_list, channel ); + gmyth_string_list_append_char_array ( str_list, "0" ); + gmyth_string_list_append_int ( str_list, BROWSE_DIRECTION_UP ); + gmyth_string_list_append_char_array ( str_list, "0" ); - do { + do + { - if (str_list != NULL && - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, - str_list) > 0) { + if ( str_list != NULL && + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, + str_list ) > 0 ) + { - if (str_list == NULL) { + if ( str_list == NULL ) + { gmyth_debug - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", - __FUNCTION__); + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!", + __FUNCTION__ ); goto done; } program_info = - gmyth_program_info_from_string_list_next_prog (str_list); + gmyth_program_info_from_string_list_next_prog ( str_list ); - if (NULL == program_info) { + if ( NULL == program_info ) + { gmyth_debug - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", - __FUNCTION__); - g_object_unref (program_info); + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!", + __FUNCTION__ ); + g_object_unref ( program_info ); goto done; } if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) && */ - (program_info->chansign != NULL - && strlen (program_info->chansign->str) > 0)) { - gmyth_debug ("OK!!! Got the next program info... [%s].", - program_info->chansign->str); - } else { + ( program_info->chansign != NULL + && strlen ( program_info->chansign->str ) > 0 ) ) + { + gmyth_debug ( "OK!!! Got the next program info... [%s].", + program_info->chansign->str ); + } + else + { gmyth_debug - ("GET_NEXT_PROGRAM_INFO request returned. Error getting " - "next program info, it is equals to NULL!!!"); - g_object_unref (program_info); + ( "GET_NEXT_PROGRAM_INFO request returned. Error getting " + "next program info, it is equals to NULL!!!" ); + g_object_unref ( program_info ); program_info = NULL; } } /* if */ } - while (str_list != NULL); + while ( str_list != NULL ); done: - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - if (tmp_str != NULL) - g_string_free (tmp_str, TRUE); + if ( tmp_str != NULL ) + g_string_free ( tmp_str, TRUE ); return program_info; } @@ -1063,40 +1123,41 @@ * @return The position, in bytes, of the offset to the read header. */ gint64 -gmyth_recorder_get_file_position (GMythRecorder * recorder) +gmyth_recorder_get_file_position ( GMythRecorder * recorder ) { gint64 pos = 0; - GString *query = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *query = g_string_new ( GMYTHTV_RECORDER_HEADER ); - GMythStringList *str_list = gmyth_string_list_new (); + GMythStringList *str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (query, " %d", recorder->recorder_num); + g_string_append_printf ( query, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, query); - gmyth_string_list_append_char_array (str_list, "GET_FILE_POSITION"); + gmyth_string_list_append_string ( str_list, query ); + gmyth_string_list_append_char_array ( str_list, "GET_FILE_POSITION" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL - && strstr (str->str, "bad") == NULL) - pos = gmyth_string_list_get_int64 (str_list, 0); - g_string_free (str, TRUE); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL + && strstr ( str->str, "bad" ) == NULL ) + pos = gmyth_string_list_get_int64 ( str_list, 0 ); + g_string_free ( str, TRUE ); } #ifndef GMYTHTV_ENABLE_DEBUG - gmyth_debug ("[%s] Got file position = %lld\n", __FUNCTION__, pos); + gmyth_debug ( "[%s] Got file position = %lld\n", __FUNCTION__, pos ); #endif - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (query, TRUE); + g_string_free ( query, TRUE ); return pos; } @@ -1109,49 +1170,51 @@ * @return true, if the actual remote file is bein recorded. */ gboolean -gmyth_recorder_is_recording (GMythRecorder * recorder) +gmyth_recorder_is_recording ( GMythRecorder * recorder ) { gboolean ret = TRUE; - g_return_val_if_fail (recorder != NULL, FALSE); + g_return_val_if_fail ( recorder != NULL, FALSE ); - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + GMythStringList *str_list = gmyth_string_list_new ( ); + GString *message = g_string_new ( "" ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER, - recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_char_array (str_list, "IS_RECORDING"); + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER, + recorder->recorder_num ); + gmyth_string_list_append_string ( str_list, message ); + gmyth_string_list_append_char_array ( str_list, "IS_RECORDING" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL - && strcmp (str->str, "bad") != 0) { - gint is_rec = gmyth_string_list_get_int (str_list, 0); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL + && strcmp ( str->str, "bad" ) != 0 ) + { + gint is_rec = gmyth_string_list_get_int ( str_list, 0 ); - if (is_rec != 0) + if ( is_rec != 0 ) ret = TRUE; else ret = FALSE; } - g_string_free (str, TRUE); + g_string_free ( str, TRUE ); } - gmyth_debug ("%s, stream is %s being recorded!\n", ret ? "YES" : "NO", - ret ? "" : "NOT"); + gmyth_debug ( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", + ret ? "" : "NOT" ); //g_static_mutex_unlock (&mutex); - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (message, TRUE); + g_string_free ( message, TRUE ); return ret; @@ -1165,45 +1228,47 @@ * @return true, if the recording had been actually closed. */ gboolean -gmyth_recorder_finish_recording (GMythRecorder * recorder) +gmyth_recorder_finish_recording ( GMythRecorder * recorder ) { gboolean ret = TRUE; - g_return_val_if_fail (recorder != NULL, FALSE); + g_return_val_if_fail ( recorder != NULL, FALSE ); - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + GMythStringList *str_list = gmyth_string_list_new ( ); + GString *message = g_string_new ( "" ); - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER, - recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_char_array (str_list, "FINISH_RECORDING"); + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER, + recorder->recorder_num ); + gmyth_string_list_append_string ( str_list, message ); + gmyth_string_list_append_char_array ( str_list, "FINISH_RECORDING" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL && - strcmp (str->str, "ok") != 0) { - gint is_rec = gmyth_string_list_get_int (str_list, 0); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL && + strcmp ( str->str, "ok" ) != 0 ) + { + gint is_rec = gmyth_string_list_get_int ( str_list, 0 ); - if (is_rec != 0) + if ( is_rec != 0 ) ret = TRUE; else ret = FALSE; } - g_string_free (str, TRUE); + g_string_free ( str, TRUE ); } - gmyth_debug ("%s, stream is %s finished!\n", ret ? "YES" : "NO", - ret ? "" : "NOT"); + gmyth_debug ( "%s, stream is %s finished!\n", ret ? "YES" : "NO", + ret ? "" : "NOT" ); //g_static_mutex_unlock (&mutex); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (message, TRUE); + g_string_free ( message, TRUE ); return ret; } @@ -1217,44 +1282,46 @@ * @return true, if the recording had been actually stopped. */ gboolean -gmyth_recorder_stop_playing (GMythRecorder * recorder) +gmyth_recorder_stop_playing ( GMythRecorder * recorder ) { gboolean ret = TRUE; - g_return_val_if_fail (recorder != NULL, FALSE); + g_return_val_if_fail ( recorder != NULL, FALSE ); - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + GMythStringList *str_list = gmyth_string_list_new ( ); + GString *message = g_string_new ( "" ); - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER, - recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_char_array (str_list, "STOP_PLAYING"); + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER, + recorder->recorder_num ); + gmyth_string_list_append_string ( str_list, message ); + gmyth_string_list_append_char_array ( str_list, "STOP_PLAYING" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL && - strcmp (str->str, "ok") != 0) { - gint is_rec = gmyth_string_list_get_int (str_list, 0); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL && + strcmp ( str->str, "ok" ) != 0 ) + { + gint is_rec = gmyth_string_list_get_int ( str_list, 0 ); - if (is_rec != 0) + if ( is_rec != 0 ) ret = TRUE; else ret = FALSE; } - g_string_free (str, TRUE); + g_string_free ( str, TRUE ); } - gmyth_debug ("%s, stream is %s stopped!\n", ret ? "YES" : "NO", - ret ? "" : "NOT"); + gmyth_debug ( "%s, stream is %s stopped!\n", ret ? "YES" : "NO", + ret ? "" : "NOT" ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (message, TRUE); + g_string_free ( message, TRUE ); return ret; } @@ -1267,42 +1334,44 @@ * @return true, if the tuner had been freed. */ gboolean -gmyth_recorder_free_tuner (GMythRecorder * recorder) +gmyth_recorder_free_tuner ( GMythRecorder * recorder ) { gboolean ret = TRUE; - g_return_val_if_fail (recorder != NULL, FALSE); + g_return_val_if_fail ( recorder != NULL, FALSE ); - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); + GMythStringList *str_list = gmyth_string_list_new ( ); + GString *message = g_string_new ( "" ); - g_string_printf (message, "%s %d", "FREE_TUNER", recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); + g_string_printf ( message, "%s %d", "FREE_TUNER", recorder->recorder_num ); + gmyth_string_list_append_string ( str_list, message ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL && - g_ascii_strncasecmp (str->str, "ok", 2) != 0) { - gint is_rec = gmyth_string_list_get_int (str_list, 0); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL && + g_ascii_strncasecmp ( str->str, "ok", 2 ) != 0 ) + { + gint is_rec = gmyth_string_list_get_int ( str_list, 0 ); - if (is_rec != 0) + if ( is_rec != 0 ) ret = TRUE; else ret = FALSE; } - g_string_free (str, TRUE); + g_string_free ( str, TRUE ); } - gmyth_debug ("%s, tuner is %s freed!\n", ret ? "YES" : "NO", - ret ? "" : "NOT"); + gmyth_debug ( "%s, tuner is %s freed!\n", ret ? "YES" : "NO", + ret ? "" : "NOT" ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (message, TRUE); + g_string_free ( message, TRUE ); return ret; } @@ -1316,41 +1385,42 @@ * @return The framerate (double value) of the current video. */ gdouble -gmyth_recorder_get_framerate (GMythRecorder * recorder) +gmyth_recorder_get_framerate ( GMythRecorder * recorder ) { gdouble fr = 0.0f; - GString *query = g_string_new (GMYTHTV_RECORDER_HEADER); + GString *query = g_string_new ( GMYTHTV_RECORDER_HEADER ); - GMythStringList *str_list = gmyth_string_list_new (); + GMythStringList *str_list = gmyth_string_list_new ( ); - g_mutex_lock (recorder->mutex); + g_mutex_lock ( recorder->mutex ); - g_string_append_printf (query, " %d", recorder->recorder_num); + g_string_append_printf ( query, " %d", recorder->recorder_num ); - gmyth_string_list_append_string (str_list, query); - gmyth_string_list_append_char_array (str_list, "GET_FRAMERATE"); + gmyth_string_list_append_string ( str_list, query ); + gmyth_string_list_append_char_array ( str_list, "GET_FRAMERATE" ); - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list); + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) { + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 ) + { GString *str = NULL; - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL - && strstr (str->str, "bad") == NULL) - fr = g_ascii_strtod (str->str, NULL); + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL + && strstr ( str->str, "bad" ) == NULL ) + fr = g_ascii_strtod ( str->str, NULL ); - g_string_free (str, TRUE); + g_string_free ( str, TRUE ); } #ifndef GMYTHTV_ENABLE_DEBUG - gmyth_debug ("[%s] Got file position = %f\n", __FUNCTION__, fr); + gmyth_debug ( "[%s] Got file position = %f\n", __FUNCTION__, fr ); #endif - g_mutex_unlock (recorder->mutex); + g_mutex_unlock ( recorder->mutex ); - if (str_list != NULL) - g_object_unref (str_list); + if ( str_list != NULL ) + g_object_unref ( str_list ); - g_string_free (query, TRUE); + g_string_free ( query, TRUE ); return fr; diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_recorder.h Wed May 23 19:50:41 2007 +0100 @@ -11,22 +11,21 @@ * @author Hallyson Luiz de Morais Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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_RECORDER_H__ #define __GMYTH_RECORDER_H__ @@ -54,99 +53,106 @@ typedef struct _GMythRecorderClass GMythRecorderClass; struct _GMythRecorderClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythRecorder -{ - GObject parent; + { + GObject parent; - /* socket descriptor */ - GMythSocket *myth_socket; + /* socket descriptor */ + GMythSocket *myth_socket; - gint recorder_num; - GString *hostname; - gint port; + gint recorder_num; + GString *hostname; + gint port; - GList *progs_info_list; + GList *progs_info_list; - GMutex *mutex; -}; + GMutex *mutex; + }; typedef enum _GMythRecorderChannelChangeDirection -{ - CHANNEL_DIRECTION_UP = 0, - CHANNEL_DIRECTION_DOWN, - CHANNEL_DIRECTION_FAVORITE, - CHANNEL_DIRECTION_SAME -} GMythRecorderChannelChangeDirection; + { + CHANNEL_DIRECTION_UP = 0, + CHANNEL_DIRECTION_DOWN, + CHANNEL_DIRECTION_FAVORITE, + CHANNEL_DIRECTION_SAME + } GMythRecorderChannelChangeDirection; typedef enum _GMythRecorderBrowseDirection -{ - BROWSE_DIRECTION_SAME = 0, /* Stay in the same place */ - BROWSE_DIRECTION_UP, /* Move up one slot (down one channel) */ - BROWSE_DIRECTION_DOWN, /* Move down one slot (up one channel) */ - BROWSE_DIRECTION_LEFT, /* Move left one slot (down one time slot) */ - BROWSE_DIRECTION_RIGHT, /* Move right one slot (up one time slot) */ - BROWSE_DIRECTION_FAVORITE /* Move to the next favorite slot */ -} GMythRecorderBrowseDirection; + { + BROWSE_DIRECTION_SAME = 0, /* Stay in the same place */ + BROWSE_DIRECTION_UP, /* Move up one slot (down one channel) */ + BROWSE_DIRECTION_DOWN, /* Move down one slot (up one channel) */ + BROWSE_DIRECTION_LEFT, /* Move left one slot (down one time slot) */ + BROWSE_DIRECTION_RIGHT, /* Move right one slot (up one time slot) */ + BROWSE_DIRECTION_FAVORITE /* Move to the next favorite slot */ + } GMythRecorderBrowseDirection; -GType gmyth_recorder_get_type (void); +GType gmyth_recorder_get_type ( void ); -GMythRecorder *gmyth_recorder_new (int num, GString * hostname, gshort port); +GMythRecorder *gmyth_recorder_new ( int num, GString * hostname, gshort port ); -void gmyth_recorder_close (GMythRecorder * recorder); +void gmyth_recorder_close ( GMythRecorder * recorder ); -gboolean gmyth_recorder_setup (GMythRecorder * recorder); -gboolean gmyth_recorder_spawntv (GMythRecorder * recorder, - GString * tvchain_id); +gboolean gmyth_recorder_setup ( GMythRecorder * recorder ); +gboolean gmyth_recorder_spawntv ( GMythRecorder * recorder, + GString * tvchain_id ); -gboolean gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder); +gboolean gmyth_recorder_spawntv_no_tvchain ( GMythRecorder * recorder ); -gboolean gmyth_recorder_stop_livetv (GMythRecorder * recorder); +gboolean gmyth_recorder_stop_livetv ( GMythRecorder * recorder ); -gboolean gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder); +gboolean gmyth_recorder_send_frontend_ready_command ( GMythRecorder * + recorder ); -gboolean gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel); +gboolean gmyth_recorder_check_channel ( GMythRecorder * recorder, + gint channel ); -gboolean gmyth_recorder_check_channel_name (GMythRecorder * recorder, - gchar * channel); +gboolean gmyth_recorder_check_channel_name ( GMythRecorder * recorder, + gchar * channel ); -gboolean gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel); +gboolean gmyth_recorder_set_channel ( GMythRecorder * recorder, gint channel ); -gboolean gmyth_recorder_set_channel_name (GMythRecorder * recorder, - const gchar * channel); +gboolean gmyth_recorder_set_channel_name ( GMythRecorder * recorder, + const gchar * channel ); -gboolean gmyth_recorder_change_channel (GMythRecorder * recorder, - const GMythRecorderChannelChangeDirection direction); +gboolean gmyth_recorder_change_channel ( GMythRecorder * recorder, + const + GMythRecorderChannelChangeDirection + direction ); -GList *gmyth_recorder_get_channel_list (GMythRecorder * recorder); +GList *gmyth_recorder_get_channel_list ( GMythRecorder * recorder ); -gboolean gmyth_recorder_pause_recording (GMythRecorder * recorder); +gboolean gmyth_recorder_pause_recording ( GMythRecorder * recorder ); -GMythProgramInfo *gmyth_recorder_get_current_program_info (GMythRecorder * - recorder); +GMythProgramInfo *gmyth_recorder_get_current_program_info ( GMythRecorder * + recorder ); -GMythProgramInfo *gmyth_recorder_get_next_program_info (GMythRecorder * - recorder, const GMythRecorderBrowseDirection direction); +GMythProgramInfo *gmyth_recorder_get_next_program_info ( GMythRecorder * + recorder, + const + GMythRecorderBrowseDirection + direction ); -GMythRecorder *gmyth_recorder_get_recorder_from_num (gint rec_id); +GMythRecorder *gmyth_recorder_get_recorder_from_num ( gint rec_id ); -gint64 gmyth_recorder_get_file_position (GMythRecorder * recorder); +gint64 gmyth_recorder_get_file_position ( GMythRecorder * recorder ); -gboolean gmyth_recorder_is_recording (GMythRecorder * recorder); +gboolean gmyth_recorder_is_recording ( GMythRecorder * recorder ); -gboolean gmyth_recorder_finish_recording (GMythRecorder * recorder); +gboolean gmyth_recorder_finish_recording ( GMythRecorder * recorder ); -gboolean gmyth_recorder_stop_playing (GMythRecorder * recorder); +gboolean gmyth_recorder_stop_playing ( GMythRecorder * recorder ); -gboolean gmyth_recorder_free_tuner (GMythRecorder * recorder); +gboolean gmyth_recorder_free_tuner ( GMythRecorder * recorder ); -gdouble gmyth_recorder_get_framerate (GMythRecorder * recorder); +gdouble gmyth_recorder_get_framerate ( GMythRecorder * recorder ); G_END_DECLS #endif /* __GMYTH_REMOTE_ENCODER_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_recprofile.c --- a/gmyth/src/gmyth_recprofile.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_recprofile.c Wed May 23 19:50:41 2007 +0100 @@ -8,9 +8,6 @@ * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza * - */ -/* - * * 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 @@ -40,54 +37,54 @@ #include "gmyth_debug.h" #include "gmyth_http.h" -static void gmyth_recprofile_class_init (GMythRecProfileClass * klass); -static void gmyth_recprofile_init (GMythRecProfile * object); +static void gmyth_recprofile_class_init ( GMythRecProfileClass * klass ); +static void gmyth_recprofile_init ( GMythRecProfile * object ); -static void gmyth_recprofile_dispose (GObject * object); -static void gmyth_recprofile_finalize (GObject * object); +static void gmyth_recprofile_dispose ( GObject * object ); +static void gmyth_recprofile_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT) - static void gmyth_recprofile_class_init (GMythRecProfileClass * klass) +G_DEFINE_TYPE ( GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT ) + static void gmyth_recprofile_class_init ( GMythRecProfileClass * klass ) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass ); gobject_class->dispose = gmyth_recprofile_dispose; gobject_class->finalize = gmyth_recprofile_finalize; } static void -gmyth_recprofile_init (GMythRecProfile * recprofile) +gmyth_recprofile_init ( GMythRecProfile * recprofile ) { } static void -gmyth_recprofile_dispose (GObject * object) +gmyth_recprofile_dispose ( GObject * object ) { - GMythRecProfile *recprofile = GMYTH_RECPROFILE (object); + GMythRecProfile *recprofile = GMYTH_RECPROFILE ( object ); - if (recprofile->name) - g_free (recprofile->name); + if ( recprofile->name ) + g_free ( recprofile->name ); - if (recprofile->group) - g_free (recprofile->group); + if ( recprofile->group ) + g_free ( recprofile->group ); - if (recprofile->vcodec) - g_free (recprofile->vcodec); + if ( recprofile->vcodec ) + g_free ( recprofile->vcodec ); - if (recprofile->acodec) - g_free (recprofile->acodec); + if ( recprofile->acodec ) + g_free ( recprofile->acodec ); - if (recprofile->options) - g_free (recprofile->options); + if ( recprofile->options ) + g_free ( recprofile->options ); - G_OBJECT_CLASS (gmyth_recprofile_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_recprofile_parent_class )->dispose ( object ); } static void -gmyth_recprofile_finalize (GObject * object) +gmyth_recprofile_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_recprofile_parent_class)->finalize (object); + g_signal_handlers_destroy ( object ); + G_OBJECT_CLASS ( gmyth_recprofile_parent_class )->finalize ( object ); } /** @@ -96,10 +93,10 @@ * @return a new instance of GMythRecProfile. **/ GMythRecProfile * -gmyth_recprofile_new (void) +gmyth_recprofile_new ( void ) { GMythRecProfile *recprofile = GMYTH_RECPROFILE - (g_object_new (GMYTH_RECPROFILE_TYPE, NULL)); + ( g_object_new ( GMYTH_RECPROFILE_TYPE, NULL ) ); recprofile->id = 0; recprofile->name = NULL; @@ -121,9 +118,9 @@ * **/ GSList * -gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info) +gmyth_recprofile_get_profile_list ( GMythBackendInfo * backend_info ) { - return gmyth_http_retrieve_rec_profiles (backend_info, "Transcoders"); + return gmyth_http_retrieve_rec_profiles ( backend_info, "Transcoders" ); } /** @@ -136,10 +133,10 @@ * **/ gint -gmyth_recprofile_create_profile (GMythBackendInfo * backend_info, - GMythRecProfile * profile) +gmyth_recprofile_create_profile ( GMythBackendInfo * backend_info, + GMythRecProfile * profile ) { - return gmyth_http_create_rec_profile (backend_info, profile); + return gmyth_http_create_rec_profile ( backend_info, profile ); } /** @@ -152,9 +149,9 @@ * **/ gint -gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info, gint id) +gmyth_recprofile_del_profile_list ( GMythBackendInfo * backend_info, gint id ) { - return gmyth_http_del_rec_profile (backend_info, id); + return gmyth_http_del_rec_profile ( backend_info, id ); } /** @@ -167,7 +164,7 @@ * **/ gint -gmyth_recprofile_set_id (GMythRecProfile * rec, gint id) +gmyth_recprofile_set_id ( GMythRecProfile * rec, gint id ) { rec->id = id; return 0; @@ -184,22 +181,24 @@ * **/ gint -gmyth_recprofile_set (GMythRecProfile * rec, gchar * member, gchar * value) +gmyth_recprofile_set ( GMythRecProfile * rec, gchar * member, gchar * value ) { int ret = 0; - if (value != NULL) { - if (g_ascii_strcasecmp (member, "name") == 0) - rec->name = g_strndup (value, strlen (value)); - else if (g_ascii_strcasecmp (member, "group") == 0) - rec->group = g_strndup (value, strlen (value)); - else if (g_ascii_strcasecmp (member, "vcodec") == 0) - rec->vcodec = g_strndup (value, strlen (value)); - else if (g_ascii_strcasecmp (member, "acodec") == 0) - rec->acodec = g_strndup (value, strlen (value)); + if ( value != NULL ) + { + if ( g_ascii_strcasecmp ( member, "name" ) == 0 ) + rec->name = g_strndup ( value, strlen ( value ) ); + else if ( g_ascii_strcasecmp ( member, "group" ) == 0 ) + rec->group = g_strndup ( value, strlen ( value ) ); + else if ( g_ascii_strcasecmp ( member, "vcodec" ) == 0 ) + rec->vcodec = g_strndup ( value, strlen ( value ) ); + else if ( g_ascii_strcasecmp ( member, "acodec" ) == 0 ) + rec->acodec = g_strndup ( value, strlen ( value ) ); else ret = -1; - } else + } + else ret = -1; return ret; @@ -215,9 +214,9 @@ * **/ gint -gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name) +gmyth_recprofile_set_name ( GMythRecProfile * rec, gchar * name ) { - return gmyth_recprofile_set (rec, "name", name); + return gmyth_recprofile_set ( rec, "name", name ); } /** @@ -230,9 +229,9 @@ * **/ gint -gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group) +gmyth_recprofile_set_group ( GMythRecProfile * rec, gchar * group ) { - return gmyth_recprofile_set (rec, "group", group); + return gmyth_recprofile_set ( rec, "group", group ); } /** @@ -245,9 +244,9 @@ * **/ gint -gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec) +gmyth_recprofile_set_vcodec ( GMythRecProfile * rec, gchar * vcodec ) { - return gmyth_recprofile_set (rec, "vcodec", vcodec); + return gmyth_recprofile_set ( rec, "vcodec", vcodec ); } /** @@ -260,7 +259,7 @@ * **/ gint -gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec) +gmyth_recprofile_set_acodec ( GMythRecProfile * rec, gchar * acodec ) { - return gmyth_recprofile_set (rec, "acodec", acodec); + return gmyth_recprofile_set ( rec, "acodec", acodec ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_recprofile.h --- a/gmyth/src/gmyth_recprofile.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_recprofile.h Wed May 23 19:50:41 2007 +0100 @@ -8,8 +8,6 @@ * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza * - */ -/* * * 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 @@ -48,73 +46,73 @@ typedef struct _GMythRecProfileClass GMythRecProfileClass; struct _GMythRecProfileClass -{ - GObjectClass parent_class; - gint teste; - /* callbacks */ -}; + { + GObjectClass parent_class; + gint teste; + /* callbacks */ + }; struct _GMythRecProfile -{ - gint id; - gchar *name; - gchar *group; - gchar *vcodec; - gchar *acodec; - Options *options; -}; + { + gint id; + gchar *name; + gchar *group; + gchar *vcodec; + gchar *acodec; + Options *options; + }; struct _Options -{ - gint transcodelossless; - gint transcoderesize; - gint width; - gint height; - gint rtjpegquality; - gint rtjpeglumafilter; - gint rtjpegchromafilter; - gint mpeg4bitrate; - gint mpeg4maxquality; - gint mpeg4minquality; - gint mpeg4qualdiff; - gint mpeg4scalebitrate; - gint mpeg4optionvhq; - gint mpeg4option4mv; - gint mpeg4optionidct; - gint mpeg4optionime; - gint hardwaremjpegquality; - gint hardwaremjpeghdecimation; - gint hardwaremjpegvdecimation; - gchar *mpeg2streamtype; - gchar *mpeg2aspectratio; - gint mpeg2bitrate; - gint mpeg2maxbitrate; - gint samplerate; - gint mp3quality; - gint volume; - gchar *mpeg2audtype; - gint mpeg2audbitratel1; - gint mpeg2audbitratel2; - gint mpeg2audvolume; -}; + { + gint transcodelossless; + gint transcoderesize; + gint width; + gint height; + gint rtjpegquality; + gint rtjpeglumafilter; + gint rtjpegchromafilter; + gint mpeg4bitrate; + gint mpeg4maxquality; + gint mpeg4minquality; + gint mpeg4qualdiff; + gint mpeg4scalebitrate; + gint mpeg4optionvhq; + gint mpeg4option4mv; + gint mpeg4optionidct; + gint mpeg4optionime; + gint hardwaremjpegquality; + gint hardwaremjpeghdecimation; + gint hardwaremjpegvdecimation; + gchar *mpeg2streamtype; + gchar *mpeg2aspectratio; + gint mpeg2bitrate; + gint mpeg2maxbitrate; + gint samplerate; + gint mp3quality; + gint volume; + gchar *mpeg2audtype; + gint mpeg2audbitratel1; + gint mpeg2audbitratel2; + gint mpeg2audvolume; + }; -GType gmyth_recprofile_type (void); +GType gmyth_recprofile_type ( void ); -GMythRecProfile *gmyth_recprofile_new (void); +GMythRecProfile *gmyth_recprofile_new ( void ); -GSList *gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info); +GSList *gmyth_recprofile_get_profile_list ( GMythBackendInfo * backend_info ); -gint gmyth_recprofile_create_profile (GMythBackendInfo * backend_info, - GMythRecProfile * profile); +gint gmyth_recprofile_create_profile ( GMythBackendInfo * backend_info, + GMythRecProfile * profile ); -gint gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info, - gint id); +gint gmyth_recprofile_del_profile_list ( GMythBackendInfo * backend_info, + gint id ); -gint gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec); -gint gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec); -gint gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group); -gint gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name); -gint gmyth_recprofile_set_id (GMythRecProfile * rec, gint id); +gint gmyth_recprofile_set_acodec ( GMythRecProfile * rec, gchar * acodec ); +gint gmyth_recprofile_set_vcodec ( GMythRecProfile * rec, gchar * vcodec ); +gint gmyth_recprofile_set_group ( GMythRecProfile * rec, gchar * group ); +gint gmyth_recprofile_set_name ( GMythRecProfile * rec, gchar * name ); +gint gmyth_recprofile_set_id ( GMythRecProfile * rec, gint id ); G_END_DECLS #endif /*_GMYTH_RECPROFILE_H*/ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_remote_util.c --- a/gmyth/src/gmyth_remote_util.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_remote_util.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * @author Hallyson Luiz de Morais Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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" @@ -45,42 +44,43 @@ * @return the remote encoder instance available, or NULL if any error happens. */ GMythRecorder * -remote_request_next_free_recorder (GMythSocket * socket, gint curr) +remote_request_next_free_recorder ( GMythSocket * socket, gint curr ) { GMythRecorder *recorder = NULL; GString *hostname; gint num, port; - GMythStringList *strlist = gmyth_string_list_new (); + GMythStringList *strlist = gmyth_string_list_new ( ); - gmyth_debug ("[%s] Request next free recorder in the backend", - __FUNCTION__); + gmyth_debug ( "[%s] Request next free recorder in the backend", + __FUNCTION__ ); - gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER"); - gmyth_string_list_append_int (strlist, curr); + gmyth_string_list_append_char_array ( strlist, "GET_NEXT_FREE_RECORDER" ); + gmyth_string_list_append_int ( strlist, curr ); - if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) { - g_warning ("GET_NEXT_FREE_RECORDER request error!\n"); + if ( !gmyth_socket_sendreceive_stringlist ( socket, strlist ) ) + { + g_warning ( "GET_NEXT_FREE_RECORDER request error!\n" ); return NULL; } - num = gmyth_string_list_get_int (strlist, 0); - hostname = gmyth_string_list_get_string (strlist, 1); - port = gmyth_string_list_get_int (strlist, 2); + num = gmyth_string_list_get_int ( strlist, 0 ); + hostname = gmyth_string_list_get_string ( strlist, 1 ); + port = gmyth_string_list_get_int ( strlist, 2 ); - if (num < 0 || port < 0) + if ( num < 0 || port < 0 ) goto clean_up; gmyth_debug - ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d", - __FUNCTION__, num, hostname->str, port); + ( "[%s] Free recorder info received: num: %d, hostname: %s, port: %d", + __FUNCTION__, num, hostname->str, port ); - recorder = gmyth_recorder_new (num, hostname, port); + recorder = gmyth_recorder_new ( num, hostname, port ); clean_up: - g_string_free (hostname, TRUE); - g_object_unref (strlist); + g_string_free ( hostname, TRUE ); + g_object_unref ( strlist ); return recorder; } @@ -93,33 +93,34 @@ * @return the number of remote encoders instance available, or 0 if no one is actually free.. */ gint -gmyth_remote_util_get_free_recorder_count (GMythSocket * socket) +gmyth_remote_util_get_free_recorder_count ( GMythSocket * socket ) { gint num_recs = 0; - GMythStringList *strlist = gmyth_string_list_new (); + GMythStringList *strlist = gmyth_string_list_new ( ); - gmyth_debug ("[%s] Request next free recorder in the backend", - __FUNCTION__); + gmyth_debug ( "[%s] Request next free recorder in the backend", + __FUNCTION__ ); - gmyth_string_list_append_char_array (strlist, "GET_FREE_RECORDER_COUNT"); + gmyth_string_list_append_char_array ( strlist, "GET_FREE_RECORDER_COUNT" ); - if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) { - gmyth_debug ("GET_FREE_RECORDER_COUNT request error!"); + if ( !gmyth_socket_sendreceive_stringlist ( socket, strlist ) ) + { + gmyth_debug ( "GET_FREE_RECORDER_COUNT request error!" ); return 0; } - num_recs = gmyth_string_list_get_int (strlist, 0); + num_recs = gmyth_string_list_get_int ( strlist, 0 ); - if (num_recs < 0) + if ( num_recs < 0 ) goto clean_up; - gmyth_debug ("[%s] Free recorder info received: num recorders: %d", - __FUNCTION__, num_recs); + gmyth_debug ( "[%s] Free recorder info received: num recorders: %d", + __FUNCTION__, num_recs ); clean_up: - g_object_unref (strlist); + g_object_unref ( strlist ); return num_recs; } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_remote_util.h --- a/gmyth/src/gmyth_remote_util.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_remote_util.h Wed May 23 19:50:41 2007 +0100 @@ -8,22 +8,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Hallyson Luiz de Morais Melo * - *//* - * - * 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 - */ + * + * 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 __REMOTE_UTIL_H__ #define __REMOTE_UTIL_H__ @@ -33,9 +32,9 @@ #include "gmyth_socket.h" G_BEGIN_DECLS - GMythRecorder * remote_request_next_free_recorder (GMythSocket * socket, - gint curr); -gint gmyth_remote_util_get_free_recorder_count (GMythSocket * socket); + GMythRecorder * remote_request_next_free_recorder ( GMythSocket * socket, + gint curr ); +gint gmyth_remote_util_get_free_recorder_count ( GMythSocket * socket ); G_END_DECLS #endif diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_scheduler.c --- a/gmyth/src/gmyth_scheduler.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Alexsandro Jose Virginio dos Santos * - *//* - * - * 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 - */ + * + * 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" @@ -40,33 +39,33 @@ #include "gmyth_socket.h" #include "gmyth_debug.h" -static void gmyth_scheduler_class_init (GMythSchedulerClass * klass); -static void gmyth_scheduler_init (GMythScheduler * object); +static void gmyth_scheduler_class_init ( GMythSchedulerClass * klass ); +static void gmyth_scheduler_init ( GMythScheduler * object ); -static void gmyth_scheduler_dispose (GObject * object); -static void gmyth_scheduler_finalize (GObject * object); +static void gmyth_scheduler_dispose ( GObject * object ); +static void gmyth_scheduler_finalize ( GObject * object ); -static gint get_record_id_from_database (GMythScheduler * scheduler); -static gboolean update_backend (GMythScheduler * scheduler, gint record_id); +static gint get_record_id_from_database ( GMythScheduler * scheduler ); +static gboolean update_backend ( GMythScheduler * scheduler, gint record_id ); -G_DEFINE_TYPE (GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT) - static void gmyth_scheduler_class_init (GMythSchedulerClass * klass) +G_DEFINE_TYPE ( GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT ) + static void gmyth_scheduler_class_init ( GMythSchedulerClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_scheduler_dispose; gobject_class->finalize = gmyth_scheduler_finalize; } static void -gmyth_scheduler_init (GMythScheduler * sched) +gmyth_scheduler_init ( GMythScheduler * sched ) { sched->recordid = 0; sched->type = 0; sched->search = 0; - sched->profile = g_string_new (""); + sched->profile = g_string_new ( "" ); sched->dupin = 0; sched->dupmethod = 0; @@ -86,48 +85,50 @@ sched->maxnewest = 0; sched->recpriority = 0; - sched->recgroup = g_string_new (""); - sched->playgroup = g_string_new (""); + sched->recgroup = g_string_new ( "" ); + sched->playgroup = g_string_new ( "" ); sched->prefinput = 0; sched->inactive = 0; - sched->search_type = g_string_new (""); - sched->search_what = g_string_new (""); + sched->search_type = g_string_new ( "" ); + sched->search_what = g_string_new ( "" ); - sched->msqlquery = gmyth_query_new (); + sched->msqlquery = gmyth_query_new ( ); } static void -gmyth_scheduler_dispose (GObject * object) +gmyth_scheduler_dispose ( GObject * object ) { - GMythScheduler *scheduler = GMYTH_SCHEDULER (object); + GMythScheduler *scheduler = GMYTH_SCHEDULER ( object ); - if (scheduler->backend_info) { - g_object_unref (scheduler->backend_info); + if ( scheduler->backend_info ) + { + g_object_unref ( scheduler->backend_info ); scheduler->backend_info = NULL; } - if (scheduler->msqlquery) { - g_object_unref (scheduler->msqlquery); + if ( scheduler->msqlquery ) + { + g_object_unref ( scheduler->msqlquery ); scheduler->msqlquery = NULL; } - g_string_free (scheduler->profile, TRUE); - g_string_free (scheduler->recgroup, TRUE); - g_string_free (scheduler->playgroup, TRUE); - g_string_free (scheduler->search_type, TRUE); - g_string_free (scheduler->search_what, TRUE); + g_string_free ( scheduler->profile, TRUE ); + g_string_free ( scheduler->recgroup, TRUE ); + g_string_free ( scheduler->playgroup, TRUE ); + g_string_free ( scheduler->search_type, TRUE ); + g_string_free ( scheduler->search_what, TRUE ); - G_OBJECT_CLASS (gmyth_scheduler_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_scheduler_parent_class )->dispose ( object ); } static void -gmyth_scheduler_finalize (GObject * object) +gmyth_scheduler_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_scheduler_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_scheduler_parent_class )->finalize ( object ); } /** Creates a new instance of GMythScheduler. @@ -135,19 +136,19 @@ * @return a new instance of GMythScheduler. */ GMythScheduler * -gmyth_scheduler_new () +gmyth_scheduler_new ( ) { GMythScheduler *scheduler = - GMYTH_SCHEDULER (g_object_new (GMYTH_SCHEDULER_TYPE, NULL)); + GMYTH_SCHEDULER ( g_object_new ( GMYTH_SCHEDULER_TYPE, NULL ) ); return scheduler; } gboolean -gmyth_scheduler_connect (GMythScheduler * scheduler, - GMythBackendInfo * backend_info) +gmyth_scheduler_connect ( GMythScheduler * scheduler, + GMythBackendInfo * backend_info ) { - return gmyth_scheduler_connect_with_timeout (scheduler, backend_info, 0); + return gmyth_scheduler_connect_with_timeout ( scheduler, backend_info, 0 ); } /** Connects to the Mysql database in the backend. The backend address @@ -157,25 +158,29 @@ * @return true if connection was success, false if failed. */ gboolean -gmyth_scheduler_connect_with_timeout (GMythScheduler * scheduler, - GMythBackendInfo * backend_info, guint timeout) +gmyth_scheduler_connect_with_timeout ( GMythScheduler * scheduler, + GMythBackendInfo * backend_info, + guint timeout ) { - assert (scheduler); - g_return_val_if_fail (backend_info != NULL, FALSE); + assert ( scheduler ); + g_return_val_if_fail ( backend_info != NULL, FALSE ); - if (scheduler->backend_info) - g_object_unref (scheduler->backend_info); + if ( scheduler->backend_info ) + g_object_unref ( scheduler->backend_info ); - scheduler->backend_info = g_object_ref (backend_info); + scheduler->backend_info = g_object_ref ( backend_info ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] GMythScheduler db initializing", __FUNCTION__); - scheduler->msqlquery = gmyth_query_new (); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] GMythScheduler db initializing", __FUNCTION__ ); + scheduler->msqlquery = gmyth_query_new ( ); } - if (!gmyth_query_connect_with_timeout (scheduler->msqlquery, - scheduler->backend_info, timeout)) { - g_warning ("[%s] Error while connecting to db", __FUNCTION__); + if ( !gmyth_query_connect_with_timeout ( scheduler->msqlquery, + scheduler->backend_info, + timeout ) ) + { + g_warning ( "[%s] Error while connecting to db", __FUNCTION__ ); return FALSE; } @@ -188,12 +193,13 @@ * @return true if disconnection was success, false if failed. */ gboolean -gmyth_scheduler_disconnect (GMythScheduler * scheduler) +gmyth_scheduler_disconnect ( GMythScheduler * scheduler ) { - assert (scheduler); + assert ( scheduler ); - if (scheduler->msqlquery != NULL) { - gmyth_query_disconnect (scheduler->msqlquery); + if ( scheduler->msqlquery != NULL ) + { + gmyth_query_disconnect ( scheduler->msqlquery ); } return TRUE; @@ -206,66 +212,74 @@ * @return The amount of schedules retrieved from database, or -1 if error. */ gint -gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler, - GList ** schedule_list) +gmyth_scheduler_get_schedule_list ( GMythScheduler * scheduler, + GList ** schedule_list ) { ScheduleInfo *schedule; MYSQL_RES *msql_res; - GString *query_str = g_string_new (""); + GString *query_str = g_string_new ( "" ); gchar *date_time = NULL; - assert (scheduler); + assert ( scheduler ); - g_string_printf (query_str, - "SELECT recordid,programid,chanid,starttime,startdate," - "endtime,enddate,title,subtitle,description,category FROM record;"); + g_string_printf ( query_str, + "SELECT recordid,programid,chanid,starttime,startdate," + "endtime,enddate,title,subtitle,description,category FROM record;" ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + 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); + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str ); - if (msql_res == NULL) { - g_warning ("DB retrieval of schedule list failed"); + if ( msql_res == NULL ) + { + g_warning ( "DB retrieval of schedule list failed" ); return -1; - } else { + } + else + { MYSQL_ROW row; *schedule_list = NULL; - while ((row = mysql_fetch_row (msql_res)) != NULL) { - schedule = g_new0 (ScheduleInfo, 1); + while ( ( row = mysql_fetch_row ( msql_res ) ) != NULL ) + { + schedule = g_new0 ( ScheduleInfo, 1 ); - schedule->schedule_id = (guint) g_ascii_strtoull (row[0], NULL, 10); - schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10); - schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10); + schedule->schedule_id = + ( guint ) g_ascii_strtoull ( row[0], NULL, 10 ); + schedule->program_id = + ( guint ) g_ascii_strtoull ( row[1], NULL, 10 ); + schedule->channel_id = + ( guint ) g_ascii_strtoull ( row[2], NULL, 10 ); /* generate a time_t from a time and a date db field */ - date_time = g_strdup_printf ("%sT%s", row[4], row[3]); - schedule->start_time = gmyth_util_string_to_time_val (date_time); - g_free (date_time); + date_time = g_strdup_printf ( "%sT%s", row[4], row[3] ); + schedule->start_time = gmyth_util_string_to_time_val ( date_time ); + g_free ( date_time ); /* generate a time_t from a time and a date db field */ - date_time = g_strdup_printf ("%sT%s", row[6], row[5]); - schedule->end_time = gmyth_util_string_to_time_val (date_time); - g_free (date_time); + date_time = g_strdup_printf ( "%sT%s", row[6], row[5] ); + schedule->end_time = gmyth_util_string_to_time_val ( date_time ); + g_free ( date_time ); - schedule->title = g_string_new (row[7]); - schedule->subtitle = g_string_new (row[8]); - schedule->description = g_string_new (row[9]); - schedule->category = g_string_new (row[10]); + schedule->title = g_string_new ( row[7] ); + schedule->subtitle = g_string_new ( row[8] ); + schedule->description = g_string_new ( row[9] ); + schedule->category = g_string_new ( row[10] ); - (*schedule_list) = g_list_append (*(schedule_list), schedule); + ( *schedule_list ) = g_list_append ( *( schedule_list ), schedule ); } } - mysql_free_result (msql_res); - g_string_free (query_str, TRUE); + mysql_free_result ( msql_res ); + g_string_free ( query_str, TRUE ); - return (*schedule_list == NULL) ? 0 : g_list_length (*schedule_list); + return ( *schedule_list == NULL ) ? 0 : g_list_length ( *schedule_list ); } /** Retrieves from the backend Mysql database the list of recorded programs. @@ -275,83 +289,90 @@ * @return The amount of recorded retrieved from database, or -1 if error. */ gint -gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler, - GList ** recorded_list) +gmyth_scheduler_get_recorded_list ( GMythScheduler * scheduler, + GList ** recorded_list ) { RecordedInfo *record; MYSQL_RES *msql_res; - GString *query_str = g_string_new (""); + GString *query_str = g_string_new ( "" ); - assert (scheduler); + 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'"); + g_string_printf ( query_str, + "SELECT recordid,programid,chanid,starttime,progstart," + "endtime,progend,title,subtitle,description,category," + "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'" ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + 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); + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str ); - if (msql_res == NULL) { - g_warning ("DB retrieval of recording list failed"); + if ( msql_res == NULL ) + { + g_warning ( "DB retrieval of recording list failed" ); return -1; - } else { + } + else + { MYSQL_ROW row; - (*recorded_list) = NULL; + ( *recorded_list ) = NULL; - while ((row = mysql_fetch_row (msql_res)) != NULL) { - record = g_new0 (RecordedInfo, 1); + while ( ( row = mysql_fetch_row ( msql_res ) ) != 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->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->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]); + 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] ); - (*recorded_list) = g_list_append ((*recorded_list), record); + ( *recorded_list ) = g_list_append ( ( *recorded_list ), record ); } } - mysql_free_result (msql_res); - g_string_free (query_str, TRUE); + mysql_free_result ( msql_res ); + g_string_free ( query_str, TRUE ); - return (*recorded_list == NULL) ? 0 : g_list_length (*recorded_list); + return ( *recorded_list == NULL ) ? 0 : g_list_length ( *recorded_list ); } static void -_set_value (GMythQuery * myth_query, char *field, gchar * value, gint rec_id) +_set_value ( GMythQuery * myth_query, char *field, gchar * value, gint rec_id ) { gchar *query = g_strdup_printf - ("UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;", - rec_id, field, value, rec_id); + ( "UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;", + rec_id, field, value, rec_id ); - gmyth_query_process_statement (myth_query, query); - g_free (query); + gmyth_query_process_statement ( myth_query, query ); + g_free ( query ); } static void -_set_int_value (GMythQuery * myth_query, char *field, gint value, gint rec_id) +_set_int_value ( GMythQuery * myth_query, char *field, gint value, gint rec_id ) { - gchar *str_value = g_strdup_printf ("%d", value); + gchar *str_value = g_strdup_printf ( "%d", value ); - _set_value (myth_query, field, str_value, rec_id); - g_free (str_value); + _set_value ( myth_query, field, str_value, rec_id ); + g_free ( str_value ); } /** Requests the Mysql database in the backend to add a new schedule. @@ -363,97 +384,105 @@ * @return gboolean returns FALSE if some error occurs, TRUE otherwise */ gboolean -gmyth_scheduler_add_schedule (GMythScheduler * scheduler, - ScheduleInfo * schedule_info) +gmyth_scheduler_add_schedule ( GMythScheduler * scheduler, + ScheduleInfo * schedule_info ) { MYSQL_RES *msql_res; gchar *query_str = "INSERT record (recordid) VALUE (0);"; gchar *station = NULL; gulong rec_id; - assert (scheduler); + assert ( scheduler ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] Scheduler db connection not initialized", + __FUNCTION__ ); return FALSE; } msql_res = - gmyth_query_process_statement_with_increment (scheduler->msqlquery, - query_str, &rec_id); - mysql_free_result (msql_res); + gmyth_query_process_statement_with_increment ( scheduler->msqlquery, + query_str, &rec_id ); + mysql_free_result ( msql_res ); // Retrieves the station info query_str = - g_strdup_printf ("SELECT callsign FROM channel WHERE chanid = \"%d\";", - schedule_info->channel_id); - msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str); - if (msql_res == NULL) { - g_warning ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__); + g_strdup_printf ( "SELECT callsign FROM channel WHERE chanid = \"%d\";", + schedule_info->channel_id ); + msql_res = + gmyth_query_process_statement ( scheduler->msqlquery, query_str ); + if ( msql_res == NULL ) + { + g_warning ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ ); return FALSE; - } else { + } + else + { MYSQL_ROW row; - if ((row = mysql_fetch_row (msql_res)) != NULL) { - station = g_strdup (row[0]); + if ( ( row = mysql_fetch_row ( msql_res ) ) != NULL ) + { + station = g_strdup ( row[0] ); } } - mysql_free_result (msql_res); - g_free (query_str); + mysql_free_result ( msql_res ); + g_free ( query_str ); // _set_value (field, value, id); - _set_int_value (scheduler->msqlquery, "chanid", schedule_info->channel_id, - rec_id); - _set_value (scheduler->msqlquery, "station", station, rec_id); - _set_value (scheduler->msqlquery, "title", schedule_info->title->str, - rec_id); + _set_int_value ( scheduler->msqlquery, "chanid", schedule_info->channel_id, + rec_id ); + _set_value ( scheduler->msqlquery, "station", station, rec_id ); + _set_value ( scheduler->msqlquery, "title", schedule_info->title->str, + rec_id ); /// subtitle, description - _set_value (scheduler->msqlquery, "starttime", - gmyth_util_time_to_string_only_time (schedule_info-> - start_time), rec_id); - _set_value (scheduler->msqlquery, "startdate", - gmyth_util_time_to_string_only_date (schedule_info-> - start_time), rec_id); - _set_value (scheduler->msqlquery, "endtime", - gmyth_util_time_to_string_only_time (schedule_info->end_time), rec_id); - _set_value (scheduler->msqlquery, "enddate", - gmyth_util_time_to_string_only_date (schedule_info->end_time), rec_id); + _set_value ( scheduler->msqlquery, "starttime", + gmyth_util_time_to_string_only_time ( schedule_info-> + start_time ), rec_id ); + _set_value ( scheduler->msqlquery, "startdate", + gmyth_util_time_to_string_only_date ( schedule_info-> + start_time ), rec_id ); + _set_value ( scheduler->msqlquery, "endtime", + gmyth_util_time_to_string_only_time ( schedule_info-> + end_time ), rec_id ); + _set_value ( scheduler->msqlquery, "enddate", + gmyth_util_time_to_string_only_date ( schedule_info-> + end_time ), rec_id ); /// category, series id, program id //_set_value (scheduler->msqlquery, "findday", (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, rec_id); //_set_value (scheduler->msqlquery, "findtime", gmyth_util_time_to_string_only_time( schedule_info->start_time), rec_id); //_set_int_value (scheduler->msqlquery, "findid", (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528), rec_id); - _set_value (scheduler->msqlquery, "parentid", "0", rec_id); - _set_value (scheduler->msqlquery, "search", "0", rec_id); - _set_value (scheduler->msqlquery, "type", "1", rec_id); - _set_value (scheduler->msqlquery, "recpriority", "0", rec_id); - _set_value (scheduler->msqlquery, "startoffset", "0", rec_id); - _set_value (scheduler->msqlquery, "endoffset", "0", rec_id); - _set_value (scheduler->msqlquery, "dupmethod", "6", rec_id); // ? - _set_value (scheduler->msqlquery, "dupin", "15", rec_id); // ? + _set_value ( scheduler->msqlquery, "parentid", "0", rec_id ); + _set_value ( scheduler->msqlquery, "search", "0", rec_id ); + _set_value ( scheduler->msqlquery, "type", "1", rec_id ); + _set_value ( scheduler->msqlquery, "recpriority", "0", rec_id ); + _set_value ( scheduler->msqlquery, "startoffset", "0", rec_id ); + _set_value ( scheduler->msqlquery, "endoffset", "0", rec_id ); + _set_value ( scheduler->msqlquery, "dupmethod", "6", rec_id ); // ? + _set_value ( scheduler->msqlquery, "dupin", "15", rec_id ); // ? - _set_value (scheduler->msqlquery, "prefinput", "0", rec_id); - _set_value (scheduler->msqlquery, "inactive", "0", rec_id); - _set_value (scheduler->msqlquery, "profile", "Default", rec_id); - _set_value (scheduler->msqlquery, "recgroup", "Default", rec_id); - _set_value (scheduler->msqlquery, "storagegroup", "Default", rec_id); - _set_value (scheduler->msqlquery, "playgroup", "Default", rec_id); - _set_value (scheduler->msqlquery, "autoexpire", "1", rec_id); - _set_value (scheduler->msqlquery, "maxepisodes", "0", rec_id); - _set_value (scheduler->msqlquery, "maxnewest", "0", rec_id); - _set_value (scheduler->msqlquery, "autocommflag", "1", rec_id); - _set_value (scheduler->msqlquery, "autotranscode", "0", rec_id); - _set_value (scheduler->msqlquery, "transcoder", "0", rec_id); + _set_value ( scheduler->msqlquery, "prefinput", "0", rec_id ); + _set_value ( scheduler->msqlquery, "inactive", "0", rec_id ); + _set_value ( scheduler->msqlquery, "profile", "Default", rec_id ); + _set_value ( scheduler->msqlquery, "recgroup", "Default", rec_id ); + _set_value ( scheduler->msqlquery, "storagegroup", "Default", rec_id ); + _set_value ( scheduler->msqlquery, "playgroup", "Default", rec_id ); + _set_value ( scheduler->msqlquery, "autoexpire", "1", rec_id ); + _set_value ( scheduler->msqlquery, "maxepisodes", "0", rec_id ); + _set_value ( scheduler->msqlquery, "maxnewest", "0", rec_id ); + _set_value ( scheduler->msqlquery, "autocommflag", "1", rec_id ); + _set_value ( scheduler->msqlquery, "autotranscode", "0", rec_id ); + _set_value ( scheduler->msqlquery, "transcoder", "0", rec_id ); - _set_value (scheduler->msqlquery, "autouserjob1", "0", rec_id); - _set_value (scheduler->msqlquery, "autouserjob2", "0", rec_id); - _set_value (scheduler->msqlquery, "autouserjob3", "0", rec_id); - _set_value (scheduler->msqlquery, "autouserjob4", "0", rec_id); + _set_value ( scheduler->msqlquery, "autouserjob1", "0", rec_id ); + _set_value ( scheduler->msqlquery, "autouserjob2", "0", rec_id ); + _set_value ( scheduler->msqlquery, "autouserjob3", "0", rec_id ); + _set_value ( scheduler->msqlquery, "autouserjob4", "0", rec_id ); schedule_info->schedule_id = rec_id; /* Notify the backend of changes */ - return update_backend (scheduler, rec_id); + return update_backend ( scheduler, rec_id ); } /** Requests the Mysql database in the backend to remove an existing schedule. @@ -463,32 +492,33 @@ * @return gboolean TRUE if success, FALSE if error */ gboolean -gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint record_id) +gmyth_scheduler_delete_schedule ( GMythScheduler * scheduler, gint record_id ) { MYSQL_RES *msql_res; - GString *query_str = g_string_new (""); + GString *query_str = g_string_new ( "" ); - assert (scheduler); + assert ( scheduler ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] Scheduler db connection not initialized", + __FUNCTION__ ); return FALSE; } //======================================== - g_string_printf (query_str, - "DELETE FROM record WHERE recordid=%d", record_id); + g_string_printf ( query_str, + "DELETE FROM record WHERE recordid=%d", record_id ); msql_res = - gmyth_query_process_statement (scheduler->msqlquery, query_str->str); + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str ); - mysql_free_result (msql_res); - g_string_free (query_str, TRUE); + mysql_free_result ( msql_res ); + g_string_free ( query_str, TRUE ); // Notify the backend of the changes - return update_backend (scheduler, record_id); + return update_backend ( scheduler, record_id ); } /** Requests the Mysql database in the backend to remove an existing recorded item. @@ -498,34 +528,35 @@ * @return gboolean TRUE if success, FALSE if error */ gboolean -gmyth_scheduler_delete_recorded (GMythScheduler * scheduler, gint record_id) +gmyth_scheduler_delete_recorded ( GMythScheduler * scheduler, gint record_id ) { MYSQL_RES *msql_res; - GString *query_str = g_string_new (""); + GString *query_str = g_string_new ( "" ); - assert (scheduler); + assert ( scheduler ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] Scheduler db connection not initialized", + __FUNCTION__ ); return FALSE; } //======================================== - g_string_printf (query_str, - "DELETE FROM recorded WHERE recordid=%d", record_id); + g_string_printf ( query_str, + "DELETE FROM recorded WHERE recordid=%d", record_id ); // FIXME: Mythtv implementation runs also: DELETE FROM oldfind WHERE recordid = x msql_res = - gmyth_query_process_statement (scheduler->msqlquery, query_str->str); + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str ); - mysql_free_result (msql_res); - g_string_free (query_str, TRUE); + mysql_free_result ( msql_res ); + g_string_free ( query_str, TRUE ); // Notify the backend of the changes - return update_backend (scheduler, record_id); + return update_backend ( scheduler, record_id ); } /** Retrieves an existing recorded item information from database. The information @@ -538,101 +569,109 @@ * information, or NULL if error. */ GMythProgramInfo * -gmyth_scheduler_get_recorded (GMythScheduler * scheduler, - GString * channel, GTimeVal * starttime) +gmyth_scheduler_get_recorded ( GMythScheduler * scheduler, + GString * channel, GTimeVal * starttime ) { MYSQL_RES *msql_res; GMythProgramInfo *proginfo = NULL; - GString *query_str = g_string_new (""); - gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime); + GString *query_str = g_string_new ( "" ); + gchar *time_str = gmyth_util_time_to_string_from_time_val ( starttime ); - assert (scheduler); + assert ( scheduler ); - gmyth_debug ("[%s] channel: %s", __FUNCTION__, channel->str); + gmyth_debug ( "[%s] channel: %s", __FUNCTION__, channel->str ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] Scheduler db connection not initialized", + __FUNCTION__ ); return NULL; } - g_string_printf (query_str, - "SELECT recorded.chanid,starttime,endtime,title, " - "subtitle,description,channel.channum, " - "channel.callsign,channel.name,channel.commfree, " - "channel.outputfilters,seriesid,programid,filesize, " - "lastmodified,stars,previouslyshown,originalairdate, " - "hostname,recordid,transcoder,playgroup, " - "recorded.recpriority,progstart,progend,basename,recgroup " - "FROM recorded " "LEFT JOIN channel " - "ON recorded.chanid = channel.chanid " - "WHERE recorded.chanid = \"%s\" " - "AND starttime = \"%s\" ;", channel->str, time_str); + g_string_printf ( query_str, + "SELECT recorded.chanid,starttime,endtime,title, " + "subtitle,description,channel.channum, " + "channel.callsign,channel.name,channel.commfree, " + "channel.outputfilters,seriesid,programid,filesize, " + "lastmodified,stars,previouslyshown,originalairdate, " + "hostname,recordid,transcoder,playgroup, " + "recorded.recpriority,progstart,progend,basename,recgroup " + "FROM recorded " "LEFT JOIN channel " + "ON recorded.chanid = channel.chanid " + "WHERE recorded.chanid = \"%s\" " + "AND starttime = \"%s\" ;", channel->str, time_str ); msql_res = - gmyth_query_process_statement (scheduler->msqlquery, query_str->str); + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str ); - if (msql_res /*&& query.size() > 0 */ ) { - MYSQL_ROW msql_row = mysql_fetch_row (msql_res); + if ( msql_res /*&& query.size() > 0 */ ) + { + MYSQL_ROW msql_row = mysql_fetch_row ( msql_res ); - if (msql_row) { - proginfo = gmyth_program_info_new (); + if ( msql_row ) + { + proginfo = gmyth_program_info_new ( ); - proginfo->chanid = g_string_new (msql_row[0]); - proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]); - proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]); - proginfo->recstartts = gmyth_util_string_to_time_val (msql_row[1]); - proginfo->recendts = gmyth_util_string_to_time_val (msql_row[2]); - proginfo->title = g_string_new (msql_row[3]); - proginfo->subtitle = g_string_new (msql_row[4]); - proginfo->description = g_string_new (msql_row[5]); + proginfo->chanid = g_string_new ( msql_row[0] ); + proginfo->startts = gmyth_util_string_to_time_val ( msql_row[23] ); + proginfo->endts = gmyth_util_string_to_time_val ( msql_row[24] ); + proginfo->recstartts = + gmyth_util_string_to_time_val ( msql_row[1] ); + proginfo->recendts = gmyth_util_string_to_time_val ( msql_row[2] ); + proginfo->title = g_string_new ( msql_row[3] ); + proginfo->subtitle = g_string_new ( msql_row[4] ); + proginfo->description = g_string_new ( msql_row[5] ); - proginfo->chanstr = g_string_new (msql_row[6]); - proginfo->chansign = g_string_new (msql_row[7]); - proginfo->channame = g_string_new (msql_row[0]); + proginfo->chanstr = g_string_new ( msql_row[6] ); + proginfo->chansign = g_string_new ( msql_row[7] ); + proginfo->channame = g_string_new ( msql_row[0] ); proginfo->chancommfree = - (gint) g_ascii_strtoull (msql_row[9], NULL, 10); - proginfo->chanOutputFilters = g_string_new (msql_row[10]); - proginfo->seriesid = g_string_new (msql_row[11]); - proginfo->programid = g_string_new (msql_row[12]); - proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10); + ( gint ) g_ascii_strtoull ( msql_row[9], NULL, 10 ); + proginfo->chanOutputFilters = g_string_new ( msql_row[10] ); + proginfo->seriesid = g_string_new ( msql_row[11] ); + proginfo->programid = g_string_new ( msql_row[12] ); + proginfo->filesize = g_ascii_strtoull ( msql_row[13], NULL, 10 ); proginfo->lastmodified = - gmyth_util_string_to_time_val (msql_row[14]); - proginfo->stars = g_ascii_strtod (msql_row[15], NULL); - proginfo->repeat = (gint) g_ascii_strtoull (msql_row[16], NULL, 10); + gmyth_util_string_to_time_val ( msql_row[14] ); + proginfo->stars = g_ascii_strtod ( msql_row[15], NULL ); + proginfo->repeat = + ( gint ) g_ascii_strtoull ( msql_row[16], NULL, 10 ); - if (msql_row[17] == NULL) { + if ( msql_row[17] == NULL ) + { proginfo->originalAirDate = 0; proginfo->hasAirDate = FALSE; - } else { + } + else + { proginfo->originalAirDate = - gmyth_util_string_to_time_val (msql_row[17]); + gmyth_util_string_to_time_val ( msql_row[17] ); proginfo->hasAirDate = TRUE; } - proginfo->hostname = g_string_new (msql_row[18]); + proginfo->hostname = g_string_new ( msql_row[18] ); proginfo->recordid = - (gint) g_ascii_strtoull (msql_row[19], NULL, 10); + ( gint ) g_ascii_strtoull ( msql_row[19], NULL, 10 ); proginfo->transcoder = - (gint) g_ascii_strtoull (msql_row[20], NULL, 10); + ( gint ) g_ascii_strtoull ( msql_row[20], NULL, 10 ); //proginfo->spread = -1; //proginfo->programflags = proginfo->getProgramFlags(); - proginfo->recgroup = g_string_new (msql_row[26]); - proginfo->playgroup = g_string_new (msql_row[21]); + proginfo->recgroup = g_string_new ( msql_row[26] ); + proginfo->playgroup = g_string_new ( msql_row[21] ); proginfo->recpriority = - (gint) g_ascii_strtoull (msql_row[22], NULL, 10); + ( gint ) g_ascii_strtoull ( msql_row[22], NULL, 10 ); - proginfo->pathname = g_string_new (g_strdup (msql_row[25])); + proginfo->pathname = g_string_new ( g_strdup ( msql_row[25] ) ); - gmyth_debug ("One program info loaded from mysql database\n"); + gmyth_debug ( "One program info loaded from mysql database\n" ); } } - mysql_free_result (msql_res); - g_string_free (query_str, TRUE); - g_free (time_str); + mysql_free_result ( msql_res ); + g_string_free ( query_str, TRUE ); + g_free ( time_str ); return proginfo; } @@ -643,19 +682,20 @@ * @return gint record_id if success, -1 otherwise */ static gint -get_record_id_from_database (GMythScheduler * scheduler) +get_record_id_from_database ( GMythScheduler * scheduler ) { gint record_id; - assert (scheduler); + assert ( scheduler ); - if (scheduler->msqlquery == NULL) { - g_warning ("[%s] Scheduler db connection not initialized", - __FUNCTION__); + if ( scheduler->msqlquery == NULL ) + { + g_warning ( "[%s] Scheduler db connection not initialized", + __FUNCTION__ ); return 0; } - record_id = mysql_insert_id (scheduler->msqlquery->conn); + record_id = mysql_insert_id ( scheduler->msqlquery->conn ); return record_id; } @@ -665,121 +705,124 @@ * @param record_id the id of the modified recording. */ static gboolean -update_backend (GMythScheduler * scheduler, gint record_id) //fixme: put void and discovery record_id inside +update_backend ( GMythScheduler * scheduler, gint record_id ) //fixme: put void and discovery record_id inside { GMythSocket *socket; - GMythStringList *strlist = gmyth_string_list_new (); - GString *datastr = g_string_new ("RESCHEDULE_RECORDINGS "); + GMythStringList *strlist = gmyth_string_list_new ( ); + GString *datastr = g_string_new ( "RESCHEDULE_RECORDINGS " ); gboolean ret = FALSE; - g_string_append_printf (datastr, "%d", record_id); - gmyth_string_list_append_string (strlist, datastr); + g_string_append_printf ( datastr, "%d", record_id ); + gmyth_string_list_append_string ( strlist, datastr ); - socket = gmyth_socket_new (); - if (gmyth_socket_connect_to_backend - (socket, scheduler->backend_info->hostname, - scheduler->backend_info->port, TRUE)) { - ret = (gmyth_socket_sendreceive_stringlist (socket, strlist) > 0); - } else { - g_warning ("[%s] Connection to backend failed!", __FUNCTION__); + socket = gmyth_socket_new ( ); + if ( gmyth_socket_connect_to_backend + ( socket, scheduler->backend_info->hostname, + scheduler->backend_info->port, TRUE ) ) + { + ret = ( gmyth_socket_sendreceive_stringlist ( socket, strlist ) > 0 ); + } + else + { + g_warning ( "[%s] Connection to backend failed!", __FUNCTION__ ); } - g_string_free (datastr, TRUE); - g_object_unref (strlist); + g_string_free ( datastr, TRUE ); + g_object_unref ( strlist ); return ret; } void -gmyth_scheduler_recorded_info_get_preview (RecordedInfo * info, - GByteArray * data) +gmyth_scheduler_recorded_info_get_preview ( RecordedInfo * info, + GByteArray * data ) { } void -gmyth_recorded_info_free (RecordedInfo * info) +gmyth_recorded_info_free ( RecordedInfo * info ) { - if (info->title != NULL) - g_string_free (info->title, TRUE); + if ( info->title != NULL ) + g_string_free ( info->title, TRUE ); - if (info->subtitle != NULL) - g_string_free (info->subtitle, TRUE); + if ( info->subtitle != NULL ) + g_string_free ( info->subtitle, TRUE ); - if (info->description != NULL) - g_string_free (info->description, TRUE); + if ( info->description != NULL ) + g_string_free ( info->description, TRUE ); - if (info->category != NULL) - g_string_free (info->category, TRUE); + if ( info->category != NULL ) + g_string_free ( info->category, TRUE ); - if (info->basename != NULL) - g_string_free (info->basename, TRUE); + if ( info->basename != NULL ) + g_string_free ( info->basename, TRUE ); - if (info != NULL) - g_free (info->start_time); + if ( info != NULL ) + g_free ( info->start_time ); - if (info != NULL) - g_free (info->end_time); + if ( info != NULL ) + g_free ( info->end_time ); - g_free (info); + g_free ( info ); } static void -free_recorded_info_item (gpointer data, gpointer user_data) +free_recorded_info_item ( gpointer data, gpointer user_data ) { - RecordedInfo *info = (RecordedInfo *) data; + RecordedInfo *info = ( RecordedInfo * ) data; - gmyth_recorded_info_free (info); + gmyth_recorded_info_free ( info ); } void -gmyth_recorded_info_list_free (GList * list) +gmyth_recorded_info_list_free ( GList * list ) { - g_return_if_fail (list != NULL); + g_return_if_fail ( list != NULL ); - g_list_foreach (list, free_recorded_info_item, NULL); - g_list_free (list); + g_list_foreach ( list, free_recorded_info_item, NULL ); + g_list_free ( list ); } void -gmyth_schedule_info_free (ScheduleInfo * info) +gmyth_schedule_info_free ( ScheduleInfo * info ) { - g_return_if_fail (info != NULL); + g_return_if_fail ( info != NULL ); - if (info->title != NULL) - g_string_free (info->title, TRUE); + if ( info->title != NULL ) + g_string_free ( info->title, TRUE ); - if (info->subtitle != NULL) - g_string_free (info->subtitle, TRUE); + if ( info->subtitle != NULL ) + g_string_free ( info->subtitle, TRUE ); - if (info->description != NULL) - g_string_free (info->description, TRUE); + if ( info->description != NULL ) + g_string_free ( info->description, TRUE ); - if (info->category != NULL) - g_string_free (info->category, TRUE); + if ( info->category != NULL ) + g_string_free ( info->category, TRUE ); - if (info != NULL) - g_free (info->start_time); + if ( info != NULL ) + g_free ( info->start_time ); - if (info != NULL) - g_free (info->end_time); + if ( info != NULL ) + g_free ( info->end_time ); - g_free (info); + g_free ( info ); } static void -free_schedule_info_item (gpointer data, gpointer user_data) +free_schedule_info_item ( gpointer data, gpointer user_data ) { - ScheduleInfo *info = (ScheduleInfo *) data; + ScheduleInfo *info = ( ScheduleInfo * ) data; - gmyth_schedule_info_free (info); + gmyth_schedule_info_free ( info ); } void -gmyth_schedule_info_list_free (GList * list) +gmyth_schedule_info_list_free ( GList * list ) { - g_return_if_fail (list != NULL); + g_return_if_fail ( list != NULL ); - g_list_foreach (list, free_schedule_info_item, NULL); - g_list_free (list); + g_list_foreach ( list, free_schedule_info_item, NULL ); + g_list_free ( list ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_scheduler.h --- a/gmyth/src/gmyth_scheduler.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_scheduler.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Alexsandro Jose Virginio dos Santos * - *//* - * - * 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 - */ + * + * 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_SCHEDULER_H__ #define __GMYTH_SCHEDULER_H__ @@ -47,123 +46,125 @@ typedef struct _GMythSchedulerClass GMythSchedulerClass; struct _GMythSchedulerClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythScheduler -{ - GObject parent; + { + GObject parent; - unsigned long recordid; - unsigned long type; - unsigned long search; - GString *profile; + unsigned long recordid; + unsigned long type; + unsigned long search; + GString *profile; - long dupin; - long dupmethod; - long autoexpire; - short int autotranscode; - long transcoder; + long dupin; + long dupmethod; + long autoexpire; + short int autotranscode; + long transcoder; - short int autocommflag; - short int autouserjob1; - short int autouserjob2; - short int autouserjob3; - short int autouserjob4; + short int autocommflag; + short int autouserjob1; + short int autouserjob2; + short int autouserjob3; + short int autouserjob4; - long startoffset; - long endoffset; - long maxepisodes; - long maxnewest; + long startoffset; + long endoffset; + long maxepisodes; + long maxnewest; - long recpriority; - GString *recgroup; - GString *playgroup; + long recpriority; + GString *recgroup; + GString *playgroup; - long prefinput; - short int inactive; + long prefinput; + short int inactive; - GString *search_type; - GString *search_what; + GString *search_type; + GString *search_what; - GMythQuery *msqlquery; - GMythBackendInfo *backend_info; -}; + GMythQuery *msqlquery; + GMythBackendInfo *backend_info; + }; typedef struct -{ - guint schedule_id; - guint program_id; - guint channel_id; + { + guint schedule_id; + guint program_id; + guint channel_id; - GTimeVal *start_time; - GTimeVal *end_time; + GTimeVal *start_time; + GTimeVal *end_time; - GString *title; - GString *subtitle; - GString *description; - GString *category; + GString *title; + GString *subtitle; + GString *description; + GString *category; -} ScheduleInfo; + } ScheduleInfo; typedef struct -{ - guint record_id; - guint program_id; - guint channel_id; + { + guint record_id; + guint program_id; + guint channel_id; - GTimeVal *start_time; - GTimeVal *end_time; + GTimeVal *start_time; + GTimeVal *end_time; - GString *title; - GString *subtitle; - GString *description; - GString *category; + GString *title; + GString *subtitle; + GString *description; + GString *category; - GString *basename; + GString *basename; - guint64 filesize; + guint64 filesize; -} RecordedInfo; + } 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, guint timeout); -gboolean gmyth_scheduler_disconnect (GMythScheduler * scheduler); +GMythScheduler *gmyth_scheduler_new ( ); +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); +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); +GMythProgramInfo *gmyth_scheduler_get_recorded ( GMythScheduler * scheduler, + GString * channel, + GTimeVal * starttime ); -gint gmyth_scheduler_add_schedule (GMythScheduler * scheduler, - ScheduleInfo * schedule_info); +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); +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_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_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); +void gmyth_recorded_info_list_free ( GList * list ); +void gmyth_schedule_info_list_free ( GList * list ); G_END_DECLS #endif /* __GMYTH_SCHEDULER_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_socket.c Wed May 23 19:50:41 2007 +0100 @@ -13,22 +13,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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" @@ -76,25 +75,25 @@ static gchar *local_hostname = NULL; -static void gmyth_socket_class_init (GMythSocketClass * klass); -static void gmyth_socket_init (GMythSocket * object); +static void gmyth_socket_class_init ( GMythSocketClass * klass ); +static void gmyth_socket_init ( GMythSocket * object ); -static void gmyth_socket_dispose (GObject * object); -static void gmyth_socket_finalize (GObject * object); +static void gmyth_socket_dispose ( GObject * object ); +static void gmyth_socket_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythSocket, gmyth_socket, G_TYPE_OBJECT) - static void gmyth_socket_class_init (GMythSocketClass * klass) +G_DEFINE_TYPE ( GMythSocket, gmyth_socket, G_TYPE_OBJECT ) + static void gmyth_socket_class_init ( GMythSocketClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_socket_dispose; gobject_class->finalize = gmyth_socket_finalize; } static void -gmyth_socket_init (GMythSocket * gmyth_socket) +gmyth_socket_init ( GMythSocket * gmyth_socket ) { /* gmyth_socket->local_hostname = NULL; */ @@ -107,47 +106,48 @@ * @return gint that represents the error number from getaddrinfo(). */ static gint -gmyth_socket_toaddrinfo (const gchar * addr, gint port, - struct addrinfo **addrInfo) +gmyth_socket_toaddrinfo ( const gchar * addr, gint port, + struct addrinfo **addrInfo ) { struct addrinfo hints; gchar *portStr = NULL; gint errorn = EADDRNOTAVAIL; - g_return_val_if_fail (addr != NULL, -1); + g_return_val_if_fail ( addr != NULL, -1 ); - memset (&hints, 0, sizeof (struct addrinfo)); + memset ( &hints, 0, sizeof ( struct addrinfo ) ); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; /* hints.ai_flags = AI_NUMERICHOST; */ - if (port != -1) - portStr = g_strdup_printf ("%d", port); + if ( port != -1 ) + portStr = g_strdup_printf ( "%d", port ); else portStr = NULL; - gmyth_debug ("Getting name resolution for: %s, %d\n", addr, port); + gmyth_debug ( "Getting name resolution for: %s, %d\n", addr, port ); - if ((errorn = getaddrinfo (addr, portStr, &hints, addrInfo)) != 0) { - gmyth_debug ("[%s] Socket ERROR: %s\n", __FUNCTION__, - gai_strerror (errorn)); + if ( ( errorn = getaddrinfo ( addr, portStr, &hints, addrInfo ) ) != 0 ) + { + gmyth_debug ( "[%s] Socket ERROR: %s\n", __FUNCTION__, + gai_strerror ( errorn ) ); } - g_free (portStr); + g_free ( portStr ); return errorn; } /* -static gint -gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address ) -{ - if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) { - //gmyth_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) ); - return 0; - } else { - return -1; - } + static gint + gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address ) + { + if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) { +//gmyth_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) ); +return 0; +} else { +return -1; +} } */ @@ -160,7 +160,7 @@ * @return List with all the local net interfaces. */ GList * -gmyth_socket_get_local_addrs (GList * current_connections) +gmyth_socket_get_local_addrs ( GList * current_connections ) { GList *local_addrs = NULL; @@ -171,44 +171,45 @@ gchar *ifname; gchar *sep; - s = socket (AF_INET, SOCK_DGRAM, 0); - if (s < 0) + s = socket ( AF_INET, SOCK_DGRAM, 0 ); + if ( s < 0 ) return 0; - fd = fopen (PATH_PROC_NET_DEV, "r"); - fgets (buffer, sizeof (buffer) - 1, fd); - fgets (buffer, sizeof (buffer) - 1, fd); - while (!feof (fd)) { + fd = fopen ( PATH_PROC_NET_DEV, "r" ); + fgets ( buffer, sizeof ( buffer ) - 1, fd ); + fgets ( buffer, sizeof ( buffer ) - 1, fd ); + while ( !feof ( fd ) ) + { ifname = buffer; - if (fgets (buffer, sizeof (buffer) - 1, fd) == NULL) + if ( fgets ( buffer, sizeof ( buffer ) - 1, fd ) == NULL ) break; - sep = strrchr (buffer, ':'); - if (sep) + sep = strrchr ( buffer, ':' ); + if ( sep ) *sep = 0; - while (*ifname == ' ') + while ( *ifname == ' ' ) ifname++; struct ifreq req; - strcpy (req.ifr_name, ifname); - if (ioctl (s, SIOCGIFFLAGS, &req) < 0) + strcpy ( req.ifr_name, ifname ); + if ( ioctl ( s, SIOCGIFFLAGS, &req ) < 0 ) continue; - if (!(req.ifr_flags & IFF_UP)) + if ( !( req.ifr_flags & IFF_UP ) ) continue; - if (req.ifr_flags & IFF_LOOPBACK) + if ( req.ifr_flags & IFF_LOOPBACK ) continue; - if (ioctl (s, SIOCGIFADDR, &req) < 0) + if ( ioctl ( s, SIOCGIFADDR, &req ) < 0 ) continue; - g_strlcpy (ifaddr, - inet_ntoa (((struct sockaddr_in *) &req.ifr_addr)-> - sin_addr), sizeof (struct ifaddr) - 1); - local_addrs = g_list_append (local_addrs, g_strdup (ifaddr)); + g_strlcpy ( ifaddr, + inet_ntoa ( ( ( struct sockaddr_in * ) &req.ifr_addr )-> + sin_addr ), sizeof ( struct ifaddr ) - 1 ); + local_addrs = g_list_append ( local_addrs, g_strdup ( ifaddr ) ); gmyth_debug - ("( from the /proc/net/dev) Interface name: %s, address: %s\n", - ifname, ifaddr); + ( "( from the /proc/net/dev) Interface name: %s, address: %s\n", + ifname, ifaddr ); } - fclose (fd); - close (s); + fclose ( fd ); + close ( s ); return local_addrs; } @@ -216,25 +217,26 @@ * Get only the local addresses from the primary interface */ gchar * -gmyth_socket_get_primary_addr (void) +gmyth_socket_get_primary_addr ( void ) { - gchar *if_eth0 = g_new0 (gchar, sizeof (struct ifaddr) - 1); + gchar *if_eth0 = g_new0 ( gchar, sizeof ( struct ifaddr ) - 1 ); GList *if_tmp = NULL; - GList *interfs = gmyth_socket_get_local_addrs (NULL); + GList *interfs = gmyth_socket_get_local_addrs ( NULL ); - if (interfs != NULL && (g_list_length (interfs) > 0)) { + if ( interfs != NULL && ( g_list_length ( interfs ) > 0 ) ) + { // get the first occurrence (primary interface) - if_tmp = g_list_first (interfs); + if_tmp = g_list_first ( interfs ); - if (if_tmp != NULL) - g_strlcpy (if_eth0, (gchar *) if_tmp->data, - sizeof (struct ifaddr) - 1); + if ( if_tmp != NULL ) + g_strlcpy ( if_eth0, ( gchar * ) if_tmp->data, + sizeof ( struct ifaddr ) - 1 ); } - if (interfs != NULL) - g_list_free (interfs); + if ( interfs != NULL ) + g_list_free ( interfs ); return if_eth0; } @@ -245,23 +247,24 @@ * @return GString* get local hostname. */ GString * -gmyth_socket_get_local_hostname (void) +gmyth_socket_get_local_hostname ( void ) { char hname[50]; - gint res = gethostname (hname, 50); + gint res = gethostname ( hname, 50 ); - if (res == -1) { - gmyth_debug ("Error while getting hostname"); - return g_string_new ("default"); + if ( res == -1 ) + { + gmyth_debug ( "Error while getting hostname" ); + return g_string_new ( "default" ); } - return g_string_new (hname); + return g_string_new ( hname ); #if 0 GString *str = NULL; - if (local_hostname != NULL && strlen (local_hostname) > 0) - return g_string_new (local_hostname); + if ( local_hostname != NULL && strlen ( local_hostname ) > 0 ) + return g_string_new ( local_hostname ); gchar *localaddr = NULL; gboolean found_addr = FALSE; @@ -270,99 +273,108 @@ gchar localhostname[MAXHOSTNAMELEN]; - if (gethostname (localhostname, MAXHOSTNAMELEN) != 0) { - gmyth_debug ("Error on gethostname"); + if ( gethostname ( localhostname, MAXHOSTNAMELEN ) != 0 ) + { + gmyth_debug ( "Error on gethostname" ); } localhostname[MAXHOSTNAMELEN - 1] = 0; - gint err = gmyth_socket_toaddrinfo (localhostname, -1, &addr_info_data); + gint err = gmyth_socket_toaddrinfo ( localhostname, -1, &addr_info_data ); - if (err == EADDRNOTAVAIL) { - gmyth_debug ("[%s] Address (%s) not available. (reason = %d)\n", - __FUNCTION__, localhostname, err); + if ( err == EADDRNOTAVAIL ) + { + gmyth_debug ( "[%s] Address (%s) not available. (reason = %d)\n", + __FUNCTION__, localhostname, err ); return str; } - g_mutex_lock (gmyth_socket->mutex); + g_mutex_lock ( gmyth_socket->mutex ); addr_info0 = addr_info_data; - while (addr_info0 != NULL && addr_info0->ai_addr != NULL && - (sa = (struct sockaddr_in *) addr_info0->ai_addr) != NULL - && !found_addr) { - localaddr = inet_ntoa (sa->sin_addr); + while ( addr_info0 != NULL && addr_info0->ai_addr != NULL && + ( sa = ( struct sockaddr_in * ) addr_info0->ai_addr ) != NULL + && !found_addr ) + { + localaddr = inet_ntoa ( sa->sin_addr ); - if (localaddr != NULL && (g_strrstr (localaddr, "127") == NULL)) { - str = g_string_new (localaddr); + if ( localaddr != NULL && ( g_strrstr ( localaddr, "127" ) == NULL ) ) + { + str = g_string_new ( localaddr ); found_addr = TRUE; - g_free (localaddr); + g_free ( localaddr ); break; } -/* - if (localaddr != NULL) { - g_free (localaddr); - localaddr = NULL; - } - */ + /* + if (localaddr != NULL) { + g_free (localaddr); + localaddr = NULL; + } + */ addr_info0 = addr_info0->ai_next; }; - freeaddrinfo (addr_info_data); + freeaddrinfo ( addr_info_data ); addr_info_data = NULL; - if (found_addr == FALSE) { - gchar *prim_addr = gmyth_socket_get_primary_addr (); + if ( found_addr == FALSE ) + { + gchar *prim_addr = gmyth_socket_get_primary_addr ( ); - if (prim_addr != NULL) { + if ( prim_addr != NULL ) + { gmyth_debug - ("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n", - __FUNCTION__, prim_addr); + ( "[%s] Could not determine the local alphanumerical hostname. Setting to %s\n", + __FUNCTION__, prim_addr ); - str = g_string_new (prim_addr); - g_free (prim_addr); - } else { - str = g_string_new (localhostname); + str = g_string_new ( prim_addr ); + g_free ( prim_addr ); + } + else + { + str = g_string_new ( localhostname ); } } - g_mutex_unlock (gmyth_socket->mutex); + g_mutex_unlock ( gmyth_socket->mutex ); - if (str != NULL && str->str != NULL) - local_hostname = g_strdup (str->str); + if ( str != NULL && str->str != NULL ) + local_hostname = g_strdup ( str->str ); return str; #endif } static void -gmyth_socket_dispose (GObject * object) +gmyth_socket_dispose ( GObject * object ) { - GMythSocket *gmyth_socket = GMYTH_SOCKET (object); + GMythSocket *gmyth_socket = GMYTH_SOCKET ( object ); /* disconnect socket */ - gmyth_socket_close_connection (gmyth_socket); + gmyth_socket_close_connection ( gmyth_socket ); - g_free (gmyth_socket->hostname); + g_free ( gmyth_socket->hostname ); - g_free (local_hostname); + g_free ( local_hostname ); local_hostname = NULL; - if (gmyth_socket->mutex != NULL) { - g_mutex_free (gmyth_socket->mutex); + if ( gmyth_socket->mutex != NULL ) + { + g_mutex_free ( gmyth_socket->mutex ); gmyth_socket->mutex = NULL; } - G_OBJECT_CLASS (gmyth_socket_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_socket_parent_class )->dispose ( object ); } static void -gmyth_socket_finalize (GObject * object) +gmyth_socket_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_socket_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_socket_parent_class )->finalize ( object ); } /** Creates a new instance of GMythSocket. @@ -370,14 +382,14 @@ * @return a new instance of GMythSocket. */ GMythSocket * -gmyth_socket_new () +gmyth_socket_new ( ) { GMythSocket *gmyth_socket = - GMYTH_SOCKET (g_object_new (GMYTH_SOCKET_TYPE, NULL)); + GMYTH_SOCKET ( g_object_new ( GMYTH_SOCKET_TYPE, NULL ) ); gmyth_socket->mythtv_version = MYTHTV_VERSION_DEFAULT; - gmyth_socket->mutex = g_mutex_new (); + gmyth_socket->mutex = g_mutex_new ( ); return gmyth_socket; } @@ -392,89 +404,97 @@ * @return Any numerical value below 0, if an error had been found. */ static gint -gmyth_socket_try_connect (gint fd, struct sockaddr *remote, gint len, - struct timeval *timeout, gint * err) +gmyth_socket_try_connect ( gint fd, struct sockaddr *remote, gint len, + struct timeval *timeout, gint * err ) { /*g_return_val_if_fail( timeout != NULL, 0 ); */ gint saveflags, ret, back_err; fd_set fd_w; - saveflags = fcntl (fd, F_GETFL, 0); - if (saveflags < 0) { - gmyth_debug ("[%s] Problems when getting socket flags on fcntl.\n", - __FUNCTION__); + saveflags = fcntl ( fd, F_GETFL, 0 ); + if ( saveflags < 0 ) + { + gmyth_debug ( "[%s] Problems when getting socket flags on fcntl.\n", + __FUNCTION__ ); *err = errno; return -1; } /* Set non blocking */ - if (fcntl (fd, F_SETFL, saveflags | O_NONBLOCK) < 0) { - gmyth_debug ("[%s] Problems when setting non-blocking using fcntl.\n", - __FUNCTION__); + if ( fcntl ( fd, F_SETFL, saveflags | O_NONBLOCK ) < 0 ) + { + gmyth_debug ( "[%s] Problems when setting non-blocking using fcntl.\n", + __FUNCTION__ ); *err = errno; return -1; } /* This will return immediately */ - *err = connect (fd, remote, len); + *err = connect ( fd, remote, len ); back_err = errno; /* restore flags */ - if (fcntl (fd, F_SETFL, saveflags) < 0) { + if ( fcntl ( fd, F_SETFL, saveflags ) < 0 ) + { gmyth_debug - ("[%s] Problems when trying to restore flags with fcntl.\n", - __FUNCTION__); + ( "[%s] Problems when trying to restore flags with fcntl.\n", + __FUNCTION__ ); *err = errno; return -1; } /* return unless the connection was successful or the connect is still in progress. */ - if (*err < 0 && back_err != EINPROGRESS) { + if ( *err < 0 && back_err != EINPROGRESS ) + { gmyth_debug - ("[%s] Connection unsucessfully (it is not in progress).\n", - __FUNCTION__); + ( "[%s] Connection unsucessfully (it is not in progress).\n", + __FUNCTION__ ); *err = errno; return -1; } - FD_ZERO (&fd_w); - FD_SET (fd, &fd_w); + FD_ZERO ( &fd_w ); + FD_SET ( fd, &fd_w ); - *err = select (FD_SETSIZE, NULL, &fd_w, NULL, timeout); - if (*err < 0) { - gmyth_debug ("[%s] Connection unsucessfull (timed out).\n", - __FUNCTION__); + *err = select ( FD_SETSIZE, NULL, &fd_w, NULL, timeout ); + if ( *err < 0 ) + { + gmyth_debug ( "[%s] Connection unsucessfull (timed out).\n", + __FUNCTION__ ); *err = errno; return -1; } /* 0 means it timeout out & no fds changed */ - if (*err == 0) { + if ( *err == 0 ) + { gmyth_debug - ("[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n", - __FUNCTION__, *err); - close (fd); + ( "[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n", + __FUNCTION__, *err ); + close ( fd ); *err = ETIMEDOUT; return -1; } /* Get the return code from the connect */ - len = sizeof (ret); - *err = getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, (socklen_t *) & len); + len = sizeof ( ret ); + *err = getsockopt ( fd, SOL_SOCKET, SO_ERROR, &ret, ( socklen_t * ) & len ); - if (*err < 0) { - gmyth_debug ("[%s] Connection unsucessfull.\n", __FUNCTION__); + if ( *err < 0 ) + { + gmyth_debug ( "[%s] Connection unsucessfull.\n", __FUNCTION__ ); *err = errno; return -1; } /* ret=0 means success, otherwise it contains the errno */ - if (ret) { + if ( ret ) + { gmyth_debug - ("[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n", - __FUNCTION__); + ( "[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n", + __FUNCTION__ ); *err = ret; return -1; } @@ -493,15 +513,17 @@ gboolean -gmyth_socket_connect (GMythSocket * gmyth_socket, - const gchar * hostname, gint port) +gmyth_socket_connect ( GMythSocket * gmyth_socket, + const gchar * hostname, gint port ) { - return gmyth_socket_connect_with_timeout (gmyth_socket, hostname, port, 0); + return gmyth_socket_connect_with_timeout ( gmyth_socket, hostname, port, + 0 ); } gboolean -gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket, - const gchar * hostname, gint port, guint timeout) +gmyth_socket_connect_with_timeout ( GMythSocket * gmyth_socket, + const gchar * hostname, gint port, + guint timeout ) { struct addrinfo *addr_info_data = NULL, *addr_info0 = NULL; struct linger ling; @@ -513,109 +535,117 @@ gint errno; gboolean ret = TRUE; - gmyth_debug ("CONNECTING %s:%d", hostname, port); + gmyth_debug ( "CONNECTING %s:%d", hostname, port ); - if (hostname == NULL) - gmyth_debug ("Invalid hostname parameter!\n"); + if ( hostname == NULL ) + gmyth_debug ( "Invalid hostname parameter!\n" ); /* store hostname and port number */ - gmyth_debug ("CONNECTING %s:%d", hostname, port); + gmyth_debug ( "CONNECTING %s:%d", hostname, port ); - errno = gmyth_socket_toaddrinfo (hostname, port, &addr_info_data); + errno = gmyth_socket_toaddrinfo ( hostname, port, &addr_info_data ); - g_return_val_if_fail (addr_info_data != NULL && hostname != NULL, FALSE); + g_return_val_if_fail ( addr_info_data != NULL && hostname != NULL, FALSE ); /* hack to avoid deleting the hostname when * gmyth_socket->hostname == hostname */ tmp_str = gmyth_socket->hostname; - gmyth_socket->hostname = g_strdup (hostname); + gmyth_socket->hostname = g_strdup ( hostname ); gmyth_socket->port = port; - g_free (tmp_str); + g_free ( tmp_str ); - for (addr_info0 = addr_info_data; addr_info0; - addr_info0 = addr_info_data->ai_next) { + for ( addr_info0 = addr_info_data; addr_info0; + addr_info0 = addr_info_data->ai_next ) + { /* init socket descriptor */ gmyth_socket->sd = - socket (addr_info0->ai_family, addr_info0->ai_socktype, - addr_info0->ai_protocol); + socket ( addr_info0->ai_family, addr_info0->ai_socktype, + addr_info0->ai_protocol ); - if (gmyth_socket->sd < 0) + if ( gmyth_socket->sd < 0 ) continue; - struct timeval *timeout_val = g_new0 (struct timeval, 1); + struct timeval *timeout_val = g_new0 ( struct timeval, 1 ); - if (timeout != 0) { + if ( timeout != 0 ) + { timeout_val->tv_sec = timeout; timeout_val->tv_usec = 0; - } else { + } + else + { timeout_val->tv_sec = 5; timeout_val->tv_usec = 100; } - if (gmyth_socket_try_connect - (gmyth_socket->sd, (struct sockaddr *) addr_info0->ai_addr, - addr_info0->ai_addrlen, timeout_val, &ret_code) < 0) { - gmyth_debug ("[%s] Error connecting to backend!\n", __FUNCTION__); - if (ret_code == ETIMEDOUT) - gmyth_debug ("[%s]\tBackend host unreachable!\n", __FUNCTION__); + if ( gmyth_socket_try_connect + ( gmyth_socket->sd, ( struct sockaddr * ) addr_info0->ai_addr, + addr_info0->ai_addrlen, timeout_val, &ret_code ) < 0 ) + { + gmyth_debug ( "[%s] Error connecting to backend!\n", __FUNCTION__ ); + if ( ret_code == ETIMEDOUT ) + gmyth_debug ( "[%s]\tBackend host unreachable!\n", + __FUNCTION__ ); - close (gmyth_socket->sd); + close ( gmyth_socket->sd ); gmyth_socket->sd = -1; - gmyth_debug ("ERROR: %s\n", gai_strerror (ret_code)); - g_free (timeout_val); + gmyth_debug ( "ERROR: %s\n", gai_strerror ( ret_code ) ); + g_free ( timeout_val ); continue; } - g_free (timeout_val); + g_free ( timeout_val ); /* only will be reached if none of the error above occurred */ break; } - freeaddrinfo (addr_info_data); + freeaddrinfo ( addr_info_data ); addr_info_data = NULL; - if (gmyth_socket->sd_io_ch != NULL) { - g_io_channel_unref (gmyth_socket->sd_io_ch); + if ( gmyth_socket->sd_io_ch != NULL ) + { + g_io_channel_unref ( gmyth_socket->sd_io_ch ); gmyth_socket->sd_io_ch = NULL; } - memset (&ling, 0, sizeof (struct linger)); + memset ( &ling, 0, sizeof ( struct linger ) ); ling.l_onoff = TRUE; ling.l_linger = 1; err = - setsockopt (gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling, - sizeof (struct linger)); + setsockopt ( gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling, + sizeof ( struct linger ) ); - if (err < 0) { - gmyth_debug ("[%s] Setting connection unsucessfull.\n", __FUNCTION__); + if ( err < 0 ) + { + gmyth_debug ( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ ); err = errno; ret = FALSE; goto cleanup; } - gmyth_socket->sd_io_ch = g_io_channel_unix_new (gmyth_socket->sd); + gmyth_socket->sd_io_ch = g_io_channel_unix_new ( gmyth_socket->sd ); - g_io_channel_set_close_on_unref (gmyth_socket->sd_io_ch, TRUE); + g_io_channel_set_close_on_unref ( gmyth_socket->sd_io_ch, TRUE ); //g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL ); - GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch); + GIOFlags flags = g_io_channel_get_flags ( gmyth_socket->sd_io_ch ); /* unset the nonblock flag */ flags &= ~G_IO_FLAG_NONBLOCK; /* unset the nonblocking stuff for some time, because GNUTLS doesn't like * that */ - g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL); + g_io_channel_set_flags ( gmyth_socket->sd_io_ch, flags, NULL ); - ret = (ret_code == 0) ? TRUE : FALSE; + ret = ( ret_code == 0 ) ? TRUE : FALSE; cleanup: - if (!ret) - gmyth_debug ("GMythSocket error - return code error!"); + if ( !ret ) + gmyth_debug ( "GMythSocket error - return code error!" ); return ret; } @@ -625,9 +655,9 @@ * @param gmyth_socket The GMythSocket instance. */ GIOChannel * -gmyth_socket_get_io_channel (GMythSocket * gmyth_socket) +gmyth_socket_get_io_channel ( GMythSocket * gmyth_socket ) { - g_return_val_if_fail (gmyth_socket != NULL, NULL); + g_return_val_if_fail ( gmyth_socket != NULL, NULL ); return gmyth_socket->sd_io_ch; } @@ -638,17 +668,18 @@ * @return TRUE if the socket is able to read, FALSE if not. */ gboolean -gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket) +gmyth_socket_is_able_to_read ( GMythSocket * gmyth_socket ) { gboolean ret = TRUE; /* verify if the input (read) buffer is ready to receive data */ GIOCondition io_cond = - g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch); + g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch ); - if ((io_cond & G_IO_IN) == 0) { - gmyth_debug ("[%s] IO channel is not able to send data!\n", - __FUNCTION__); + if ( ( io_cond & G_IO_IN ) == 0 ) + { + gmyth_debug ( "[%s] IO channel is not able to send data!\n", + __FUNCTION__ ); ret = FALSE; } @@ -662,17 +693,18 @@ * @return TRUE if the socket is able to write, FALSE if not. */ gboolean -gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket) +gmyth_socket_is_able_to_write ( GMythSocket * gmyth_socket ) { gboolean ret = TRUE; /* verify if the input (read) buffer is ready to receive data */ GIOCondition io_cond = - g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch); + g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch ); - if (((io_cond & G_IO_OUT) == 0) || ((io_cond & G_IO_HUP) == 0)) { - gmyth_debug ("[%s] IO channel is not able to send data!\n", - __FUNCTION__); + if ( ( ( io_cond & G_IO_OUT ) == 0 ) || ( ( io_cond & G_IO_HUP ) == 0 ) ) + { + gmyth_debug ( "[%s] IO channel is not able to send data!\n", + __FUNCTION__ ); ret = FALSE; } @@ -686,7 +718,7 @@ * @param command The string command to be sent. */ gboolean -gmyth_socket_send_command (GMythSocket * gmyth_socket, GString * command) +gmyth_socket_send_command ( GMythSocket * gmyth_socket, GString * command ) { gboolean ret = TRUE; @@ -699,58 +731,65 @@ gsize bytes_written = 0; - g_return_val_if_fail (gmyth_socket->sd_io_ch != NULL, FALSE); + g_return_val_if_fail ( gmyth_socket->sd_io_ch != NULL, FALSE ); - if (command == NULL || (command->len <= 0) || command->str == NULL) { - gmyth_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__); + if ( command == NULL || ( command->len <= 0 ) || command->str == NULL ) + { + gmyth_debug ( "[%s] Invalid NULL command parameter!\n", __FUNCTION__ ); ret = FALSE; goto done; } - g_mutex_lock (gmyth_socket->mutex); - gmyth_debug ("Sending command to backend: %s\n", command->str); + g_mutex_lock ( gmyth_socket->mutex ); + gmyth_debug ( "Sending command to backend: %s\n", command->str ); - buffer = g_strnfill (BUFLEN, ' '); - g_snprintf (buffer, MYTH_PROTOCOL_FIELD_SIZE + 1, "%-8d", command->len); + buffer = g_strnfill ( BUFLEN, ' ' ); + g_snprintf ( buffer, MYTH_PROTOCOL_FIELD_SIZE + 1, "%-8d", command->len ); - command = g_string_prepend (command, buffer); + command = g_string_prepend ( command, buffer ); /* write bytes to socket */ - io_status = g_io_channel_write_chars (gmyth_socket->sd_io_ch, command->str, - command->len, &bytes_written, &error); + io_status = g_io_channel_write_chars ( gmyth_socket->sd_io_ch, command->str, + command->len, &bytes_written, + &error ); - if ((io_status == G_IO_STATUS_ERROR) || (bytes_written <= 0)) { - gmyth_debug ("[%s] Error while writing to socket", __FUNCTION__); + if ( ( io_status == G_IO_STATUS_ERROR ) || ( bytes_written <= 0 ) ) + { + gmyth_debug ( "[%s] Error while writing to socket", __FUNCTION__ ); ret = FALSE; - } else if (bytes_written < command->len) { - gmyth_debug ("[%s] Not all data was written socket", __FUNCTION__); + } + else if ( bytes_written < command->len ) + { + gmyth_debug ( "[%s] Not all data was written socket", __FUNCTION__ ); ret = FALSE; } - io_status = g_io_channel_flush (gmyth_socket->sd_io_ch, &error); + io_status = g_io_channel_flush ( gmyth_socket->sd_io_ch, &error ); - if ((bytes_written != command->len) - || (io_status == G_IO_STATUS_ERROR)) { + if ( ( bytes_written != command->len ) + || ( io_status == G_IO_STATUS_ERROR ) ) + { gmyth_debug - ("[%s] Some problem occurred when sending data to the socket\n", - __FUNCTION__); + ( "[%s] Some problem occurred when sending data to the socket\n", + __FUNCTION__ ); ret = TRUE; } - g_mutex_unlock (gmyth_socket->mutex); + g_mutex_unlock ( gmyth_socket->mutex ); done: - if (error != NULL) { + if ( error != NULL ) + { gmyth_debug - ("[%s] Error found reading data from IO channel: (%d, %s)\n", - __FUNCTION__, error->code, error->message); + ( "[%s] Error found reading data from IO channel: (%d, %s)\n", + __FUNCTION__, error->code, error->message ); ret = FALSE; - g_error_free (error); + g_error_free ( error ); } - if (buffer != NULL) - g_free (buffer); + if ( buffer != NULL ) + g_free ( buffer ); return ret; } @@ -766,46 +805,54 @@ * backend connection. */ static gboolean -gmyth_socket_connect_to_backend_and_events (GMythSocket * gmyth_socket, - const gchar * hostname_backend, - gint port, gboolean blocking_client, gboolean with_events) +gmyth_socket_connect_to_backend_and_events ( GMythSocket * gmyth_socket, + const gchar * hostname_backend, + gint port, + gboolean blocking_client, + gboolean with_events ) { - if (!gmyth_socket_connect (gmyth_socket, hostname_backend, port)) { - gmyth_debug ("[%s] Could not open socket to backend machine [%s]\n", - __FUNCTION__, hostname_backend); + if ( !gmyth_socket_connect ( gmyth_socket, hostname_backend, port ) ) + { + gmyth_debug ( "[%s] Could not open socket to backend machine [%s]\n", + __FUNCTION__, hostname_backend ); return FALSE; } - if (gmyth_socket_check_protocol_version (gmyth_socket)) { + if ( gmyth_socket_check_protocol_version ( gmyth_socket ) ) + { GString *result; - GString *base_str = g_string_new (""); + GString *base_str = g_string_new ( "" ); GString *hostname = NULL; - hostname = gmyth_socket_get_local_hostname (); - if (hostname == NULL) { - gmyth_debug ("Hostname not available, setting to n800frontend\n"); - hostname = g_string_new ("n800frontend"); + hostname = gmyth_socket_get_local_hostname ( ); + if ( hostname == NULL ) + { + gmyth_debug ( "Hostname not available, setting to n800frontend\n" ); + hostname = g_string_new ( "n800frontend" ); } - g_string_printf (base_str, "ANN %s %s %u", - (blocking_client ? "Playback" : "Monitor"), - hostname->str, with_events); + g_string_printf ( base_str, "ANN %s %s %u", + ( blocking_client ? "Playback" : "Monitor" ), + hostname->str, with_events ); - gmyth_socket_send_command (gmyth_socket, base_str); - result = gmyth_socket_receive_response (gmyth_socket); + gmyth_socket_send_command ( gmyth_socket, base_str ); + result = gmyth_socket_receive_response ( gmyth_socket ); - if (result != NULL) { - gmyth_debug ("Response received from backend: %s", result->str); - g_string_free (result, TRUE); + if ( result != NULL ) + { + gmyth_debug ( "Response received from backend: %s", result->str ); + g_string_free ( result, TRUE ); } - g_string_free (hostname, TRUE); - g_string_free (base_str, TRUE); + g_string_free ( hostname, TRUE ); + g_string_free ( base_str, TRUE ); return TRUE; - } else { - gmyth_debug ("[%s] GMythSocket could not connect to the backend", - __FUNCTION__); + } + else + { + gmyth_debug ( "[%s] GMythSocket could not connect to the backend", + __FUNCTION__ ); return FALSE; } } @@ -819,13 +866,15 @@ * @param blocking_client A flag to choose between blocking and non-blocking */ gboolean -gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket, - const gchar * hostname_backend, gint port, gboolean blocking_client) +gmyth_socket_connect_to_backend ( GMythSocket * gmyth_socket, + const gchar * hostname_backend, gint port, + gboolean blocking_client ) { - if (!gmyth_socket_connect_to_backend_and_events - (gmyth_socket, hostname_backend, port, blocking_client, FALSE)) { - gmyth_debug ("Could not open socket to backend machine [%s]\n", - hostname_backend); + if ( !gmyth_socket_connect_to_backend_and_events + ( gmyth_socket, hostname_backend, port, blocking_client, FALSE ) ) + { + gmyth_debug ( "Could not open socket to backend machine [%s]\n", + hostname_backend ); return FALSE; } @@ -842,14 +891,16 @@ * @param blocking_client A flag to choose between blocking and non-blocking */ gboolean -gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket, - const gchar * hostname_backend, gint port, gboolean blocking_client) +gmyth_socket_connect_to_backend_events ( GMythSocket * gmyth_socket, + const gchar * hostname_backend, + gint port, gboolean blocking_client ) { - if (!gmyth_socket_connect_to_backend_and_events - (gmyth_socket, hostname_backend, port, blocking_client, TRUE)) { + if ( !gmyth_socket_connect_to_backend_and_events + ( gmyth_socket, hostname_backend, port, blocking_client, TRUE ) ) + { gmyth_debug - ("Could not open socket to backend machine in order to receive events [%s]\n", - hostname_backend); + ( "Could not open socket to backend machine in order to receive events [%s]\n", + hostname_backend ); return FALSE; } @@ -861,7 +912,7 @@ * @param gmyth_socket The GMythSocket instance. */ void -gmyth_socket_close_connection (GMythSocket * gmyth_socket) +gmyth_socket_close_connection ( GMythSocket * gmyth_socket ) { /* if ( gmyth_socket->sd != -1 ) { @@ -870,9 +921,10 @@ } */ - if (gmyth_socket->sd_io_ch != NULL) { - g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL); - g_io_channel_unref (gmyth_socket->sd_io_ch); + if ( gmyth_socket->sd_io_ch != NULL ) + { + g_io_channel_shutdown ( gmyth_socket->sd_io_ch, TRUE, NULL ); + g_io_channel_unref ( gmyth_socket->sd_io_ch ); gmyth_socket->sd_io_ch = NULL; gmyth_socket->sd = -1; } @@ -890,8 +942,8 @@ * @return The actual MythTV the client is connected to. */ gint -gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket, - gint mythtv_version) +gmyth_socket_check_protocol_version_number ( GMythSocket * gmyth_socket, + gint mythtv_version ) { GString *response = NULL; GString *payload = NULL; @@ -899,47 +951,54 @@ gint mythtv_new_version = MYTHTV_CANNOT_NEGOTIATE_VERSION; guint max_iterations = MYTHTV_MAX_VERSION_CHECKS; - assert (gmyth_socket); + assert ( gmyth_socket ); try_new_version: - payload = g_string_new ("MYTH_PROTO_VERSION"); - g_string_append_printf (payload, " %d", mythtv_version); + payload = g_string_new ( "MYTH_PROTO_VERSION" ); + g_string_append_printf ( payload, " %d", mythtv_version ); - gmyth_socket_send_command (gmyth_socket, payload); - response = gmyth_socket_receive_response (gmyth_socket); + gmyth_socket_send_command ( gmyth_socket, payload ); + response = gmyth_socket_receive_response ( gmyth_socket ); - if (response == NULL) { - gmyth_debug ("[%s] Check protocol version error! Not answered!", - __FUNCTION__); + if ( response == NULL ) + { + gmyth_debug ( "[%s] Check protocol version error! Not answered!", + __FUNCTION__ ); res = FALSE; goto done; } - res = g_str_has_prefix (response->str, "ACCEPT"); - if (!res) { - gmyth_debug ("[%s] Protocol version request error: %s", __FUNCTION__, - response->str); + res = g_str_has_prefix ( response->str, "ACCEPT" ); + if ( !res ) + { + gmyth_debug ( "[%s] Protocol version request error: %s", __FUNCTION__, + response->str ); /* get the version number returned by the REJECT message */ - if ((res = g_str_has_prefix (response->str, "REJECT")) == TRUE) { + if ( ( res = g_str_has_prefix ( response->str, "REJECT" ) ) == TRUE ) + { gchar *new_version = NULL; - new_version = g_strrstr (response->str, "]"); - if (new_version != NULL) { + new_version = g_strrstr ( response->str, "]" ); + if ( new_version != NULL ) + { ++new_version; /* skip ']' character */ - if (new_version != NULL) { - gmyth_debug ("[%s] got MythTV version = %s.\n", - __FUNCTION__, new_version); + if ( new_version != NULL ) + { + gmyth_debug ( "[%s] got MythTV version = %s.\n", + __FUNCTION__, new_version ); mythtv_version = - (gint) g_ascii_strtoull (new_version, NULL, 10); + ( gint ) g_ascii_strtoull ( new_version, NULL, 10 ); /* do reconnection to the socket (socket is closed if the MythTV version was wrong) */ - gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname, - gmyth_socket->port); + gmyth_socket_connect ( gmyth_socket, gmyth_socket->hostname, + gmyth_socket->port ); new_version = NULL; - if (--max_iterations > 0) { - g_string_free (payload, TRUE); - g_string_free (response, TRUE); + if ( --max_iterations > 0 ) + { + g_string_free ( payload, TRUE ); + g_string_free ( response, TRUE ); goto try_new_version; - } else + } + else goto done; } } @@ -947,14 +1006,15 @@ } /* change the return value to a valid one */ - if (res) { + if ( res ) + { mythtv_new_version = mythtv_version; gmyth_socket->mythtv_version = mythtv_new_version; } done: - g_string_free (payload, TRUE); - g_string_free (response, TRUE); + g_string_free ( payload, TRUE ); + g_string_free ( response, TRUE ); return mythtv_new_version; } @@ -965,12 +1025,12 @@ * @return TRUE if supports, FALSE if not. */ gboolean -gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket) +gmyth_socket_check_protocol_version ( GMythSocket * gmyth_socket ) { - return ((gmyth_socket->mythtv_version = - gmyth_socket_check_protocol_version_number (gmyth_socket, - MYTHTV_VERSION_DEFAULT)) - != MYTHTV_CANNOT_NEGOTIATE_VERSION); + return ( ( gmyth_socket->mythtv_version = + gmyth_socket_check_protocol_version_number ( gmyth_socket, + MYTHTV_VERSION_DEFAULT ) ) + != MYTHTV_CANNOT_NEGOTIATE_VERSION ); } /** Returns the Mythtv backend supported version. @@ -979,7 +1039,7 @@ * @return The actual MythTV version number. */ gint -gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket) +gmyth_socket_get_protocol_version ( GMythSocket * gmyth_socket ) { return gmyth_socket->mythtv_version; } @@ -990,7 +1050,7 @@ * @return The response received, or NULL if error or nothing was received. */ GString * -gmyth_socket_receive_response (GMythSocket * gmyth_socket) +gmyth_socket_receive_response ( GMythSocket * gmyth_socket ) { GIOStatus io_status = G_IO_STATUS_NORMAL; GError *error = NULL; @@ -1001,48 +1061,53 @@ gsize bytes_read = 0; gint len = 0; - if (gmyth_socket == NULL) + if ( gmyth_socket == NULL ) return NULL; GIOCondition io_cond; /* verify if the input (read) buffer is ready to receive data */ - g_mutex_lock (gmyth_socket->mutex); + g_mutex_lock ( gmyth_socket->mutex ); - buffer = g_strnfill (MYTH_PROTOCOL_FIELD_SIZE, ' '); - if (NULL == gmyth_socket->sd_io_ch) { - gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname, - gmyth_socket->port); + buffer = g_strnfill ( MYTH_PROTOCOL_FIELD_SIZE, ' ' ); + if ( NULL == gmyth_socket->sd_io_ch ) + { + gmyth_socket_connect ( gmyth_socket, gmyth_socket->hostname, + gmyth_socket->port ); } - io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch); + io_cond = g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch ); /* if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) ) gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd ); */ - if (gmyth_socket->sd_io_ch-> - is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 ) */ ) + if ( gmyth_socket->sd_io_ch-> + is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 ) */ ) io_status = - g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer, - MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, &error); + g_io_channel_read_chars ( gmyth_socket->sd_io_ch, buffer, + MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, + &error ); else - return g_string_new (""); + return g_string_new ( "" ); /* verify if the input (read) buffer is ready to receive data */ - io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch); + io_cond = g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch ); //if ( ( io_cond & G_IO_IN ) == 0 ) // return NULL; - gmyth_debug ("[%s] Bytes read = %d\n", __FUNCTION__, bytes_read); + gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read ); - if ((io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0)) { - gmyth_debug ("[%s] Error in mythprotocol response from backend\n", - __FUNCTION__); + if ( ( io_status == G_IO_STATUS_ERROR ) || ( bytes_read <= 0 ) ) + { + gmyth_debug ( "[%s] Error in mythprotocol response from backend\n", + __FUNCTION__ ); str = NULL; //return NULL; - } else if (buffer != NULL && strlen (buffer) > 0) { + } + else if ( buffer != NULL && strlen ( buffer ) > 0 ) + { //io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error ); /* verify if the input (read) buffer is ready to receive data */ @@ -1053,9 +1118,9 @@ /* removes trailing whitespace */ //buffer_aux = g_strstrip (buffer); - len = (gint) g_ascii_strtoull (g_strstrip (buffer), NULL, 10); + len = ( gint ) g_ascii_strtoull ( g_strstrip ( buffer ), NULL, 10 ); - g_free (buffer); + g_free ( buffer ); /* if (buffer_aux != NULL) { @@ -1064,41 +1129,42 @@ } */ - buffer = g_new0 (gchar, len + 1); + buffer = g_new0 ( gchar, len + 1 ); bytes_read = 0; - if (!(gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL)) + if ( !( gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL ) ) return NULL; - if (gmyth_socket->sd_io_ch->is_readable) + if ( gmyth_socket->sd_io_ch->is_readable ) io_status = - g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer, len, - &bytes_read, &error); + g_io_channel_read_chars ( gmyth_socket->sd_io_ch, buffer, len, + &bytes_read, &error ); else - return g_string_new (""); + return g_string_new ( "" ); buffer[bytes_read] = '\0'; //} } - g_mutex_unlock (gmyth_socket->mutex); + g_mutex_unlock ( gmyth_socket->mutex ); //g_static_rw_lock_reader_unlock (&rwlock); - gmyth_debug ("Response received from backend: ----- {%s}\n", buffer); - if ((bytes_read != len) || (io_status == G_IO_STATUS_ERROR)) + gmyth_debug ( "Response received from backend: ----- {%s}\n", buffer ); + if ( ( bytes_read != len ) || ( io_status == G_IO_STATUS_ERROR ) ) str = NULL; else - str = g_string_new (buffer); + str = g_string_new ( buffer ); - if (error != NULL) { + if ( error != NULL ) + { gmyth_debug - ("[%s] Error found receiving response from the IO channel: (%d, %s)\n", - __FUNCTION__, error->code, error->message); + ( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", + __FUNCTION__, error->code, error->message ); str = NULL; - g_error_free (error); + g_error_free ( error ); } - g_free (buffer); + g_free ( buffer ); return str; } @@ -1109,49 +1175,56 @@ * @return TRUE if command was sent, FALSE if any error happens. */ gboolean -gmyth_socket_write_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list) +gmyth_socket_write_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ) { GList *tmp_list = NULL; GPtrArray *ptr_array = NULL; gchar *str_array = NULL; - g_mutex_lock (gmyth_socket->mutex); + g_mutex_lock ( gmyth_socket->mutex ); //g_static_rw_lock_writer_lock (&rwlock); - ptr_array = g_ptr_array_sized_new (g_list_length (str_list->glist)); + ptr_array = g_ptr_array_sized_new ( g_list_length ( str_list->glist ) ); // FIXME: change this implementation! tmp_list = str_list->glist; - for (; tmp_list; tmp_list = tmp_list->next) { - if (tmp_list->data != NULL) { - g_ptr_array_add (ptr_array, ((GString *) tmp_list->data)->str); - } else { - g_ptr_array_add (ptr_array, ""); + for ( ; tmp_list; tmp_list = tmp_list->next ) + { + if ( tmp_list->data != NULL ) + { + g_ptr_array_add ( ptr_array, + ( ( GString * ) tmp_list->data )->str ); + } + else + { + g_ptr_array_add ( ptr_array, "" ); } } - g_ptr_array_add (ptr_array, NULL); // g_str_joinv() needs a NULL terminated string + g_ptr_array_add ( ptr_array, NULL ); // g_str_joinv() needs a NULL terminated string - str_array = g_strjoinv (MYTH_SEPARATOR, (gchar **) (ptr_array->pdata)); + str_array = + g_strjoinv ( MYTH_SEPARATOR, ( gchar ** ) ( ptr_array->pdata ) ); - g_mutex_unlock (gmyth_socket->mutex); + g_mutex_unlock ( gmyth_socket->mutex ); //g_static_rw_lock_writer_unlock (&rwlock); - gmyth_debug ("[%s] Sending socket request: %s\n", __FUNCTION__, str_array); + gmyth_debug ( "[%s] Sending socket request: %s\n", __FUNCTION__, + str_array ); // Sends message to backend // TODO: implement looping to send remaining data, and add timeout testing! - GString *command = g_string_new (str_array); + GString *command = g_string_new ( str_array ); - gmyth_socket_send_command (gmyth_socket, command); + gmyth_socket_send_command ( gmyth_socket, command ); - g_string_free (command, TRUE); + g_string_free ( command, TRUE ); - g_free (str_array); + g_free ( str_array ); /* ptr_array is pointing to data inside str_list->glist */ - g_ptr_array_free (ptr_array, TRUE); + g_ptr_array_free ( ptr_array, TRUE ); return TRUE; } @@ -1163,34 +1236,36 @@ * @return The number of received strings. */ gint -gmyth_socket_read_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list) +gmyth_socket_read_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ) { GString *response; gint i; - gmyth_string_list_clear_all (str_list); + gmyth_string_list_clear_all ( str_list ); - response = gmyth_socket_receive_response (gmyth_socket); - if (response != NULL && response->str != NULL && response->len > 0) { + response = gmyth_socket_receive_response ( gmyth_socket ); + if ( response != NULL && response->str != NULL && response->len > 0 ) + { gchar **str_array; - g_mutex_lock (gmyth_socket->mutex); + g_mutex_lock ( gmyth_socket->mutex ); - str_array = g_strsplit (response->str, MYTH_SEPARATOR, -1); + str_array = g_strsplit ( response->str, MYTH_SEPARATOR, -1 ); - for (i = 0; i < g_strv_length (str_array); i++) { + for ( i = 0; i < g_strv_length ( str_array ); i++ ) + { //if ( str_array[i] != NULL && strlen( str_array[i] ) > 0 ) - gmyth_string_list_append_char_array (str_list, str_array[i]); + gmyth_string_list_append_char_array ( str_list, str_array[i] ); } - g_mutex_unlock (gmyth_socket->mutex); - g_strfreev (str_array); + g_mutex_unlock ( gmyth_socket->mutex ); + g_strfreev ( str_array ); } - g_string_free (response, TRUE); + g_string_free ( response, TRUE ); - return gmyth_string_list_length (str_list); + return gmyth_string_list_length ( str_list ); } /** Formats a Mythtv protocol command based on str_list and sends it to @@ -1203,10 +1278,10 @@ * error happens. */ gint -gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list) +gmyth_socket_sendreceive_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ) { - gmyth_socket_write_stringlist (gmyth_socket, str_list); + gmyth_socket_write_stringlist ( gmyth_socket, str_list ); - return gmyth_socket_read_stringlist (gmyth_socket, str_list); + return gmyth_socket_read_stringlist ( gmyth_socket, str_list ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_socket.h --- a/gmyth/src/gmyth_socket.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_socket.h Wed May 23 19:50:41 2007 +0100 @@ -13,22 +13,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Lins Borges * - *//* - * - * 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 - */ + * + * 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_SOCKET_H__ #define __GMYTH_SOCKET_H__ @@ -54,72 +53,77 @@ typedef struct _GMythSocketClass GMythSocketClass; struct _GMythSocketClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythSocket -{ - GObject parent; + { + GObject parent; - GMutex *mutex; + GMutex *mutex; - /* socket descriptor */ - gint sd; - GIOChannel *sd_io_ch; + /* socket descriptor */ + gint sd; + GIOChannel *sd_io_ch; - gchar *hostname; - gint port; - gint mythtv_version; -}; + gchar *hostname; + gint port; + gint mythtv_version; + }; /* used when no protocol version number was negotiated */ #define MYTHTV_CANNOT_NEGOTIATE_VERSION 0 -GType gmyth_socket_get_type (void); +GType gmyth_socket_get_type ( void ); -GMythSocket *gmyth_socket_new (); +GMythSocket *gmyth_socket_new ( ); -GIOChannel *gmyth_socket_get_io_channel (GMythSocket * gmyth_socket); +GIOChannel *gmyth_socket_get_io_channel ( GMythSocket * gmyth_socket ); -gboolean gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket); -gboolean gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket); +gboolean gmyth_socket_is_able_to_read ( GMythSocket * gmyth_socket ); +gboolean gmyth_socket_is_able_to_write ( GMythSocket * gmyth_socket ); -gboolean gmyth_socket_send_command (GMythSocket * gmyth_socket, - GString * command); -GString *gmyth_socket_receive_response (GMythSocket * gmyth_socket); -gint gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list); +gboolean gmyth_socket_send_command ( GMythSocket * gmyth_socket, + GString * command ); +GString *gmyth_socket_receive_response ( GMythSocket * gmyth_socket ); +gint gmyth_socket_sendreceive_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ); -gboolean gmyth_socket_connect (GMythSocket * gmyth_socket, - const gchar * hostname, gint port); -gboolean gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket, - const gchar * hostname, gint port, guint timeout); +gboolean gmyth_socket_connect ( GMythSocket * gmyth_socket, + const gchar * hostname, gint port ); +gboolean gmyth_socket_connect_with_timeout ( GMythSocket * gmyth_socket, + const gchar * hostname, gint port, + guint timeout ); -gboolean gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket, - const gchar * hostname_backend, gint port, gboolean blocking_client); +gboolean gmyth_socket_connect_to_backend ( GMythSocket * gmyth_socket, + const gchar * hostname_backend, + gint port, + gboolean blocking_client ); -gboolean gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket, - const gchar * hostname_backend, gint port, gboolean blocking_client); +gboolean gmyth_socket_connect_to_backend_events ( GMythSocket * gmyth_socket, + const gchar * + hostname_backend, gint port, + gboolean blocking_client ); -gchar *gmyth_socket_get_primary_addr (void); +gchar *gmyth_socket_get_primary_addr ( void ); -GString *gmyth_socket_get_local_hostname (void); +GString *gmyth_socket_get_local_hostname ( void ); -void gmyth_socket_close_connection (GMythSocket * gmyth_socket); +void gmyth_socket_close_connection ( GMythSocket * gmyth_socket ); -gboolean gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket); -gint gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket, - gint mythtv_version); +gboolean gmyth_socket_check_protocol_version ( GMythSocket * gmyth_socket ); +gint gmyth_socket_check_protocol_version_number ( GMythSocket * gmyth_socket, + gint mythtv_version ); -gint gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket); +gint gmyth_socket_get_protocol_version ( GMythSocket * gmyth_socket ); -gboolean gmyth_socket_write_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list); -gint gmyth_socket_read_stringlist (GMythSocket * gmyth_socket, - GMythStringList * str_list); +gboolean gmyth_socket_write_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ); +gint gmyth_socket_read_stringlist ( GMythSocket * gmyth_socket, + GMythStringList * str_list ); G_END_DECLS #endif /* __GMYTH_SOCKET_H__ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_stringlist.c --- a/gmyth/src/gmyth_stringlist.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_stringlist.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Hallyson Luiz de Morais Melo * - *//* - * - * 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 - */ + * + * 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" @@ -34,47 +33,47 @@ #include "gmyth_debug.h" -static void gmyth_string_list_class_init (GMythStringListClass * klass); -static void gmyth_string_list_init (GMythStringList * object); +static void gmyth_string_list_class_init ( GMythStringListClass * klass ); +static void gmyth_string_list_init ( GMythStringList * object ); -static void gmyth_string_list_dispose (GObject * object); -static void gmyth_string_list_finalize (GObject * object); +static void gmyth_string_list_dispose ( GObject * object ); +static void gmyth_string_list_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythStringList, gmyth_string_list, G_TYPE_OBJECT) - static void gmyth_string_list_class_init (GMythStringListClass * klass) +G_DEFINE_TYPE ( GMythStringList, gmyth_string_list, G_TYPE_OBJECT ) + static void gmyth_string_list_class_init ( GMythStringListClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_string_list_dispose; gobject_class->finalize = gmyth_string_list_finalize; } static void -gmyth_string_list_init (GMythStringList * gmyth_string_list) +gmyth_string_list_init ( GMythStringList * gmyth_string_list ) { gmyth_string_list->glist = NULL; } static void -gmyth_string_list_dispose (GObject * object) +gmyth_string_list_dispose ( GObject * object ) { - GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (object); + GMythStringList *gmyth_string_list = GMYTH_STRING_LIST ( object ); - gmyth_string_list_clear_all (gmyth_string_list); + gmyth_string_list_clear_all ( gmyth_string_list ); - G_OBJECT_CLASS (gmyth_string_list_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_string_list_parent_class )->dispose ( object ); } static void -gmyth_string_list_finalize (GObject * object) +gmyth_string_list_finalize ( GObject * object ) { //GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object); - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_string_list_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_string_list_parent_class )->finalize ( object ); } /** Creates a new instance of GStringList. @@ -82,10 +81,10 @@ * @return a new instance of GStringList. */ GMythStringList * -gmyth_string_list_new () +gmyth_string_list_new ( ) { GMythStringList *gmyth_string_list = - GMYTH_STRING_LIST (g_object_new (GMYTH_STRING_LIST_TYPE, NULL)); + GMYTH_STRING_LIST ( g_object_new ( GMYTH_STRING_LIST_TYPE, NULL ) ); return gmyth_string_list; } @@ -98,13 +97,13 @@ * @return The appended guint64 converted to a GString object. */ GString * -gmyth_string_list_append_int (GMythStringList * strlist, const gint value) +gmyth_string_list_append_int ( GMythStringList * strlist, const gint value ) { - GString *value_str = g_string_new (""); + GString *value_str = g_string_new ( "" ); - g_string_printf (value_str, "%d", value); + g_string_printf ( value_str, "%d", value ); - strlist->glist = g_list_append (strlist->glist, value_str); + strlist->glist = g_list_append ( strlist->glist, value_str ); return value_str; } @@ -117,29 +116,30 @@ * @return The appended guint64 converted to a GString object. */ GString * -gmyth_string_list_append_uint64 (GMythStringList * strlist, const guint64 value) +gmyth_string_list_append_uint64 ( GMythStringList * strlist, + const guint64 value ) { - GString *tmp_str1 = g_string_new (""); - GString *tmp_str2 = g_string_new (""); + GString *tmp_str1 = g_string_new ( "" ); + GString *tmp_str2 = g_string_new ( "" ); - gmyth_debug ("value = %llu.\n", value); + gmyth_debug ( "value = %llu.\n", value ); - gulong l2 = ((guint64) value & 0xffffffff); - gulong l1 = ((guint64) value >> 32); + gulong l2 = ( ( guint64 ) value & 0xffffffff ); + gulong l1 = ( ( guint64 ) value >> 32 ); /* high order part of guint64 value */ - g_string_printf (tmp_str1, "%lu", l1); + g_string_printf ( tmp_str1, "%lu", l1 ); - gmyth_debug ("[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str); + gmyth_debug ( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str ); - strlist->glist = g_list_append (strlist->glist, tmp_str1); + strlist->glist = g_list_append ( strlist->glist, tmp_str1 ); /* low order part of guint64 value */ - g_string_printf (tmp_str2, "%lu", l2); + g_string_printf ( tmp_str2, "%lu", l2 ); - gmyth_debug ("[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str); + gmyth_debug ( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str ); - strlist->glist = g_list_append (strlist->glist, tmp_str2); + strlist->glist = g_list_append ( strlist->glist, tmp_str2 ); return tmp_str2; } @@ -152,29 +152,29 @@ * @return The appended gint64 converted to a GString object. */ GString * -gmyth_string_list_append_int64 (GMythStringList * strlist, const gint64 value) +gmyth_string_list_append_int64 ( GMythStringList * strlist, const gint64 value ) { - GString *tmp_str1 = g_string_new (""); - GString *tmp_str2 = g_string_new (""); + GString *tmp_str1 = g_string_new ( "" ); + GString *tmp_str2 = g_string_new ( "" ); - gmyth_debug ("value = %lld.\n", value); + gmyth_debug ( "value = %lld.\n", value ); - glong l2 = ((gint64) value & 0xffffffff); - glong l1 = ((gint64) value >> 32); + glong l2 = ( ( gint64 ) value & 0xffffffff ); + glong l1 = ( ( gint64 ) value >> 32 ); /* high order part of gint64 value */ - g_string_printf (tmp_str1, "%ld", l1); + g_string_printf ( tmp_str1, "%ld", l1 ); - gmyth_debug ("[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str); + gmyth_debug ( "[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str ); - strlist->glist = g_list_append (strlist->glist, tmp_str1); + strlist->glist = g_list_append ( strlist->glist, tmp_str1 ); /* low order part of gint64 value */ - g_string_printf (tmp_str2, "%ld", l2); + g_string_printf ( tmp_str2, "%ld", l2 ); - gmyth_debug ("[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str); + gmyth_debug ( "[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str ); - strlist->glist = g_list_append (strlist->glist, tmp_str2); + strlist->glist = g_list_append ( strlist->glist, tmp_str2 ); return tmp_str2; } @@ -187,16 +187,16 @@ * @return The appended char array converted to a GString object. */ GString * -gmyth_string_list_append_char_array (GMythStringList * strlist, - const gchar * value) +gmyth_string_list_append_char_array ( GMythStringList * strlist, + const gchar * value ) { GString *tmp_str = NULL; - g_return_val_if_fail (strlist != NULL, NULL); + g_return_val_if_fail ( strlist != NULL, NULL ); - tmp_str = g_string_new (value); + tmp_str = g_string_new ( value ); - strlist->glist = g_list_append (strlist->glist, tmp_str); + strlist->glist = g_list_append ( strlist->glist, tmp_str ); return tmp_str; } @@ -209,15 +209,18 @@ * @return The appended string itself. */ GString * -gmyth_string_list_append_string (GMythStringList * strlist, GString * value) +gmyth_string_list_append_string ( GMythStringList * strlist, GString * value ) { - g_return_val_if_fail (strlist != NULL, NULL); + g_return_val_if_fail ( strlist != NULL, NULL ); - if (value != NULL) { + if ( value != NULL ) + { strlist->glist = - g_list_append (strlist->glist, g_string_new (value->str)); - } else { - strlist->glist = g_list_append (strlist->glist, NULL); + g_list_append ( strlist->glist, g_string_new ( value->str ) ); + } + else + { + strlist->glist = g_list_append ( strlist->glist, NULL ); } return value; @@ -230,20 +233,21 @@ * @return The integer value. */ gint -gmyth_string_list_get_int (GMythStringList * strlist, const gint index) +gmyth_string_list_get_int ( GMythStringList * strlist, const gint index ) { //TODO: Create static method check_index() GString *tmp_str = NULL; - g_return_val_if_fail (strlist != NULL, 0); + g_return_val_if_fail ( strlist != NULL, 0 ); - tmp_str = (GString *) g_list_nth_data (strlist->glist, index); + tmp_str = ( GString * ) g_list_nth_data ( strlist->glist, index ); - if (NULL == tmp_str || NULL == tmp_str->str || strlen (tmp_str->str) <= 0) + if ( NULL == tmp_str || NULL == tmp_str->str + || strlen ( tmp_str->str ) <= 0 ) return 0; - return (gint) ( /* 0x00000000ffffffffL & (gint64) */ - g_ascii_strtoull (tmp_str->str, NULL, 10)); + return ( gint ) ( /* 0x00000000ffffffffL & (gint64) */ + g_ascii_strtoull ( tmp_str->str, NULL, 10 ) ); } /** Gets a guint64 value from the string list at the given position. @@ -256,45 +260,54 @@ * @return The guint64 value. */ guint64 -gmyth_string_list_get_uint64 (GMythStringList * strlist, const gint index) +gmyth_string_list_get_uint64 ( GMythStringList * strlist, const gint index ) { //TODO: Create static method check_index() guint64 ret_value = 0; guint64 l2 = 0; - g_return_val_if_fail (strlist != NULL, 0); + g_return_val_if_fail ( strlist != NULL, 0 ); const GString *tmp_str1 = - (GString *) g_list_nth_data (strlist->glist, index); + ( GString * ) g_list_nth_data ( strlist->glist, index ); const GString *tmp_str2 = - (GString *) g_list_nth_data (strlist->glist, index + 1); + ( GString * ) g_list_nth_data ( strlist->glist, index + 1 ); - if (tmp_str1 != NULL) - gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__, - tmp_str1->str); - if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) { - } else { - gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str); + if ( tmp_str1 != NULL ) + gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__, + tmp_str1->str ); + if ( tmp_str2 == NULL || strlen ( tmp_str2->str ) > 0 ) + { + } + else + { + gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__, + tmp_str2->str ); } - guint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff */ - ); + guint64 l1 = ( ( guint64 ) g_ascii_strtoull ( tmp_str1->str, NULL, 10 ) /*& 0xffffffff */ + ); - if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) { - l2 = ((guint64) g_ascii_strtoull (tmp_str2->str, NULL, 10) - /*& 0xffffffff */ - ); - } else { + if ( tmp_str2 != NULL && tmp_str2->str != NULL + && strlen ( tmp_str2->str ) > 0 ) + { + l2 = ( ( guint64 ) g_ascii_strtoull ( tmp_str2->str, NULL, 10 ) + /*& 0xffffffff */ + ); + } + else + { l2 = l1; l1 = 0; } - gmyth_debug ("[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2); + gmyth_debug ( "[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2 ); - ret_value = ((guint64) (l2) /*& 0xffffffff */ ) | ((guint64) l1 << 32); + ret_value = + ( ( guint64 ) ( l2 ) /*& 0xffffffff */ ) | ( ( guint64 ) l1 << 32 ); - gmyth_debug ("[%s] returning uint64 value = %llu\n", __FUNCTION__, - ret_value); + gmyth_debug ( "[%s] returning uint64 value = %llu\n", __FUNCTION__, + ret_value ); return ret_value; } @@ -309,45 +322,54 @@ * @return The gint64 value. */ gint64 -gmyth_string_list_get_int64 (GMythStringList * strlist, const gint index) +gmyth_string_list_get_int64 ( GMythStringList * strlist, const gint index ) { //TODO: Create static method check_index() gint64 ret_value = 0; gint64 l2 = 0; - g_return_val_if_fail (strlist != NULL, 0); + g_return_val_if_fail ( strlist != NULL, 0 ); const GString *tmp_str1 = - (GString *) g_list_nth_data (strlist->glist, index); + ( GString * ) g_list_nth_data ( strlist->glist, index ); const GString *tmp_str2 = - (GString *) g_list_nth_data (strlist->glist, index + 1); + ( GString * ) g_list_nth_data ( strlist->glist, index + 1 ); - if (tmp_str1 != NULL) - gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__, - tmp_str1->str); - if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) { - } else { - gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str); + if ( tmp_str1 != NULL ) + gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__, + tmp_str1->str ); + if ( tmp_str2 == NULL || strlen ( tmp_str2->str ) > 0 ) + { + } + else + { + gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__, + tmp_str2->str ); } - gint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff */ - ); + gint64 l1 = ( ( guint64 ) g_ascii_strtoull ( tmp_str1->str, NULL, 10 ) /*& 0xffffffff */ + ); - if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) { - l2 = ((gint64) g_ascii_strtoull (tmp_str2->str, NULL, 10) - /*& 0xffffffff */ - ); - } else { + if ( tmp_str2 != NULL && tmp_str2->str != NULL + && strlen ( tmp_str2->str ) > 0 ) + { + l2 = ( ( gint64 ) g_ascii_strtoull ( tmp_str2->str, NULL, 10 ) + /*& 0xffffffff */ + ); + } + else + { l2 = l1; l1 = 0; } - gmyth_debug ("[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2); + gmyth_debug ( "[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2 ); - ret_value = ((gint64) (l2) /*& 0xffffffff */ ) | ((gint64) l1 << 32); + ret_value = + ( ( gint64 ) ( l2 ) /*& 0xffffffff */ ) | ( ( gint64 ) l1 << 32 ); - gmyth_debug ("[%s] returning int64 value = %lld\n", __FUNCTION__, - ret_value); + gmyth_debug ( "[%s] returning int64 value = %lld\n", __FUNCTION__, + ret_value ); return ret_value; } @@ -360,26 +382,27 @@ * @return A pointer to the string data. */ GString * -gmyth_string_list_get_string (GMythStringList * strlist, const gint index) +gmyth_string_list_get_string ( GMythStringList * strlist, const gint index ) { GString *ret; - if (!strlist || !(strlist->glist)) { - gmyth_debug ("%s received Null arguments", __FUNCTION__); + if ( !strlist || !( strlist->glist ) ) + { + gmyth_debug ( "%s received Null arguments", __FUNCTION__ ); return NULL; } - ret = (GString *) g_list_nth_data (strlist->glist, index); + ret = ( GString * ) g_list_nth_data ( strlist->glist, index ); - return g_string_new (ret->str); + return g_string_new ( ret->str ); } static void -gmyth_string_list_clear_element (GString * str_elem, void *data_aux) +gmyth_string_list_clear_element ( GString * str_elem, void *data_aux ) { - if (str_elem != NULL) - g_string_free (str_elem, TRUE); + if ( str_elem != NULL ) + g_string_free ( str_elem, TRUE ); } /** Removes all strings from the string list. @@ -387,12 +410,13 @@ * @param strlist The GMythStringList instance. */ void -gmyth_string_list_clear_all (GMythStringList * strlist) +gmyth_string_list_clear_all ( GMythStringList * strlist ) { - if (strlist != NULL && strlist->glist) { - g_list_foreach (strlist->glist, - (GFunc) gmyth_string_list_clear_element, NULL); - g_list_free (strlist->glist); + if ( strlist != NULL && strlist->glist ) + { + g_list_foreach ( strlist->glist, + ( GFunc ) gmyth_string_list_clear_element, NULL ); + g_list_free ( strlist->glist ); strlist->glist = NULL; } } @@ -403,10 +427,10 @@ * @return the string list length. */ gint -gmyth_string_list_length (GMythStringList * strlist) +gmyth_string_list_length ( GMythStringList * strlist ) { - if (!(strlist != NULL && strlist->glist != NULL)) + if ( !( strlist != NULL && strlist->glist != NULL ) ) return 0; - return g_list_length (strlist->glist); + return g_list_length ( strlist->glist ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_stringlist.h --- a/gmyth/src/gmyth_stringlist.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_stringlist.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Hallyson Luiz de Morais Melo * - *//* - * - * 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 - */ + * + * 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_STRING_LIST_H_ #define GMYTH_STRING_LIST_H_ @@ -49,52 +48,52 @@ typedef struct _GMythStringListClass GMythStringListClass; struct _GMythStringListClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythStringList -{ - GObject parent; + { + GObject parent; - /* string list */ - GList *glist; -}; + /* string list */ + GList *glist; + }; -GType gmyth_string_list_get_type (void); +GType gmyth_string_list_get_type ( void ); -GMythStringList *gmyth_string_list_new (void); +GMythStringList *gmyth_string_list_new ( void ); -void gmyth_string_list_clear_all (GMythStringList * strlist); -int gmyth_string_list_length (GMythStringList * strlist); +void gmyth_string_list_clear_all ( GMythStringList * strlist ); +int gmyth_string_list_length ( GMythStringList * strlist ); -GString *gmyth_string_list_append_int (GMythStringList * strlist, - const gint value); -GString *gmyth_string_list_append_uint64 (GMythStringList * strlist, - const guint64 value); +GString *gmyth_string_list_append_int ( GMythStringList * strlist, + const gint value ); +GString *gmyth_string_list_append_uint64 ( GMythStringList * strlist, + const guint64 value ); -GString *gmyth_string_list_append_int64 (GMythStringList * strlist, - const gint64 value); +GString *gmyth_string_list_append_int64 ( GMythStringList * strlist, + const gint64 value ); -GString *gmyth_string_list_append_char_array (GMythStringList * strlist, - const char *value); -GString *gmyth_string_list_append_string (GMythStringList * strlist, - GString * value); +GString *gmyth_string_list_append_char_array ( GMythStringList * strlist, + const char *value ); +GString *gmyth_string_list_append_string ( GMythStringList * strlist, + GString * value ); -int gmyth_string_list_get_int (GMythStringList * strlist, const gint index); -guint64 gmyth_string_list_get_uint64 (GMythStringList * strlist, - const gint index); -gint64 gmyth_string_list_get_int64 (GMythStringList * strlist, - const gint index); -GString *gmyth_string_list_get_string (GMythStringList * strlist, - const gint index); +int gmyth_string_list_get_int ( GMythStringList * strlist, const gint index ); +guint64 gmyth_string_list_get_uint64 ( GMythStringList * strlist, + const gint index ); +gint64 gmyth_string_list_get_int64 ( GMythStringList * strlist, + const gint index ); +GString *gmyth_string_list_get_string ( GMythStringList * strlist, + const gint index ); #define gmyth_string_list_get_char_array(strlist, index) \ - (gmyth_string_list_get_string(strlist, index))->str + (gmyth_string_list_get_string(strlist, index))->str G_END_DECLS #endif /*GMYTH_STRING_LIST_H_ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_transcoder.c --- a/gmyth/src/gmyth_transcoder.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_transcoder.c Wed May 23 19:50:41 2007 +0100 @@ -8,8 +8,6 @@ * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza * - */ -/* * * 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 @@ -41,48 +39,48 @@ #include "gmyth_jobqueue.h" #include "gmyth_transcoder.h" -static void gmyth_transcoder_class_init (GMythTranscoderClass * klass); -static void gmyth_transcoder_init (GMythTranscoder * object); +static void gmyth_transcoder_class_init ( GMythTranscoderClass * klass ); +static void gmyth_transcoder_init ( GMythTranscoder * object ); -static void gmyth_transcoder_dispose (GObject * object); -static void gmyth_transcoder_finalize (GObject * object); +static void gmyth_transcoder_dispose ( GObject * object ); +static void gmyth_transcoder_finalize ( GObject * object ); -G_DEFINE_TYPE (GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT) - static void gmyth_transcoder_class_init (GMythTranscoderClass * klass) +G_DEFINE_TYPE ( GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT ) + static void gmyth_transcoder_class_init ( GMythTranscoderClass * klass ) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass ); gobject_class->dispose = gmyth_transcoder_dispose; gobject_class->finalize = gmyth_transcoder_finalize; } static void -gmyth_transcoder_init (GMythTranscoder * transcoder) +gmyth_transcoder_init ( GMythTranscoder * transcoder ) { transcoder->started = FALSE; } static void -gmyth_transcoder_dispose (GObject * object) +gmyth_transcoder_dispose ( GObject * object ) { - GMythTranscoder *transcoder = GMYTH_TRANSCODER (object); + GMythTranscoder *transcoder = GMYTH_TRANSCODER ( object ); - g_free (transcoder->output_filename); - g_free (transcoder->filename); - g_free (transcoder->profile); - g_free (transcoder->starttime); + g_free ( transcoder->output_filename ); + g_free ( transcoder->filename ); + g_free ( transcoder->profile ); + g_free ( transcoder->starttime ); - if (transcoder->backend_info) - g_object_unref (transcoder->backend_info); + if ( transcoder->backend_info ) + g_object_unref ( transcoder->backend_info ); - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_transcoder_parent_class )->dispose ( object ); } static void -gmyth_transcoder_finalize (GObject * object) +gmyth_transcoder_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object); + g_signal_handlers_destroy ( object ); + G_OBJECT_CLASS ( gmyth_transcoder_parent_class )->finalize ( object ); } /** @@ -91,13 +89,14 @@ * @return a new instance of GMythTranscoder. **/ GMythTranscoder * -gmyth_transcoder_new (GMythBackendInfo * backend_info) +gmyth_transcoder_new ( GMythBackendInfo * backend_info ) { GMythTranscoder *transcoder = GMYTH_TRANSCODER - (g_object_new (GMYTH_TRANSCODER_TYPE, NULL)); + ( g_object_new ( GMYTH_TRANSCODER_TYPE, NULL ) ); - if (backend_info != NULL) { - g_object_ref (backend_info); + if ( backend_info != NULL ) + { + g_object_ref ( backend_info ); transcoder->backend_info = backend_info; } @@ -113,37 +112,42 @@ * **/ static gchar * -gmyth_transcoder_date_change_format (gchar * date_s, int format) +gmyth_transcoder_date_change_format ( gchar * date_s, int format ) { - if (date_s != NULL) { - gint length = strlen (date_s); + if ( date_s != NULL ) + { + gint length = strlen ( date_s ); //create the right date format - gchar *src = (gchar *) g_malloc0 (sizeof (gchar) * length); + gchar *src = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * length ); - strncpy (src, date_s, length); + strncpy ( src, date_s, length ); gchar *dst; - if (format == DATE_FILE) { - dst = (gchar *) g_malloc0 (sizeof (gchar) * 16); - snprintf (dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src + 5, - src + 7, src + 9, src + 11, src + 13); + if ( format == DATE_FILE ) + { + dst = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * 16 ); + snprintf ( dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src + 5, + src + 7, src + 9, src + 11, src + 13 ); dst[15] = '\0'; - } else if (format == DATE_ISO) { - dst = (gchar *) g_malloc0 (sizeof (gchar) * 20); - snprintf (dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src + 4, - src + 6, src + 8, src + 10, src + 12); + } + else if ( format == DATE_ISO ) + { + dst = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * 20 ); + snprintf ( dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src + 4, + src + 6, src + 8, src + 10, src + 12 ); dst[19] = '\0'; } - gchar *ret = g_strdup (dst); + gchar *ret = g_strdup ( dst ); - g_free (src); - g_free (dst); + g_free ( src ); + g_free ( dst ); return ret; - } else + } + else return NULL; } @@ -156,11 +160,11 @@ * **/ void -gmyth_transcoder_set_output (GMythTranscoder * transcoder, - gboolean value, const gchar * outputfile) +gmyth_transcoder_set_output ( GMythTranscoder * transcoder, + gboolean value, const gchar * outputfile ) { transcoder->output = value; - transcoder->output_filename = g_strdup (outputfile); + transcoder->output_filename = g_strdup ( outputfile ); } /** @@ -171,23 +175,25 @@ * **/ void -gmyth_transcoder_set_filename (GMythTranscoder * transcoder, const gchar * file) +gmyth_transcoder_set_filename ( GMythTranscoder * transcoder, + const gchar * file ) { // fixme: if this method is called twice, memory will not be dealocated // one transcoder can be used only for one file request? - if (file != NULL) { - gchar **splited = g_strsplit (file, "_", 2); + if ( file != NULL ) + { + gchar **splited = g_strsplit ( file, "_", 2 ); // Get chanid - sscanf (splited[0], "%d", &(transcoder->chanid)); + sscanf ( splited[0], "%d", &( transcoder->chanid ) ); // Get starttime - gchar **date = g_strsplit (splited[1], ".", 2); + gchar **date = g_strsplit ( splited[1], ".", 2 ); transcoder->starttime = - gmyth_transcoder_date_change_format (date[0], DATE_ISO); + gmyth_transcoder_date_change_format ( date[0], DATE_ISO ); - transcoder->filename = g_strdup (file); + transcoder->filename = g_strdup ( file ); } } @@ -202,70 +208,74 @@ * **/ gint -gmyth_transcoder_set_profile (GMythTranscoder * trans, const gchar * value) +gmyth_transcoder_set_profile ( GMythTranscoder * trans, const gchar * value ) { - g_return_val_if_fail (value != NULL, -1); + g_return_val_if_fail ( value != NULL, -1 ); - trans->profile = g_strndup (value, strlen (value)); + trans->profile = g_strndup ( value, strlen ( value ) ); return 0; } gboolean -gmyth_transcoder_start (GMythTranscoder * trans) +gmyth_transcoder_start ( GMythTranscoder * trans ) { - g_return_val_if_fail (trans != NULL, FALSE); - g_return_val_if_fail (trans->backend_info != NULL, FALSE); - g_return_val_if_fail (trans->filename != NULL, FALSE); + g_return_val_if_fail ( trans != NULL, FALSE ); + g_return_val_if_fail ( trans->backend_info != NULL, FALSE ); + g_return_val_if_fail ( trans->filename != NULL, FALSE ); - if (trans->started == FALSE) { // not started yet - if (!gmyth_util_file_exists (trans->backend_info, trans->filename)) { - gmyth_debug ("File %s does not exist", trans->filename); + if ( trans->started == FALSE ) + { // not started yet + if ( !gmyth_util_file_exists ( trans->backend_info, trans->filename ) ) + { + gmyth_debug ( "File %s does not exist", trans->filename ); } - trans->started = gmyth_jobqueue_add_job (trans, "JOB_TRANSCODE"); - if (trans->started == FALSE) - gmyth_debug ("Error while starting GMythTranscoder to file: %s", - trans->output_filename); - } else { - gmyth_debug ("GMythTransfer already started!"); + trans->started = gmyth_jobqueue_add_job ( trans, "JOB_TRANSCODE" ); + if ( trans->started == FALSE ) + gmyth_debug ( "Error while starting GMythTranscoder to file: %s", + trans->output_filename ); + } + else + { + gmyth_debug ( "GMythTransfer already started!" ); } return trans->started; } gboolean -gmyth_transcoder_pause (GMythTranscoder * trans) +gmyth_transcoder_pause ( GMythTranscoder * trans ) { - g_return_val_if_fail (trans != NULL, FALSE); - g_return_val_if_fail (trans->started == TRUE, FALSE); + g_return_val_if_fail ( trans != NULL, FALSE ); + g_return_val_if_fail ( trans->started == TRUE, FALSE ); - return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE"); + return gmyth_jobqueue_change_cmd ( trans, "PAUSE", "JOB_TRANSCODE" ); } gboolean -gmyth_transcoder_resume (GMythTranscoder * trans) +gmyth_transcoder_resume ( GMythTranscoder * trans ) { - g_return_val_if_fail (trans != NULL, FALSE); + g_return_val_if_fail ( trans != NULL, FALSE ); - return gmyth_jobqueue_change_cmd (trans, "RESUME", "JOB_TRANSCODE"); + return gmyth_jobqueue_change_cmd ( trans, "RESUME", "JOB_TRANSCODE" ); } gboolean -gmyth_transcoder_cancel (GMythTranscoder * trans) +gmyth_transcoder_cancel ( GMythTranscoder * trans ) { - g_return_val_if_fail (trans != NULL, FALSE); - g_return_val_if_fail (trans->started == TRUE, FALSE); + g_return_val_if_fail ( trans != NULL, FALSE ); + g_return_val_if_fail ( trans->started == TRUE, FALSE ); trans->started = FALSE; - return gmyth_jobqueue_change_cmd (trans, "STOP", "JOB_TRANSCODE"); + return gmyth_jobqueue_change_cmd ( trans, "STOP", "JOB_TRANSCODE" ); } //fixme: implement this method gint -gmyth_transcoder_get_progress (GMythTranscoder * trans) +gmyth_transcoder_get_progress ( GMythTranscoder * trans ) { static int fixme = 0; - return (fixme++) % 101; + return ( fixme++ ) % 101; } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_transcoder.h --- a/gmyth/src/gmyth_transcoder.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_transcoder.h Wed May 23 19:50:41 2007 +0100 @@ -7,9 +7,6 @@ * * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza - * - */ -/* * * 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 @@ -51,51 +48,51 @@ typedef struct _GMythTranscoderClass GMythTranscoderClass; struct _GMythTranscoderClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ -}; + /* callbacks */ + }; /** * The GMythTranscoder structure is a class to implement functions * related to transcoding. */ struct _GMythTranscoder -{ - GObject parent; + { + GObject parent; - gboolean cutlist; - gboolean output; - gboolean started; + gboolean cutlist; + gboolean output; + gboolean started; - /* private begin */ - gchar *output_filename; - gchar *filename; - gchar *profile; - /* private end */ + /* private begin */ + gchar *output_filename; + gchar *filename; + gchar *profile; + /* private end */ - gchar *starttime; + gchar *starttime; - gint chanid; + gint chanid; - GMythBackendInfo *backend_info; -}; + GMythBackendInfo *backend_info; + }; -GType gmyth_transcoder_type (void); +GType gmyth_transcoder_type ( void ); -GMythTranscoder *gmyth_transcoder_new (GMythBackendInfo * backend_info); -void gmyth_transcoder_set_output (GMythTranscoder * transcode, - gboolean value, const gchar * outputfile); -void gmyth_transcoder_set_filename (GMythTranscoder * transcode, - const gchar * file); -gint gmyth_transcoder_set_profile (GMythTranscoder * trans, - const gchar * value); -gboolean gmyth_transcoder_start (GMythTranscoder * trans); -gboolean gmyth_transcoder_pause (GMythTranscoder * trans); -gboolean gmyth_transcoder_resume (GMythTranscoder * trans); -gboolean gmyth_transcoder_cancel (GMythTranscoder * trans); -gint gmyth_transcoder_get_progress (GMythTranscoder * trans); +GMythTranscoder *gmyth_transcoder_new ( GMythBackendInfo * backend_info ); +void gmyth_transcoder_set_output ( GMythTranscoder * transcode, + gboolean value, const gchar * outputfile ); +void gmyth_transcoder_set_filename ( GMythTranscoder * transcode, + const gchar * file ); +gint gmyth_transcoder_set_profile ( GMythTranscoder * trans, + const gchar * value ); +gboolean gmyth_transcoder_start ( GMythTranscoder * trans ); +gboolean gmyth_transcoder_pause ( GMythTranscoder * trans ); +gboolean gmyth_transcoder_resume ( GMythTranscoder * trans ); +gboolean gmyth_transcoder_cancel ( GMythTranscoder * trans ); +gint gmyth_transcoder_get_progress ( GMythTranscoder * trans ); G_END_DECLS diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_tvchain.c --- a/gmyth/src/gmyth_tvchain.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_tvchain.c Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Hallyson Luiz de Morais Melo * - *//* - * - * 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 - */ + * + * 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" @@ -44,85 +43,90 @@ #include "gmyth_scheduler.h" #include "gmyth_debug.h" -static void gmyth_tvchain_class_init (GMythTVChainClass * klass); -static void gmyth_tvchain_init (GMythTVChain * object); +static void gmyth_tvchain_class_init ( GMythTVChainClass * klass ); +static void gmyth_tvchain_init ( GMythTVChain * object ); -static void gmyth_tvchain_dispose (GObject * object); -static void gmyth_tvchain_finalize (GObject * object); +static void gmyth_tvchain_dispose ( GObject * object ); +static void gmyth_tvchain_finalize ( GObject * object ); -static void free_tvchain_entry (gpointer data, gpointer user_data); +static void free_tvchain_entry ( gpointer data, gpointer user_data ); -G_DEFINE_TYPE (GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT) - static void gmyth_tvchain_class_init (GMythTVChainClass * klass) +G_DEFINE_TYPE ( GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT ) + static void gmyth_tvchain_class_init ( GMythTVChainClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_tvchain_dispose; gobject_class->finalize = gmyth_tvchain_finalize; } static void -gmyth_tvchain_init (GMythTVChain * tvchain) +gmyth_tvchain_init ( GMythTVChain * tvchain ) { tvchain->tvchain_id = NULL; - tvchain->cur_chanid = g_string_new (""); + tvchain->cur_chanid = g_string_new ( "" ); tvchain->cur_startts = NULL; - tvchain->mutex = g_mutex_new (); + tvchain->mutex = g_mutex_new ( ); } GMythTVChain * -gmyth_tvchain_new () +gmyth_tvchain_new ( ) { GMythTVChain *tvchain = - GMYTH_TVCHAIN (g_object_new (GMYTH_TVCHAIN_TYPE, NULL)); + GMYTH_TVCHAIN ( g_object_new ( GMYTH_TVCHAIN_TYPE, NULL ) ); return tvchain; } static void -gmyth_tvchain_dispose (GObject * object) +gmyth_tvchain_dispose ( GObject * object ) { - GMythTVChain *tvchain = GMYTH_TVCHAIN (object); + GMythTVChain *tvchain = GMYTH_TVCHAIN ( object ); - if (tvchain->tvchain_id != NULL) { - g_string_free (tvchain->tvchain_id, TRUE); + if ( tvchain->tvchain_id != NULL ) + { + g_string_free ( tvchain->tvchain_id, TRUE ); tvchain->tvchain_id = NULL; } - if (tvchain->mutex != NULL) { - g_mutex_free (tvchain->mutex); + if ( tvchain->mutex != NULL ) + { + g_mutex_free ( tvchain->mutex ); tvchain->mutex = NULL; } - if (tvchain->tvchain_list != NULL) { - g_list_foreach (tvchain->tvchain_list, free_tvchain_entry, NULL); - g_list_free (tvchain->tvchain_list); + if ( tvchain->tvchain_list != NULL ) + { + g_list_foreach ( tvchain->tvchain_list, free_tvchain_entry, NULL ); + g_list_free ( tvchain->tvchain_list ); } - if (tvchain->cur_chanid != NULL) { - g_string_free (tvchain->cur_chanid, TRUE); + if ( tvchain->cur_chanid != NULL ) + { + g_string_free ( tvchain->cur_chanid, TRUE ); tvchain->cur_chanid = NULL; } - if (tvchain->backend_info) { - g_object_unref (tvchain->backend_info); + if ( tvchain->backend_info ) + { + g_object_unref ( tvchain->backend_info ); tvchain->backend_info = NULL; } - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_tvchain_parent_class )->dispose ( object ); } static void -gmyth_tvchain_finalize (GObject * object) +gmyth_tvchain_finalize ( GObject * object ) { - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_tvchain_parent_class )->finalize ( object ); } /** Initializes the tvchain and generates the tvchain id. @@ -131,41 +135,45 @@ * @param hostname The local hostname used to generate the tvchain id. */ gboolean -gmyth_tvchain_initialize (GMythTVChain * tvchain, - GMythBackendInfo * backend_info) +gmyth_tvchain_initialize ( GMythTVChain * tvchain, + GMythBackendInfo * backend_info ) { const char *hostname; - assert (tvchain); - g_return_val_if_fail (backend_info != NULL, FALSE); + assert ( tvchain ); + g_return_val_if_fail ( backend_info != NULL, FALSE ); - g_object_ref (backend_info); + g_object_ref ( backend_info ); tvchain->backend_info = backend_info; - hostname = gmyth_backend_info_get_hostname (backend_info); + hostname = gmyth_backend_info_get_hostname ( backend_info ); - if (tvchain->tvchain_id == NULL) { + if ( tvchain->tvchain_id == NULL ) + { gchar *isodate = NULL; - GTimeVal *cur_time = g_new0 (GTimeVal, 1); + GTimeVal *cur_time = g_new0 ( GTimeVal, 1 ); //struct tm* gmyth_util_time_val_to_date ( const GTimeVal* time ) - g_get_current_time (cur_time); + g_get_current_time ( cur_time ); isodate = gmyth_util_time_to_isoformat_from_time_val_fmt - ("%Y-%m-%dT%H:%M:%S", cur_time); + ( "%Y-%m-%dT%H:%M:%S", cur_time ); tvchain->tvchain_id = - g_string_sized_new (7 + strlen (hostname) + strlen (isodate)); - g_string_printf (tvchain->tvchain_id, "live-%s-%s", hostname, isodate); + g_string_sized_new ( 7 + strlen ( hostname ) + strlen ( isodate ) ); + g_string_printf ( tvchain->tvchain_id, "live-%s-%s", hostname, + isodate ); - gmyth_debug ("[%s] tv_chain_id: %s", __FUNCTION__, - tvchain->tvchain_id->str); + gmyth_debug ( "[%s] tv_chain_id: %s", __FUNCTION__, + tvchain->tvchain_id->str ); - g_free (isodate); - g_free (cur_time); - } else { - gmyth_debug ("[%s] TVchain already initialized", __FUNCTION__); + g_free ( isodate ); + g_free ( cur_time ); + } + else + { + gmyth_debug ( "[%s] TVchain already initialized", __FUNCTION__ ); } return TRUE; @@ -177,9 +185,10 @@ * @return The tvchain id. */ GString * -gmyth_tvchain_get_id (GMythTVChain * tvchain) +gmyth_tvchain_get_id ( GMythTVChain * tvchain ) { - g_return_val_if_fail (tvchain != NULL && tvchain->tvchain_id != NULL, NULL); + g_return_val_if_fail ( tvchain != NULL + && tvchain->tvchain_id != NULL, NULL ); return tvchain->tvchain_id; } @@ -190,7 +199,7 @@ * @return TRUE if success, or FALSE if error. */ gboolean -gmyth_tvchain_reload_all (GMythTVChain * tvchain) +gmyth_tvchain_reload_all ( GMythTVChain * tvchain ) { MYSQL_ROW msql_row; MYSQL_RES *msql_res = NULL; @@ -198,100 +207,108 @@ gboolean ret = TRUE; GString *stmt_str = NULL; - g_mutex_lock (tvchain->mutex); + g_mutex_lock ( tvchain->mutex ); /* gets the initial size of the TVChain entries list */ - guint prev_size = g_list_length (tvchain->tvchain_list); + guint prev_size = g_list_length ( tvchain->tvchain_list ); - gmyth_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str); + gmyth_debug ( "[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str ); - if (tvchain != NULL && tvchain->tvchain_list != NULL) { - g_list_free (tvchain->tvchain_list); + if ( tvchain != NULL && tvchain->tvchain_list != NULL ) + { + g_list_free ( tvchain->tvchain_list ); tvchain->tvchain_list = NULL; } /* TODO: Reuse gmyth_query already connected from context */ - gmyth_query = gmyth_query_new (); - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) { - gmyth_debug ("[%s] Could not connect to db", __FUNCTION__); - g_mutex_unlock (tvchain->mutex); + gmyth_query = gmyth_query_new ( ); + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) ) + { + gmyth_debug ( "[%s] Could not connect to db", __FUNCTION__ ); + g_mutex_unlock ( tvchain->mutex ); ret = FALSE; goto done; } - stmt_str = g_string_new (""); - g_string_printf (stmt_str, - "SELECT chanid, starttime, endtime, discontinuity, " - "chainpos, hostprefix, cardtype, channame, input " - "FROM tvchain " - "WHERE chainid = \"%s\" ORDER BY chainpos;", tvchain->tvchain_id->str); + stmt_str = g_string_new ( "" ); + g_string_printf ( stmt_str, + "SELECT chanid, starttime, endtime, discontinuity, " + "chainpos, hostprefix, cardtype, channame, input " + "FROM tvchain " + "WHERE chainid = \"%s\" ORDER BY chainpos;", + tvchain->tvchain_id->str ); - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str); - if (msql_res != NULL) { + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str ); + if ( msql_res != NULL ) + { - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) { + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL ) + { struct LiveTVChainEntry *entry = - g_new0 (struct LiveTVChainEntry, 1); - entry->chanid = g_string_new (msql_row[0]); + g_new0 ( struct LiveTVChainEntry, 1 ); + entry->chanid = g_string_new ( msql_row[0] ); entry->starttime = - gmyth_util_string_to_time_val ((const gchar *) msql_row[1]); + gmyth_util_string_to_time_val ( ( const gchar * ) msql_row[1] ); entry->endtime = - gmyth_util_string_to_time_val ((const gchar *) msql_row[2]); + gmyth_util_string_to_time_val ( ( const gchar * ) msql_row[2] ); entry->discontinuity = - g_ascii_strtoull (msql_row[3], NULL, 10) != 0; - entry->hostprefix = g_string_new (msql_row[5]); - entry->cardtype = g_string_new (msql_row[6]); - entry->channum = g_string_new (msql_row[7]); - entry->inputname = g_string_new (msql_row[8]); + g_ascii_strtoull ( msql_row[3], NULL, 10 ) != 0; + entry->hostprefix = g_string_new ( msql_row[5] ); + entry->cardtype = g_string_new ( msql_row[6] ); + entry->channum = g_string_new ( msql_row[7] ); + entry->inputname = g_string_new ( msql_row[8] ); //m_maxpos = query.value(4).toInt() + 1; gmyth_debug - ("[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n", - __FUNCTION__, entry->channum->str, entry->chanid->str, - (gchar *) msql_row[1], (gchar *) msql_row[2]); + ( "[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n", + __FUNCTION__, entry->channum->str, entry->chanid->str, + ( gchar * ) msql_row[1], ( gchar * ) msql_row[2] ); /* add this to get the actual start timestamp of the last recording */ - if (tvchain->cur_startts < entry->starttime) + if ( tvchain->cur_startts < entry->starttime ) tvchain->cur_startts = entry->starttime; tvchain->tvchain_list = - g_list_append (tvchain->tvchain_list, entry); + g_list_append ( tvchain->tvchain_list, entry ); } - } else { - gmyth_debug ("gmyth_tvchain_reload_all query error!\n"); - g_mutex_unlock (tvchain->mutex); + } + else + { + gmyth_debug ( "gmyth_tvchain_reload_all query error!\n" ); + g_mutex_unlock ( tvchain->mutex ); ret = FALSE; goto done; } - g_mutex_unlock (tvchain->mutex); + g_mutex_unlock ( tvchain->mutex ); tvchain->cur_pos = - gmyth_tvchain_program_is_at (tvchain, tvchain->cur_chanid, - tvchain->cur_startts); - gmyth_debug ("[%s] TVChain current position = %d.\n", __FUNCTION__, - tvchain->cur_pos); + gmyth_tvchain_program_is_at ( tvchain, tvchain->cur_chanid, + tvchain->cur_startts ); + gmyth_debug ( "[%s] TVChain current position = %d.\n", __FUNCTION__, + tvchain->cur_pos ); - if (tvchain->cur_pos < 0) + if ( tvchain->cur_pos < 0 ) tvchain->cur_pos = 0; // if (m_switchid >= 0) // m_switchid = ProgramIsAt(m_switchentry.chanid,m_switchentry.starttime); - if (prev_size != g_list_length (tvchain->tvchain_list)) { - gmyth_debug ("[%s] Added new recording", __FUNCTION__); + if ( prev_size != g_list_length ( tvchain->tvchain_list ) ) + { + gmyth_debug ( "[%s] Added new recording", __FUNCTION__ ); } done: - if (stmt_str != NULL) - g_string_free (stmt_str, TRUE); + if ( stmt_str != NULL ) + g_string_free ( stmt_str, TRUE ); - if (msql_res != NULL) - mysql_free_result (msql_res); + if ( msql_res != NULL ) + mysql_free_result ( msql_res ); - if (gmyth_query != NULL) - g_object_unref (gmyth_query); + if ( gmyth_query != NULL ) + g_object_unref ( gmyth_query ); return ret; } @@ -304,7 +321,7 @@ * @return A program info listage. */ GList * -gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain) +gmyth_tvchain_get_program_info_list ( GMythTVChain * tvchain ) { GList *prog_list = NULL; MYSQL_ROW msql_row; @@ -312,51 +329,57 @@ GMythQuery *gmyth_query = NULL; GString *stmt_str = NULL; - g_mutex_lock (tvchain->mutex); + g_mutex_lock ( tvchain->mutex ); - gmyth_query = gmyth_query_new (); - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) { - gmyth_debug ("Could not connect to db."); + gmyth_query = gmyth_query_new ( ); + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) ) + { + gmyth_debug ( "Could not connect to db." ); goto done; } - stmt_str = g_string_new (""); - g_string_printf (stmt_str, - "SELECT channum, icon " "FROM channel " "ORDER BY channum;"); + stmt_str = g_string_new ( "" ); + g_string_printf ( stmt_str, + "SELECT channum, icon " "FROM channel " + "ORDER BY channum;" ); - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str); - if (msql_res != NULL) { + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str ); + if ( msql_res != NULL ) + { - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) { - GMythProgramInfo *entry = gmyth_program_info_new (); + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL ) + { + GMythProgramInfo *entry = gmyth_program_info_new ( ); - entry->channame = g_string_new (msql_row[0]); - entry->chansign = g_string_new (msql_row[1]); + entry->channame = g_string_new ( msql_row[0] ); + entry->chansign = g_string_new ( msql_row[1] ); gmyth_debug - ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", - entry->channame->str, entry->chansign->str, - (gchar *) msql_row[0], (gchar *) msql_row[1]); + ( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", + entry->channame->str, entry->chansign->str, + ( gchar * ) msql_row[0], ( gchar * ) msql_row[1] ); - prog_list = g_list_append (prog_list, entry); + prog_list = g_list_append ( prog_list, entry ); } - } else { + } + else + { gmyth_debug - ("Query error when trying to get the channel list from database!\n"); + ( "Query error when trying to get the channel list from database!\n" ); goto done; } done: - g_mutex_unlock (tvchain->mutex); + g_mutex_unlock ( tvchain->mutex ); - if (stmt_str != NULL) - g_string_free (stmt_str, TRUE); + if ( stmt_str != NULL ) + g_string_free ( stmt_str, TRUE ); - if (msql_res != NULL) - mysql_free_result (msql_res); + if ( msql_res != NULL ) + mysql_free_result ( msql_res ); - if (gmyth_query != NULL) - g_object_unref (gmyth_query); + if ( gmyth_query != NULL ) + g_object_unref ( gmyth_query ); return prog_list; } @@ -370,8 +393,8 @@ * @return A program info listage, based on a given channel name. */ GList * -gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain, - const gchar * channel) +gmyth_tvchain_get_program_info_from_channel ( GMythTVChain * tvchain, + const gchar * channel ) { GList *prog_list = NULL; MYSQL_ROW msql_row; @@ -379,52 +402,58 @@ GMythQuery *gmyth_query = NULL; GString *stmt_str = NULL; - g_mutex_lock (tvchain->mutex); + g_mutex_lock ( tvchain->mutex ); - gmyth_query = gmyth_query_new (); - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) { - gmyth_debug ("Could not connect to db."); + gmyth_query = gmyth_query_new ( ); + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) ) + { + gmyth_debug ( "Could not connect to db." ); goto done; } - stmt_str = g_string_new (""); - g_string_printf (stmt_str, - "SELECT channum, icon " - "FROM channel " "WHERE channum = \"%s\" ORDER BY channum;", channel); + stmt_str = g_string_new ( "" ); + g_string_printf ( stmt_str, + "SELECT channum, icon " + "FROM channel " + "WHERE channum = \"%s\" ORDER BY channum;", channel ); - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str); - if (msql_res != NULL) { + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str ); + if ( msql_res != NULL ) + { - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) { - GMythProgramInfo *entry = gmyth_program_info_new (); + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL ) + { + GMythProgramInfo *entry = gmyth_program_info_new ( ); - entry->channame = g_string_new (msql_row[0]); - entry->chansign = g_string_new (msql_row[1]); + entry->channame = g_string_new ( msql_row[0] ); + entry->chansign = g_string_new ( msql_row[1] ); gmyth_debug - ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", - entry->channame->str, entry->chansign->str, - (gchar *) msql_row[0], (gchar *) msql_row[1]); + ( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", + entry->channame->str, entry->chansign->str, + ( gchar * ) msql_row[0], ( gchar * ) msql_row[1] ); - prog_list = g_list_append (prog_list, entry); + prog_list = g_list_append ( prog_list, entry ); } - } else { + } + else + { gmyth_debug - ("Query error when trying to get the channel list from database!\n"); + ( "Query error when trying to get the channel list from database!\n" ); goto done; } done: - g_mutex_unlock (tvchain->mutex); + g_mutex_unlock ( tvchain->mutex ); - if (stmt_str != NULL) - g_string_free (stmt_str, TRUE); + if ( stmt_str != NULL ) + g_string_free ( stmt_str, TRUE ); - if (msql_res != NULL) - mysql_free_result (msql_res); + if ( msql_res != NULL ) + mysql_free_result ( msql_res ); - if (gmyth_query != NULL) - g_object_unref (gmyth_query); + if ( gmyth_query != NULL ) + g_object_unref ( gmyth_query ); return prog_list; } @@ -440,26 +469,28 @@ * @return The position of the related program info in the TV chain. */ gint -gmyth_tvchain_program_is_at (GMythTVChain * tvchain, GString * chanid, - GTimeVal * startts) +gmyth_tvchain_program_is_at ( GMythTVChain * tvchain, GString * chanid, + GTimeVal * startts ) { gint count = 0; struct LiveTVChainEntry *entry; GList *tmp_list = tvchain->tvchain_list; - guint list_size = g_list_length (tvchain->tvchain_list); + guint list_size = g_list_length ( tvchain->tvchain_list ); - g_mutex_lock (tvchain->mutex); + g_mutex_lock ( tvchain->mutex ); - for (; tmp_list && (count < list_size); - tmp_list = tvchain->tvchain_list->next, count++) { - entry = (struct LiveTVChainEntry *) tmp_list->data; - if (!g_strncasecmp (entry->chanid->str, chanid->str, chanid->len) - && entry->starttime == startts) { - g_mutex_unlock (tvchain->mutex); + for ( ; tmp_list && ( count < list_size ); + tmp_list = tvchain->tvchain_list->next, count++ ) + { + entry = ( struct LiveTVChainEntry * ) tmp_list->data; + if ( !g_strncasecmp ( entry->chanid->str, chanid->str, chanid->len ) + && entry->starttime == startts ) + { + g_mutex_unlock ( tvchain->mutex ); return count; } } - g_mutex_unlock (tvchain->mutex); + g_mutex_unlock ( tvchain->mutex ); return -1; } @@ -472,14 +503,14 @@ * @return The program info structure. */ GMythProgramInfo * -gmyth_tvchain_get_program_at (GMythTVChain * tvchain, gint index) +gmyth_tvchain_get_program_at ( GMythTVChain * tvchain, gint index ) { struct LiveTVChainEntry *entry; - entry = gmyth_tvchain_get_entry_at (tvchain, index); + entry = gmyth_tvchain_get_entry_at ( tvchain, index ); - if (entry) - return gmyth_tvchain_entry_to_program (tvchain, entry); + if ( entry ) + return gmyth_tvchain_entry_to_program ( tvchain, entry ); return NULL; } @@ -491,32 +522,36 @@ * @return The LiveTVchainEntry structure. */ struct LiveTVChainEntry * -gmyth_tvchain_get_entry_at (GMythTVChain * tvchain, gint index) +gmyth_tvchain_get_entry_at ( GMythTVChain * tvchain, gint index ) { struct LiveTVChainEntry *chain_entry = NULL; - g_return_val_if_fail (tvchain != NULL - && tvchain->tvchain_list != NULL, NULL); + g_return_val_if_fail ( tvchain != NULL + && tvchain->tvchain_list != NULL, NULL ); - g_mutex_lock (tvchain->mutex); + g_mutex_lock ( tvchain->mutex ); - gint size = g_list_length (tvchain->tvchain_list); - gint new_index = (index < 0 || index >= size) ? size - 1 : index; + gint size = g_list_length ( tvchain->tvchain_list ); + gint new_index = ( index < 0 || index >= size ) ? size - 1 : index; - if (new_index >= 0) + if ( new_index >= 0 ) chain_entry = - (struct LiveTVChainEntry *) g_list_nth_data (tvchain-> - tvchain_list, new_index); + ( struct LiveTVChainEntry * ) g_list_nth_data ( tvchain-> + tvchain_list, + new_index ); - g_mutex_unlock (tvchain->mutex); + g_mutex_unlock ( tvchain->mutex ); - if (chain_entry != NULL) { - gmyth_debug ("[%s] Got TV Chain entry at %d.\n", __FUNCTION__, - new_index); + if ( chain_entry != NULL ) + { + gmyth_debug ( "[%s] Got TV Chain entry at %d.\n", __FUNCTION__, + new_index ); - } else { - gmyth_debug ("[%s] failed to get entry at index %d", __FUNCTION__, - index); + } + else + { + gmyth_debug ( "[%s] failed to get entry at index %d", __FUNCTION__, + index ); } return chain_entry; @@ -531,73 +566,85 @@ * @return The program info. */ GMythProgramInfo * -gmyth_tvchain_entry_to_program (GMythTVChain * tvchain, - struct LiveTVChainEntry * entry) +gmyth_tvchain_entry_to_program ( GMythTVChain * tvchain, + struct LiveTVChainEntry * entry ) { GMythProgramInfo *proginfo = NULL; - g_return_val_if_fail (tvchain != NULL, NULL); + g_return_val_if_fail ( tvchain != NULL, NULL ); - if (!entry || !tvchain) { - gmyth_debug ("gmyth_tvchain_entry_to_program() received NULL argument"); + if ( !entry || !tvchain ) + { + gmyth_debug + ( "gmyth_tvchain_entry_to_program() received NULL argument" ); return NULL; } - GMythScheduler *scheduler = gmyth_scheduler_new (); + GMythScheduler *scheduler = gmyth_scheduler_new ( ); - gmyth_scheduler_connect (scheduler, tvchain->backend_info); - proginfo = gmyth_scheduler_get_recorded (scheduler, - entry->chanid, entry->starttime); - gmyth_scheduler_disconnect (scheduler); + gmyth_scheduler_connect ( scheduler, tvchain->backend_info ); + proginfo = gmyth_scheduler_get_recorded ( scheduler, + entry->chanid, entry->starttime ); + gmyth_scheduler_disconnect ( scheduler ); - if (proginfo) { + if ( proginfo ) + { proginfo->pathname = - g_string_prepend (proginfo->pathname, entry->hostprefix->str); - } else { + g_string_prepend ( proginfo->pathname, entry->hostprefix->str ); + } + else + { gmyth_debug - ("tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!", - entry->chanid->str, entry->starttime->tv_sec); + ( "tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!", + entry->chanid->str, entry->starttime->tv_sec ); } return proginfo; } static void -free_tvchain_entry (gpointer data, gpointer user_data) +free_tvchain_entry ( gpointer data, gpointer user_data ) { struct LiveTVChainEntry *entry; - g_return_if_fail (data != NULL); + g_return_if_fail ( data != NULL ); - entry = (struct LiveTVChainEntry *) data; + entry = ( struct LiveTVChainEntry * ) data; - if (entry->chanid != NULL) { - g_string_free (entry->chanid, TRUE); + if ( entry->chanid != NULL ) + { + g_string_free ( entry->chanid, TRUE ); } - if (entry->starttime != NULL) { - g_free (entry->starttime); + if ( entry->starttime != NULL ) + { + g_free ( entry->starttime ); } - if (entry->endtime != NULL) { - g_free (entry->endtime); + if ( entry->endtime != NULL ) + { + g_free ( entry->endtime ); } - if (entry->hostprefix) { - g_string_free (entry->hostprefix, TRUE); + if ( entry->hostprefix ) + { + g_string_free ( entry->hostprefix, TRUE ); } - if (entry->cardtype) { - g_string_free (entry->cardtype, TRUE); + if ( entry->cardtype ) + { + g_string_free ( entry->cardtype, TRUE ); } - if (entry->channum) { - g_string_free (entry->channum, TRUE); + if ( entry->channum ) + { + g_string_free ( entry->channum, TRUE ); } - if (entry->inputname) { - g_string_free (entry->inputname, TRUE); + if ( entry->inputname ) + { + g_string_free ( entry->inputname, TRUE ); } - g_free (entry); + g_free ( entry ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_tvchain.h --- a/gmyth/src/gmyth_tvchain.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_tvchain.h Wed May 23 19:50:41 2007 +0100 @@ -9,22 +9,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Hallyson Luiz de Morais Melo * - *//* - * - * 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 - */ + * + * 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 LIVETVCHAIN_H_ #define LIVETVCHAIN_H_ @@ -47,67 +46,68 @@ struct LiveTVChainEntry -{ - GString *chanid; + { + GString *chanid; - GTimeVal *starttime; - GTimeVal *endtime; + GTimeVal *starttime; + GTimeVal *endtime; - gboolean discontinuity; // if true, can't play smooth from last entry - GString *hostprefix; - GString *cardtype; - GString *channum; - GString *inputname; -}; + gboolean discontinuity; // if true, can't play smooth from last entry + GString *hostprefix; + GString *cardtype; + GString *channum; + GString *inputname; + }; struct _GMythTVChainClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythTVChain -{ - GObject parent; + { + GObject parent; - GString *tvchain_id; - GList *tvchain_list; + GString *tvchain_id; + GList *tvchain_list; - GTimeVal *cur_startts; - GString *cur_chanid; - gint cur_pos; + GTimeVal *cur_startts; + GString *cur_chanid; + gint cur_pos; - GMythBackendInfo *backend_info; + GMythBackendInfo *backend_info; - GMutex *mutex; -}; + GMutex *mutex; + }; -GType gmyth_tvchain_get_type (void); +GType gmyth_tvchain_get_type ( void ); -GMythTVChain *gmyth_tvchain_new (); +GMythTVChain *gmyth_tvchain_new ( ); -gboolean gmyth_tvchain_initialize (GMythTVChain * tvchain, - GMythBackendInfo * backend_info); -gboolean gmyth_tvchain_reload_all (GMythTVChain * tvchain); -GString *gmyth_tvchain_get_id (GMythTVChain * tvchain); -gint gmyth_tvchain_program_is_at (GMythTVChain * tvchain, - GString * chanid, GTimeVal * startts); +gboolean gmyth_tvchain_initialize ( GMythTVChain * tvchain, + GMythBackendInfo * backend_info ); +gboolean gmyth_tvchain_reload_all ( GMythTVChain * tvchain ); +GString *gmyth_tvchain_get_id ( GMythTVChain * tvchain ); +gint gmyth_tvchain_program_is_at ( GMythTVChain * tvchain, + GString * chanid, GTimeVal * startts ); -struct LiveTVChainEntry *gmyth_tvchain_get_entry_at (GMythTVChain * tvchain, - gint index); +struct LiveTVChainEntry *gmyth_tvchain_get_entry_at ( GMythTVChain * tvchain, + gint index ); -GMythProgramInfo *gmyth_tvchain_entry_to_program (GMythTVChain * tvchain, - struct LiveTVChainEntry *entry); -GMythProgramInfo *gmyth_tvchain_get_program_at (GMythTVChain * tvchain, - gint index); +GMythProgramInfo *gmyth_tvchain_entry_to_program ( GMythTVChain * tvchain, + struct LiveTVChainEntry + *entry ); +GMythProgramInfo *gmyth_tvchain_get_program_at ( GMythTVChain * tvchain, + gint index ); -GList *gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain, - const gchar * channel); +GList *gmyth_tvchain_get_program_info_from_channel ( GMythTVChain * tvchain, + const gchar * channel ); -GList *gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain); +GList *gmyth_tvchain_get_program_info_list ( GMythTVChain * tvchain ); G_END_DECLS #endif /*LIVETVCHAIN_H_ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_uri.c Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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" @@ -40,89 +39,97 @@ #include "gmyth_debug.h" -static void gmyth_uri_class_init (GMythURIClass * klass); -static void gmyth_uri_init (GMythURI * object); +static void gmyth_uri_class_init ( GMythURIClass * klass ); +static void gmyth_uri_init ( GMythURI * object ); -static void gmyth_uri_dispose (GObject * object); -static void gmyth_uri_finalize (GObject * object); +static void gmyth_uri_dispose ( GObject * object ); +static void gmyth_uri_finalize ( GObject * object ); -static void gmyth_uri_parser_setup_and_new (GMythURI * uri, - const gchar * value); -static gchar *gmyth_uri_print_field (const GString * field); +static void gmyth_uri_parser_setup_and_new ( GMythURI * uri, + const gchar * value ); +static gchar *gmyth_uri_print_field ( const GString * field ); -G_DEFINE_TYPE (GMythURI, gmyth_uri, G_TYPE_OBJECT) - static void gmyth_uri_class_init (GMythURIClass * klass) +G_DEFINE_TYPE ( GMythURI, gmyth_uri, G_TYPE_OBJECT ) + static void gmyth_uri_class_init ( GMythURIClass * klass ) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *) klass; + gobject_class = ( GObjectClass * ) klass; gobject_class->dispose = gmyth_uri_dispose; gobject_class->finalize = gmyth_uri_finalize; } static void -gmyth_uri_init (GMythURI * gmyth_uri) +gmyth_uri_init ( GMythURI * gmyth_uri ) { } static void -gmyth_uri_dispose (GObject * object) +gmyth_uri_dispose ( GObject * object ) { - GMythURI *gmyth_uri = GMYTH_URI (object); + GMythURI *gmyth_uri = GMYTH_URI ( object ); - if (gmyth_uri->host != NULL) { - g_string_free (gmyth_uri->host, TRUE); + if ( gmyth_uri->host != NULL ) + { + g_string_free ( gmyth_uri->host, TRUE ); gmyth_uri->host = NULL; } - if (gmyth_uri->protocol != NULL) { - g_string_free (gmyth_uri->protocol, TRUE); + if ( gmyth_uri->protocol != NULL ) + { + g_string_free ( gmyth_uri->protocol, TRUE ); gmyth_uri->protocol = NULL; } - if (gmyth_uri->path != NULL) { - g_string_free (gmyth_uri->path, TRUE); + if ( gmyth_uri->path != NULL ) + { + g_string_free ( gmyth_uri->path, TRUE ); gmyth_uri->path = NULL; } - if (gmyth_uri->fragment != NULL) { - g_string_free (gmyth_uri->fragment, TRUE); + if ( gmyth_uri->fragment != NULL ) + { + g_string_free ( gmyth_uri->fragment, TRUE ); gmyth_uri->fragment = NULL; } - if (gmyth_uri->user != NULL) { - g_string_free (gmyth_uri->user, TRUE); + if ( gmyth_uri->user != NULL ) + { + g_string_free ( gmyth_uri->user, TRUE ); gmyth_uri->user = NULL; } - if (gmyth_uri->password != NULL) { - g_string_free (gmyth_uri->password, TRUE); + if ( gmyth_uri->password != NULL ) + { + g_string_free ( gmyth_uri->password, TRUE ); gmyth_uri->password = NULL; } - if (gmyth_uri->query != NULL) { - g_string_free (gmyth_uri->query, TRUE); + if ( gmyth_uri->query != NULL ) + { + g_string_free ( gmyth_uri->query, TRUE ); gmyth_uri->query = NULL; } - if (gmyth_uri->uri != NULL) { - g_string_free (gmyth_uri->uri, TRUE); + if ( gmyth_uri->uri != NULL ) + { + g_string_free ( gmyth_uri->uri, TRUE ); gmyth_uri->uri = NULL; } - G_OBJECT_CLASS (gmyth_uri_parent_class)->dispose (object); + G_OBJECT_CLASS ( gmyth_uri_parent_class )->dispose ( object ); } static void -gmyth_uri_finalize (GObject * object) +gmyth_uri_finalize ( GObject * object ) { //GMythURI *gmyth_uri = GMYTH_URI(object); - g_signal_handlers_destroy (object); + g_signal_handlers_destroy ( object ); - G_OBJECT_CLASS (gmyth_uri_parent_class)->finalize (object); + G_OBJECT_CLASS ( gmyth_uri_parent_class )->finalize ( object ); } /** @@ -131,9 +138,9 @@ * @return a new instance of GMythURI. */ GMythURI * -gmyth_uri_new (void) +gmyth_uri_new ( void ) { - GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL)); + GMythURI *gmyth_uri = GMYTH_URI ( g_object_new ( GMYTH_URI_TYPE, NULL ) ); return gmyth_uri; } @@ -146,11 +153,11 @@ * @return a new instance of GMythURI. */ GMythURI * -gmyth_uri_new_with_value (const gchar * uri_str) +gmyth_uri_new_with_value ( const gchar * uri_str ) { - GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL)); + GMythURI *gmyth_uri = GMYTH_URI ( g_object_new ( GMYTH_URI_TYPE, NULL ) ); - gmyth_uri_parser_setup_and_new (gmyth_uri, uri_str); + gmyth_uri_parser_setup_and_new ( gmyth_uri, uri_str ); return gmyth_uri; } @@ -165,18 +172,18 @@ * haystack function parameter doesn't contains the needle string argument. */ static gint -gmyth_strstr (const gchar * haystack, const gchar * needle) +gmyth_strstr ( const gchar * haystack, const gchar * needle ) { gchar *strPos; - if (haystack == NULL || needle == NULL) + if ( haystack == NULL || needle == NULL ) return -1; - strPos = strstr (haystack, needle); - if (strPos == NULL) + strPos = strstr ( haystack, needle ); + if ( strPos == NULL ) return -1; - return (strPos - haystack); + return ( strPos - haystack ); } @@ -188,15 +195,15 @@ * @return true, if the URI is absolute. */ static gboolean -gmyth_uri_isabsolute (const GMythURI * uri) +gmyth_uri_isabsolute ( const GMythURI * uri ) { gboolean ret = FALSE; - g_return_val_if_fail (uri != NULL && uri->uri != NULL - && uri->protocol != NULL, FALSE); + g_return_val_if_fail ( uri != NULL && uri->uri != NULL + && uri->protocol != NULL, FALSE ); - if (gmyth_strstr (uri->uri->str, GMYTH_URI_PROTOCOL_DELIM) == 0 - || strlen (uri->protocol->str) > 0) + if ( gmyth_strstr ( uri->uri->str, GMYTH_URI_PROTOCOL_DELIM ) == 0 + || strlen ( uri->protocol->str ) > 0 ) ret = TRUE; return ret; @@ -216,19 +223,21 @@ * or -1 if the no character of the list could be found. */ static gint -gmyth_strrchr (const gchar * str, const gchar * chars, const gint nchars) +gmyth_strrchr ( const gchar * str, const gchar * chars, const gint nchars ) { gint strLen; gint i, j; - if (str == NULL || chars == NULL) + if ( str == NULL || chars == NULL ) return -1; - strLen = strlen (str); - for (i = (strLen - 1); 0 <= i; i--) { - for (j = 0; j < nchars; j++) { - if (str[i] == chars[j]) + strLen = strlen ( str ); + for ( i = ( strLen - 1 ); 0 <= i; i-- ) + { + for ( j = 0; j < nchars; j++ ) + { + if ( str[i] == chars[j] ) return i; } } @@ -238,9 +247,9 @@ } static gchar * -gmyth_uri_print_field (const GString * field) +gmyth_uri_print_field ( const GString * field ) { - if (field != NULL && field->str != NULL && strlen (field->str) > 0) + if ( field != NULL && field->str != NULL && strlen ( field->str ) > 0 ) return field->str; else return ""; @@ -254,7 +263,7 @@ * */ static void -gmyth_uri_parser_setup_and_new (GMythURI * uri, const gchar * value) +gmyth_uri_parser_setup_and_new ( GMythURI * uri, const gchar * value ) { gint uriLen; @@ -274,126 +283,143 @@ gint queryLen; */ - uriLen = strlen (value); - uri->uri = g_string_new (value); + uriLen = strlen ( value ); + uri->uri = g_string_new ( value ); currIdx = 0; - /*** Protocol ****/ - protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM); - if (0 < protoIdx) { - uri->protocol = g_string_new_len (value, protoIdx); - currIdx += protoIdx + strlen (GMYTH_URI_PROTOCOL_DELIM); + /*** Protocol ****/ + protoIdx = gmyth_strstr ( value, GMYTH_URI_PROTOCOL_DELIM ); + if ( 0 < protoIdx ) + { + uri->protocol = g_string_new_len ( value, protoIdx ); + currIdx += protoIdx + strlen ( GMYTH_URI_PROTOCOL_DELIM ); } - /*** User (Password) ****/ - atIdx = gmyth_strstr (value + currIdx, GMYTH_URI_USER_DELIM); - if (0 < atIdx) { - colonIdx = gmyth_strstr (value + currIdx, GMYTH_URI_COLON_DELIM); + /*** User (Password) ****/ + atIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_USER_DELIM ); + if ( 0 < atIdx ) + { + colonIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_COLON_DELIM ); - if (0 < colonIdx && colonIdx < atIdx) { - uri->user = g_string_new_len (value + currIdx, colonIdx); + if ( 0 < colonIdx && colonIdx < atIdx ) + { + uri->user = g_string_new_len ( value + currIdx, colonIdx ); uri->password = - g_string_new_len (value + currIdx + colonIdx + 1, - atIdx - (colonIdx + 1)); - } else - uri->user = g_string_new_len (value + currIdx, atIdx - currIdx); + g_string_new_len ( value + currIdx + colonIdx + 1, + atIdx - ( colonIdx + 1 ) ); + } + else + uri->user = g_string_new_len ( value + currIdx, atIdx - currIdx ); currIdx += atIdx + 1; } - /*** Host (Port) ****/ - shashIdx = gmyth_strstr (value + currIdx, GMYTH_URI_SLASH_DELIM); - if (0 < shashIdx) - uri->host = g_string_new_len (value + currIdx, shashIdx); - else if (gmyth_uri_isabsolute (uri) == TRUE) + /*** Host (Port) ****/ + shashIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_SLASH_DELIM ); + if ( 0 < shashIdx ) + uri->host = g_string_new_len ( value + currIdx, shashIdx ); + else if ( gmyth_uri_isabsolute ( uri ) == TRUE ) uri->host = - g_string_new_len (value + currIdx, strlen (value) - currIdx); + g_string_new_len ( value + currIdx, strlen ( value ) - currIdx ); - host = gmyth_uri_get_host (uri); - colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1); - eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1); - if ((0 < colonIdx) && (eblacketIdx < colonIdx)) { + host = gmyth_uri_get_host ( uri ); + colonIdx = gmyth_strrchr ( host, GMYTH_URI_COLON_DELIM, 1 ); + eblacketIdx = gmyth_strrchr ( host, GMYTH_URI_EBLACET_DELIM, 1 ); + if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) + { GString *portStr = NULL; - GString *hostStr = g_string_new (host != NULL ? host : ""); + GString *hostStr = g_string_new ( host != NULL ? host : "" ); hostLen = hostStr->len; - /**** host ****/ - uri->host = g_string_erase (uri->host, 0, hostLen); - uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx); - if (0 < hostLen) { - if (host[0] == '[' && host[hostLen - 1] == ']') - uri->host = g_string_new_len (hostStr->str + 1, colonIdx - 2); + /**** host ****/ + uri->host = g_string_erase ( uri->host, 0, hostLen ); + uri->host = + g_string_insert_len ( uri->host, 0, hostStr->str, colonIdx ); + if ( 0 < hostLen ) + { + if ( host[0] == '[' && host[hostLen - 1] == ']' ) + uri->host = g_string_new_len ( hostStr->str + 1, colonIdx - 2 ); } - /**** port ****/ + /**** port ****/ portStr = - g_string_new_len (hostStr->str + colonIdx + 1, - hostLen - colonIdx - 1); - uri->port = (gint) g_ascii_strtoull (portStr->str, NULL, 10); - g_string_free (portStr, TRUE); - g_string_free (hostStr, TRUE); - } else { - const gchar *protocol = gmyth_uri_get_protocol (uri); + g_string_new_len ( hostStr->str + colonIdx + 1, + hostLen - colonIdx - 1 ); + uri->port = ( gint ) g_ascii_strtoull ( portStr->str, NULL, 10 ); + g_string_free ( portStr, TRUE ); + g_string_free ( hostStr, TRUE ); + } + else + { + const gchar *protocol = gmyth_uri_get_protocol ( uri ); uri->port = GMYTH_URI_KNKOWN_PORT; - if (strcmp (protocol, GMYTH_URI_PROTOCOL_HTTP) == 0) + if ( strcmp ( protocol, GMYTH_URI_PROTOCOL_HTTP ) == 0 ) uri->port = GMYTH_URI_DEFAULT_HTTP_PORT; - if (strcmp (protocol, GMYTH_URI_PROTOCOL_FTP) == 0) + if ( strcmp ( protocol, GMYTH_URI_PROTOCOL_FTP ) == 0 ) uri->port = GMYTH_URI_DEFAULT_FTP_PORT; } - if (shashIdx > 0) + if ( shashIdx > 0 ) currIdx += shashIdx; /* Handle relative URL */ - if (gmyth_uri_isabsolute (uri) == FALSE) { + if ( gmyth_uri_isabsolute ( uri ) == FALSE ) + { - if (shashIdx != 0) { + if ( shashIdx != 0 ) + { /* Add slash delimiter at the beginning of the URL, if it doesn't exist */ - uri->path = g_string_new (GMYTH_URI_SLASH_DELIM); + uri->path = g_string_new ( GMYTH_URI_SLASH_DELIM ); } - uri->path = g_string_append (uri->path, value); + uri->path = g_string_append ( uri->path, value ); - } else { + } + else + { /* First set path simply to the rest of URI */ - uri->path = g_string_new_len (value + currIdx, uriLen - currIdx); + uri->path = g_string_new_len ( value + currIdx, uriLen - currIdx ); } //gmyth_debug( "uri value: %s", value ); uri->query = - g_string_new (g_strstr_len - (value, strlen (value), GMYTH_URI_QUESTION_DELIM)); + g_string_new ( g_strstr_len + ( value, strlen ( value ), GMYTH_URI_QUESTION_DELIM ) ); - eIdx = gmyth_strstr (value + currIdx, GMYTH_URI_QUESTION_DELIM); + eIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_QUESTION_DELIM ); - if (0 < eIdx) { + if ( 0 < eIdx ) + { uri->query = - g_string_new (g_strstr_len - (value, strlen (value), GMYTH_URI_QUESTION_DELIM)); - gmyth_debug ("query = %s", uri->query->str); + g_string_new ( g_strstr_len + ( value, strlen ( value ), + GMYTH_URI_QUESTION_DELIM ) ); + gmyth_debug ( "query = %s", uri->query->str ); } - /**** Path (Query/Fragment) ****/ - sharpIdx = gmyth_strstr (value + currIdx, GMYTH_URI_E_DELIM); - if (0 < sharpIdx) { - uri->path = g_string_append_len (uri->path, value + currIdx, sharpIdx); + /**** Path (Query/Fragment) ****/ + sharpIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_E_DELIM ); + if ( 0 < sharpIdx ) + { + uri->path = + g_string_append_len ( uri->path, value + currIdx, sharpIdx ); uri->fragment = - g_string_new_len (value + currIdx + sharpIdx + 1, - uriLen - (currIdx + sharpIdx + 1)); + g_string_new_len ( value + currIdx + sharpIdx + 1, + uriLen - ( currIdx + sharpIdx + 1 ) ); } gmyth_debug - ("[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, " - "user = %s, password = %s.\n", __FUNCTION__, - gmyth_uri_print_field (uri->host), uri->port, - gmyth_uri_print_field (uri->path), - gmyth_uri_print_field (uri->query), - gmyth_uri_print_field (uri->fragment), - gmyth_uri_print_field (uri->user), - gmyth_uri_print_field (uri->password)); + ( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, " + "user = %s, password = %s.\n", __FUNCTION__, + gmyth_uri_print_field ( uri->host ), uri->port, + gmyth_uri_print_field ( uri->path ), + gmyth_uri_print_field ( uri->query ), + gmyth_uri_print_field ( uri->fragment ), + gmyth_uri_print_field ( uri->user ), + gmyth_uri_print_field ( uri->password ) ); } @@ -406,11 +432,11 @@ * @return true, if these two URI instances are equals. */ gboolean -gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2) +gmyth_uri_is_equals ( GMythURI * uri1, GMythURI * uri2 ) { - return (g_ascii_strcasecmp - (gmyth_uri_get_host (uri1), gmyth_uri_get_host (uri2)) == 0 - && gmyth_uri_get_port (uri1) == gmyth_uri_get_port (uri2)); + return ( g_ascii_strcasecmp + ( gmyth_uri_get_host ( uri1 ), gmyth_uri_get_host ( uri2 ) ) == 0 + && gmyth_uri_get_port ( uri1 ) == gmyth_uri_get_port ( uri2 ) ); } /** @@ -421,22 +447,22 @@ * @return true, if the URI points to LiveTV content. */ gboolean -gmyth_uri_is_livetv (GMythURI * uri) +gmyth_uri_is_livetv ( GMythURI * uri ) { gboolean ret = TRUE; - g_return_val_if_fail (uri != NULL, FALSE); - g_return_val_if_fail (uri->uri != NULL, FALSE); - g_return_val_if_fail (uri->uri->str != NULL, FALSE); + g_return_val_if_fail ( uri != NULL, FALSE ); + g_return_val_if_fail ( uri->uri != NULL, FALSE ); + g_return_val_if_fail ( uri->uri->str != NULL, FALSE ); - if ((strstr (uri->uri->str, "channel") == NULL) || - (strstr (uri->uri->str, "livetv") == NULL)) + if ( ( strstr ( uri->uri->str, "channel" ) == NULL ) || + ( strstr ( uri->uri->str, "livetv" ) == NULL ) ) ret = FALSE; - if (ret) - gmyth_debug ("This URI is a LiveTV recording..."); + if ( ret ) + gmyth_debug ( "This URI is a LiveTV recording..." ); else - gmyth_debug ("This URI is a stored remote recording."); + gmyth_debug ( "This URI is a stored remote recording." ); return ret; @@ -451,31 +477,35 @@ * of the URI string. */ gchar * -gmyth_uri_get_channel_name (GMythURI * uri) +gmyth_uri_get_channel_name ( GMythURI * uri ) { gchar *channel = NULL; - g_return_val_if_fail (uri != NULL && uri->uri != NULL - && uri->uri->str != NULL, FALSE); + g_return_val_if_fail ( uri != NULL && uri->uri != NULL + && uri->uri->str != NULL, FALSE ); - gchar *channel_query = g_strstr_len (gmyth_uri_get_query (uri), - strlen (gmyth_uri_get_query (uri)), - "channel"); + gchar *channel_query = g_strstr_len ( gmyth_uri_get_query ( uri ), + strlen ( gmyth_uri_get_query + ( uri ) ), + "channel" ); - if (channel_query != NULL) { - gchar **chan_key_value = g_strsplit (gmyth_uri_get_query (uri), "=", 2); + if ( channel_query != NULL ) + { + gchar **chan_key_value = + g_strsplit ( gmyth_uri_get_query ( uri ), "=", 2 ); /* gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] ); */ - if (chan_key_value[1] != NULL && strlen (chan_key_value[1]) > 0) { - channel = g_strdup (chan_key_value[1]); + if ( chan_key_value[1] != NULL && strlen ( chan_key_value[1] ) > 0 ) + { + channel = g_strdup ( chan_key_value[1] ); } - if (chan_key_value != NULL) - g_strfreev (chan_key_value); + if ( chan_key_value != NULL ) + g_strfreev ( chan_key_value ); } - gmyth_debug ("Got channel decimal value from the URI: %s", channel); + gmyth_debug ( "Got channel decimal value from the URI: %s", channel ); return channel; @@ -490,12 +520,13 @@ * of the URI string, or -1 it if couldn't be converted. */ gint -gmyth_uri_get_channel_num (GMythURI * uri) +gmyth_uri_get_channel_num ( GMythURI * uri ) { - gchar *channel_name = gmyth_uri_get_channel_name (uri); + gchar *channel_name = gmyth_uri_get_channel_name ( uri ); - if (channel_name != NULL) { - return g_ascii_strtoull (channel_name, NULL, 10); + if ( channel_name != NULL ) + { + return g_ascii_strtoull ( channel_name, NULL, 10 ); } return -1; @@ -510,37 +541,37 @@ * @return true, if the URI points to a local file. */ gboolean -gmyth_uri_is_local_file (const GMythURI * uri) +gmyth_uri_is_local_file ( const GMythURI * uri ) { gboolean ret = FALSE; gint len = -1; - GString *hostname = gmyth_socket_get_local_hostname (); + GString *hostname = gmyth_socket_get_local_hostname ( ); - g_return_val_if_fail (uri != NULL, FALSE); + g_return_val_if_fail ( uri != NULL, FALSE ); - len = strlen (gmyth_uri_get_host (uri)); + len = strlen ( gmyth_uri_get_host ( uri ) ); // gmyth_debug("URI: host = %s, hostname = %s.", uri->host->str, hostname != NULL ? hostname->str : "[no hostname]"); - ret = (NULL != hostname && (g_ascii_strncasecmp (uri->host->str, (hostname)->str, len) == 0) /*|| - ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */ - ); + ret = ( NULL != hostname && ( g_ascii_strncasecmp ( uri->host->str, ( hostname )->str, len ) == 0 ) /*|| + ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */ + ); - if (ret) - gmyth_debug ("This URI is a local file..."); + if ( ret ) + gmyth_debug ( "This URI is a local file..." ); else - gmyth_debug ("This URI is NOT a local file..."); + gmyth_debug ( "This URI is NOT a local file..." ); return ret; } char * -gmyth_uri_to_string (const GMythURI * uri) +gmyth_uri_to_string ( const GMythURI * uri ) { - g_return_val_if_fail (uri != NULL, NULL); - g_return_val_if_fail (uri->uri != NULL, NULL); + g_return_val_if_fail ( uri != NULL, NULL ); + g_return_val_if_fail ( uri->uri != NULL, NULL ); - return g_strdup (uri->uri->str); + return g_strdup ( uri->uri->str ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_uri.h --- a/gmyth/src/gmyth_uri.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_uri.h Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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_URI_H_ #define _GMYTH_URI_H_ @@ -47,9 +46,9 @@ typedef struct _GMythURI GMythURI; typedef struct _GMythURIClass GMythURIClass; -/**************************************** -* Define -****************************************/ + /**************************************** + * Define + ****************************************/ #define GMYTH_URI_KNKOWN_PORT (-1) #define GMYTH_URI_DEFAULT_HTTP_PORT 80 @@ -72,44 +71,44 @@ #define GMYTH_URI_PROTOCOL_HTTP "http" #define GMYTH_URI_PROTOCOL_FTP "ftp" -/**************************************** -* Data Type -****************************************/ + /**************************************** + * Data Type + ****************************************/ struct _GMythURIClass -{ - GObjectClass parent_class; + { + GObjectClass parent_class; - /* callbacks */ - /* no one for now */ -}; + /* callbacks */ + /* no one for now */ + }; struct _GMythURI -{ + { - GObject parent; + GObject parent; - GString *uri; - GString *host; - gint port; - GString *protocol; - GString *path; - GString *fragment; - GString *user; - GString *password; - GString *query; + GString *uri; + GString *host; + gint port; + GString *protocol; + GString *path; + GString *fragment; + GString *user; + GString *password; + GString *query; -}; + }; -GType gmyth_uri_get_type (void); -GMythURI *gmyth_uri_new (void); -GMythURI *gmyth_uri_new_with_value (const gchar * value); -gboolean gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2); -gboolean gmyth_uri_is_livetv (GMythURI * uri); -gint gmyth_uri_get_channel_num (GMythURI * uri); -gchar *gmyth_uri_get_channel_name (GMythURI * uri); -char *gmyth_uri_to_string (const GMythURI * uri); -gboolean gmyth_uri_is_local_file (const GMythURI * uri); +GType gmyth_uri_get_type ( void ); +GMythURI *gmyth_uri_new ( void ); +GMythURI *gmyth_uri_new_with_value ( const gchar * value ); +gboolean gmyth_uri_is_equals ( GMythURI * uri1, GMythURI * uri2 ); +gboolean gmyth_uri_is_livetv ( GMythURI * uri ); +gint gmyth_uri_get_channel_num ( GMythURI * uri ); +gchar *gmyth_uri_get_channel_name ( GMythURI * uri ); +char *gmyth_uri_to_string ( const GMythURI * uri ); +gboolean gmyth_uri_is_local_file ( const GMythURI * uri ); #define gmyth_uri_get_host(urip) ( urip->host != NULL ? urip->host->str : "" ) #define gmyth_uri_get_port(urip) ( urip->port ) diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_util.c --- a/gmyth/src/gmyth_util.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_util.c Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * @author Hallyson Luiz de Morais Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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" @@ -48,9 +47,9 @@ #include "gmyth_debug.h" #if !GLIB_CHECK_VERSION (2, 10, 0) -gchar *g_time_val_to_iso8601 (GTimeVal * time_); -gboolean g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_); -void g_date_set_time_val (GDate * date, GTimeVal * timeval); +gchar *g_time_val_to_iso8601 ( GTimeVal * time_ ); +gboolean g_time_val_from_iso8601 ( const gchar * iso_date, GTimeVal * time_ ); +void g_date_set_time_val ( GDate * date, GTimeVal * timeval ); #endif @@ -64,22 +63,24 @@ * @return GString* the converted isoformat string */ GString * -gmyth_util_time_to_isoformat (time_t time_value) +gmyth_util_time_to_isoformat ( time_t time_value ) { struct tm tm_time; GString *result; - if (localtime_r (&time_value, &tm_time) == NULL) { - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n"); + if ( localtime_r ( &time_value, &tm_time ) == NULL ) + { + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" ); return NULL; } - result = g_string_sized_new (20); - g_string_printf (result, "%04d-%02d-%02dT%02d:%02d:%02d", - tm_time.tm_year + 1900, tm_time.tm_mon + 1, - tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec); + result = g_string_sized_new ( 20 ); + g_string_printf ( result, "%04d-%02d-%02dT%02d:%02d:%02d", + tm_time.tm_year + 1900, tm_time.tm_mon + 1, + tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min, + tm_time.tm_sec ); - gmyth_debug ("Result (ISO 8601) = %s", result->str); + gmyth_debug ( "Result (ISO 8601) = %s", result->str ); return result; } @@ -94,8 +95,8 @@ * @return GString* the converted isoformat string */ gchar * -gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar * fmt_string, - const GTimeVal * time_val) +gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar * fmt_string, + const GTimeVal * time_val ) { gchar *result = NULL; struct tm *tm_time = NULL; @@ -103,40 +104,45 @@ gint buffer_len = 0; - g_return_val_if_fail (fmt_string != NULL, NULL); + g_return_val_if_fail ( fmt_string != NULL, NULL ); - g_return_val_if_fail (time_val != NULL, NULL); + g_return_val_if_fail ( time_val != NULL, NULL ); time = time_val->tv_sec; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC ); - tm_time = g_malloc0 (sizeof (struct tm)); + tm_time = g_malloc0 ( sizeof ( struct tm ) ); - if (NULL == localtime_r (&time, tm_time)) { - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n"); - } else { + if ( NULL == localtime_r ( &time, tm_time ) ) + { + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" ); + } + else + { /* we first check the return of strftime to allocate a buffer of the correct size */ - buffer_len = strftime (NULL, SSIZE_MAX, fmt_string, tm_time); - if (buffer_len > 0) { - result = g_malloc0 (buffer_len + 1); - if (result == NULL) { + buffer_len = strftime ( NULL, SSIZE_MAX, fmt_string, tm_time ); + if ( buffer_len > 0 ) + { + result = g_malloc0 ( buffer_len + 1 ); + if ( result == NULL ) + { gmyth_debug - ("gmyth_util_time_to_isoformat convertion error!\n"); + ( "gmyth_util_time_to_isoformat convertion error!\n" ); return NULL; } - strftime (result, buffer_len + 1, fmt_string, tm_time); - gmyth_debug ("Dateline (ISO result): %s", result); + strftime ( result, buffer_len + 1, fmt_string, tm_time ); + gmyth_debug ( "Dateline (ISO result): %s", result ); } } /* if */ - gmyth_debug ("Result (strftime) = %s", result); + gmyth_debug ( "Result (strftime) = %s", result ); //strptime( result, "%Y-%m-%dT%H:%M:%SZ", tm_time ); //strftime( result, strlen(result), fmt_string, tm_time ); - g_free (tm_time); + g_free ( tm_time ); - gmyth_debug ("Result (ISO 8601) = %s", result); + gmyth_debug ( "Result (ISO 8601) = %s", result ); return result; } @@ -151,11 +157,11 @@ * @return GString* the converted isoformat string */ gchar * -gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time) +gmyth_util_time_to_isoformat_from_time_val ( const GTimeVal * time ) { gchar *result = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S", - time); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d %H:%M:%S", + time ); //result[10] = ' '; //result[ strlen(result) - 1] = '\0'; @@ -173,11 +179,11 @@ * @return GString* the converted isoformat string */ gchar * -gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time) +gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal * time ) { gchar *result = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%dT%H:%M:%S", - time); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%dT%H:%M:%S", + time ); return result; } @@ -192,10 +198,10 @@ * @return GString* the converted isoformat string */ gchar * -gmyth_util_time_to_string_only_date (const GTimeVal * time) +gmyth_util_time_to_string_only_date ( const GTimeVal * time ) { gchar *result = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d", time); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d", time ); //result[10] = ' '; //result[ strlen(result) - 1] = '\0'; return result; @@ -211,10 +217,10 @@ * @return GString* the converted isoformat string */ gchar * -gmyth_util_time_to_string_only_time (const GTimeVal * time) +gmyth_util_time_to_string_only_time ( const GTimeVal * time ) { gchar *result = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%H:%M:%S", time); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%H:%M:%S", time ); //result[10] = ' '; //result[ strlen(result) - 1] = '\0'; return result; @@ -230,12 +236,12 @@ * @return GString* the converted string */ GString * -gmyth_util_time_to_string (time_t time_value) +gmyth_util_time_to_string ( time_t time_value ) { - GString *result = gmyth_util_time_to_isoformat (time_value); + GString *result = gmyth_util_time_to_isoformat ( time_value ); result->str[10] = ' '; - result->str[strlen (result->str) - 1] = '\0'; + result->str[strlen ( result->str ) - 1] = '\0'; return result; } @@ -250,11 +256,11 @@ * @return GString* the converted string */ gchar * -gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val) +gmyth_util_time_to_string_from_time_val ( const GTimeVal * time_val ) { gchar *result = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S", - time_val); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d %H:%M:%S", + time_val ); //result[10] = ' '; @@ -268,20 +274,21 @@ * @return time_t the time converted value */ time_t -gmyth_util_string_to_time (GString * time_str) +gmyth_util_string_to_time ( GString * time_str ) { gint year, month, day, hour, min, sec; - gmyth_debug ("[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ? - time_str->str : "[time string is NULL!]", time_str->str); + gmyth_debug ( "[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ? + time_str->str : "[time string is NULL!]", time_str->str ); - if (sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d", - &year, &month, &day, &hour, &min, &sec) < 3) { - gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n"); + if ( sscanf ( time_str->str, "%04d-%02d-%02d %02d:%02d:%02d", + &year, &month, &day, &hour, &min, &sec ) < 3 ) + { + gmyth_debug ( "GMythUtil: isoformat_to_time converter error!\n" ); return 0; } - struct tm *tm_time = g_malloc0 (sizeof (struct tm)); + struct tm *tm_time = g_malloc0 ( sizeof ( struct tm ) ); tm_time->tm_year = year - 1900; tm_time->tm_mon = month - 1; @@ -290,7 +297,7 @@ tm_time->tm_min = min; tm_time->tm_sec = sec; - return mktime (tm_time); + return mktime ( tm_time ); } /** Converts a GString in the following format @@ -300,23 +307,25 @@ * @return time_t the time converted value */ struct tm * -gmyth_util_time_val_to_date (const GTimeVal * time) +gmyth_util_time_val_to_date ( const GTimeVal * time ) { - struct tm *date = g_malloc0 (sizeof (struct tm)); + struct tm *date = g_malloc0 ( sizeof ( struct tm ) ); time_t time_micros = time->tv_sec; // + (gint)( time->tv_usec / G_USEC_PER_SEC ); - if (NULL == date) { + if ( NULL == date ) + { gmyth_debug - ("GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n"); + ( "GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n" ); return NULL; } - if (NULL == localtime_r (&time_micros, date)) { - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n"); + if ( NULL == localtime_r ( &time_micros, date ) ) + { + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" ); return NULL; } - gmyth_debug ("Converted from GTimeVal == %s to GDate", asctime (date)); + gmyth_debug ( "Converted from GTimeVal == %s to GDate", asctime ( date ) ); return date; } @@ -328,37 +337,42 @@ * @return time_t the time converted value */ GTimeVal * -gmyth_util_string_to_time_val_fmt (const gchar * fmt_string, - const gchar * time_str) +gmyth_util_string_to_time_val_fmt ( const gchar * fmt_string, + const gchar * time_str ) { - GTimeVal *time = g_new0 (GTimeVal, 1); + GTimeVal *time = g_new0 ( GTimeVal, 1 ); struct tm *tm_time = NULL; time_t time_micros; gchar *result; - gmyth_debug ("[%s] time_str = %s. [%s]", time_str, time_str != NULL ? - time_str : "[time string is NULL!]", time_str); + gmyth_debug ( "[%s] time_str = %s. [%s]", time_str, time_str != NULL ? + time_str : "[time string is NULL!]", time_str ); - if (NULL == time_str) { - gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n"); + if ( NULL == time_str ) + { + gmyth_debug ( "GMythUtil: isoformat_to_time converter error!\n" ); return NULL; } - tm_time = g_malloc0 (sizeof (struct tm)); + tm_time = g_malloc0 ( sizeof ( struct tm ) ); /* we first check the return of strftime to allocate a buffer of the correct size */ - result = strptime (time_str, "%Y-%m-%dT%H:%M:%S", tm_time); - if (NULL == result) { + result = strptime ( time_str, "%Y-%m-%dT%H:%M:%S", tm_time ); + if ( NULL == result ) + { /* we first check the return of strftime to allocate a buffer of the correct size */ - result = strptime (time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time); - if (NULL == result) { + result = strptime ( time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time ); + if ( NULL == result ) + { /* we first check the return of strftime to allocate a buffer of the correct size */ - result = strptime (time_str, "%Y-%m-%d %H:%M:%S", tm_time); - if (NULL == result) { - result = strptime (time_str, "%Y-%m-%dT%H:%M", tm_time); - if (NULL == result) { - gmyth_debug ("Dateline (ISO result): %s", result); - g_free (tm_time); + result = strptime ( time_str, "%Y-%m-%d %H:%M:%S", tm_time ); + if ( NULL == result ) + { + result = strptime ( time_str, "%Y-%m-%dT%H:%M", tm_time ); + if ( NULL == result ) + { + gmyth_debug ( "Dateline (ISO result): %s", result ); + g_free ( tm_time ); return NULL; //goto done; } @@ -366,13 +380,13 @@ } } - time_micros = mktime (tm_time); + time_micros = mktime ( tm_time ); time->tv_sec = time_micros; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC ); - gmyth_debug ("After mktime call... = %s", asctime (tm_time)); + gmyth_debug ( "After mktime call... = %s", asctime ( tm_time ) ); - g_free (tm_time); + g_free ( tm_time ); return time; } @@ -384,10 +398,10 @@ * @return time_t the time converted value */ GTimeVal * -gmyth_util_string_to_time_val (const gchar * time_str) +gmyth_util_string_to_time_val ( const gchar * time_str ) { GTimeVal *time = - gmyth_util_string_to_time_val_fmt ("%Y-%m-%d %H:%M:%S", time_str); + gmyth_util_string_to_time_val_fmt ( "%Y-%m-%d %H:%M:%S", time_str ); return time; } @@ -401,42 +415,44 @@ * @return true, if the remote file exists. */ gboolean -gmyth_util_file_exists (GMythBackendInfo * backend_info, const gchar * filename) +gmyth_util_file_exists ( GMythBackendInfo * backend_info, + const gchar * filename ) { GMythSocket *socket; gboolean res; - gmyth_debug ("Check if file %s exists", filename); + gmyth_debug ( "Check if file %s exists", filename ); - g_return_val_if_fail (backend_info != NULL, FALSE); - g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail ( backend_info != NULL, FALSE ); + g_return_val_if_fail ( filename != NULL, FALSE ); - socket = gmyth_socket_new (); - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, - backend_info->port, TRUE); + socket = gmyth_socket_new ( ); + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname, + backend_info->port, TRUE ); - if (res == TRUE) { + if ( res == TRUE ) + { GMythStringList *slist; GMythProgramInfo *program = NULL; - program = gmyth_program_info_new (); - program->pathname = g_string_new (filename); + program = gmyth_program_info_new ( ); + program->pathname = g_string_new ( filename ); - slist = gmyth_string_list_new (); - gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE"); + slist = gmyth_string_list_new ( ); + gmyth_string_list_append_char_array ( slist, "QUERY_CHECKFILE" ); - gmyth_program_info_to_string_list (program, slist); + gmyth_program_info_to_string_list ( program, slist ); - gmyth_socket_sendreceive_stringlist (socket, slist); + gmyth_socket_sendreceive_stringlist ( socket, slist ); - res = (gmyth_string_list_get_int (slist, 0) == 1); + res = ( gmyth_string_list_get_int ( slist, 0 ) == 1 ); - g_object_unref (program); - g_object_unref (slist); + g_object_unref ( program ); + g_object_unref ( slist ); - gmyth_socket_close_connection (socket); + gmyth_socket_close_connection ( socket ); } - g_object_unref (socket); + g_object_unref ( socket ); return res; } @@ -450,50 +466,52 @@ * @return true, if the remote file exists. */ gboolean -gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo * backend_info, - const gchar * filename, gchar ** current_dir) +gmyth_util_file_exists_and_get_remote_dir ( GMythBackendInfo * backend_info, + const gchar * filename, + gchar ** current_dir ) { GMythSocket *socket; gboolean res; *current_dir = NULL; - socket = gmyth_socket_new (); - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, - backend_info->port, TRUE); + socket = gmyth_socket_new ( ); + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname, + backend_info->port, TRUE ); - if (res == TRUE) { + if ( res == TRUE ) + { GMythStringList *slist; GMythProgramInfo *program = NULL; - program = gmyth_program_info_new (); - program->pathname = g_string_new (filename); + program = gmyth_program_info_new ( ); + program->pathname = g_string_new ( filename ); - slist = gmyth_string_list_new (); - gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE"); + slist = gmyth_string_list_new ( ); + gmyth_string_list_append_char_array ( slist, "QUERY_CHECKFILE" ); - gmyth_program_info_to_string_list (program, slist); + gmyth_program_info_to_string_list ( program, slist ); - gmyth_socket_sendreceive_stringlist (socket, slist); + gmyth_socket_sendreceive_stringlist ( socket, slist ); - res = (gmyth_string_list_get_int (slist, 0) == 1); + res = ( gmyth_string_list_get_int ( slist, 0 ) == 1 ); - if ((gmyth_string_list_length (slist) > 1) && - gmyth_string_list_get_char_array (slist, 1) != NULL) + if ( ( gmyth_string_list_length ( slist ) > 1 ) && + gmyth_string_list_get_char_array ( slist, 1 ) != NULL ) *current_dir = - g_strdup (gmyth_string_list_get_char_array (slist, 1)); + g_strdup ( gmyth_string_list_get_char_array ( slist, 1 ) ); - if (*current_dir != NULL) - gmyth_debug ("Current directory = %s.", (*current_dir != NULL) - ? *current_dir : "[directory not found]"); + if ( *current_dir != NULL ) + gmyth_debug ( "Current directory = %s.", ( *current_dir != NULL ) + ? *current_dir : "[directory not found]" ); - g_object_unref (program); + g_object_unref ( program ); - g_object_unref (slist); + g_object_unref ( slist ); - gmyth_socket_close_connection (socket); + gmyth_socket_close_connection ( socket ); } - g_object_unref (socket); + g_object_unref ( socket ); return res; } @@ -507,22 +525,22 @@ * @return The string representing the file name. */ gchar * -gmyth_util_create_filename (const gint chan_id, const GTimeVal * start_time) +gmyth_util_create_filename ( const gint chan_id, const GTimeVal * start_time ) { gchar *basename = NULL; - g_return_val_if_fail (start_time != NULL, NULL); + g_return_val_if_fail ( start_time != NULL, NULL ); gchar *isodate = - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y%m%d%H%M%S", - start_time); + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y%m%d%H%M%S", + start_time ); - basename = g_strdup_printf ("%d_%s", chan_id, isodate); + basename = g_strdup_printf ( "%d_%s", chan_id, isodate ); - gmyth_debug ("Basename (from chan_id and start_time): %s", basename); + gmyth_debug ( "Basename (from chan_id and start_time): %s", basename ); - if (isodate) - g_free (isodate); + if ( isodate ) + g_free ( isodate ); return basename; } @@ -535,55 +553,60 @@ * @return a pointer to a GList with all the channels. */ GList * -gmyth_util_get_channel_list (GMythBackendInfo * backend_info) +gmyth_util_get_channel_list ( GMythBackendInfo * backend_info ) { GMythRecorder *recorder; GList *channel_list = NULL; gboolean res = FALSE; - gmyth_debug ("Gets channel list."); + gmyth_debug ( "Gets channel list." ); - g_return_val_if_fail (backend_info != NULL, FALSE); + g_return_val_if_fail ( backend_info != NULL, FALSE ); recorder = - gmyth_recorder_new (1, - g_string_new (gmyth_backend_info_get_hostname - (backend_info)), gmyth_backend_info_get_port (backend_info)); - res = gmyth_recorder_setup (recorder); + gmyth_recorder_new ( 1, + g_string_new ( gmyth_backend_info_get_hostname + ( backend_info ) ), + gmyth_backend_info_get_port ( backend_info ) ); + res = gmyth_recorder_setup ( recorder ); - if (res == TRUE) { + if ( res == TRUE ) + { //GList* channel_list = gmyth_recorder_get_channel_list( recorder ); - gmyth_debug ("Yeah, got channel list!!!"); + gmyth_debug ( "Yeah, got channel list!!!" ); GList *ch = NULL; GMythChannelInfo *channel_info = NULL; - for (ch = gmyth_recorder_get_channel_list (recorder); ch != NULL;) { - channel_info = g_malloc0 (sizeof (GMythChannelInfo)); + for ( ch = gmyth_recorder_get_channel_list ( recorder ); ch != NULL; ) + { + channel_info = g_malloc0 ( sizeof ( GMythChannelInfo ) ); channel_info->channel_ID = 0; channel_info->channel_num = - g_string_new (g_strdup ((gchar *) ch->data)); - channel_info->channel_name = g_string_new (""); - gmyth_debug ("Printing channel info... (%s)", - channel_info->channel_num->str); + g_string_new ( g_strdup ( ( gchar * ) ch->data ) ); + channel_info->channel_name = g_string_new ( "" ); + gmyth_debug ( "Printing channel info... (%s)", + channel_info->channel_num->str ); channel_list = - g_list_append (channel_list, - g_memdup (channel_info, sizeof (GMythChannelInfo))); + g_list_append ( channel_list, + g_memdup ( channel_info, + sizeof ( GMythChannelInfo ) ) ); - ch = g_list_next (ch); + ch = g_list_next ( ch ); - if (channel_info != NULL) - g_free (channel_info); + if ( channel_info != NULL ) + g_free ( channel_info ); } - } /* if */ - else { - gmyth_debug ("No, couldn't get the channel list!!!"); + } /* if */ + else + { + gmyth_debug ( "No, couldn't get the channel list!!!" ); } - gmyth_debug ("Got %d channels!!!", g_list_length (channel_list)); + gmyth_debug ( "Got %d channels!!!", g_list_length ( channel_list ) ); - g_object_unref (recorder); + g_object_unref ( recorder ); return channel_list; } @@ -596,51 +619,56 @@ * @return The program info's listage. */ GSList * -gmyth_util_get_all_recordings (GMythBackendInfo * backend_info) +gmyth_util_get_all_recordings ( GMythBackendInfo * backend_info ) { GSList *program_list = NULL; GMythSocket *socket; gboolean res; - socket = gmyth_socket_new (); - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname, - backend_info->port, TRUE); + socket = gmyth_socket_new ( ); + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname, + backend_info->port, TRUE ); - if (res == TRUE) { - GMythStringList *slist = gmyth_string_list_new (); + if ( res == TRUE ) + { + GMythStringList *slist = gmyth_string_list_new ( ); guint pos = 0; - gmyth_string_list_append_char_array (slist, "QUERY_RECORDINGS Play"); + gmyth_string_list_append_char_array ( slist, "QUERY_RECORDINGS Play" ); - gmyth_socket_sendreceive_stringlist (socket, slist); + gmyth_socket_sendreceive_stringlist ( socket, slist ); - if (slist != NULL && (gmyth_string_list_length (slist) > 0)) { + if ( slist != NULL && ( gmyth_string_list_length ( slist ) > 0 ) ) + { GMythProgramInfo *program = NULL; - gmyth_debug ("OK! Got the program list [size=%d].", - gmyth_string_list_length (slist)); + gmyth_debug ( "OK! Got the program list [size=%d].", + gmyth_string_list_length ( slist ) ); - do { + do + { program = - gmyth_program_info_from_string_list_from_pos (slist, pos); + gmyth_program_info_from_string_list_from_pos ( slist, pos ); - if (program != NULL) { + if ( program != NULL ) + { pos += 41; - program_list = g_slist_append (program_list, program); - } else + program_list = g_slist_append ( program_list, program ); + } + else break; } - while (gmyth_string_list_length (slist) > pos); + while ( gmyth_string_list_length ( slist ) > pos ); } /* if */ - g_object_unref (slist); + g_object_unref ( slist ); - gmyth_socket_close_connection (socket); + gmyth_socket_close_connection ( socket ); } - g_object_unref (socket); + g_object_unref ( socket ); return program_list; } @@ -654,27 +682,31 @@ * @return The requested program info. */ GMythProgramInfo * -gmyth_util_get_recording_from_channel (GMythBackendInfo * backend_info, - const gchar * channel) +gmyth_util_get_recording_from_channel ( GMythBackendInfo * backend_info, + const gchar * channel ) { GSList *program_list = NULL; GMythProgramInfo *program = NULL; - program_list = gmyth_util_get_all_recordings (backend_info); + program_list = gmyth_util_get_all_recordings ( backend_info ); - if (program_list != NULL && g_slist_length (program_list) > 0) { + if ( program_list != NULL && g_slist_length ( program_list ) > 0 ) + { GMythProgramInfo *program = NULL; guint pos = 0; - gmyth_debug ("OK! Got the program list [size=%d].", - g_slist_length (program_list)); + gmyth_debug ( "OK! Got the program list [size=%d].", + g_slist_length ( program_list ) ); - while (pos < g_slist_length (program_list)) { - program = (GMythProgramInfo *) g_slist_nth_data (program_list, pos); + while ( pos < g_slist_length ( program_list ) ) + { + program = + ( GMythProgramInfo * ) g_slist_nth_data ( program_list, pos ); - if (program != NULL && program->channame != NULL && - g_ascii_strncasecmp (program->channame->str, channel, - strlen (channel)) == 0) { + if ( program != NULL && program->channame != NULL && + g_ascii_strncasecmp ( program->channame->str, channel, + strlen ( channel ) ) == 0 ) + { break; } @@ -692,7 +724,7 @@ /* Hacked from glib 2.10 */ static time_t -mktime_utc (struct tm *tm) +mktime_utc ( struct tm *tm ) { time_t retval; @@ -703,90 +735,98 @@ #endif #ifndef HAVE_TIMEGM - if (tm->tm_mon < 0 || tm->tm_mon > 11) - return (time_t) - 1; + if ( tm->tm_mon < 0 || tm->tm_mon > 11 ) + return ( time_t ) - 1; - retval = (tm->tm_year - 70) * 365; - retval += (tm->tm_year - 68) / 4; + retval = ( tm->tm_year - 70 ) * 365; + retval += ( tm->tm_year - 68 ) / 4; retval += days_before[tm->tm_mon] + tm->tm_mday - 1; - if (tm->tm_year % 4 == 0 && tm->tm_mon < 2) + if ( tm->tm_year % 4 == 0 && tm->tm_mon < 2 ) retval -= 1; retval = - ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec; + ( ( ( ( retval * 24 ) + tm->tm_hour ) * 60 ) + tm->tm_min ) * 60 + + tm->tm_sec; #else - retval = timegm (tm); + retval = timegm ( tm ); #endif /* !HAVE_TIMEGM */ return retval; } gboolean -g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_) +g_time_val_from_iso8601 ( const gchar * iso_date, GTimeVal * time_ ) { struct tm tm; long val; - g_return_val_if_fail (iso_date != NULL, FALSE); - g_return_val_if_fail (time_ != NULL, FALSE); + g_return_val_if_fail ( iso_date != NULL, FALSE ); + g_return_val_if_fail ( time_ != NULL, FALSE ); - val = strtoul (iso_date, (char **) &iso_date, 10); - if (*iso_date == '-') { + val = strtoul ( iso_date, ( char ** ) &iso_date, 10 ); + if ( *iso_date == '-' ) + { /* YYYY-MM-DD */ tm.tm_year = val - 1900; iso_date++; - tm.tm_mon = strtoul (iso_date, (char **) &iso_date, 10) - 1; + tm.tm_mon = strtoul ( iso_date, ( char ** ) &iso_date, 10 ) - 1; - if (*iso_date++ != '-') + if ( *iso_date++ != '-' ) return FALSE; - tm.tm_mday = strtoul (iso_date, (char **) &iso_date, 10); - } else { + tm.tm_mday = strtoul ( iso_date, ( char ** ) &iso_date, 10 ); + } + else + { /* YYYYMMDD */ tm.tm_mday = val % 100; - tm.tm_mon = (val % 10000) / 100 - 1; + tm.tm_mon = ( val % 10000 ) / 100 - 1; tm.tm_year = val / 10000 - 1900; } - if (*iso_date++ != 'T') + if ( *iso_date++ != 'T' ) return FALSE; - val = strtoul (iso_date, (char **) &iso_date, 10); - if (*iso_date == ':') { + val = strtoul ( iso_date, ( char ** ) &iso_date, 10 ); + if ( *iso_date == ':' ) + { /* hh:mm:ss */ tm.tm_hour = val; iso_date++; - tm.tm_min = strtoul (iso_date, (char **) &iso_date, 10); + tm.tm_min = strtoul ( iso_date, ( char ** ) &iso_date, 10 ); - if (*iso_date++ != ':') + if ( *iso_date++ != ':' ) return FALSE; - tm.tm_sec = strtoul (iso_date, (char **) &iso_date, 10); - } else { + tm.tm_sec = strtoul ( iso_date, ( char ** ) &iso_date, 10 ); + } + else + { /* hhmmss */ tm.tm_sec = val % 100; - tm.tm_min = (val % 10000) / 100; + tm.tm_min = ( val % 10000 ) / 100; tm.tm_hour = val / 10000; } - time_->tv_sec = mktime_utc (&tm); + time_->tv_sec = mktime_utc ( &tm ); time_->tv_usec = 1; - if (*iso_date == '.') - time_->tv_usec = strtoul (iso_date + 1, (char **) &iso_date, 10); + if ( *iso_date == '.' ) + time_->tv_usec = strtoul ( iso_date + 1, ( char ** ) &iso_date, 10 ); - if (*iso_date == '+' || *iso_date == '-') { - gint sign = (*iso_date == '+') ? -1 : 1; + if ( *iso_date == '+' || *iso_date == '-' ) + { + gint sign = ( *iso_date == '+' ) ? -1 : 1; - val = 60 * strtoul (iso_date + 1, (char **) &iso_date, 10); + val = 60 * strtoul ( iso_date + 1, ( char ** ) &iso_date, 10 ); - if (*iso_date == ':') - val = 60 * val + strtoul (iso_date + 1, NULL, 10); + if ( *iso_date == ':' ) + val = 60 * val + strtoul ( iso_date + 1, NULL, 10 ); else - val = 60 * (val / 100) + (val % 100); + val = 60 * ( val / 100 ) + ( val % 100 ); - time_->tv_sec += (time_t) (val * sign); + time_->tv_sec += ( time_t ) ( val * sign ); } return TRUE; @@ -794,18 +834,19 @@ gchar * -g_time_val_to_iso8601 (GTimeVal * time_) +g_time_val_to_iso8601 ( GTimeVal * time_ ) { gchar *retval; - g_return_val_if_fail (time_->tv_usec >= 0 - && time_->tv_usec < G_USEC_PER_SEC, NULL); + g_return_val_if_fail ( time_->tv_usec >= 0 + && time_->tv_usec < G_USEC_PER_SEC, NULL ); #define ISO_8601_LEN 21 #define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ" - retval = g_new0 (gchar, ISO_8601_LEN + 1); + retval = g_new0 ( gchar, ISO_8601_LEN + 1 ); - strftime (retval, ISO_8601_LEN, ISO_8601_FORMAT, gmtime (&(time_->tv_sec))); + strftime ( retval, ISO_8601_LEN, ISO_8601_FORMAT, + gmtime ( &( time_->tv_sec ) ) ); return retval; } @@ -814,32 +855,34 @@ /* Hacked from glib 2.10 */ void -g_date_set_time_t (GDate * date, time_t timet) +g_date_set_time_t ( GDate * date, time_t timet ) { struct tm tm; - g_return_if_fail (date != NULL); + g_return_if_fail ( date != NULL ); #ifdef HAVE_LOCALTIME_R - localtime_r (&timet, &tm); + localtime_r ( &timet, &tm ); #else { - struct tm *ptm = localtime (&timet); + struct tm *ptm = localtime ( &timet ); - if (ptm == NULL) { + if ( ptm == NULL ) + { /* Happens at least in Microsoft's C library if you pass a * negative time_t. Use 2000-01-01 as default date. */ #ifndef G_DISABLE_CHECKS - g_return_if_fail_warning (G_LOG_DOMAIN, "g_date_set_time", - "ptm != NULL"); + g_return_if_fail_warning ( G_LOG_DOMAIN, "g_date_set_time", + "ptm != NULL" ); #endif tm.tm_mon = 0; tm.tm_mday = 1; tm.tm_year = 100; - } else - memcpy ((void *) &tm, (void *) ptm, sizeof (struct tm)); + } + else + memcpy ( ( void * ) &tm, ( void * ) ptm, sizeof ( struct tm ) ); } #endif @@ -849,16 +892,17 @@ date->day = tm.tm_mday; date->year = tm.tm_year + 1900; - g_return_if_fail (g_date_valid_dmy (date->day, date->month, date->year)); + g_return_if_fail ( g_date_valid_dmy + ( date->day, date->month, date->year ) ); date->dmy = TRUE; } void -g_date_set_time_val (GDate * date, GTimeVal * timeval) +g_date_set_time_val ( GDate * date, GTimeVal * timeval ) { - g_date_set_time_t (date, (time_t) timeval->tv_sec); + g_date_set_time_t ( date, ( time_t ) timeval->tv_sec ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_util.h --- a/gmyth/src/gmyth_util.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_util.h Wed May 23 19:50:41 2007 +0100 @@ -10,22 +10,21 @@ * @author Hallyson Luiz de Morais Melo * @author Rosfran Borges * - *//* - * - * 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 - */ + * + * 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_UTIL_H_ #define GMYTH_UTIL_H_ @@ -37,44 +36,50 @@ #include "gmyth_backendinfo.h" #include "gmyth_programinfo.h" -G_BEGIN_DECLS GString *gmyth_util_time_to_isoformat (time_t time_value); -GString *gmyth_util_time_to_string (time_t time_value); -time_t gmyth_util_string_to_time (GString * time_str); +G_BEGIN_DECLS GString *gmyth_util_time_to_isoformat ( time_t time_value ); +GString *gmyth_util_time_to_string ( time_t time_value ); +time_t gmyth_util_string_to_time ( GString * time_str ); -gchar *gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar * - fmt_string, const GTimeVal * time_val); +gchar *gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar * + fmt_string, + const GTimeVal * + time_val ); -GTimeVal *gmyth_util_string_to_time_val_fmt (const gchar * fmt_string, - const gchar * time_str); +GTimeVal *gmyth_util_string_to_time_val_fmt ( const gchar * fmt_string, + const gchar * time_str ); -GTimeVal *gmyth_util_string_to_time_val (const gchar * time_str); +GTimeVal *gmyth_util_string_to_time_val ( const gchar * time_str ); -gchar *gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time); -gchar *gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time); +gchar *gmyth_util_time_to_isoformat_from_time_val ( const GTimeVal * time ); +gchar *gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal * time ); -gchar *gmyth_util_time_to_string_only_date (const GTimeVal * time); +gchar *gmyth_util_time_to_string_only_date ( const GTimeVal * time ); -gchar *gmyth_util_time_to_string_only_time (const GTimeVal * time); +gchar *gmyth_util_time_to_string_only_time ( const GTimeVal * time ); -gchar *gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val); +gchar *gmyth_util_time_to_string_from_time_val ( const GTimeVal * time_val ); -struct tm *gmyth_util_time_val_to_date (const GTimeVal * time); +struct tm *gmyth_util_time_val_to_date ( const GTimeVal * time ); -gboolean gmyth_util_file_exists (GMythBackendInfo * backend_info, - const gchar * filename); +gboolean gmyth_util_file_exists ( GMythBackendInfo * backend_info, + const gchar * filename ); -gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo * - backend_info, const gchar * filename, gchar ** current_dir); +gboolean gmyth_util_file_exists_and_get_remote_dir ( GMythBackendInfo * + backend_info, + const gchar * filename, + gchar ** current_dir ); -gchar *gmyth_util_create_filename (const gint chan_id, - const GTimeVal * start_time); +gchar *gmyth_util_create_filename ( const gint chan_id, + const GTimeVal * start_time ); -GList *gmyth_util_get_channel_list (GMythBackendInfo * backend_info); +GList *gmyth_util_get_channel_list ( GMythBackendInfo * backend_info ); -GSList *gmyth_util_get_all_recordings (GMythBackendInfo * backend_info); +GSList *gmyth_util_get_all_recordings ( GMythBackendInfo * backend_info ); -GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo * - backend_info, const gchar * channel); +GMythProgramInfo *gmyth_util_get_recording_from_channel ( GMythBackendInfo * + backend_info, + const gchar * + channel ); G_END_DECLS #endif /*GMYTH_UTIL_H_ */ diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_vlc.c --- a/gmyth/src/gmyth_vlc.c Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_vlc.c Wed May 23 19:50:41 2007 +0100 @@ -36,8 +36,8 @@ #include "gmyth_socket.h" /* static functions */ -static int _socket_send (int socket, gchar * msg); -static int _socket_recv (int socket, gchar * buf); +static int _socket_send ( int socket, gchar * msg ); +static int _socket_recv ( int socket, gchar * buf ); /** Primitive function to send a message through the socket * @@ -46,17 +46,17 @@ * @return 0 if success */ static int -_socket_send (int socket, gchar * msg) +_socket_send ( int socket, gchar * msg ) { - size_t size = strlen (msg) + 2; // (\n + \0) - gchar *final = (gchar *) g_malloc0 (sizeof (gchar) * size); + size_t size = strlen ( msg ) + 2; // (\n + \0) + gchar *final = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size ); - g_snprintf (final, size, "%s\n", msg); + g_snprintf ( final, size, "%s\n", msg ); - if (send (socket, final, strlen (final), 0) == -1) - perror ("GMyth_VLC: send error"); + if ( send ( socket, final, strlen ( final ), 0 ) == -1 ) + perror ( "GMyth_VLC: send error" ); - g_free (final); + g_free ( final ); return 0; } @@ -68,12 +68,13 @@ * @return 0 if success */ static int -_socket_recv (int socket, gchar * buf) +_socket_recv ( int socket, gchar * buf ) { int numbytes = 0; - if ((numbytes = recv (socket, buf, BUFFER - 1, 0)) == -1) { - perror ("GMyth_VLC: recv error"); + if ( ( numbytes = recv ( socket, buf, BUFFER - 1, 0 ) ) == -1 ) + { + perror ( "GMyth_VLC: recv error" ); return -1; } @@ -91,18 +92,19 @@ * @return 0 if success */ int -gmyth_vlc_setup_output (GMythVlc * vlc, int output, gchar * kind, gchar * opts) +gmyth_vlc_setup_output ( GMythVlc * vlc, int output, gchar * kind, + gchar * opts ) { int ret; - size_t size = strlen (opts) + 25; - gchar *msg = g_malloc0 (sizeof (gchar) * size); + size_t size = strlen ( opts ) + 25; + gchar *msg = g_malloc0 ( sizeof ( gchar ) * size ); - g_snprintf (msg, size, "setup output%d %s %s", output, kind, opts); + g_snprintf ( msg, size, "setup output%d %s %s", output, kind, opts ); - ret = _socket_send (vlc->sockfd, msg); + ret = _socket_send ( vlc->sockfd, msg ); - g_free (msg); + g_free ( msg ); return ret; } @@ -115,9 +117,9 @@ * @return 0 if success */ int -gmyth_vlc_clean_playlist (GMythVlc * vlc) +gmyth_vlc_clean_playlist ( GMythVlc * vlc ) { - return _socket_send (vlc->sockfd, "del all"); + return _socket_send ( vlc->sockfd, "del all" ); } @@ -129,16 +131,16 @@ * @return 0 if success */ int -gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command) +gmyth_vlc_control_input ( GMythVlc * vlc, int output, gchar * command ) { size_t size = 25; - gchar *msg = g_malloc0 (sizeof (gchar) * size); + gchar *msg = g_malloc0 ( sizeof ( gchar ) * size ); - g_snprintf (msg, size, "control output%d %s", output, command); + g_snprintf ( msg, size, "control output%d %s", output, command ); - int ret = _socket_send (vlc->sockfd, msg); + int ret = _socket_send ( vlc->sockfd, msg ); - g_free (msg); + g_free ( msg ); return ret; } @@ -152,9 +154,9 @@ * @return 0 if success */ int -gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file) +gmyth_vlc_create_input ( GMythVlc * vlc, int output, gchar * file ) { - return gmyth_vlc_setup_output (vlc, output, "input", file); + return gmyth_vlc_setup_output ( vlc, output, "input", file ); } @@ -166,43 +168,44 @@ * @return 0 if success */ int -gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type, int port, int vcodec) +gmyth_vlc_create_channel ( GMythVlc * vlc, gchar * type, int port, int vcodec ) { int ret; size_t size = 40; - gchar *msg = (gchar *) g_malloc0 (sizeof (gchar) * size); + gchar *msg = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size ); - g_snprintf (msg, size, "new output%d %s enabled loop", - vlc->n_outputs, type); + g_snprintf ( msg, size, "new output%d %s enabled loop", + vlc->n_outputs, type ); - ret = _socket_send (vlc->sockfd, msg); + ret = _socket_send ( vlc->sockfd, msg ); - if (ret > -1) { - gmyth_vlc_setup_output (vlc, vlc->n_outputs, "option", "sout-keep=1"); + if ( ret > -1 ) + { + gmyth_vlc_setup_output ( vlc, vlc->n_outputs, "option", "sout-keep=1" ); - g_free (msg); + g_free ( msg ); size = 256; - msg = (gchar *) g_malloc0 (sizeof (gchar) * size); + msg = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size ); - if (vcodec == MPEG1) + if ( vcodec == MPEG1 ) // Best transcode option for N800 (MP1V) - g_snprintf (msg, size, "#transcode{vcodec=mp1v,vb=384," - "fps=25.0,scale=1,acodec=mpga," - "ab=64,channels=1}:duplicate{dst=" - "std{access=http,mux=mpeg1,dst=" ":%d}}", port); + g_snprintf ( msg, size, "#transcode{vcodec=mp1v,vb=384," + "fps=25.0,scale=1,acodec=mpga," + "ab=64,channels=1}:duplicate{dst=" + "std{access=http,mux=mpeg1,dst=" ":%d}}", port ); else // Best transcode option for N800 (THEORA) - g_snprintf (msg, size, "#transcode{vcodec=theo,vb=384," - "fps=25.0,scale=1,acodec=vorb," - "ab=64,channels=1}:duplicate{dst=" - "std{access=http,mux=ogg,dst=" ":%d}}", port); + g_snprintf ( msg, size, "#transcode{vcodec=theo,vb=384," + "fps=25.0,scale=1,acodec=vorb," + "ab=64,channels=1}:duplicate{dst=" + "std{access=http,mux=ogg,dst=" ":%d}}", port ); - ret = gmyth_vlc_setup_output (vlc, vlc->n_outputs, "output", msg); + ret = gmyth_vlc_setup_output ( vlc, vlc->n_outputs, "output", msg ); vlc->n_outputs++; } - g_free (msg); + g_free ( msg ); return ret; } @@ -216,44 +219,48 @@ * @return 0 if success */ int -gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info, - gchar * passwd, int port) +gmyth_vlc_connect ( GMythVlc * vlc, GMythBackendInfo * backend_info, + gchar * passwd, int port ) { int numbytes; - if ((vlc->he = gethostbyname (backend_info->hostname)) == NULL) { - herror ("GMyth_VLC: gethostbyname error"); + if ( ( vlc->he = gethostbyname ( backend_info->hostname ) ) == NULL ) + { + herror ( "GMyth_VLC: gethostbyname error" ); return -1; } - if ((vlc->sockfd = socket (PF_INET, SOCK_STREAM, 0)) == -1) { - perror ("GMyth_VLC: socket error"); + if ( ( vlc->sockfd = socket ( PF_INET, SOCK_STREAM, 0 ) ) == -1 ) + { + perror ( "GMyth_VLC: socket error" ); return -1; } // Socket properties vlc->their_addr.sin_family = AF_INET; - vlc->their_addr.sin_port = htons (port); - vlc->their_addr.sin_addr = *((struct in_addr *) vlc->he->h_addr); - memset (&(vlc->their_addr.sin_zero), '\0', 8); + vlc->their_addr.sin_port = htons ( port ); + vlc->their_addr.sin_addr = *( ( struct in_addr * ) vlc->he->h_addr ); + memset ( &( vlc->their_addr.sin_zero ), '\0', 8 ); - if (connect (vlc->sockfd, (struct sockaddr *) &(vlc->their_addr), - sizeof (struct sockaddr)) == -1) { - perror ("GMyth_VLC: connect error. Check VLC's telnet interface"); + if ( connect ( vlc->sockfd, ( struct sockaddr * ) &( vlc->their_addr ), + sizeof ( struct sockaddr ) ) == -1 ) + { + perror ( "GMyth_VLC: connect error. Check VLC's telnet interface" ); return -1; } // Receive the Password's Prompt - numbytes = _socket_recv (vlc->sockfd, vlc->buf); + numbytes = _socket_recv ( vlc->sockfd, vlc->buf ); // Send the Password. We don't have to // care about passwords being sent in plain text // because telnet protocol does it. - _socket_send (vlc->sockfd, passwd); + _socket_send ( vlc->sockfd, passwd ); // Receive the Welcome msg - numbytes = _socket_recv (vlc->sockfd, vlc->buf); - if (numbytes > -1) - if (strncmp (vlc->buf, "\r\nWrong password.", 17) == 0) { - perror ("Gmyth_VLC: passwd error. Check your passwd"); + numbytes = _socket_recv ( vlc->sockfd, vlc->buf ); + if ( numbytes > -1 ) + if ( strncmp ( vlc->buf, "\r\nWrong password.", 17 ) == 0 ) + { + perror ( "Gmyth_VLC: passwd error. Check your passwd" ); return -2; } @@ -269,17 +276,18 @@ * @return 0 if success */ int -gmyth_vlc_disconnect (GMythVlc * vlc) +gmyth_vlc_disconnect ( GMythVlc * vlc ) { int ret; - ret = gmyth_vlc_clean_playlist (vlc); + ret = gmyth_vlc_clean_playlist ( vlc ); - if (ret > -1) { + if ( ret > -1 ) + { vlc->n_outputs = 0; vlc->n_inputs = 0; } - return close (vlc->sockfd); + return close ( vlc->sockfd ); } diff -r 9ade4c5e5db8 -r 2f28edb4d804 gmyth/src/gmyth_vlc.h --- a/gmyth/src/gmyth_vlc.h Wed May 23 19:21:26 2007 +0100 +++ b/gmyth/src/gmyth_vlc.h Wed May 23 19:50:41 2007 +0100 @@ -53,42 +53,42 @@ typedef struct _GMythVlc GMythVlc; struct _GMythVlc -{ - int sockfd; + { + int sockfd; - // Number of outputs used - int n_outputs; + // Number of outputs used + int n_outputs; - // Number of inputs - int n_inputs; + // Number of inputs + int n_inputs; - // Socket vars - struct hostent *he; - struct sockaddr_in their_addr; + // Socket vars + struct hostent *he; + struct sockaddr_in their_addr; - char buf[BUFFER]; -}; + char buf[BUFFER]; + }; -int gmyth_vlc_setup_output (GMythVlc * vlc, int output, - gchar * kind, gchar * opts); +int gmyth_vlc_setup_output ( GMythVlc * vlc, int output, + gchar * kind, gchar * opts ); -int gmyth_vlc_clean_playlist (GMythVlc * vlc); +int gmyth_vlc_clean_playlist ( GMythVlc * vlc ); -int gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command); +int gmyth_vlc_control_input ( GMythVlc * vlc, int output, gchar * command ); -int gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file); +int gmyth_vlc_create_input ( GMythVlc * vlc, int output, gchar * file ); -int gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type, - int port, int vcodec); +int gmyth_vlc_create_channel ( GMythVlc * vlc, gchar * type, + int port, int vcodec ); -int gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info, - gchar * passwd, int port); +int gmyth_vlc_connect ( GMythVlc * vlc, GMythBackendInfo * backend_info, + gchar * passwd, int port ); -int gmyth_vlc_disconnect (GMythVlc * vlc); +int gmyth_vlc_disconnect ( GMythVlc * vlc ); G_END_DECLS #endif /* __GMYTH_VLC_H__ */