[svn r704] Added gmyth-upnp-search, to search for MythTV UPnP devices. trunk
authorrosfran
Wed May 23 16:11:29 2007 +0100 (2007-05-23)
branchtrunk
changeset 6989019388af980
parent 697 e323e95b88dd
child 699 3710052a05c9
[svn r704] Added gmyth-upnp-search, to search for MythTV UPnP devices.
gmyth/configure.ac
gmyth/samples/Makefile.am
gmyth/samples/gmyth_upnp_search.c
gmyth/src/Makefile.am
gmyth/src/gmyth-indent.sh
gmyth/src/gmyth.h
gmyth/src/gmyth_backendinfo.c
gmyth/src/gmyth_backendinfo.h
gmyth/src/gmyth_common.c
gmyth/src/gmyth_common.h
gmyth/src/gmyth_debug.c
gmyth/src/gmyth_debug.h
gmyth/src/gmyth_epg.c
gmyth/src/gmyth_epg.h
gmyth/src/gmyth_file.c
gmyth/src/gmyth_file.h
gmyth/src/gmyth_file_local.c
gmyth/src/gmyth_file_local.h
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_file_transfer.h
gmyth/src/gmyth_http.c
gmyth/src/gmyth_http.h
gmyth/src/gmyth_jobqueue.c
gmyth/src/gmyth_jobqueue.h
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_livetv.h
gmyth/src/gmyth_monitor_handler.c
gmyth/src/gmyth_monitor_handler.h
gmyth/src/gmyth_programinfo.c
gmyth/src/gmyth_programinfo.h
gmyth/src/gmyth_query.c
gmyth/src/gmyth_query.h
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_recorder.h
gmyth/src/gmyth_recprofile.c
gmyth/src/gmyth_recprofile.h
gmyth/src/gmyth_remote_util.c
gmyth/src/gmyth_remote_util.h
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_scheduler.h
gmyth/src/gmyth_socket.c
gmyth/src/gmyth_socket.h
gmyth/src/gmyth_stringlist.c
gmyth/src/gmyth_stringlist.h
gmyth/src/gmyth_transcoder.c
gmyth/src/gmyth_transcoder.h
gmyth/src/gmyth_tvchain.c
gmyth/src/gmyth_tvchain.h
gmyth/src/gmyth_uri.c
gmyth/src/gmyth_uri.h
gmyth/src/gmyth_util.c
gmyth/src/gmyth_util.h
gmyth/src/gmyth_vlc.c
gmyth/src/gmyth_vlc.h
     1.1 --- a/gmyth/configure.ac	Tue May 22 19:21:42 2007 +0100
     1.2 +++ b/gmyth/configure.ac	Wed May 23 16:11:29 2007 +0100
     1.3 @@ -149,6 +149,20 @@
     1.4          CFLAGS="$CFLAGS -pg"
     1.5  fi
     1.6  
     1.7 +AC_ARG_ENABLE(upnp,
     1.8 +        AS_HELP_STRING([--enable-upnp],
     1.9 +                [enable clinkc's UPnP library (default = no)]),
    1.10 +                [
    1.11 +                        if test $enableval = no; then
    1.12 +                                USE_UPNP=no;
    1.13 +                        else
    1.14 +                                USE_UPNP=yes;
    1.15 +                        fi
    1.16 +                ],[
    1.17 +                        USE_UPNP=no;
    1.18 +                ]
    1.19 +)
    1.20 +
    1.21  # Check for pkgconfig
    1.22  AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
    1.23  # Give error and exit if we don't have pkgconfig
    1.24 @@ -218,6 +232,16 @@
    1.25  AC_SUBST(LIBCURL_CFLAGS)
    1.26  AC_SUBST(LIBCURL_LIBS)
    1.27  
    1.28 +if [ test $USE_UPNP = yes ]; then
    1.29 +	# checks if the gmyth-upnp library can be found
    1.30 +	PKG_CHECK_MODULES(UPNP, gmyth-upnp, HAVE_UPNP=yes, HAVE_UPNP=no)
    1.31 +	if test "x$HAVE_UPNP" = "xyes"; then
    1.32 +		AC_DEFINE(HAVE_UPNP, 1, [GMyth UPnP library found!])
    1.33 +		CFLAGS="$CFLAGS -DHAVE_UPNP"
    1.34 +	fi
    1.35 +fi
    1.36 +
    1.37 +AM_CONDITIONAL(HAVE_UPNP, test "x$HAVE_UPNP" = "xyes")
    1.38  
    1.39  #
    1.40  # mysql libraries
    1.41 @@ -228,7 +252,6 @@
    1.42  fi
    1.43  AC_SUBST(MYSQL_CFLAGS)
    1.44  
    1.45 -
    1.46  AC_CHECK_PROG(MYSQL_LIBS,mysql_config,`mysql_config --libs`)
    1.47  if test -z "$MYSQL_LIBS"; then
    1.48          AC_MSG_ERROR([Could not find mysql_config script. Make sure the mysql client libraries are installed])
     2.1 --- a/gmyth/samples/Makefile.am	Tue May 22 19:21:42 2007 +0100
     2.2 +++ b/gmyth/samples/Makefile.am	Wed May 23 16:11:29 2007 +0100
     2.3 @@ -1,4 +1,4 @@
     2.4 -bin_PROGRAMS = gmyth-cat gmyth-ls
     2.5 +bin_PROGRAMS = gmyth-cat gmyth-ls gmyth-upnp-search
     2.6  
     2.7  gmyth_cat_SOURCES = \
     2.8          gmyth_cat.c
     2.9 @@ -6,6 +6,11 @@
    2.10  gmyth_ls_SOURCES = \
    2.11          gmyth_ls.c
    2.12  
    2.13 +if HAVE_UPNP
    2.14 +gmyth_upnp_search_SOURCES = \
    2.15 +        gmyth_upnp_search.c
    2.16 +endif
    2.17 +
    2.18  LDADD = \
    2.19          $(top_builddir)/src/libgmyth.la
    2.20  
    2.21 @@ -19,4 +24,11 @@
    2.22          -I$(top_srcdir)/src \
    2.23          $(GLIB_CFLAGS) \
    2.24          $(GOBJECT_CFLAGS)
    2.25 +if HAVE_UPNP
    2.26 +INCLUDES += \
    2.27 +	$(UPNP_CFLAGS)
    2.28  
    2.29 +AM_LDFLAGS += \
    2.30 +	$(UPNP_LIBS)
    2.31 +endif
    2.32 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/gmyth/samples/gmyth_upnp_search.c	Wed May 23 16:11:29 2007 +0100
     3.3 @@ -0,0 +1,119 @@
     3.4 +
     3.5 +#ifdef HAVE_CONFIG_H
     3.6 +#include "config.h"
     3.7 +#endif
     3.8 +
     3.9 +#include <stdio.h>
    3.10 +#include <glib.h>
    3.11 +
    3.12 +#include <gmyth-upnp/gmyth_upnp.h>
    3.13 +
    3.14 +#include "gmyth_backendinfo.h"
    3.15 +#include "gmyth_file_transfer.h"
    3.16 +#include "gmyth_livetv.h"
    3.17 +#include "gmyth_util.h"
    3.18 +#include "gmyth_common.h"
    3.19 +
    3.20 +typedef struct {
    3.21 +    GMythBackendInfo *b_info;
    3.22 +    gchar* mythtv_id;
    3.23 +} gupnp_options_t;
    3.24 +
    3.25 +static gupnp_options_t*
    3.26 +_gupnp_options_new ()
    3.27 +{
    3.28 +    gupnp_options_t *options = g_new0 (gupnp_options_t, 1);
    3.29 +    options->b_info = gmyth_backend_info_new ();
    3.30 +
    3.31 +    return options;
    3.32 +}
    3.33 +
    3.34 +static void
    3.35 +_gupnp_options_free (gupnp_options_t *options)
    3.36 +{
    3.37 +    g_return_if_fail (options != NULL);
    3.38 +
    3.39 +    if (options->b_info)
    3.40 +        g_object_unref (options->b_info);
    3.41 +    g_free (options->mythtv_id);
    3.42 +}
    3.43 +
    3.44 +static gboolean
    3.45 +_parse_args (int argc, char *argv[], gupnp_options_t *options)
    3.46 +{
    3.47 +    GError *error = NULL;
    3.48 +    GOptionContext *context;
    3.49 +
    3.50 +    gchar *mythtv_id = NULL;
    3.51 +
    3.52 +    GOptionEntry entries[] =
    3.53 +    {
    3.54 +        { "mythtvid", 'm', 0, G_OPTION_ARG_STRING, &mythtv_id, "MythTV UPnP service "
    3.55 +          "identifigupnpion", "UPNP_ID" },
    3.56 +    
    3.57 +        { NULL }
    3.58 +    };
    3.59 +
    3.60 +    g_return_val_if_fail (options != NULL, FALSE);
    3.61 +
    3.62 +    context = g_option_context_new ("- searches for a list of connected mythtv backend recorded "
    3.63 +    				    "file and prints it on the standard output\n");
    3.64 +    g_option_context_add_main_entries (context, entries, NULL);
    3.65 +    g_option_context_parse (context, &argc, &argv, &error);
    3.66 +    g_option_context_set_help_enabled (context, TRUE);
    3.67 +
    3.68 +    g_option_context_free (context);
    3.69 +
    3.70 +    g_free (mythtv_id);
    3.71 +
    3.72 +    return TRUE;
    3.73 +}
    3.74 +
    3.75 +
    3.76 +static void
    3.77 +_got_upnp_device( GMythUPnPDeviceStatus status, gchar *udn )
    3.78 +{
    3.79 +	g_print( "Got Device !!! [%d, %s]", status, udn );
    3.80 +}
    3.81 +
    3.82 +static gboolean
    3.83 +_gupnp_search_devices (gupnp_options_t *options)
    3.84 +{
    3.85 +    GList *upnp_servers = NULL;
    3.86 +    GMythUPnP *gupnp;
    3.87 +    GMythBackendInfo *backend_info = gmyth_backend_info_new();
    3.88 +
    3.89 +    g_return_val_if_fail (options != NULL, FALSE);
    3.90 +    g_return_val_if_fail (options->b_info != NULL, FALSE);
    3.91 +
    3.92 +    gupnp = gmyth_upnp_new( backend_info, _got_upnp_device );
    3.93 +    upnp_servers = gmyth_upnp_do_search_sync( gupnp );
    3.94 +
    3.95 +    g_list_free (upnp_servers);
    3.96 +    g_object_unref (gupnp);
    3.97 +
    3.98 +    return TRUE;
    3.99 +}
   3.100 +
   3.101 +int
   3.102 +main (int argc, char *argv[])
   3.103 +{
   3.104 +    gboolean res = FALSE;
   3.105 +    gupnp_options_t *options;
   3.106 +
   3.107 +    g_type_init ();
   3.108 +    if (!g_thread_supported()) g_thread_init (NULL);
   3.109 +
   3.110 +    options = _gupnp_options_new ();
   3.111 +    res = _parse_args (argc, argv, options);
   3.112 +    if (!res) {
   3.113 +        g_printerr ("Argument invalid. Type --help\n");
   3.114 +        return 1;
   3.115 +    }
   3.116 +
   3.117 +    res = _gupnp_search_devices (options);
   3.118 +
   3.119 +    _gupnp_options_free (options);
   3.120 +
   3.121 +    return 0;
   3.122 +}
     4.1 --- a/gmyth/src/Makefile.am	Tue May 22 19:21:42 2007 +0100
     4.2 +++ b/gmyth/src/Makefile.am	Wed May 23 16:11:29 2007 +0100
     4.3 @@ -100,10 +100,10 @@
     4.4  if HAVE_INDENT
     4.5  indent: 
     4.6  	@for src_file in $(libgmyth_la_SOURCES); do \
     4.7 -		indent -gnu -i4 -l80 -bfda -nut -pcs -psl -bli0 -cs -cli4 -nbfda -sai -saw -saf -sbi4 -npro -nfca $$src_file; \
     4.8 +		./gst-indent.sh $$src_file; \
     4.9  	done; \
    4.10  	for inc_file in $(libgmyth_include_HEADERS); do \
    4.11 -		indent -gnu -i4 -l80 -bfda -nut -pcs -psl -bli0 -cs -cli4 -nbfda -sai -saw -saf -sbi4 -npro -nfca $$inc_file; \
    4.12 +		./gst-indent.sh $$inc_file; \
    4.13  	done;
    4.14  endif
    4.15  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gmyth/src/gmyth-indent.sh	Wed May 23 16:11:29 2007 +0100
     5.3 @@ -0,0 +1,25 @@
     5.4 +#!/bin/sh
     5.5 +indent \
     5.6 +	-gnu \
     5.7 +	-i4 \
     5.8 +	-l80 \
     5.9 +	-bfda \
    5.10 +	-nut \
    5.11 +	-pcs \
    5.12 +	-psl \
    5.13 +	-bli0 \
    5.14 +	-cs \
    5.15 +	-cli0 \
    5.16 +	-nbfda \
    5.17 +	-sai \
    5.18 +	-saw \
    5.19 +	-saf \
    5.20 +	-sbi4 \
    5.21 +	-npro \
    5.22 +	-nfca \
    5.23 +	-nsc \
    5.24 +	-ts4 \
    5.25 +	-prs \
    5.26 +	-bap \
    5.27 +	$*
    5.28 +
     6.1 --- a/gmyth/src/gmyth.h	Tue May 22 19:21:42 2007 +0100
     6.2 +++ b/gmyth/src/gmyth.h	Wed May 23 16:11:29 2007 +0100
     6.3 @@ -7,22 +7,22 @@
     6.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
     6.5   * @author Renato Filho <renato.filho@indt.org.br>
     6.6   *
     6.7 - *//*
     6.8 - * 
     6.9 - * This program is free software; you can redistribute it and/or modify
    6.10 - * it under the terms of the GNU Lesser General Public License as published by
    6.11 - * the Free Software Foundation; either version 2 of the License, or
    6.12 - * (at your option) any later version.
    6.13 - *
    6.14 - * This program is distributed in the hope that it will be useful,
    6.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.17 - * GNU General Public License for more details.
    6.18 - *
    6.19 - * You should have received a copy of the GNU Lesser General Public License
    6.20 - * along with this program; if not, write to the Free Software
    6.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.22 - */
    6.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
    6.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
    6.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
    6.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
    6.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
    6.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
    6.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    6.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
    6.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
    6.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    6.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
    6.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
    6.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    6.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
    6.39  
    6.40  
    6.41  
     7.1 --- a/gmyth/src/gmyth_backendinfo.c	Tue May 22 19:21:42 2007 +0100
     7.2 +++ b/gmyth/src/gmyth_backendinfo.c	Wed May 23 16:11:29 2007 +0100
     7.3 @@ -10,23 +10,23 @@
     7.4   * @author Hallyson Melo <hallyson.melo@indt.org.br>
     7.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
     7.6   *
     7.7 - *//*
     7.8 - * 
     7.9 - * This program is free software; you can redistribute it and/or modify
    7.10 - * it under the terms of the GNU Lesser General Public License as published by
    7.11 - * the Free Software Foundation; either version 2 of the License, or
    7.12 - * (at your option) any later version.
    7.13 - *
    7.14 - * This program is distributed in the hope that it will be useful,
    7.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.17 - * GNU General Public License for more details.
    7.18 - *
    7.19 - * You should have received a copy of the GNU Lesser General Public License
    7.20 - * along with this program; if not, write to the Free Software
    7.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.22 - */
    7.23 - 
    7.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
    7.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
    7.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
    7.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
    7.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
    7.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
    7.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    7.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
    7.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
    7.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    7.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
    7.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
    7.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
    7.40 +
    7.41  #ifdef HAVE_CONFIG_H
    7.42  #include "config.h"
    7.43  #endif
    7.44 @@ -35,38 +35,36 @@
    7.45  #include "gmyth_uri.h"
    7.46  #include "gmyth_debug.h"
    7.47  
    7.48 -static void gmyth_backend_info_class_init  (GMythBackendInfoClass *klass);
    7.49 -static void gmyth_backend_info_init        (GMythBackendInfo *object);
    7.50 +static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass);
    7.51 +static void gmyth_backend_info_init (GMythBackendInfo * object);
    7.52  
    7.53 -static void gmyth_backend_info_dispose  (GObject *object);
    7.54 -static void gmyth_backend_info_finalize (GObject *object);
    7.55 +static void gmyth_backend_info_dispose (GObject * object);
    7.56 +static void gmyth_backend_info_finalize (GObject * object);
    7.57  
    7.58 -G_DEFINE_TYPE(GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT)
    7.59 -    
    7.60 -static void
    7.61 -gmyth_backend_info_class_init (GMythBackendInfoClass *klass)
    7.62 +G_DEFINE_TYPE (GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT)
    7.63 +     static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass)
    7.64  {
    7.65      GObjectClass *gobject_class;
    7.66  
    7.67      gobject_class = (GObjectClass *) klass;
    7.68  
    7.69 -    gobject_class->dispose  = gmyth_backend_info_dispose;
    7.70 -    gobject_class->finalize = gmyth_backend_info_finalize;	
    7.71 +    gobject_class->dispose = gmyth_backend_info_dispose;
    7.72 +    gobject_class->finalize = gmyth_backend_info_finalize;
    7.73  }
    7.74  
    7.75  static void
    7.76 -gmyth_backend_info_init (GMythBackendInfo *backend_info)
    7.77 +gmyth_backend_info_init (GMythBackendInfo * backend_info)
    7.78  {
    7.79      backend_info->hostname = NULL;
    7.80      backend_info->username = NULL;
    7.81 -    backend_info->password = NULL;    
    7.82 -    backend_info->db_name  = NULL;
    7.83 +    backend_info->password = NULL;
    7.84 +    backend_info->db_name = NULL;
    7.85      backend_info->port = -1;
    7.86      backend_info->status_port = -1;
    7.87  }
    7.88  
    7.89  static void
    7.90 -gmyth_backend_info_dispose  (GObject *object)
    7.91 +gmyth_backend_info_dispose (GObject * object)
    7.92  {
    7.93      GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO (object);
    7.94  
    7.95 @@ -78,7 +76,7 @@
    7.96      backend_info->hostname = NULL;
    7.97      backend_info->username = NULL;
    7.98      backend_info->password = NULL;
    7.99 -    backend_info->db_name  = NULL;
   7.100 +    backend_info->db_name = NULL;
   7.101      backend_info->port = -1;
   7.102      backend_info->status_port = -1;
   7.103  
   7.104 @@ -86,7 +84,7 @@
   7.105  }
   7.106  
   7.107  static void
   7.108 -gmyth_backend_info_finalize (GObject *object)
   7.109 +gmyth_backend_info_finalize (GObject * object)
   7.110  {
   7.111      g_signal_handlers_destroy (object);
   7.112  
   7.113 @@ -98,12 +96,12 @@
   7.114   * 
   7.115   * @return a new instance of GMythBackendInfo.
   7.116   */
   7.117 -GMythBackendInfo*
   7.118 +GMythBackendInfo *
   7.119  gmyth_backend_info_new ()
   7.120  {
   7.121 -    GMythBackendInfo *backend_info = 
   7.122 -        GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
   7.123 -    
   7.124 +    GMythBackendInfo *backend_info =
   7.125 +        GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
   7.126 +
   7.127      return backend_info;
   7.128  }
   7.129  
   7.130 @@ -119,12 +117,12 @@
   7.131   * 
   7.132   * @return a new instance of GMythBackendInfo.
   7.133   */
   7.134 -GMythBackendInfo*
   7.135 -gmyth_backend_info_new_full (const gchar *hostname, const gchar *username,
   7.136 -	const gchar *password, const gchar *db_name, gint port)
   7.137 +GMythBackendInfo *
   7.138 +gmyth_backend_info_new_full (const gchar * hostname, const gchar * username,
   7.139 +    const gchar * password, const gchar * db_name, gint port)
   7.140  {
   7.141 -    GMythBackendInfo *backend_info = 
   7.142 -        GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
   7.143 +    GMythBackendInfo *backend_info =
   7.144 +        GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
   7.145  
   7.146      gmyth_backend_info_set_hostname (backend_info, hostname);
   7.147      gmyth_backend_info_set_username (backend_info, username);
   7.148 @@ -143,48 +141,51 @@
   7.149   * 
   7.150   * @return a new instance of GMythBackendInfo.
   7.151   */
   7.152 -GMythBackendInfo*
   7.153 -gmyth_backend_info_new_with_uri ( const gchar *uri_str )
   7.154 +GMythBackendInfo *
   7.155 +gmyth_backend_info_new_with_uri (const gchar * uri_str)
   7.156  {
   7.157 -    GMythBackendInfo *backend_info = 
   7.158 -        GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
   7.159 -        
   7.160 -    GMythURI *uri = gmyth_uri_new_with_value( uri_str );
   7.161 -    
   7.162 -    gchar** path_parts = g_strsplit( gmyth_uri_get_path (uri), "&", -1 );
   7.163 -    
   7.164 -    gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri) );
   7.165 -    gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user (uri) );
   7.166 -    gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password (uri) );
   7.167 +    GMythBackendInfo *backend_info =
   7.168 +        GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
   7.169 +
   7.170 +    GMythURI *uri = gmyth_uri_new_with_value (uri_str);
   7.171 +
   7.172 +    gchar **path_parts = g_strsplit (gmyth_uri_get_path (uri), "&", -1);
   7.173 +
   7.174 +    gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri));
   7.175 +    gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user (uri));
   7.176 +    gmyth_backend_info_set_password (backend_info,
   7.177 +        gmyth_uri_get_password (uri));
   7.178  
   7.179      /* gets the path info to database name, from the URI, and removes the trash chars */
   7.180 -    gmyth_backend_info_set_db_name (backend_info, path_parts != NULL && 
   7.181 -                                    strlen( path_parts[0] ) > 0 ? 
   7.182 -                                        g_strstrip( g_strdelimit( path_parts[0], "/?", ' ' ) )
   7.183 -                						: gmyth_uri_get_path (uri) );
   7.184 +    gmyth_backend_info_set_db_name (backend_info, path_parts != NULL &&
   7.185 +        strlen (path_parts[0]) > 0 ?
   7.186 +        g_strstrip (g_strdelimit
   7.187 +            (path_parts[0], "/?", ' ')) : gmyth_uri_get_path (uri));
   7.188  
   7.189 -    gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port (uri) );
   7.190 -    
   7.191 +    gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port (uri));
   7.192 +
   7.193      g_object_unref (uri);
   7.194 -    g_strfreev( path_parts );
   7.195 -		
   7.196 +    g_strfreev (path_parts);
   7.197 +
   7.198      return backend_info;
   7.199  }
   7.200  
   7.201  void
   7.202 -gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const gchar *hostname)
   7.203 +gmyth_backend_info_set_hostname (GMythBackendInfo * backend_info,
   7.204 +    const gchar * hostname)
   7.205  {
   7.206      g_return_if_fail (backend_info != NULL);
   7.207 -    
   7.208 -    if ( NULL == hostname || strlen(hostname) <= 0 ) { 
   7.209 -        gmyth_debug ( "Error trying to set a hostname equals to NULL." );
   7.210 -    } else {    	
   7.211 +
   7.212 +    if (NULL == hostname || strlen (hostname) <= 0) {
   7.213 +        gmyth_debug ("Error trying to set a hostname equals to NULL.");
   7.214 +    } else {
   7.215          backend_info->hostname = g_strdup (hostname);
   7.216      }
   7.217  }
   7.218  
   7.219  void
   7.220 -gmyth_backend_info_set_username (GMythBackendInfo *backend_info, const gchar *username)
   7.221 +gmyth_backend_info_set_username (GMythBackendInfo * backend_info,
   7.222 +    const gchar * username)
   7.223  {
   7.224      g_return_if_fail (backend_info != NULL);
   7.225  
   7.226 @@ -192,7 +193,8 @@
   7.227  }
   7.228  
   7.229  void
   7.230 -gmyth_backend_info_set_password (GMythBackendInfo *backend_info, const gchar *password)
   7.231 +gmyth_backend_info_set_password (GMythBackendInfo * backend_info,
   7.232 +    const gchar * password)
   7.233  {
   7.234      g_return_if_fail (backend_info != NULL);
   7.235  
   7.236 @@ -200,7 +202,8 @@
   7.237  }
   7.238  
   7.239  void
   7.240 -gmyth_backend_info_set_db_name (GMythBackendInfo *backend_info, const gchar *db_name)
   7.241 +gmyth_backend_info_set_db_name (GMythBackendInfo * backend_info,
   7.242 +    const gchar * db_name)
   7.243  {
   7.244      g_return_if_fail (backend_info != NULL);
   7.245  
   7.246 @@ -208,55 +211,55 @@
   7.247  }
   7.248  
   7.249  void
   7.250 -gmyth_backend_info_set_port (GMythBackendInfo *backend_info, gint port )
   7.251 +gmyth_backend_info_set_port (GMythBackendInfo * backend_info, gint port)
   7.252  {
   7.253      g_return_if_fail (backend_info != NULL);
   7.254  
   7.255 -    if ( port <= 0 ) { 
   7.256 -        gmyth_debug ( "Error trying to set a port less than 0." );
   7.257 -    } else {    	
   7.258 +    if (port <= 0) {
   7.259 +        gmyth_debug ("Error trying to set a port less than 0.");
   7.260 +    } else {
   7.261          backend_info->port = port;
   7.262      }
   7.263  }
   7.264  
   7.265  void
   7.266 -gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info, gint port )
   7.267 +gmyth_backend_info_set_status_port (GMythBackendInfo * backend_info, gint port)
   7.268  {
   7.269      g_return_if_fail (backend_info != NULL);
   7.270  
   7.271 -    if ( port <= 0 ) { 
   7.272 -        gmyth_debug ( "Error trying to set the status port to less than zero." );
   7.273 -    } else {    	
   7.274 +    if (port <= 0) {
   7.275 +        gmyth_debug ("Error trying to set the status port to less than zero.");
   7.276 +    } else {
   7.277          backend_info->status_port = port;
   7.278      }
   7.279  }
   7.280  
   7.281 -const gchar*
   7.282 -gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info)
   7.283 +const gchar *
   7.284 +gmyth_backend_info_get_hostname (GMythBackendInfo * backend_info)
   7.285  {
   7.286      g_return_val_if_fail (backend_info != NULL, NULL);
   7.287  
   7.288      return backend_info->hostname;
   7.289  }
   7.290  
   7.291 -const gchar*
   7.292 -gmyth_backend_info_get_username (GMythBackendInfo *backend_info)
   7.293 +const gchar *
   7.294 +gmyth_backend_info_get_username (GMythBackendInfo * backend_info)
   7.295  {
   7.296      g_return_val_if_fail (backend_info != NULL, NULL);
   7.297  
   7.298      return backend_info->username;
   7.299  }
   7.300  
   7.301 -const gchar*
   7.302 -gmyth_backend_info_get_password (GMythBackendInfo *backend_info)
   7.303 +const gchar *
   7.304 +gmyth_backend_info_get_password (GMythBackendInfo * backend_info)
   7.305  {
   7.306      g_return_val_if_fail (backend_info != NULL, NULL);
   7.307  
   7.308      return backend_info->password;
   7.309  }
   7.310  
   7.311 -const gchar*
   7.312 -gmyth_backend_info_get_db_name (GMythBackendInfo *backend_info)
   7.313 +const gchar *
   7.314 +gmyth_backend_info_get_db_name (GMythBackendInfo * backend_info)
   7.315  {
   7.316      g_return_val_if_fail (backend_info != NULL, NULL);
   7.317  
   7.318 @@ -264,7 +267,7 @@
   7.319  }
   7.320  
   7.321  gint
   7.322 -gmyth_backend_info_get_port (GMythBackendInfo *backend_info)
   7.323 +gmyth_backend_info_get_port (GMythBackendInfo * backend_info)
   7.324  {
   7.325      g_return_val_if_fail (backend_info != NULL, -1);
   7.326  
   7.327 @@ -279,46 +282,49 @@
   7.328   * 
   7.329   * @return an instance of GMythURI, created from a GMythBackendInfo.
   7.330   */
   7.331 -GMythURI*
   7.332 -gmyth_backend_info_get_uri (GMythBackendInfo *backend_info)
   7.333 +GMythURI *
   7.334 +gmyth_backend_info_get_uri (GMythBackendInfo * backend_info)
   7.335  {
   7.336      GMythURI *uri = NULL;
   7.337 -    gchar* uri_str = NULL;
   7.338 +    gchar *uri_str = NULL;
   7.339      gchar *user_info = NULL;
   7.340      gchar *db_data = NULL;
   7.341 -    
   7.342 -    if ( ( backend_info->username != NULL && strlen(backend_info->username) > 0 ) )
   7.343 -        user_info = g_strdup_printf( "%s:%s@", backend_info->username, backend_info->password );
   7.344  
   7.345 -    if ( backend_info->db_name != NULL && strlen(backend_info->db_name) > 0 )
   7.346 -    {
   7.347 -        if ( ( g_strrstr( backend_info->db_name, "_" ) != NULL ) )
   7.348 -            db_data = g_strdup( backend_info->db_name );
   7.349 +    if ((backend_info->username != NULL && strlen (backend_info->username) > 0))
   7.350 +        user_info =
   7.351 +            g_strdup_printf ("%s:%s@", backend_info->username,
   7.352 +            backend_info->password);
   7.353 +
   7.354 +    if (backend_info->db_name != NULL && strlen (backend_info->db_name) > 0) {
   7.355 +        if ((g_strrstr (backend_info->db_name, "_") != NULL))
   7.356 +            db_data = g_strdup (backend_info->db_name);
   7.357          else
   7.358 -            db_data = g_strdup_printf( "?%s&", backend_info->db_name );
   7.359 +            db_data = g_strdup_printf ("?%s&", backend_info->db_name);
   7.360      }
   7.361      //else if ( ( ( g_strrstr( backend_info->path, "livetv" ) != NULL ) || 
   7.362      //            ( g_strrstr( backend_info->path, "/?" ) != NULL ) )
   7.363 -    
   7.364 -    uri_str = g_strdup_printf( "myth://%s%s:%d/%s", user_info != NULL && strlen( user_info ) > 0 ? user_info : "", backend_info->hostname, 
   7.365 -            backend_info->port, db_data != NULL && strlen( db_data ) > 0 ? db_data : "");
   7.366 +
   7.367 +    uri_str = g_strdup_printf ("myth://%s%s:%d/%s", user_info != NULL
   7.368 +        && strlen (user_info) > 0 ? user_info : "",
   7.369 +        backend_info->hostname, backend_info->port,
   7.370 +        db_data != NULL && strlen (db_data) > 0 ? db_data : "");
   7.371      uri = gmyth_uri_new_with_value (uri_str);
   7.372  
   7.373 -    if ( user_info != NULL )
   7.374 -        g_free( user_info );
   7.375 +    if (user_info != NULL)
   7.376 +        g_free (user_info);
   7.377  
   7.378 -    if ( db_data != NULL )
   7.379 -        g_free( db_data );
   7.380 -    
   7.381 +    if (db_data != NULL)
   7.382 +        g_free (db_data);
   7.383 +
   7.384      g_free (uri_str);
   7.385 -    	
   7.386 -    return uri;	
   7.387 +
   7.388 +    return uri;
   7.389  }
   7.390  
   7.391  gboolean
   7.392 -gmyth_backend_info_is_local_file(GMythBackendInfo *backend_info)
   7.393 +gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info)
   7.394  {
   7.395      g_return_val_if_fail (backend_info != NULL, FALSE);
   7.396 -    
   7.397 -    return gmyth_uri_is_local_file( gmyth_backend_info_get_uri( backend_info ) );
   7.398 +
   7.399 +    return gmyth_uri_is_local_file (gmyth_backend_info_get_uri (backend_info));
   7.400  }
     8.1 --- a/gmyth/src/gmyth_backendinfo.h	Tue May 22 19:21:42 2007 +0100
     8.2 +++ b/gmyth/src/gmyth_backendinfo.h	Wed May 23 16:11:29 2007 +0100
     8.3 @@ -10,22 +10,22 @@
     8.4   * @author Hallyson Melo <hallyson.melo@indt.org.br>
     8.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
     8.6   *
     8.7 - *//*
     8.8 - * 
     8.9 - * This program is free software; you can redistribute it and/or modify
    8.10 - * it under the terms of the GNU Lesser General Public License as published by
    8.11 - * the Free Software Foundation; either version 2 of the License, or
    8.12 - * (at your option) any later version.
    8.13 - *
    8.14 - * This program is distributed in the hope that it will be useful,
    8.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.17 - * GNU General Public License for more details.
    8.18 - *
    8.19 - * You should have received a copy of the GNU Lesser General Public License
    8.20 - * along with this program; if not, write to the Free Software
    8.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.22 - */
    8.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
    8.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
    8.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
    8.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
    8.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
    8.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
    8.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    8.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
    8.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
    8.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    8.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
    8.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
    8.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
    8.39  
    8.40  #ifndef __GMYTH_BACKEND_INFO_H__
    8.41  #define __GMYTH_BACKEND_INFO_H__
    8.42 @@ -35,24 +35,21 @@
    8.43  #include "gmyth_uri.h"
    8.44  
    8.45  G_BEGIN_DECLS
    8.46 -
    8.47  #define GMYTH_BACKEND_INFO_TYPE               (gmyth_backend_info_get_type ())
    8.48  #define GMYTH_BACKEND_INFO(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfo))
    8.49  #define GMYTH_BACKEND_INFO_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass))
    8.50  #define IS_GMYTH_BACKEND_INFO(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_BACKEND_INFO_TYPE))
    8.51  #define IS_GMYTH_BACKEND_INFO_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_BACKEND_INFO_TYPE))
    8.52  #define GMYTH_BACKEND_INFO_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_BACKEND_INFO_TYPE, GMythBackendInfoClass))
    8.53 -
    8.54 -
    8.55 -typedef struct _GMythBackendInfo         GMythBackendInfo;
    8.56 -typedef struct _GMythBackendInfoClass    GMythBackendInfoClass;
    8.57 +typedef struct _GMythBackendInfo GMythBackendInfo;
    8.58 +typedef struct _GMythBackendInfoClass GMythBackendInfoClass;
    8.59  
    8.60  struct _GMythBackendInfoClass
    8.61  {
    8.62 -  GObjectClass parent_class;
    8.63 +    GObjectClass parent_class;
    8.64  
    8.65 -  /* callbacks */
    8.66 -  /* no one for now */
    8.67 +    /* callbacks */
    8.68 +    /* no one for now */
    8.69  };
    8.70  
    8.71  struct _GMythBackendInfo
    8.72 @@ -72,43 +69,38 @@
    8.73      /** The backend status port for http connection */
    8.74      gint status_port;
    8.75      //gchar *path;
    8.76 -    
    8.77 +
    8.78      //GMythURI* uri;
    8.79  };
    8.80  
    8.81  
    8.82 -GType               gmyth_backend_info_get_type     (void);
    8.83 -GMythBackendInfo*   gmyth_backend_info_new          (void);
    8.84 -GMythBackendInfo*   gmyth_backend_info_new_full     (const gchar *hostname, 
    8.85 -                                                     const gchar *username, 
    8.86 -                                                     const gchar *password,
    8.87 -                                                     const gchar *db_name, 
    8.88 -                                                     gint port);
    8.89 -GMythBackendInfo*   gmyth_backend_info_new_with_uri (const gchar *uri_str);
    8.90 -void                gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, 
    8.91 -                                                     const gchar *hostname);
    8.92 -void                gmyth_backend_info_set_username (GMythBackendInfo *backend_info, 
    8.93 -                                                     const gchar *username);
    8.94 -void                gmyth_backend_info_set_password (GMythBackendInfo *backend_info, 
    8.95 -                                                     const gchar *password);
    8.96 -void                gmyth_backend_info_set_db_name  (GMythBackendInfo *backend_info, 
    8.97 -                                                     const gchar *db_name);
    8.98 -void                gmyth_backend_info_set_port     (GMythBackendInfo *backend_info, 
    8.99 -                                                     gint port);
   8.100 -void                gmyth_backend_info_set_status_port (GMythBackendInfo *backend_info,
   8.101 -							gint port);
   8.102 +GType gmyth_backend_info_get_type (void);
   8.103 +GMythBackendInfo *gmyth_backend_info_new (void);
   8.104 +GMythBackendInfo *gmyth_backend_info_new_full (const gchar * hostname,
   8.105 +    const gchar * username,
   8.106 +    const gchar * password, const gchar * db_name, gint port);
   8.107 +GMythBackendInfo *gmyth_backend_info_new_with_uri (const gchar * uri_str);
   8.108 +void gmyth_backend_info_set_hostname (GMythBackendInfo * backend_info,
   8.109 +    const gchar * hostname);
   8.110 +void gmyth_backend_info_set_username (GMythBackendInfo * backend_info,
   8.111 +    const gchar * username);
   8.112 +void gmyth_backend_info_set_password (GMythBackendInfo * backend_info,
   8.113 +    const gchar * password);
   8.114 +void gmyth_backend_info_set_db_name (GMythBackendInfo * backend_info,
   8.115 +    const gchar * db_name);
   8.116 +void gmyth_backend_info_set_port (GMythBackendInfo * backend_info, gint port);
   8.117 +void gmyth_backend_info_set_status_port (GMythBackendInfo * backend_info,
   8.118 +    gint port);
   8.119  
   8.120 -const gchar*        gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info);
   8.121 -const gchar*        gmyth_backend_info_get_username (GMythBackendInfo *backend_info);
   8.122 -const gchar*        gmyth_backend_info_get_password (GMythBackendInfo *backend_info);
   8.123 -const gchar*        gmyth_backend_info_get_db_name  (GMythBackendInfo *backend_info);
   8.124 -gint                gmyth_backend_info_get_port     (GMythBackendInfo *backend_info);
   8.125 +const gchar *gmyth_backend_info_get_hostname (GMythBackendInfo * backend_info);
   8.126 +const gchar *gmyth_backend_info_get_username (GMythBackendInfo * backend_info);
   8.127 +const gchar *gmyth_backend_info_get_password (GMythBackendInfo * backend_info);
   8.128 +const gchar *gmyth_backend_info_get_db_name (GMythBackendInfo * backend_info);
   8.129 +gint gmyth_backend_info_get_port (GMythBackendInfo * backend_info);
   8.130  
   8.131 -GMythURI*           gmyth_backend_info_get_uri	    (GMythBackendInfo *backend_info);
   8.132 +GMythURI *gmyth_backend_info_get_uri (GMythBackendInfo * backend_info);
   8.133  
   8.134 -gboolean            gmyth_backend_info_is_local_file(GMythBackendInfo *backend_info);
   8.135 +gboolean gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info);
   8.136  
   8.137  G_END_DECLS
   8.138 -
   8.139  #endif /* __GMYTH_BACKEND_INFO_H__ */
   8.140 -
     9.1 --- a/gmyth/src/gmyth_common.c	Tue May 22 19:21:42 2007 +0100
     9.2 +++ b/gmyth/src/gmyth_common.c	Wed May 23 16:11:29 2007 +0100
     9.3 @@ -9,22 +9,22 @@
     9.4   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
     9.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
     9.6   *
     9.7 - *//*
     9.8 - * 
     9.9 - * This program is free software; you can redistribute it and/or modify
    9.10 - * it under the terms of the GNU Lesser General Public License as published by
    9.11 - * the Free Software Foundation; either version 2 of the License, or
    9.12 - * (at your option) any later version.
    9.13 - *
    9.14 - * This program is distributed in the hope that it will be useful,
    9.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.17 - * GNU General Public License for more details.
    9.18 - *
    9.19 - * You should have received a copy of the GNU Lesser General Public License
    9.20 - * along with this program; if not, write to the Free Software
    9.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.22 - */
    9.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
    9.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
    9.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
    9.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
    9.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
    9.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
    9.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    9.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
    9.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
    9.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
    9.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
    9.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
    9.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
    9.39  
    9.40  #ifdef HAVE_CONFIG_H
    9.41  #include "config.h"
    9.42 @@ -34,8 +34,8 @@
    9.43  #include "gmyth_debug.h"
    9.44  #include "gmyth_util.h"
    9.45  
    9.46 -static void free_channel_data(gpointer data, gpointer user_data);
    9.47 -static void free_program_data(gpointer data, gpointer user_data);
    9.48 +static void free_channel_data (gpointer data, gpointer user_data);
    9.49 +static void free_program_data (gpointer data, gpointer user_data);
    9.50  
    9.51  /** 
    9.52   * Frees the memory allocated to the GMythChannelInfo objects inside list.
    9.53 @@ -44,11 +44,11 @@
    9.54   * 
    9.55   * @param list the GList containing a list of GMythChannelInfo to free.
    9.56   */
    9.57 -void 
    9.58 -gmyth_free_channel_list (GList *list) 
    9.59 +void
    9.60 +gmyth_free_channel_list (GList * list)
    9.61  {
    9.62      g_return_if_fail (list != NULL);
    9.63 -	
    9.64 +
    9.65      g_list_foreach (list, free_channel_data, NULL);
    9.66      g_list_free (list);
    9.67  }
    9.68 @@ -61,16 +61,16 @@
    9.69   * @param list the GList containing a list of GMythProgramInfo to free.
    9.70   */
    9.71  void
    9.72 -gmyth_free_program_list(GList *list)
    9.73 +gmyth_free_program_list (GList * list)
    9.74  {
    9.75      g_return_if_fail (list != NULL);
    9.76 -	
    9.77 +
    9.78      g_list_foreach (list, free_program_data, NULL);
    9.79      g_list_free (list);
    9.80  }
    9.81  
    9.82  void
    9.83 -gmyth_channel_info_free (GMythChannelInfo *channel)
    9.84 +gmyth_channel_info_free (GMythChannelInfo * channel)
    9.85  {
    9.86      g_return_if_fail (channel != NULL);
    9.87  
    9.88 @@ -90,17 +90,17 @@
    9.89   * Prints the channel info to the standard output. The gmyth debug must be enabled.
    9.90   * @param channel_info the GMythChannelInfo instance
    9.91   */
    9.92 -void 
    9.93 -gmyth_channel_info_print (GMythChannelInfo *channel_info)
    9.94 +void
    9.95 +gmyth_channel_info_print (GMythChannelInfo * channel_info)
    9.96  {
    9.97  #ifdef GMYTH_USE_DEBUG
    9.98 -    if ( channel_info != NULL ) {
    9.99 -	g_return_if_fail (channel_info->channel_name != NULL);
   9.100 -	g_return_if_fail (channel_info->channel_num != NULL);
   9.101 +    if (channel_info != NULL) {
   9.102 +        g_return_if_fail (channel_info->channel_name != NULL);
   9.103 +        g_return_if_fail (channel_info->channel_num != NULL);
   9.104  
   9.105 -        gmyth_debug("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n", 
   9.106 -             channel_info->channel_name->str, channel_info->channel_num->str, 
   9.107 -             channel_info->channel_ID);
   9.108 +        gmyth_debug ("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n",
   9.109 +            channel_info->channel_name->str,
   9.110 +            channel_info->channel_num->str, channel_info->channel_ID);
   9.111  
   9.112      }
   9.113  #endif
   9.114 @@ -110,41 +110,43 @@
   9.115   * Prints the program info to the standard output. The gmyth debug must be enabled.
   9.116   * @param channel_info the GMythProgramInfo instance
   9.117   */
   9.118 -void 
   9.119 -gmyth_program_info_print(GMythProgramInfo *program_info)
   9.120 +void
   9.121 +gmyth_program_info_print (GMythProgramInfo * program_info)
   9.122  {
   9.123  #ifdef GMYTH_USE_DEBUG
   9.124      g_return_if_fail (program_info);
   9.125  
   9.126 -    gmyth_debug( "ProgramInfo\n\tTitle = %s\n\t"
   9.127 -                "Description = %s\n\t"
   9.128 -	        "Start time= %s\t"
   9.129 -	        "End time = %s\n"
   9.130 -	        "Path name = %s\n"
   9.131 -	        "File size = %lld\n",
   9.132 -	       	program_info->title ? program_info->title->str : "NULL",
   9.133 -	        program_info->description ? program_info->description->str : "NULL", 
   9.134 -	        gmyth_util_time_to_string_from_time_val(program_info->startts),
   9.135 -	        gmyth_util_time_to_string_from_time_val(program_info->endts), 
   9.136 -	        program_info->pathname ? program_info->pathname->str : "NULL",
   9.137 -	        program_info->filesize );
   9.138 +    gmyth_debug ("ProgramInfo\n\tTitle = %s\n\t"
   9.139 +        "Description = %s\n\t"
   9.140 +        "Start time= %s\t"
   9.141 +        "End time = %s\n"
   9.142 +        "Path name = %s\n"
   9.143 +        "File size = %lld\n",
   9.144 +        program_info->title ? program_info->title->str : "NULL",
   9.145 +        program_info->description ? program_info->description->
   9.146 +        str : "NULL",
   9.147 +        gmyth_util_time_to_string_from_time_val (program_info->
   9.148 +            startts),
   9.149 +        gmyth_util_time_to_string_from_time_val (program_info->
   9.150 +            endts),
   9.151 +        program_info->pathname ? program_info->pathname->str : "NULL",
   9.152 +        program_info->filesize);
   9.153  #endif
   9.154  }
   9.155  
   9.156 -static void 
   9.157 +static void
   9.158  free_channel_data (gpointer data, gpointer user_data)
   9.159  {
   9.160      /* Frees the GMythChannelInfo structure */
   9.161 -    GMythChannelInfo *channel = (GMythChannelInfo*) data;
   9.162 +    GMythChannelInfo *channel = (GMythChannelInfo *) data;
   9.163  
   9.164 -    gmyth_channel_info_free(channel);
   9.165 +    gmyth_channel_info_free (channel);
   9.166  }
   9.167  
   9.168  static void
   9.169 -free_program_data(gpointer data, gpointer user_data)
   9.170 +free_program_data (gpointer data, gpointer user_data)
   9.171  {
   9.172      g_return_if_fail (data != NULL);
   9.173  
   9.174 -    g_object_unref((GMythProgramInfo*) data);
   9.175 +    g_object_unref ((GMythProgramInfo *) data);
   9.176  }
   9.177 -
    10.1 --- a/gmyth/src/gmyth_common.h	Tue May 22 19:21:42 2007 +0100
    10.2 +++ b/gmyth/src/gmyth_common.h	Wed May 23 16:11:29 2007 +0100
    10.3 @@ -9,22 +9,22 @@
    10.4   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    10.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    10.6   *
    10.7 - *//*
    10.8 - * 
    10.9 - * This program is free software; you can redistribute it and/or modify
   10.10 - * it under the terms of the GNU Lesser General Public License as published by
   10.11 - * the Free Software Foundation; either version 2 of the License, or
   10.12 - * (at your option) any later version.
   10.13 - *
   10.14 - * This program is distributed in the hope that it will be useful,
   10.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.17 - * GNU General Public License for more details.
   10.18 - *
   10.19 - * You should have received a copy of the GNU Lesser General Public License
   10.20 - * along with this program; if not, write to the Free Software
   10.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.22 - */
   10.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   10.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   10.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   10.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   10.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   10.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   10.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   10.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   10.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   10.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   10.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   10.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   10.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   10.39  
   10.40  #ifndef GMYTH_COMMON_H_
   10.41  #define GMYTH_COMMON_H_
   10.42 @@ -35,35 +35,34 @@
   10.43  #include "gmyth_programinfo.h"
   10.44  
   10.45  G_BEGIN_DECLS
   10.46 -
   10.47  /**
   10.48   * The GMythChannelInfo structure represents the channel information
   10.49   * stored in the backend database.
   10.50   */
   10.51 -typedef struct {
   10.52 -	/** The channel ID in backend database */
   10.53 -	gint channel_ID;
   10.54 -	
   10.55 +    typedef struct
   10.56 +{
   10.57 +        /** The channel ID in backend database */
   10.58 +    gint channel_ID;
   10.59 +
   10.60          /** The channel number */
   10.61 -	GString* channel_num; 
   10.62 -	
   10.63 -	/** The channel name in backend database */
   10.64 -	GString *channel_name;
   10.65 +    GString *channel_num;
   10.66 +
   10.67 +        /** The channel name in backend database */
   10.68 +    GString *channel_name;
   10.69  
   10.70          /** The channel icon path in the backend database */
   10.71 -        GString *channel_icon;
   10.72 +    GString *channel_icon;
   10.73  
   10.74  } GMythChannelInfo;
   10.75  
   10.76 -void gmyth_free_channel_list(GList *list);
   10.77 -void gmyth_free_program_list(GList *list);
   10.78 +void gmyth_free_channel_list (GList * list);
   10.79 +void gmyth_free_program_list (GList * list);
   10.80  
   10.81 -void gmyth_channel_info_free (GMythChannelInfo *channel_info);
   10.82 +void gmyth_channel_info_free (GMythChannelInfo * channel_info);
   10.83  
   10.84  
   10.85 -void gmyth_channel_info_print (GMythChannelInfo *channel_info);
   10.86 -void gmyth_program_info_print (GMythProgramInfo *program_info);
   10.87 +void gmyth_channel_info_print (GMythChannelInfo * channel_info);
   10.88 +void gmyth_program_info_print (GMythProgramInfo * program_info);
   10.89  
   10.90  G_END_DECLS
   10.91 -
   10.92  #endif /* GMYTH_COMMON_H_ */
    11.1 --- a/gmyth/src/gmyth_debug.c	Tue May 22 19:21:42 2007 +0100
    11.2 +++ b/gmyth/src/gmyth_debug.c	Wed May 23 16:11:29 2007 +0100
    11.3 @@ -7,23 +7,23 @@
    11.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    11.5   * @author Renato Filho <renato.filho@indt.org.br>
    11.6   *
    11.7 - *//*
    11.8 - * 
    11.9 - * This program is free software; you can redistribute it and/or modify
   11.10 - * it under the terms of the GNU Lesser General Public License as published by
   11.11 - * the Free Software Foundation; either version 2 of the License, or
   11.12 - * (at your option) any later version.
   11.13 - *
   11.14 - * This program is distributed in the hope that it will be useful,
   11.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.17 - * GNU General Public License for more details.
   11.18 - *
   11.19 - * You should have received a copy of the GNU Lesser General Public License
   11.20 - * along with this program; if not, write to the Free Software
   11.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.22 - */
   11.23 - 
   11.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   11.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   11.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   11.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   11.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   11.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   11.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   11.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   11.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   11.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   11.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   11.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   11.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   11.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   11.40 +
   11.41  #ifdef HAVE_CONFIG_H
   11.42  #include "config.h"
   11.43  #endif
   11.44 @@ -32,10 +32,7 @@
   11.45  
   11.46  void
   11.47  gmyth_debug_real (const char *func,
   11.48 -                  const char *file,
   11.49 -                  const int line,
   11.50 -                  gboolean newline,
   11.51 -                  const char *format, ...)
   11.52 +    const char *file, const int line, gboolean newline, const char *format, ...)
   11.53  {
   11.54      va_list args;
   11.55      char buffer[1025];
   11.56 @@ -51,6 +48,7 @@
   11.57      time (&the_time);
   11.58      strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
   11.59  
   11.60 -    g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
   11.61 -            str_time, g_thread_self (), func, file, line, buffer);
   11.62 +    g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
   11.63 +        "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self (), func,
   11.64 +        file, line, buffer);
   11.65  }
    12.1 --- a/gmyth/src/gmyth_debug.h	Tue May 22 19:21:42 2007 +0100
    12.2 +++ b/gmyth/src/gmyth_debug.h	Wed May 23 16:11:29 2007 +0100
    12.3 @@ -7,22 +7,22 @@
    12.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    12.5   * @author Renato Filho <renato.filho@indt.org.br>
    12.6   *
    12.7 - *//*
    12.8 - * 
    12.9 - * This program is free software; you can redistribute it and/or modify
   12.10 - * it under the terms of the GNU Lesser General Public License as published by
   12.11 - * the Free Software Foundation; either version 2 of the License, or
   12.12 - * (at your option) any later version.
   12.13 - *
   12.14 - * This program is distributed in the hope that it will be useful,
   12.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.17 - * GNU General Public License for more details.
   12.18 - *
   12.19 - * You should have received a copy of the GNU Lesser General Public License
   12.20 - * along with this program; if not, write to the Free Software
   12.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.22 - */
   12.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   12.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   12.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   12.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   12.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   12.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   12.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   12.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   12.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   12.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   12.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   12.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   12.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   12.39  
   12.40  #ifndef __GMYTH_DEBUG_H__
   12.41  #define __GMYTH_DEBUG_H__
   12.42 @@ -32,18 +32,15 @@
   12.43  #include <time.h>
   12.44  
   12.45  G_BEGIN_DECLS
   12.46 -
   12.47  #ifdef GMYTH_USE_DEBUG
   12.48  #define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
   12.49  #else
   12.50  #define gmyth_debug(...)
   12.51  #endif
   12.52 -
   12.53 -void gmyth_debug_real (const char *func,
   12.54 -                       const char *file,
   12.55 -                       int line,
   12.56 -                       gboolean newline,
   12.57 -                       const char *format, ...) G_GNUC_PRINTF (5, 6);
   12.58 +    void
   12.59 +gmyth_debug_real (const char *func,
   12.60 +    const char *file, int line, gboolean newline, const char *format, ...)
   12.61 +G_GNUC_PRINTF (5, 6);
   12.62  
   12.63  G_END_DECLS
   12.64  #endif
    13.1 --- a/gmyth/src/gmyth_epg.c	Tue May 22 19:21:42 2007 +0100
    13.2 +++ b/gmyth/src/gmyth_epg.c	Wed May 23 16:11:29 2007 +0100
    13.3 @@ -9,23 +9,23 @@
    13.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    13.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    13.6   *
    13.7 - *//*
    13.8 - * 
    13.9 - * This program is free software; you can redistribute it and/or modify
   13.10 - * it under the terms of the GNU Lesser General Public License as published by
   13.11 - * the Free Software Foundation; either version 2 of the License, or
   13.12 - * (at your option) any later version.
   13.13 - *
   13.14 - * This program is distributed in the hope that it will be useful,
   13.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.17 - * GNU General Public License for more details.
   13.18 - *
   13.19 - * You should have received a copy of the GNU Lesser General Public License
   13.20 - * along with this program; if not, write to the Free Software
   13.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.22 - */
   13.23 - 
   13.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   13.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   13.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   13.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   13.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   13.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   13.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   13.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   13.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   13.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   13.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   13.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   13.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   13.40 +
   13.41  #ifdef HAVE_CONFIG_H
   13.42  #include "config.h"
   13.43  #endif
   13.44 @@ -41,44 +41,42 @@
   13.45  #include "gmyth_file_transfer.h"
   13.46  #include "gmyth_debug.h"
   13.47  
   13.48 -static void gmyth_epg_class_init          (GMythEPGClass *klass);
   13.49 -static void gmyth_epg_init                (GMythEPG *object);
   13.50 +static void gmyth_epg_class_init (GMythEPGClass * klass);
   13.51 +static void gmyth_epg_init (GMythEPG * object);
   13.52  
   13.53 -static void gmyth_epg_dispose  (GObject *object);
   13.54 -static void gmyth_epg_finalize (GObject *object);
   13.55 +static void gmyth_epg_dispose (GObject * object);
   13.56 +static void gmyth_epg_finalize (GObject * object);
   13.57  
   13.58 -G_DEFINE_TYPE(GMythEPG, gmyth_epg, G_TYPE_OBJECT)
   13.59 -    
   13.60 -static void
   13.61 -gmyth_epg_class_init (GMythEPGClass *klass)
   13.62 +G_DEFINE_TYPE (GMythEPG, gmyth_epg, G_TYPE_OBJECT)
   13.63 +     static void gmyth_epg_class_init (GMythEPGClass * klass)
   13.64  {
   13.65      GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   13.66 -	
   13.67 -    gobject_class->dispose  = gmyth_epg_dispose;
   13.68 -    gobject_class->finalize = gmyth_epg_finalize;	
   13.69 +
   13.70 +    gobject_class->dispose = gmyth_epg_dispose;
   13.71 +    gobject_class->finalize = gmyth_epg_finalize;
   13.72  }
   13.73  
   13.74  static void
   13.75 -gmyth_epg_init (GMythEPG *gmyth_epg)
   13.76 +gmyth_epg_init (GMythEPG * gmyth_epg)
   13.77  {
   13.78  
   13.79  }
   13.80  
   13.81  static void
   13.82 -gmyth_epg_dispose  (GObject *object)
   13.83 +gmyth_epg_dispose (GObject * object)
   13.84  {
   13.85 -    GMythEPG *gmyth_epg = GMYTH_EPG(object);
   13.86 -   
   13.87 +    GMythEPG *gmyth_epg = GMYTH_EPG (object);
   13.88 +
   13.89      if (gmyth_epg->sqlquery != NULL) {
   13.90          g_object_unref (gmyth_epg->sqlquery);
   13.91 -	gmyth_epg->sqlquery = NULL;
   13.92 +        gmyth_epg->sqlquery = NULL;
   13.93      }
   13.94  
   13.95      G_OBJECT_CLASS (gmyth_epg_parent_class)->dispose (object);
   13.96  }
   13.97  
   13.98  static void
   13.99 -gmyth_epg_finalize (GObject *object)
  13.100 +gmyth_epg_finalize (GObject * object)
  13.101  {
  13.102      g_signal_handlers_destroy (object);
  13.103  
  13.104 @@ -90,10 +88,10 @@
  13.105   * 
  13.106   * @return a new instance of GMythEPG.
  13.107   */
  13.108 -GMythEPG*
  13.109 +GMythEPG *
  13.110  gmyth_epg_new (void)
  13.111  {
  13.112 -    GMythEPG *epg = GMYTH_EPG (g_object_new(GMYTH_EPG_TYPE, NULL));
  13.113 +    GMythEPG *epg = GMYTH_EPG (g_object_new (GMYTH_EPG_TYPE, NULL));
  13.114  
  13.115      return epg;
  13.116  }
  13.117 @@ -105,16 +103,16 @@
  13.118   * @return true if connection was success, false if failed.
  13.119   */
  13.120  gboolean
  13.121 -gmyth_epg_connect (GMythEPG *gmyth_epg, GMythBackendInfo *backend_info)
  13.122 +gmyth_epg_connect (GMythEPG * gmyth_epg, GMythBackendInfo * backend_info)
  13.123  {
  13.124      g_return_val_if_fail (gmyth_epg != NULL, FALSE);
  13.125  
  13.126      if (gmyth_epg->sqlquery == NULL) {
  13.127 -	gmyth_debug ("[%s] Creating gmyth_query", __FUNCTION__);
  13.128 -        gmyth_epg->sqlquery = gmyth_query_new ( );
  13.129 +        gmyth_debug ("[%s] Creating gmyth_query", __FUNCTION__);
  13.130 +        gmyth_epg->sqlquery = gmyth_query_new ();
  13.131      }
  13.132  
  13.133 -    if (!gmyth_query_connect(gmyth_epg->sqlquery, backend_info)) {
  13.134 +    if (!gmyth_query_connect (gmyth_epg->sqlquery, backend_info)) {
  13.135          gmyth_debug ("[%s] Error while connecting to db", __FUNCTION__);
  13.136          return FALSE;
  13.137      }
  13.138 @@ -122,7 +120,7 @@
  13.139      gmyth_epg->backend_info = backend_info;
  13.140      g_object_ref (backend_info);
  13.141  
  13.142 -    return TRUE;	
  13.143 +    return TRUE;
  13.144  }
  13.145  
  13.146  /** Disconnects from the Mysql database in the backend.
  13.147 @@ -131,11 +129,11 @@
  13.148   * @return true if disconnection was success, false if failed.
  13.149   */
  13.150  gboolean
  13.151 -gmyth_epg_disconnect (GMythEPG *gmyth_epg)
  13.152 +gmyth_epg_disconnect (GMythEPG * gmyth_epg)
  13.153  {
  13.154      g_return_val_if_fail (gmyth_epg != NULL, FALSE);
  13.155  
  13.156 -    if (gmyth_epg->sqlquery != NULL) {	
  13.157 +    if (gmyth_epg->sqlquery != NULL) {
  13.158          gmyth_query_disconnect (gmyth_epg->sqlquery);
  13.159          g_object_unref (gmyth_epg->sqlquery);
  13.160          gmyth_epg->sqlquery = NULL;
  13.161 @@ -145,7 +143,7 @@
  13.162          g_object_unref (gmyth_epg->backend_info);
  13.163          gmyth_epg->backend_info = NULL;
  13.164      }
  13.165 -	
  13.166 +
  13.167      return TRUE;
  13.168  }
  13.169  
  13.170 @@ -156,74 +154,78 @@
  13.171   * @return The amount of channels retrieved from database,  or -1 if error.
  13.172   */
  13.173  gint
  13.174 -gmyth_epg_get_channel_list (GMythEPG *gmyth_epg, GList **glist_ptr)
  13.175 +gmyth_epg_get_channel_list (GMythEPG * gmyth_epg, GList ** glist_ptr)
  13.176  {
  13.177      MYSQL_RES *msql_res;
  13.178  
  13.179      g_return_val_if_fail (gmyth_epg != NULL, -1);
  13.180  
  13.181 -    msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, 
  13.182 -    		"SELECT chanid, channum, name, icon FROM channel;");
  13.183 +    msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery,
  13.184 +        "SELECT chanid, channum, name, icon FROM channel;");
  13.185  
  13.186      (*glist_ptr) = NULL;
  13.187 -	
  13.188 +
  13.189      if (msql_res == NULL) {
  13.190          gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
  13.191          return -1;
  13.192      } else {
  13.193          MYSQL_ROW row;
  13.194 -        GMythChannelInfo *channel_info;        
  13.195 +        GMythChannelInfo *channel_info;
  13.196  
  13.197          while ((row = mysql_fetch_row (msql_res)) != NULL) {
  13.198  
  13.199 -            channel_info = g_new0(GMythChannelInfo, 1);
  13.200 -            channel_info->channel_ID = (gint) g_ascii_strtoull (row[0], NULL, 10);
  13.201 +            channel_info = g_new0 (GMythChannelInfo, 1);
  13.202 +            channel_info->channel_ID =
  13.203 +                (gint) g_ascii_strtoull (row[0], NULL, 10);
  13.204              channel_info->channel_num = g_string_new (row[1]);
  13.205              channel_info->channel_name = g_string_new (row[2]);
  13.206              channel_info->channel_icon = g_string_new (row[3]);
  13.207 -#ifdef GMYTH_USE_DEBUG       
  13.208 -            gmyth_channel_info_print(channel_info);
  13.209 -#endif            
  13.210 +#ifdef GMYTH_USE_DEBUG
  13.211 +            gmyth_channel_info_print (channel_info);
  13.212 +#endif
  13.213              (*glist_ptr) = g_list_append ((*glist_ptr), channel_info);
  13.214 -    	}
  13.215 +        }
  13.216      }
  13.217      mysql_free_result (msql_res);
  13.218 -    
  13.219 -    return (!(*glist_ptr)) ?  0 : g_list_length (*glist_ptr);
  13.220 +
  13.221 +    return (!(*glist_ptr)) ? 0 : g_list_length (*glist_ptr);
  13.222  }
  13.223  
  13.224 -GMythChannelInfo*
  13.225 -gmyth_epg_get_channel_info (GMythEPG *gmyth_epg, gint channel_id)
  13.226 +GMythChannelInfo *
  13.227 +gmyth_epg_get_channel_info (GMythEPG * gmyth_epg, gint channel_id)
  13.228  {
  13.229      GMythChannelInfo *channel_info = NULL;
  13.230      MYSQL_RES *msql_res;
  13.231 -    gchar* query_str;
  13.232 +    gchar *query_str;
  13.233  
  13.234      g_return_val_if_fail (gmyth_epg != NULL, NULL);
  13.235  
  13.236 -    query_str = g_strdup_printf ("SELECT channum, name, icon FROM channel WHERE chanid=%d;", channel_id);
  13.237 +    query_str =
  13.238 +        g_strdup_printf
  13.239 +        ("SELECT channum, name, icon FROM channel WHERE chanid=%d;",
  13.240 +        channel_id);
  13.241      msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, query_str);
  13.242  
  13.243      if (msql_res == NULL) {
  13.244          gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
  13.245 -	return NULL;
  13.246 +        return NULL;
  13.247      } else {
  13.248          MYSQL_ROW row;
  13.249  
  13.250          if ((row = mysql_fetch_row (msql_res)) != NULL) {
  13.251  
  13.252 -            channel_info = g_new0(GMythChannelInfo, 1);
  13.253 +            channel_info = g_new0 (GMythChannelInfo, 1);
  13.254              channel_info->channel_ID = channel_id;
  13.255              channel_info->channel_num = g_string_new (row[0]);
  13.256              channel_info->channel_name = g_string_new (row[1]);
  13.257              channel_info->channel_icon = g_string_new (row[2]);
  13.258 -#ifdef GMYTH_USE_DEBUG       
  13.259 -            gmyth_channel_info_print(channel_info);
  13.260 -#endif            
  13.261 -    	}
  13.262 +#ifdef GMYTH_USE_DEBUG
  13.263 +            gmyth_channel_info_print (channel_info);
  13.264 +#endif
  13.265 +        }
  13.266      }
  13.267      mysql_free_result (msql_res);
  13.268 -    
  13.269 +
  13.270      return channel_info;
  13.271  }
  13.272  
  13.273 @@ -238,19 +240,20 @@
  13.274   * @return The amount of channels retrieved from database, or -1 if error.
  13.275   */
  13.276  gint
  13.277 -gmyth_epg_get_program_list (GMythEPG *gmyth_epg, GList **proglist,
  13.278 -		const gint chan_num, GTimeVal *starttime, GTimeVal *endtime)
  13.279 +gmyth_epg_get_program_list (GMythEPG * gmyth_epg, GList ** proglist,
  13.280 +    const gint chan_num, GTimeVal * starttime, GTimeVal * endtime)
  13.281  {
  13.282  
  13.283 -    gchar *startts = gmyth_util_time_to_string_from_time_val(starttime);
  13.284 -    gchar *endts = gmyth_util_time_to_string_from_time_val(endtime);
  13.285 +    gchar *startts = gmyth_util_time_to_string_from_time_val (starttime);
  13.286 +    gchar *endts = gmyth_util_time_to_string_from_time_val (endtime);
  13.287      MYSQL_ROW row;
  13.288      GString *querystr;
  13.289 -    
  13.290 -    assert(gmyth_epg);
  13.291 -    
  13.292 -    querystr = g_string_new(
  13.293 -        "SELECT DISTINCT program.chanid, program.starttime, program.endtime, "
  13.294 +
  13.295 +    assert (gmyth_epg);
  13.296 +
  13.297 +    querystr =
  13.298 +        g_string_new
  13.299 +        ("SELECT DISTINCT program.chanid, program.starttime, program.endtime, "
  13.300          "    program.title, program.subtitle, program.description, "
  13.301          "    program.category, channel.channum, channel.callsign, "
  13.302          "    channel.name, program.previouslyshown, channel.commfree, "
  13.303 @@ -258,59 +261,57 @@
  13.304          "    program.airdate, program.stars, program.originalairdate, "
  13.305          "    program.category_type, oldrecstatus.recordid, "
  13.306          "    oldrecstatus.rectype, oldrecstatus.recstatus, "
  13.307 -        "    oldrecstatus.findid "
  13.308 -        "FROM program "
  13.309 +        "    oldrecstatus.findid " "FROM program "
  13.310          "LEFT JOIN channel ON program.chanid = channel.chanid "
  13.311          "LEFT JOIN oldrecorded AS oldrecstatus ON "
  13.312          "    program.title = oldrecstatus.title AND "
  13.313          "    channel.callsign = oldrecstatus.station AND "
  13.314 -        "    program.starttime = oldrecstatus.starttime "
  13.315 -        );
  13.316 -        
  13.317 -    g_string_append_printf (querystr, 
  13.318 +        "    program.starttime = oldrecstatus.starttime ");
  13.319 +
  13.320 +    g_string_append_printf (querystr,
  13.321          "WHERE program.chanid = %d "
  13.322          "  AND program.endtime >= '%s' "
  13.323          "  AND program.starttime <= '%s' "
  13.324 -        "  AND program.manualid = 0 ",
  13.325 -        chan_num, startts, endts);
  13.326 +        "  AND program.manualid = 0 ", chan_num, startts, endts);
  13.327  
  13.328 -    if (!g_strrstr(querystr->str, " GROUP BY "))
  13.329 -        querystr = g_string_append(querystr,
  13.330 +    if (!g_strrstr (querystr->str, " GROUP BY "))
  13.331 +        querystr = g_string_append (querystr,
  13.332              " GROUP BY program.starttime, channel.channum, "
  13.333              "  channel.callsign, program.title ");
  13.334  
  13.335 -    if (!g_strrstr(querystr->str, " LIMIT "))
  13.336 -        querystr = g_string_append(querystr, " LIMIT 1000 ");
  13.337 +    if (!g_strrstr (querystr->str, " LIMIT "))
  13.338 +        querystr = g_string_append (querystr, " LIMIT 1000 ");
  13.339  
  13.340 -    MYSQL_RES *res_set = 
  13.341 -        gmyth_query_process_statement(gmyth_epg->sqlquery, querystr->str);
  13.342 +    MYSQL_RES *res_set =
  13.343 +        gmyth_query_process_statement (gmyth_epg->sqlquery, querystr->str);
  13.344  
  13.345      if (res_set == NULL) {
  13.346          gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
  13.347 -		return -1;
  13.348 +        return -1;
  13.349      }
  13.350  
  13.351 -    (*proglist) = NULL;        
  13.352 +    (*proglist) = NULL;
  13.353      while ((row = mysql_fetch_row (res_set)) != NULL) {
  13.354  
  13.355          GMythProgramInfo *p = gmyth_program_info_new ();
  13.356 +
  13.357          p->chanid = g_string_new (row[0]);
  13.358  
  13.359          p->startts = gmyth_util_string_to_time_val (row[1]);
  13.360          p->endts = gmyth_util_string_to_time_val (row[2]);
  13.361 -                                                     
  13.362 +
  13.363          p->recstartts = g_new0 (GTimeVal, 1);
  13.364 -	p->recstartts->tv_sec  = p->startts->tv_sec;
  13.365 -	p->recstartts->tv_usec = p->startts->tv_usec;
  13.366 +        p->recstartts->tv_sec = p->startts->tv_sec;
  13.367 +        p->recstartts->tv_usec = p->startts->tv_usec;
  13.368  
  13.369          p->recendts = g_new0 (GTimeVal, 1);
  13.370 -	p->recendts->tv_sec  = p->endts->tv_sec;
  13.371 -	p->recendts->tv_usec = p->endts->tv_usec;
  13.372 +        p->recendts->tv_sec = p->endts->tv_sec;
  13.373 +        p->recendts->tv_usec = p->endts->tv_usec;
  13.374  
  13.375          p->lastmodified = g_new0 (GTimeVal, 1);
  13.376 -	p->lastmodified->tv_sec  = p->startts->tv_sec;
  13.377 -	p->lastmodified->tv_usec = p->startts->tv_usec;
  13.378 -    
  13.379 +        p->lastmodified->tv_sec = p->startts->tv_sec;
  13.380 +        p->lastmodified->tv_usec = p->startts->tv_usec;
  13.381 +
  13.382          p->title = g_string_new (row[3]);
  13.383          p->subtitle = g_string_new (row[4]);
  13.384          p->description = g_string_new (row[5]);
  13.385 @@ -318,40 +319,41 @@
  13.386          p->chanstr = g_string_new (row[7]);
  13.387          p->chansign = g_string_new (row[8]);
  13.388          p->channame = g_string_new (row[9]);
  13.389 -        p->repeat = g_ascii_strtoull(row[10], NULL, 10);
  13.390 -        p->chancommfree = g_ascii_strtoull(row[11], NULL, 10);
  13.391 +        p->repeat = g_ascii_strtoull (row[10], NULL, 10);
  13.392 +        p->chancommfree = g_ascii_strtoull (row[11], NULL, 10);
  13.393          p->chanOutputFilters = g_string_new (row[12]);
  13.394          p->seriesid = g_string_new (row[13]);
  13.395          p->programid = g_string_new (row[14]);
  13.396          p->year = g_string_new (row[15]);
  13.397 -        p->stars = g_ascii_strtod(row[16], NULL);
  13.398 +        p->stars = g_ascii_strtod (row[16], NULL);
  13.399  
  13.400 -        if (!row[17] || !strcmp(row[17], "")) {
  13.401 +        if (!row[17] || !strcmp (row[17], "")) {
  13.402              p->originalAirDate = 0;
  13.403              p->hasAirDate = FALSE;
  13.404          } else {
  13.405              p->originalAirDate = gmyth_util_string_to_time_val (row[17]);
  13.406              p->hasAirDate = TRUE;
  13.407          }
  13.408 -        
  13.409 +
  13.410          p->catType = g_string_new (row[18]);
  13.411  
  13.412 -        *proglist = g_list_append((*proglist), p);
  13.413 +        *proglist = g_list_append ((*proglist), p);
  13.414  
  13.415 -#ifdef GMYTH_USE_DEBUG        
  13.416 +#ifdef GMYTH_USE_DEBUG
  13.417          gmyth_program_info_print (p);
  13.418 -#endif        
  13.419 +#endif
  13.420      }
  13.421  
  13.422      /* deallocate */
  13.423      mysql_free_result (res_set);
  13.424 -    g_string_free(querystr, TRUE);
  13.425 +    g_string_free (querystr, TRUE);
  13.426  
  13.427      return TRUE;
  13.428  }
  13.429  
  13.430 -gboolean 
  13.431 -gmyth_epg_channel_has_icon (GMythEPG *gmyth_epg, GMythChannelInfo *channel_info)
  13.432 +gboolean
  13.433 +gmyth_epg_channel_has_icon (GMythEPG * gmyth_epg,
  13.434 +    GMythChannelInfo * channel_info)
  13.435  {
  13.436      gboolean res = FALSE;
  13.437  
  13.438 @@ -359,7 +361,9 @@
  13.439      g_return_val_if_fail (channel_info != NULL, FALSE);
  13.440  
  13.441      if (channel_info->channel_icon != NULL) {
  13.442 -        res = gmyth_util_file_exists (gmyth_epg->backend_info, channel_info->channel_icon->str);
  13.443 +        res =
  13.444 +            gmyth_util_file_exists (gmyth_epg->backend_info,
  13.445 +            channel_info->channel_icon->str);
  13.446      }
  13.447  
  13.448      return res;
  13.449 @@ -372,7 +376,8 @@
  13.450   * @return TRUE if success, FALSE if any error happens.
  13.451   */
  13.452  gboolean
  13.453 -gmyth_epg_channel_get_icon (GMythEPG *gmyth_epg, GMythChannelInfo *channel_info, guint8 **data, guint *length)
  13.454 +gmyth_epg_channel_get_icon (GMythEPG * gmyth_epg,
  13.455 +    GMythChannelInfo * channel_info, guint8 ** data, guint * length)
  13.456  {
  13.457      gboolean res = FALSE;
  13.458  
  13.459 @@ -380,12 +385,15 @@
  13.460      g_return_val_if_fail (channel_info != NULL, FALSE);
  13.461  
  13.462      if (gmyth_epg_channel_has_icon (gmyth_epg, channel_info)) {
  13.463 -        GMythFileTransfer *transfer = gmyth_file_transfer_new (gmyth_epg->backend_info);
  13.464 +        GMythFileTransfer *transfer =
  13.465 +            gmyth_file_transfer_new (gmyth_epg->backend_info);
  13.466          GMythFileReadResult gmyth_res;
  13.467          GByteArray *icon_data;
  13.468          guint64 icon_length = 0;
  13.469  
  13.470 -        res = gmyth_file_transfer_open (transfer, channel_info->channel_icon->str);
  13.471 +        res =
  13.472 +            gmyth_file_transfer_open (transfer,
  13.473 +            channel_info->channel_icon->str);
  13.474          if (!res) {
  13.475              gmyth_debug ("Channel icon could not be opened");
  13.476              return FALSE;
  13.477 @@ -398,7 +406,8 @@
  13.478          }
  13.479  
  13.480          icon_data = g_byte_array_new ();
  13.481 -        gmyth_res = gmyth_file_transfer_read (transfer, icon_data, icon_length, FALSE);
  13.482 +        gmyth_res =
  13.483 +            gmyth_file_transfer_read (transfer, icon_data, icon_length, FALSE);
  13.484          if (gmyth_res == GMYTH_FILE_READ_EOF) {
  13.485              *length = icon_length;
  13.486              *data = icon_data->data;
  13.487 @@ -413,4 +422,3 @@
  13.488  
  13.489      return res;
  13.490  }
  13.491 -
    14.1 --- a/gmyth/src/gmyth_epg.h	Tue May 22 19:21:42 2007 +0100
    14.2 +++ b/gmyth/src/gmyth_epg.h	Wed May 23 16:11:29 2007 +0100
    14.3 @@ -9,22 +9,22 @@
    14.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    14.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    14.6   *
    14.7 - *//*
    14.8 - * 
    14.9 - * This program is free software; you can redistribute it and/or modify
   14.10 - * it under the terms of the GNU Lesser General Public License as published by
   14.11 - * the Free Software Foundation; either version 2 of the License, or
   14.12 - * (at your option) any later version.
   14.13 - *
   14.14 - * This program is distributed in the hope that it will be useful,
   14.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.17 - * GNU General Public License for more details.
   14.18 - *
   14.19 - * You should have received a copy of the GNU Lesser General Public License
   14.20 - * along with this program; if not, write to the Free Software
   14.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   14.22 - */
   14.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   14.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   14.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   14.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   14.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   14.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   14.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   14.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   14.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   14.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   14.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   14.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   14.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   14.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   14.39  
   14.40  #ifndef GMYTH_EPG_H_
   14.41  #define GMYTH_EPG_H_
   14.42 @@ -35,23 +35,21 @@
   14.43  #include "gmyth_common.h"
   14.44  
   14.45  G_BEGIN_DECLS
   14.46 -
   14.47  #define GMYTH_EPG_TYPE               (gmyth_epg_get_type ())
   14.48  #define GMYTH_EPG(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_EPG_TYPE, GMythEPG))
   14.49  #define GMYTH_EPG_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_EPG_TYPE, GMythEPGClass))
   14.50  #define IS_GMYTH_EPG(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_EPG_TYPE))
   14.51  #define IS_GMYTH_EPG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_EPG_TYPE))
   14.52  #define GMYTH_EPG_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_EPG_TYPE, GMythEPGClass))
   14.53 -
   14.54 -typedef struct _GMythEPG         GMythEPG;
   14.55 -typedef struct _GMythEPGClass    GMythEPGClass;
   14.56 +typedef struct _GMythEPG GMythEPG;
   14.57 +typedef struct _GMythEPGClass GMythEPGClass;
   14.58  
   14.59  struct _GMythEPGClass
   14.60  {
   14.61 -  GObjectClass parent_class;
   14.62 +    GObjectClass parent_class;
   14.63  
   14.64 -  /* callbacks */
   14.65 -  /* no one for now */
   14.66 +    /* callbacks */
   14.67 +    /* no one for now */
   14.68  };
   14.69  
   14.70  struct _GMythEPG
   14.71 @@ -62,22 +60,26 @@
   14.72      GMythBackendInfo *backend_info;
   14.73  };
   14.74  
   14.75 -GType          gmyth_epg_get_type (void);
   14.76 +GType gmyth_epg_get_type (void);
   14.77  
   14.78 -GMythEPG* gmyth_epg_new (void);
   14.79 +GMythEPG *gmyth_epg_new (void);
   14.80  
   14.81 -gboolean gmyth_epg_connect (GMythEPG *gmyth_epg, GMythBackendInfo *backend_info);
   14.82 -gboolean gmyth_epg_disconnect (GMythEPG *gmyth_epg);
   14.83 +gboolean gmyth_epg_connect (GMythEPG * gmyth_epg,
   14.84 +    GMythBackendInfo * backend_info);
   14.85 +gboolean gmyth_epg_disconnect (GMythEPG * gmyth_epg);
   14.86  
   14.87 -gint gmyth_epg_get_channel_list (GMythEPG *gmyth_epg, GList **glist_ptr);
   14.88 -gint gmyth_epg_get_program_list (GMythEPG *gmyth_epg, GList **proglist,
   14.89 -		const gint chanNum, GTimeVal *starttime, GTimeVal *endtime);
   14.90 +gint gmyth_epg_get_channel_list (GMythEPG * gmyth_epg, GList ** glist_ptr);
   14.91 +gint gmyth_epg_get_program_list (GMythEPG * gmyth_epg, GList ** proglist,
   14.92 +    const gint chanNum, GTimeVal * starttime, GTimeVal * endtime);
   14.93  
   14.94 -GMythChannelInfo* gmyth_epg_get_channel_info (GMythEPG *gmyth_epg, gint channel_id);
   14.95 +GMythChannelInfo *gmyth_epg_get_channel_info (GMythEPG * gmyth_epg,
   14.96 +    gint channel_id);
   14.97  
   14.98  
   14.99 -gboolean gmyth_epg_channel_has_icon (GMythEPG *gmyth_epg, GMythChannelInfo *channel);
  14.100 -gboolean gmyth_epg_channel_get_icon (GMythEPG *gmyth_epg, GMythChannelInfo *channel, guint8 **data, guint *length);
  14.101 +gboolean gmyth_epg_channel_has_icon (GMythEPG * gmyth_epg,
  14.102 +    GMythChannelInfo * channel);
  14.103 +gboolean gmyth_epg_channel_get_icon (GMythEPG * gmyth_epg,
  14.104 +    GMythChannelInfo * channel, guint8 ** data, guint * length);
  14.105  
  14.106  
  14.107 -#endif /*GMYTH_EPG_H_*/
  14.108 +#endif /*GMYTH_EPG_H_ */
    15.1 --- a/gmyth/src/gmyth_file.c	Tue May 22 19:21:42 2007 +0100
    15.2 +++ b/gmyth/src/gmyth_file.c	Wed May 23 16:11:29 2007 +0100
    15.3 @@ -9,23 +9,23 @@
    15.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    15.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    15.6   *
    15.7 - *//*
    15.8 - * 
    15.9 - * This program is free software; you can redistribute it and/or modify
   15.10 - * it under the terms of the GNU Lesser General Public License as published by
   15.11 - * the Free Software Foundation; either version 2 of the License, or
   15.12 - * (at your option) any later version.
   15.13 - *
   15.14 - * This program is distributed in the hope that it will be useful,
   15.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.17 - * GNU General Public License for more details.
   15.18 - *
   15.19 - * You should have received a copy of the GNU Lesser General Public License
   15.20 - * along with this program; if not, write to the Free Software
   15.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   15.22 - */
   15.23 - 
   15.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   15.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   15.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   15.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   15.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   15.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   15.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   15.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   15.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   15.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   15.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   15.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   15.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   15.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   15.40 +
   15.41  #ifdef HAVE_CONFIG_H
   15.42  #include "config.h"
   15.43  #endif
   15.44 @@ -53,20 +53,21 @@
   15.45  #define GMYTH_FILE_GET_PRIVATE(obj) \
   15.46      (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TYPE, GMythFilePrivate))
   15.47  
   15.48 -struct _GMythFilePrivate {
   15.49 -	gboolean                disposed;
   15.50 -    gint64                  offset;
   15.51 -    guint64                 filesize;
   15.52 -    
   15.53 -    GMythBackendInfo        *backend_info;
   15.54 +struct _GMythFilePrivate
   15.55 +{
   15.56 +    gboolean disposed;
   15.57 +    gint64 offset;
   15.58 +    guint64 filesize;
   15.59  
   15.60 -	/* Myth URI structure */
   15.61 -	gchar                   *filename;
   15.62 +    GMythBackendInfo *backend_info;
   15.63  
   15.64 -	gint 					file_id;
   15.65 +    /* Myth URI structure */
   15.66 +    gchar *filename;
   15.67 +
   15.68 +    gint file_id;
   15.69  };
   15.70  
   15.71 -enum 
   15.72 +enum
   15.73  {
   15.74      PROP_GMYTH_FILE_DUMMY,
   15.75      PROP_GMYTH_FILE_FILENAME,
   15.76 @@ -81,15 +82,13 @@
   15.77  static void gmyth_file_get_property (GObject * object, guint prop_id,
   15.78      GValue * value, GParamSpec * pspec);
   15.79  
   15.80 -static void gmyth_file_class_init          (GMythFileClass *klass);
   15.81 -static void gmyth_file_init                (GMythFile *object);
   15.82 -static void gmyth_file_dispose             (GObject *object);
   15.83 -static void gmyth_file_finalize            (GObject *object);
   15.84 +static void gmyth_file_class_init (GMythFileClass * klass);
   15.85 +static void gmyth_file_init (GMythFile * object);
   15.86 +static void gmyth_file_dispose (GObject * object);
   15.87 +static void gmyth_file_finalize (GObject * object);
   15.88  
   15.89 -G_DEFINE_TYPE(GMythFile, gmyth_file, G_TYPE_OBJECT)
   15.90 -
   15.91 -static void
   15.92 -gmyth_file_class_init (GMythFileClass *klass)
   15.93 +G_DEFINE_TYPE (GMythFile, gmyth_file, G_TYPE_OBJECT)
   15.94 +     static void gmyth_file_class_init (GMythFileClass * klass)
   15.95  {
   15.96      GObjectClass *gobject_class;
   15.97      GMythFileClass *gtransfer_class;
   15.98 @@ -97,82 +96,88 @@
   15.99      gobject_class = (GObjectClass *) klass;
  15.100      gtransfer_class = (GMythFileClass *) gobject_class;
  15.101  
  15.102 -    gobject_class->dispose  = gmyth_file_dispose;
  15.103 +    gobject_class->dispose = gmyth_file_dispose;
  15.104      gobject_class->finalize = gmyth_file_finalize;
  15.105 -    
  15.106 +
  15.107      gobject_class->set_property = gmyth_file_set_property;
  15.108      gobject_class->get_property = gmyth_file_get_property;
  15.109 -    
  15.110 +
  15.111      g_object_class_install_property
  15.112 -          (gobject_class, PROP_GMYTH_FILE_FILENAME,
  15.113 -          g_param_spec_string ("filename", "filename",
  15.114 -              "The file name.",
  15.115 -              "", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | 
  15.116 -                  G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.117 -    
  15.118 +        (gobject_class, PROP_GMYTH_FILE_FILENAME,
  15.119 +        g_param_spec_string ("filename", "filename",
  15.120 +            "The file name.",
  15.121 +            "",
  15.122 +            G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
  15.123 +            G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.124 +
  15.125      g_object_class_install_property
  15.126 -          (gobject_class, PROP_GMYTH_FILE_OFFSET,
  15.127 -          g_param_spec_int64 ("file-offset", "file-offset",
  15.128 -                  "The offset (position) of this file", 0, G_MAXINT64, 0, G_PARAM_STATIC_NAME | 
  15.129 -                      G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.130 -    
  15.131 +        (gobject_class, PROP_GMYTH_FILE_OFFSET,
  15.132 +        g_param_spec_int64 ("file-offset", "file-offset",
  15.133 +            "The offset (position) of this file", 0,
  15.134 +            G_MAXINT64, 0,
  15.135 +            G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
  15.136 +            G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.137 +
  15.138      g_object_class_install_property
  15.139 -          (gobject_class, PROP_GMYTH_FILE_FILESIZE,
  15.140 -          g_param_spec_uint64 ("file-size", "file-size",
  15.141 -              "The file size in bytes",
  15.142 -              0, G_MAXUINT64, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | 
  15.143 -                  G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.144 -    
  15.145 +        (gobject_class, PROP_GMYTH_FILE_FILESIZE,
  15.146 +        g_param_spec_uint64 ("file-size", "file-size",
  15.147 +            "The file size in bytes",
  15.148 +            0, G_MAXUINT64, 0,
  15.149 +            G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
  15.150 +            G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.151 +
  15.152      g_object_class_install_property
  15.153 -          (gobject_class, PROP_GMYTH_FILE_BACKEND_INFO,
  15.154 -          g_param_spec_object ("backend-info", "backend-info",
  15.155 -                  "The Backend Information about the remote server", 
  15.156 -                  G_TYPE_OBJECT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | 
  15.157 -                      G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.158 -    
  15.159 +        (gobject_class, PROP_GMYTH_FILE_BACKEND_INFO,
  15.160 +        g_param_spec_object ("backend-info", "backend-info",
  15.161 +            "The Backend Information about the remote server",
  15.162 +            G_TYPE_OBJECT,
  15.163 +            G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
  15.164 +            G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.165 +
  15.166      g_object_class_install_property
  15.167 -          (gobject_class, PROP_GMYTH_FILE_FILEID,
  15.168 -          g_param_spec_int ("file-id", "file-id",
  15.169 -                  "The file ID", 0, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | 
  15.170 -                      G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.171 -  
  15.172 -   g_type_class_add_private (gobject_class, sizeof (GMythFilePrivate));
  15.173 +        (gobject_class, PROP_GMYTH_FILE_FILEID,
  15.174 +        g_param_spec_int ("file-id", "file-id",
  15.175 +            "The file ID", 0, G_MAXINT, 0,
  15.176 +            G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
  15.177 +            G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
  15.178 +
  15.179 +    g_type_class_add_private (gobject_class, sizeof (GMythFilePrivate));
  15.180  
  15.181  }
  15.182  
  15.183  static void
  15.184 -gmyth_file_init (GMythFile *file)
  15.185 -{ 
  15.186 -    g_return_if_fail( file != NULL );
  15.187 +gmyth_file_init (GMythFile * file)
  15.188 +{
  15.189 +    g_return_if_fail (file != NULL);
  15.190  
  15.191 -    file->priv = GMYTH_FILE_GET_PRIVATE(file);
  15.192 +    file->priv = GMYTH_FILE_GET_PRIVATE (file);
  15.193  }
  15.194  
  15.195  static void
  15.196 -gmyth_file_dispose  (GObject *object)
  15.197 -{	
  15.198 +gmyth_file_dispose (GObject * object)
  15.199 +{
  15.200      GMythFilePrivate *priv;
  15.201 -	GMythFile *file = GMYTH_FILE (object);
  15.202 +    GMythFile *file = GMYTH_FILE (object);
  15.203  
  15.204 -    g_return_if_fail( file != NULL );
  15.205 +    g_return_if_fail (file != NULL);
  15.206  
  15.207 -    priv = GMYTH_FILE_GET_PRIVATE(file);
  15.208 +    priv = GMYTH_FILE_GET_PRIVATE (file);
  15.209  
  15.210      if (priv->disposed) {
  15.211          /* If dispose did already run, return. */
  15.212          return;
  15.213      }
  15.214 -    
  15.215 +
  15.216      /* Make sure dispose does not run twice. */
  15.217      priv->disposed = TRUE;
  15.218 -    
  15.219 -    if (priv->backend_info != NULL ) {
  15.220 -        g_object_unref (priv->backend_info );
  15.221 +
  15.222 +    if (priv->backend_info != NULL) {
  15.223 +        g_object_unref (priv->backend_info);
  15.224          priv->backend_info = NULL;
  15.225      }
  15.226  
  15.227 -    if (priv->filename != NULL ) {
  15.228 -        g_free (priv->filename );
  15.229 +    if (priv->filename != NULL) {
  15.230 +        g_free (priv->filename);
  15.231          priv->filename = NULL;
  15.232      }
  15.233  
  15.234 @@ -180,11 +185,11 @@
  15.235  }
  15.236  
  15.237  static void
  15.238 -gmyth_file_finalize (GObject *object)
  15.239 +gmyth_file_finalize (GObject * object)
  15.240  {
  15.241 -  g_signal_handlers_destroy (object);
  15.242 +    g_signal_handlers_destroy (object);
  15.243  
  15.244 -  G_OBJECT_CLASS (gmyth_file_parent_class)->finalize (object);
  15.245 +    G_OBJECT_CLASS (gmyth_file_parent_class)->finalize (object);
  15.246  }
  15.247  
  15.248  /** 
  15.249 @@ -195,44 +200,50 @@
  15.250   * 
  15.251   * @return a new instance of the File Transfer. 
  15.252   */
  15.253 -GMythFile*
  15.254 -gmyth_file_new (GMythBackendInfo *backend_info)
  15.255 +GMythFile *
  15.256 +gmyth_file_new (GMythBackendInfo * backend_info)
  15.257  {
  15.258 -  GMythFile *file = NULL;
  15.259 +    GMythFile *file = NULL;
  15.260  
  15.261 -  g_return_val_if_fail (backend_info != NULL, NULL);
  15.262 -  
  15.263 -  GParameter * __params = g_new0 (GParameter, 1);
  15.264 -  GParameter * __params_it = __params;
  15.265 -  
  15.266 -  (__params_it->name = "backend-info", g_value_init (&__params_it->value, G_TYPE_OBJECT), 
  15.267 -          g_value_set_object (&__params_it->value, backend_info), __params_it++);
  15.268 -  file = g_object_newv (GMYTH_FILE_TYPE, __params_it - __params, __params);
  15.269 +    g_return_val_if_fail (backend_info != NULL, NULL);
  15.270  
  15.271 -  return file;
  15.272 +    GParameter *__params = g_new0 (GParameter, 1);
  15.273 +    GParameter *__params_it = __params;
  15.274 +
  15.275 +    (__params_it->name =
  15.276 +        "backend-info", g_value_init (&__params_it->value, G_TYPE_OBJECT),
  15.277 +        g_value_set_object (&__params_it->value, backend_info), __params_it++);
  15.278 +    file = g_object_newv (GMYTH_FILE_TYPE, __params_it - __params, __params);
  15.279 +
  15.280 +    return file;
  15.281  }
  15.282  
  15.283 -gchar*
  15.284 -gmyth_file_get_file_name (GMythFile *file)
  15.285 +gchar *
  15.286 +gmyth_file_get_file_name (GMythFile * file)
  15.287  {
  15.288 -    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE(file);
  15.289 +    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
  15.290  
  15.291 -    g_return_val_if_fail( file != NULL, NULL );
  15.292 -    
  15.293 +    g_return_val_if_fail (file != NULL, NULL);
  15.294 +
  15.295      return priv->filename;
  15.296  }
  15.297  
  15.298  void
  15.299 -gmyth_file_set_file_name (GMythFile *file, const gchar* filename)
  15.300 -{    
  15.301 -    g_return_if_fail( file != NULL );
  15.302 -    g_return_if_fail( filename != NULL );
  15.303 -    
  15.304 -    gchar* __temp2 = NULL;
  15.305 -    const gchar* __temp1 = NULL;
  15.306 -    file->priv->filename = (__temp2 = (__temp1 = filename, (__temp1 == NULL ? 
  15.307 -            NULL : g_strdup (__temp1))), (file->priv->filename == NULL ? 
  15.308 -            NULL : (file->priv->filename = (g_free (file->priv->filename), NULL))), __temp2);
  15.309 +gmyth_file_set_file_name (GMythFile * file, const gchar * filename)
  15.310 +{
  15.311 +    g_return_if_fail (file != NULL);
  15.312 +    g_return_if_fail (filename != NULL);
  15.313 +
  15.314 +    gchar *__temp2 = NULL;
  15.315 +    const gchar *__temp1 = NULL;
  15.316 +
  15.317 +    file->priv->filename = (__temp2 = (__temp1 = filename, (__temp1 == NULL ?
  15.318 +                NULL :
  15.319 +                g_strdup
  15.320 +                (__temp1))),
  15.321 +        (file->priv->filename ==
  15.322 +            NULL ? NULL : (file->priv->filename =
  15.323 +                (g_free (file->priv->filename), NULL))), __temp2);
  15.324  }
  15.325  
  15.326  /** 
  15.327 @@ -242,14 +253,14 @@
  15.328   * 
  15.329   * @return a new instance of the File Transfer. 
  15.330   */
  15.331 -GMythFile* 
  15.332 -gmyth_file_new_with_uri (const gchar* uri_str)
  15.333 +GMythFile *
  15.334 +gmyth_file_new_with_uri (const gchar * uri_str)
  15.335  {
  15.336 -  GMythFile *file = GMYTH_FILE ( g_object_new (GMYTH_FILE_TYPE, NULL) );
  15.337 -  GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
  15.338 +    GMythFile *file = GMYTH_FILE (g_object_new (GMYTH_FILE_TYPE, NULL));
  15.339 +    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
  15.340  
  15.341 -  priv->backend_info = gmyth_backend_info_new_with_uri (uri_str);
  15.342 -  return file;
  15.343 +    priv->backend_info = gmyth_backend_info_new_with_uri (uri_str);
  15.344 +    return file;
  15.345  }
  15.346  
  15.347  /** 
  15.348 @@ -261,22 +272,21 @@
  15.349   * @return <code>true</code>, if the connection opening had been done successfully. 
  15.350   */
  15.351  gboolean
  15.352 -gmyth_file_setup (GMythFile *file, const gchar* filename)
  15.353 +gmyth_file_setup (GMythFile * file, const gchar * filename)
  15.354  {
  15.355      gboolean ret = TRUE;
  15.356      GMythFilePrivate *priv;
  15.357 -  
  15.358 +
  15.359      g_return_val_if_fail (file != NULL, FALSE);
  15.360 -    g_return_val_if_fail (filename != NULL && strlen(filename) > 0, FALSE);
  15.361 +    g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE);
  15.362  
  15.363      priv = GMYTH_FILE_GET_PRIVATE (file);
  15.364  
  15.365 -    if (priv->filename != NULL)
  15.366 -    {
  15.367 +    if (priv->filename != NULL) {
  15.368          gmyth_file_close (file);
  15.369      }
  15.370  
  15.371 -    priv->filename = g_strdup( filename );
  15.372 +    priv->filename = g_strdup (filename);
  15.373  
  15.374      return ret;
  15.375  }
  15.376 @@ -287,7 +297,7 @@
  15.377   * @param file The actual File Transfer instance. 
  15.378   */
  15.379  void
  15.380 -gmyth_file_close (GMythFile *file )
  15.381 +gmyth_file_close (GMythFile * file)
  15.382  {
  15.383      GMythFilePrivate *priv;
  15.384  
  15.385 @@ -308,7 +318,7 @@
  15.386   * @return The actual file size in bytes. 
  15.387   */
  15.388  guint64
  15.389 -gmyth_file_get_filesize (GMythFile *file)
  15.390 +gmyth_file_get_filesize (GMythFile * file)
  15.391  {
  15.392      GMythFilePrivate *priv;
  15.393  
  15.394 @@ -325,12 +335,12 @@
  15.395   * @param filesize The actual File Transfer size, in bytes.
  15.396   */
  15.397  void
  15.398 -gmyth_file_set_filesize (GMythFile *file, guint64 filesize)
  15.399 +gmyth_file_set_filesize (GMythFile * file, guint64 filesize)
  15.400  {
  15.401      GMythFilePrivate *priv;
  15.402  
  15.403      priv = GMYTH_FILE_GET_PRIVATE (file);
  15.404 -    
  15.405 +
  15.406      priv->filesize = filesize;
  15.407  }
  15.408  
  15.409 @@ -342,7 +352,7 @@
  15.410   * @return The actual file offset in bytes. 
  15.411   */
  15.412  gint64
  15.413 -gmyth_file_get_offset (GMythFile *file)
  15.414 +gmyth_file_get_offset (GMythFile * file)
  15.415  {
  15.416      g_return_val_if_fail (file != NULL, 0);
  15.417  
  15.418 @@ -356,29 +366,32 @@
  15.419   * @param filesize The actual File offset, in bytes.
  15.420   */
  15.421  void
  15.422 -gmyth_file_set_offset (GMythFile *file, gint64 offset)
  15.423 +gmyth_file_set_offset (GMythFile * file, gint64 offset)
  15.424  {
  15.425      GMythFilePrivate *priv;
  15.426 -    
  15.427 +
  15.428      priv = GMYTH_FILE_GET_PRIVATE (file);
  15.429 -    
  15.430 +
  15.431      priv->offset = offset;
  15.432  }
  15.433  
  15.434 -gchar*
  15.435 -gmyth_file_get_uri (GMythFile *file)
  15.436 +gchar *
  15.437 +gmyth_file_get_uri (GMythFile * file)
  15.438  {
  15.439 -    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE(file);
  15.440 +    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
  15.441      gchar *uri = NULL;
  15.442  
  15.443 -    g_return_val_if_fail( file != NULL, NULL );
  15.444 -    
  15.445 -    if ( g_strstr_len( priv->filename, strlen(priv->filename), "://" ) != NULL )
  15.446 -        uri = g_strdup( priv->filename );
  15.447 +    g_return_val_if_fail (file != NULL, NULL);
  15.448 +
  15.449 +    if (g_strstr_len (priv->filename, strlen (priv->filename), "://") != NULL)
  15.450 +        uri = g_strdup (priv->filename);
  15.451      else
  15.452 -        uri = g_strdup_printf( "myth://%s:%d/%s", gmyth_backend_info_get_hostname( priv->backend_info ), 
  15.453 -                gmyth_backend_info_get_port( priv->backend_info ), priv->filename );
  15.454 -    
  15.455 +        uri =
  15.456 +            g_strdup_printf ("myth://%s:%d/%s",
  15.457 +            gmyth_backend_info_get_hostname (priv->
  15.458 +                backend_info),
  15.459 +            gmyth_backend_info_get_port (priv->backend_info), priv->filename);
  15.460 +
  15.461      return uri;
  15.462  }
  15.463  
  15.464 @@ -386,55 +399,56 @@
  15.465  gmyth_file_set_property (GObject * object, guint prop_id,
  15.466      const GValue * value, GParamSpec * pspec)
  15.467  {
  15.468 -    GMythFilePrivate* priv = GMYTH_FILE_GET_PRIVATE( GMYTH_FILE(object) );
  15.469 +    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object));
  15.470  
  15.471      switch (prop_id) {
  15.472          case PROP_GMYTH_FILE_FILENAME:
  15.473          {
  15.474 -          if (!g_value_get_string (value)) {
  15.475 -              break;
  15.476 -          }
  15.477 -    
  15.478 -          if (priv->filename != NULL) {
  15.479 -            g_free (priv->filename);
  15.480 -            priv->filename = NULL;
  15.481 -          }
  15.482 -          priv->filename = g_value_dup_string (value);
  15.483 -          gmyth_debug( "Changed the filename to [%s]!", priv->filename );
  15.484 -          break;
  15.485 +            if (!g_value_get_string (value)) {
  15.486 +                break;
  15.487 +            }
  15.488 +
  15.489 +            if (priv->filename != NULL) {
  15.490 +                g_free (priv->filename);
  15.491 +                priv->filename = NULL;
  15.492 +            }
  15.493 +            priv->filename = g_value_dup_string (value);
  15.494 +            gmyth_debug ("Changed the filename to [%s]!", priv->filename);
  15.495 +            break;
  15.496          }
  15.497          case PROP_GMYTH_FILE_OFFSET:
  15.498          {
  15.499 -          priv->offset = g_value_get_int64 (value);
  15.500 -          break;
  15.501 +            priv->offset = g_value_get_int64 (value);
  15.502 +            break;
  15.503          }
  15.504          case PROP_GMYTH_FILE_FILESIZE:
  15.505          {
  15.506 -          priv->filesize = g_value_get_uint64 (value);
  15.507 -          break;
  15.508 +            priv->filesize = g_value_get_uint64 (value);
  15.509 +            break;
  15.510          }
  15.511          case PROP_GMYTH_FILE_BACKEND_INFO:
  15.512          {
  15.513 -          if (!g_value_get_object (value)) {
  15.514 -              break;
  15.515 -          }
  15.516 -    
  15.517 -          if (priv->backend_info != NULL) {
  15.518 -            g_object_unref (priv->backend_info);
  15.519 -           priv->backend_info = NULL;
  15.520 -          }          
  15.521 -          priv->backend_info = g_value_get_object (value);
  15.522 -          gmyth_debug( "Changed the backend info to [%s]!", gmyth_backend_info_get_hostname( priv->backend_info ) );
  15.523 -          break;
  15.524 +            if (!g_value_get_object (value)) {
  15.525 +                break;
  15.526 +            }
  15.527 +
  15.528 +            if (priv->backend_info != NULL) {
  15.529 +                g_object_unref (priv->backend_info);
  15.530 +                priv->backend_info = NULL;
  15.531 +            }
  15.532 +            priv->backend_info = g_value_get_object (value);
  15.533 +            gmyth_debug ("Changed the backend info to [%s]!",
  15.534 +                gmyth_backend_info_get_hostname (priv->backend_info));
  15.535 +            break;
  15.536          }
  15.537          case PROP_GMYTH_FILE_FILEID:
  15.538          {
  15.539 -          priv->file_id = g_value_get_int (value);
  15.540 -          break;
  15.541 +            priv->file_id = g_value_get_int (value);
  15.542 +            break;
  15.543          }
  15.544          default:
  15.545 -          G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  15.546 -          break;
  15.547 +            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  15.548 +            break;
  15.549      }
  15.550  
  15.551  }
  15.552 @@ -443,36 +457,34 @@
  15.553  gmyth_file_get_property (GObject * object, guint prop_id,
  15.554      GValue * value, GParamSpec * pspec)
  15.555  {
  15.556 -  GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE( GMYTH_FILE (object) );
  15.557 +    GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object));
  15.558  
  15.559 -  switch (prop_id) {
  15.560 -    case PROP_GMYTH_FILE_FILENAME:
  15.561 -    {
  15.562 -      gmyth_debug( "Got the filename to [%s]!", priv->filename );
  15.563 -      g_value_set_string (value, priv->filename);
  15.564 -      break;
  15.565 +    switch (prop_id) {
  15.566 +        case PROP_GMYTH_FILE_FILENAME:
  15.567 +        {
  15.568 +            gmyth_debug ("Got the filename to [%s]!", priv->filename);
  15.569 +            g_value_set_string (value, priv->filename);
  15.570 +            break;
  15.571 +        }
  15.572 +        case PROP_GMYTH_FILE_OFFSET:
  15.573 +        {
  15.574 +            g_value_set_int64 (value, priv->offset);
  15.575 +            break;
  15.576 +        }
  15.577 +        case PROP_GMYTH_FILE_FILESIZE:
  15.578 +        {
  15.579 +            g_value_set_uint64 (value, priv->filesize);
  15.580 +            break;
  15.581 +        }
  15.582 +        case PROP_GMYTH_FILE_BACKEND_INFO:
  15.583 +            g_value_set_object (value, priv->backend_info);
  15.584 +            break;
  15.585 +        case PROP_GMYTH_FILE_FILEID:
  15.586 +            g_value_set_int (value, priv->file_id);
  15.587 +            break;
  15.588 +        default:
  15.589 +            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  15.590 +            break;
  15.591      }
  15.592 -    case PROP_GMYTH_FILE_OFFSET:
  15.593 -    {
  15.594 -      g_value_set_int64 (value, priv->offset);
  15.595 -      break;
  15.596 -    }
  15.597 -    case PROP_GMYTH_FILE_FILESIZE:
  15.598 -    {
  15.599 -      g_value_set_uint64 (value, priv->filesize);
  15.600 -      break;
  15.601 -    }
  15.602 -    case PROP_GMYTH_FILE_BACKEND_INFO:
  15.603 -      g_value_set_object (value, priv->backend_info);
  15.604 -      break;
  15.605 -    case PROP_GMYTH_FILE_FILEID:
  15.606 -      g_value_set_int (value, priv->file_id);
  15.607 -      break;
  15.608 -    default:
  15.609 -      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  15.610 -      break;
  15.611 -  }
  15.612 -  
  15.613 +
  15.614  }
  15.615 -
  15.616 -
    16.1 --- a/gmyth/src/gmyth_file.h	Tue May 22 19:21:42 2007 +0100
    16.2 +++ b/gmyth/src/gmyth_file.h	Wed May 23 16:11:29 2007 +0100
    16.3 @@ -9,23 +9,23 @@
    16.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    16.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    16.6   *
    16.7 - *//*
    16.8 - * 
    16.9 - * This program is free software; you can redistribute it and/or modify
   16.10 - * it under the terms of the GNU Lesser General Public License as published by
   16.11 - * the Free Software Foundation; either version 2 of the License, or
   16.12 - * (at your option) any later version.
   16.13 - *
   16.14 - * This program is distributed in the hope that it will be useful,
   16.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.17 - * GNU General Public License for more details.
   16.18 - *
   16.19 - * You should have received a copy of the GNU Lesser General Public License
   16.20 - * along with this program; if not, write to the Free Software
   16.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16.22 - */
   16.23 - 
   16.24 +          *//*
   16.25 +       * 
   16.26 +       * This program is free software; you can redistribute it and/or modify
   16.27 +       * it under the terms of the GNU Lesser General Public License as published by
   16.28 +       * the Free Software Foundation; either version 2 of the License, or
   16.29 +       * (at your option) any later version.
   16.30 +       *
   16.31 +       * This program is distributed in the hope that it will be useful,
   16.32 +       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.33 +       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.34 +       * GNU General Public License for more details.
   16.35 +       *
   16.36 +       * You should have received a copy of the GNU Lesser General Public License
   16.37 +       * along with this program; if not, write to the Free Software
   16.38 +       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16.39 +       */
   16.40 +
   16.41  #ifndef __GMYTH_FILE_H__
   16.42  #define __GMYTH_FILE_H__
   16.43  
   16.44 @@ -43,53 +43,50 @@
   16.45  #include <unistd.h>
   16.46  
   16.47  G_BEGIN_DECLS
   16.48 -
   16.49  #define GMYTH_FILE_TYPE               (gmyth_file_get_type ())
   16.50  #define GMYTH_FILE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_TYPE, GMythFile))
   16.51  #define GMYTH_FILE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TYPE, GMythFileClass))
   16.52  #define IS_GMYTH_FILE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_FILE_TYPE))
   16.53  #define IS_GMYTH_FILE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TYPE))
   16.54  #define GMYTH_FILE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_TYPE, GMythFileClass))
   16.55 -
   16.56 -typedef enum {
   16.57 -    GMYTH_FILE_READ_OK                 = 0,
   16.58 -    GMYTH_FILE_READ_NEXT_PROG_CHAIN    = 1,
   16.59 -    GMYTH_FILE_READ_ERROR              = 2,
   16.60 -    GMYTH_FILE_READ_EOF                = 3
   16.61 +    typedef enum
   16.62 +{
   16.63 +    GMYTH_FILE_READ_OK = 0,
   16.64 +    GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1,
   16.65 +    GMYTH_FILE_READ_ERROR = 2,
   16.66 +    GMYTH_FILE_READ_EOF = 3
   16.67  } GMythFileReadResult;
   16.68  
   16.69 -typedef struct _GMythFile         GMythFile;
   16.70 -typedef struct _GMythFileClass    GMythFileClass;
   16.71 -typedef struct _GMythFilePrivate  GMythFilePrivate;
   16.72 +typedef struct _GMythFile GMythFile;
   16.73 +typedef struct _GMythFileClass GMythFileClass;
   16.74 +typedef struct _GMythFilePrivate GMythFilePrivate;
   16.75  
   16.76  struct _GMythFile
   16.77  {
   16.78 -	GObject 				parent;
   16.79 -	GMythFilePrivate        *priv;
   16.80 +    GObject parent;
   16.81 +    GMythFilePrivate *priv;
   16.82  };
   16.83  
   16.84  struct _GMythFileClass
   16.85  {
   16.86 -	GObjectClass           parent_class;
   16.87 +    GObjectClass parent_class;
   16.88  };
   16.89  
   16.90 -GType               gmyth_file_get_type         (void);
   16.91 -GMythFile*          gmyth_file_new              (GMythBackendInfo *backend_info);
   16.92 -gchar*              gmyth_file_get_file_name    (GMythFile *file);
   16.93 -void                gmyth_file_set_file_name    (GMythFile *file, const gchar* filename);
   16.94 -gboolean            gmyth_file_setup            (GMythFile *file, 
   16.95 -                                				    const gchar* filename);
   16.96 -void                gmyth_file_close            (GMythFile *file);
   16.97 -gboolean            gmyth_file_is_open          (GMythFile *file);
   16.98 +GType gmyth_file_get_type (void);
   16.99 +GMythFile *gmyth_file_new (GMythBackendInfo * backend_info);
  16.100 +gchar *gmyth_file_get_file_name (GMythFile * file);
  16.101 +void gmyth_file_set_file_name (GMythFile * file, const gchar * filename);
  16.102 +gboolean gmyth_file_setup (GMythFile * file, const gchar * filename);
  16.103 +void gmyth_file_close (GMythFile * file);
  16.104 +gboolean gmyth_file_is_open (GMythFile * file);
  16.105  
  16.106 -guint64             gmyth_file_get_filesize     (GMythFile *file);
  16.107 -void                gmyth_file_set_filesize     (GMythFile *file, guint64 filesize);
  16.108 +guint64 gmyth_file_get_filesize (GMythFile * file);
  16.109 +void gmyth_file_set_filesize (GMythFile * file, guint64 filesize);
  16.110  
  16.111 -gint64              gmyth_file_get_offset       (GMythFile *file);
  16.112 -void                gmyth_file_set_offset       (GMythFile *file, gint64 offset);
  16.113 +gint64 gmyth_file_get_offset (GMythFile * file);
  16.114 +void gmyth_file_set_offset (GMythFile * file, gint64 offset);
  16.115  
  16.116 -gchar*              gmyth_file_get_uri          (GMythFile *file);
  16.117 +gchar *gmyth_file_get_uri (GMythFile * file);
  16.118  
  16.119  G_END_DECLS
  16.120 -
  16.121  #endif /* __GMYTH_FILE_H__ */
    17.1 --- a/gmyth/src/gmyth_file_local.c	Tue May 22 19:21:42 2007 +0100
    17.2 +++ b/gmyth/src/gmyth_file_local.c	Wed May 23 16:11:29 2007 +0100
    17.3 @@ -9,23 +9,23 @@
    17.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    17.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    17.6   *
    17.7 - *//*
    17.8 - * 
    17.9 - * This program is free software; you can redistribute it and/or modify
   17.10 - * it under the terms of the GNU Lesser General Public License as published by
   17.11 - * the Free Software Foundation; either version 2 of the License, or
   17.12 - * (at your option) any later version.
   17.13 - *
   17.14 - * This program is distributed in the hope that it will be useful,
   17.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.17 - * GNU General Public License for more details.
   17.18 - *
   17.19 - * You should have received a copy of the GNU Lesser General Public License
   17.20 - * along with this program; if not, write to the Free Software
   17.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17.22 - */
   17.23 - 
   17.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   17.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   17.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   17.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   17.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   17.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   17.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   17.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   17.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   17.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   17.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   17.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   17.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   17.40 +
   17.41  #ifdef HAVE_CONFIG_H
   17.42  #include "config.h"
   17.43  #endif
   17.44 @@ -53,31 +53,31 @@
   17.45  #define GMYTH_FILE_LOCAL_GET_PRIVATE(obj) \
   17.46      (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalPrivate))
   17.47  
   17.48 -struct _GMythFileLocalPrivate {
   17.49 -    
   17.50 -	gboolean disposed;
   17.51 -    
   17.52 -    GMutex        *mutex;
   17.53 -    
   17.54 -    gint          fd;
   17.55 -    
   17.56 -    GIOChannel    *file_io;
   17.57 +struct _GMythFileLocalPrivate
   17.58 +{
   17.59 +
   17.60 +    gboolean disposed;
   17.61 +
   17.62 +    GMutex *mutex;
   17.63 +
   17.64 +    gint fd;
   17.65 +
   17.66 +    GIOChannel *file_io;
   17.67  
   17.68  };
   17.69  
   17.70 -static void gmyth_file_local_class_init          (GMythFileLocalClass *klass);
   17.71 -static void gmyth_file_local_init                (GMythFileLocal *object);
   17.72 -static void gmyth_file_local_dispose             (GObject *object);
   17.73 -static void gmyth_file_local_finalize            (GObject *object);
   17.74 +static void gmyth_file_local_class_init (GMythFileLocalClass * klass);
   17.75 +static void gmyth_file_local_init (GMythFileLocal * object);
   17.76 +static void gmyth_file_local_dispose (GObject * object);
   17.77 +static void gmyth_file_local_finalize (GObject * object);
   17.78  
   17.79 -static gboolean _control_acquire_context( GMythFileLocal *file_local, gboolean do_wait );
   17.80 +static gboolean _control_acquire_context (GMythFileLocal * file_local,
   17.81 +    gboolean do_wait);
   17.82  
   17.83 -static gboolean _control_release_context( GMythFileLocal *file_local );
   17.84 +static gboolean _control_release_context (GMythFileLocal * file_local);
   17.85  
   17.86 -G_DEFINE_TYPE(GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE)
   17.87 -
   17.88 -static void
   17.89 -gmyth_file_local_class_init (GMythFileLocalClass *klass)
   17.90 +G_DEFINE_TYPE (GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE)
   17.91 +     static void gmyth_file_local_class_init (GMythFileLocalClass * klass)
   17.92  {
   17.93      GObjectClass *gobject_class;
   17.94      GMythFileLocalClass *gtransfer_class;
   17.95 @@ -85,49 +85,50 @@
   17.96      gobject_class = (GObjectClass *) klass;
   17.97      gtransfer_class = (GMythFileLocalClass *) gobject_class;
   17.98  
   17.99 -    gobject_class->dispose  = gmyth_file_local_dispose;
  17.100 +    gobject_class->dispose = gmyth_file_local_dispose;
  17.101      gobject_class->finalize = gmyth_file_local_finalize;
  17.102 -  
  17.103 +
  17.104      g_type_class_add_private (gobject_class, sizeof (GMythFileLocalPrivate));
  17.105  
  17.106  }
  17.107  
  17.108  static void
  17.109 -gmyth_file_local_init (GMythFileLocal *file_local)
  17.110 -{ 
  17.111 +gmyth_file_local_init (GMythFileLocal * file_local)
  17.112 +{
  17.113      GMythFileLocalPrivate *priv;
  17.114 -    g_return_if_fail( file_local != NULL );
  17.115  
  17.116 -    priv = GMYTH_FILE_LOCAL_GET_PRIVATE(file_local);	
  17.117 -    
  17.118 -    priv->mutex = g_mutex_new();
  17.119 +    g_return_if_fail (file_local != NULL);
  17.120 +
  17.121 +    priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.122 +
  17.123 +    priv->mutex = g_mutex_new ();
  17.124  }
  17.125  
  17.126  static void
  17.127 -gmyth_file_local_dispose  (GObject *object)
  17.128 -{	
  17.129 +gmyth_file_local_dispose (GObject * object)
  17.130 +{
  17.131      GMythFileLocalPrivate *priv;
  17.132 -	GMythFileLocal *file_local = GMYTH_FILE_LOCAL(object);
  17.133 +    GMythFileLocal *file_local = GMYTH_FILE_LOCAL (object);
  17.134  
  17.135 -    g_return_if_fail( file_local != NULL );
  17.136 +    g_return_if_fail (file_local != NULL);
  17.137  
  17.138 -    priv = GMYTH_FILE_LOCAL_GET_PRIVATE(file_local);	
  17.139 +    priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.140  
  17.141      if (priv->disposed) {
  17.142          /* If dispose did already run, return. */
  17.143          return;
  17.144      }
  17.145 -    
  17.146 +
  17.147      /* Make sure dispose does not run twice. */
  17.148      priv->disposed = TRUE;
  17.149 -    
  17.150 -    if (priv->mutex != NULL ) {
  17.151 -        g_mutex_free (priv->mutex );
  17.152 +
  17.153 +    if (priv->mutex != NULL) {
  17.154 +        g_mutex_free (priv->mutex);
  17.155          priv->mutex = NULL;
  17.156      }
  17.157 -    
  17.158 -    if (priv->file_io != NULL ) {
  17.159 -        g_io_channel_unref (priv->file_io );
  17.160 +
  17.161 +    if (priv->file_io != NULL) {
  17.162 +        g_io_channel_unref (priv->file_io);
  17.163          priv->file_io = NULL;
  17.164      }
  17.165  
  17.166 @@ -135,11 +136,11 @@
  17.167  }
  17.168  
  17.169  static void
  17.170 -gmyth_file_local_finalize (GObject *object)
  17.171 +gmyth_file_local_finalize (GObject * object)
  17.172  {
  17.173 -  g_signal_handlers_destroy (object);
  17.174 +    g_signal_handlers_destroy (object);
  17.175  
  17.176 -  G_OBJECT_CLASS (gmyth_file_local_parent_class)->finalize (object);
  17.177 +    G_OBJECT_CLASS (gmyth_file_local_parent_class)->finalize (object);
  17.178  }
  17.179  
  17.180  /** 
  17.181 @@ -150,12 +151,13 @@
  17.182   * 
  17.183   * @return a new instance of the File Transfer. 
  17.184   */
  17.185 -GMythFileLocal*
  17.186 -gmyth_file_local_new (GMythBackendInfo *backend_info)
  17.187 +GMythFileLocal *
  17.188 +gmyth_file_local_new (GMythBackendInfo * backend_info)
  17.189  {
  17.190 -    GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
  17.191 +    GMythFileLocal *file_local =
  17.192 +        GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
  17.193  
  17.194 -    g_object_set ( GMYTH_FILE( file_local ), "backend-info", &backend_info, NULL );
  17.195 +    g_object_set (GMYTH_FILE (file_local), "backend-info", &backend_info, NULL);
  17.196  
  17.197      return file_local;
  17.198  }
  17.199 @@ -167,34 +169,35 @@
  17.200   * 
  17.201   * @return a new instance of the File Transfer.
  17.202   */
  17.203 -GMythFileLocal* 
  17.204 -gmyth_file_local_new_with_uri (const gchar* uri_str)
  17.205 +GMythFileLocal *
  17.206 +gmyth_file_local_new_with_uri (const gchar * uri_str)
  17.207  {
  17.208 -    GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
  17.209 -    GMythURI *uri = gmyth_uri_new_with_value(uri_str);
  17.210 -    
  17.211 -    gmyth_debug( "GMythURI path segment = %s", gmyth_uri_get_path(uri) );
  17.212 -    
  17.213 -    g_object_set( GMYTH_FILE( file_local),
  17.214 -            "backend-info", gmyth_backend_info_new_with_uri( uri_str ),
  17.215 -            "filename", g_strdup( gmyth_uri_get_path(uri) ),
  17.216 -            NULL );
  17.217 -    
  17.218 -    g_object_unref( uri );
  17.219 -    
  17.220 +    GMythFileLocal *file_local =
  17.221 +        GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
  17.222 +    GMythURI *uri = gmyth_uri_new_with_value (uri_str);
  17.223 +
  17.224 +    gmyth_debug ("GMythURI path segment = %s", gmyth_uri_get_path (uri));
  17.225 +
  17.226 +    g_object_set (GMYTH_FILE (file_local),
  17.227 +        "backend-info", gmyth_backend_info_new_with_uri (uri_str),
  17.228 +        "filename", g_strdup (gmyth_uri_get_path (uri)), NULL);
  17.229 +
  17.230 +    g_object_unref (uri);
  17.231 +
  17.232      return file_local;
  17.233  }
  17.234  
  17.235 -gchar*
  17.236 -gmyth_file_local_get_file_name (GMythFileLocal *file_local)
  17.237 +gchar *
  17.238 +gmyth_file_local_get_file_name (GMythFileLocal * file_local)
  17.239  {
  17.240 -    return gmyth_file_get_file_name( GMYTH_FILE( file_local ) );
  17.241 +    return gmyth_file_get_file_name (GMYTH_FILE (file_local));
  17.242  }
  17.243  
  17.244  void
  17.245 -gmyth_file_local_set_file_name (GMythFileLocal *file_local, const gchar* filename)
  17.246 +gmyth_file_local_set_file_name (GMythFileLocal * file_local,
  17.247 +    const gchar * filename)
  17.248  {
  17.249 -    gmyth_file_set_file_name( GMYTH_FILE( file_local ), filename );
  17.250 +    gmyth_file_set_file_name (GMYTH_FILE (file_local), filename);
  17.251  }
  17.252  
  17.253  /** 
  17.254 @@ -205,24 +208,24 @@
  17.255   * @return <code>true</code>, if the connection opening had been done successfully. 
  17.256   */
  17.257  gboolean
  17.258 -gmyth_file_local_open (GMythFileLocal *file_local)
  17.259 +gmyth_file_local_open (GMythFileLocal * file_local)
  17.260  {
  17.261      gboolean ret = TRUE;
  17.262      GMythFileLocalPrivate *priv;
  17.263      gchar *file_name_uri = NULL;
  17.264 -  
  17.265 +
  17.266      g_return_val_if_fail (file_local != NULL, FALSE);
  17.267  
  17.268      priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.269 -    file_name_uri = gmyth_file_local_get_file_name(file_local);
  17.270 +    file_name_uri = gmyth_file_local_get_file_name (file_local);
  17.271  
  17.272 -    if ( file_name_uri != NULL )
  17.273 -    {
  17.274 -        priv->file_io = g_io_channel_new_file( g_strdup( file_name_uri ), "r+", NULL );
  17.275 -        g_free( file_name_uri );
  17.276 +    if (file_name_uri != NULL) {
  17.277 +        priv->file_io =
  17.278 +            g_io_channel_new_file (g_strdup (file_name_uri), "r+", NULL);
  17.279 +        g_free (file_name_uri);
  17.280      }
  17.281  
  17.282 -    if ( priv->file_io < 0 )
  17.283 +    if (priv->file_io < 0)
  17.284          ret = FALSE;
  17.285  
  17.286      return ret;
  17.287 @@ -234,7 +237,7 @@
  17.288   * @param file_local The actual File Transfer instance. 
  17.289   */
  17.290  void
  17.291 -gmyth_file_local_close (GMythFileLocal *file_local )
  17.292 +gmyth_file_local_close (GMythFileLocal * file_local)
  17.293  {
  17.294      g_return_if_fail (file_local != NULL);
  17.295  }
  17.296 @@ -247,10 +250,10 @@
  17.297   * 
  17.298   * @return <code>true</code>, if the acquire had been got. 
  17.299   */
  17.300 -static gboolean 
  17.301 -_control_acquire_context( GMythFileLocal *file_local, gboolean do_wait )
  17.302 +static gboolean
  17.303 +_control_acquire_context (GMythFileLocal * file_local, gboolean do_wait)
  17.304  {
  17.305 -    gboolean ret = TRUE;    
  17.306 +    gboolean ret = TRUE;
  17.307      GMythFileLocalPrivate *priv;
  17.308  
  17.309      g_return_val_if_fail (file_local != NULL, FALSE);
  17.310 @@ -267,17 +270,17 @@
  17.311   * 
  17.312   * @return <code>true</code>, if the local file read/write permissions had been releaseds. 
  17.313   */
  17.314 -static gboolean 
  17.315 -_control_release_context( GMythFileLocal *file_local ) 
  17.316 +static gboolean
  17.317 +_control_release_context (GMythFileLocal * file_local)
  17.318  {
  17.319      gboolean ret = TRUE;
  17.320      GMythFileLocalPrivate *priv;
  17.321  
  17.322      g_return_val_if_fail (file_local != NULL, FALSE);
  17.323      priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.324 -   
  17.325 -    g_mutex_unlock (priv->mutex );  
  17.326 - 
  17.327 +
  17.328 +    g_mutex_unlock (priv->mutex);
  17.329 +
  17.330      return ret;
  17.331  }
  17.332  
  17.333 @@ -294,8 +297,9 @@
  17.334   * @return The actual block size (in bytes) returned by REQUEST_BLOCK message,
  17.335   *              or the error code. 
  17.336   */
  17.337 -GMythFileReadResult 
  17.338 -gmyth_file_local_read(GMythFileLocal *file_local, GByteArray *data, gint size, gboolean read_unlimited)
  17.339 +GMythFileReadResult
  17.340 +gmyth_file_local_read (GMythFileLocal * file_local, GByteArray * data,
  17.341 +    gint size, gboolean read_unlimited)
  17.342  {
  17.343      gsize bytes_read = 0;
  17.344      gint64 total_read = 0;
  17.345 @@ -312,21 +316,19 @@
  17.346  
  17.347      priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.348  
  17.349 -    io_status = g_io_channel_set_encoding( priv->file_io, NULL, &error );
  17.350 -    if ( io_status == G_IO_STATUS_NORMAL )
  17.351 -        gmyth_debug ( "Setting encoding to binary file data stream.\n" );
  17.352 +    io_status = g_io_channel_set_encoding (priv->file_io, NULL, &error);
  17.353 +    if (io_status == G_IO_STATUS_NORMAL)
  17.354 +        gmyth_debug ("Setting encoding to binary file data stream.\n");
  17.355  
  17.356 -    io_cond = g_io_channel_get_buffer_condition( priv->file_io );  
  17.357 +    io_cond = g_io_channel_get_buffer_condition (priv->file_io);
  17.358  
  17.359 -    _control_acquire_context (file_local, TRUE );
  17.360 +    _control_acquire_context (file_local, TRUE);
  17.361  
  17.362      if (size > 0) {
  17.363          gchar *data_buffer = g_new0 (gchar, size);
  17.364 -        io_status = g_io_channel_read_chars (priv->file_io, 
  17.365 -                                             data_buffer,
  17.366 -                                             (gsize) size,
  17.367 -                                             &bytes_read, 
  17.368 -                                             &error);
  17.369 +
  17.370 +        io_status = g_io_channel_read_chars (priv->file_io,
  17.371 +            data_buffer, (gsize) size, &bytes_read, &error);
  17.372  
  17.373          if (io_status != G_IO_STATUS_NORMAL) {
  17.374              gmyth_debug ("Error on io_channel");
  17.375 @@ -336,55 +338,60 @@
  17.376          }
  17.377  
  17.378          /* append new data to the increasing byte array */
  17.379 -        data = g_byte_array_append (data, (const guint8*)data_buffer, bytes_read);
  17.380 +        data =
  17.381 +            g_byte_array_append (data, (const guint8 *) data_buffer,
  17.382 +            bytes_read);
  17.383          total_read += bytes_read;
  17.384 -        
  17.385 -        if (!read_unlimited && ( gmyth_file_local_get_filesize(file_local) > 0) && 
  17.386 -                (gmyth_file_local_get_offset(file_local) == gmyth_file_local_get_filesize(file_local))) {
  17.387 +
  17.388 +        if (!read_unlimited && (gmyth_file_local_get_filesize (file_local) > 0)
  17.389 +            && (gmyth_file_local_get_offset (file_local) ==
  17.390 +                gmyth_file_local_get_filesize (file_local))) {
  17.391              retval = GMYTH_FILE_READ_EOF;
  17.392              goto error;
  17.393          }
  17.394 -        
  17.395 +
  17.396          g_free (data_buffer);
  17.397 -    } else { 
  17.398 +    } else {
  17.399          retval = GMYTH_FILE_READ_ERROR;
  17.400      }
  17.401  
  17.402 -error:
  17.403 +  error:
  17.404      _control_release_context (file_local);
  17.405  
  17.406 -    if ( error != NULL ) {
  17.407 -        gmyth_debug ("Cleaning-up ERROR: [msg = %s, code = %d]\n", error->message, 
  17.408 -            error->code);
  17.409 +    if (error != NULL) {
  17.410 +        gmyth_debug ("Cleaning-up ERROR: [msg = %s, code = %d]\n",
  17.411 +            error->message, error->code);
  17.412          g_error_free (error);
  17.413      }
  17.414 -  
  17.415 -    if ( total_read > 0 )
  17.416 -        gmyth_file_local_set_offset(file_local, ( gmyth_file_local_get_offset(file_local) + total_read ) );             
  17.417 +
  17.418 +    if (total_read > 0)
  17.419 +        gmyth_file_local_set_offset (file_local,
  17.420 +            (gmyth_file_local_get_offset (file_local) + total_read));
  17.421  
  17.422      return retval;
  17.423  }
  17.424  
  17.425  gint64
  17.426 -gmyth_file_local_seek(GMythFileLocal *file_local, gint64 pos, GSeekType whence)
  17.427 +gmyth_file_local_seek (GMythFileLocal * file_local, gint64 pos,
  17.428 +    GSeekType whence)
  17.429  {
  17.430      GMythFileLocalPrivate *priv;
  17.431 -  
  17.432 +
  17.433      GError *error;
  17.434 -  
  17.435 +
  17.436      GIOStatus io_status = G_IO_STATUS_NORMAL;
  17.437 -  
  17.438 +
  17.439      g_return_val_if_fail (file_local != NULL, -1);
  17.440 -  
  17.441 +
  17.442      priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
  17.443 - 
  17.444 +
  17.445      io_status = g_io_channel_seek_position (priv->file_io, pos, whence, &error);
  17.446 -    
  17.447 -    if ( io_status == G_IO_STATUS_ERROR )
  17.448 +
  17.449 +    if (io_status == G_IO_STATUS_ERROR)
  17.450          pos = -1;
  17.451 -    
  17.452 +
  17.453      return pos;
  17.454 -    
  17.455 +
  17.456  }
  17.457  
  17.458  /** 
  17.459 @@ -395,11 +402,11 @@
  17.460   * @return The actual file_local size in bytes. 
  17.461   */
  17.462  guint64
  17.463 -gmyth_file_local_get_filesize (GMythFileLocal *file_local)
  17.464 +gmyth_file_local_get_filesize (GMythFileLocal * file_local)
  17.465  {
  17.466      g_return_val_if_fail (file_local != NULL, 0);
  17.467  
  17.468 -    return gmyth_file_get_filesize( GMYTH_FILE(file_local) );
  17.469 +    return gmyth_file_get_filesize (GMYTH_FILE (file_local));
  17.470  }
  17.471  
  17.472  /** 
  17.473 @@ -409,11 +416,11 @@
  17.474   * @param filesize The actual File Transfer size, in bytes.
  17.475   */
  17.476  void
  17.477 -gmyth_file_local_set_filesize (GMythFileLocal *file_local, guint64 filesize)
  17.478 +gmyth_file_local_set_filesize (GMythFileLocal * file_local, guint64 filesize)
  17.479  {
  17.480      g_return_if_fail (file_local != NULL);
  17.481  
  17.482 -    gmyth_file_set_filesize( GMYTH_FILE(file_local), filesize );
  17.483 +    gmyth_file_set_filesize (GMYTH_FILE (file_local), filesize);
  17.484  }
  17.485  
  17.486  /** 
  17.487 @@ -424,11 +431,11 @@
  17.488   * @return The actual file offset in bytes.
  17.489   */
  17.490  gint64
  17.491 -gmyth_file_local_get_offset (GMythFileLocal *file_local)
  17.492 +gmyth_file_local_get_offset (GMythFileLocal * file_local)
  17.493  {
  17.494      g_return_val_if_fail (file_local != NULL, 0);
  17.495  
  17.496 -    return gmyth_file_get_offset ( GMYTH_FILE(file_local) );
  17.497 +    return gmyth_file_get_offset (GMYTH_FILE (file_local));
  17.498  }
  17.499  
  17.500  /** 
  17.501 @@ -438,10 +445,9 @@
  17.502   * @param offset The actual File Local offset, in bytes.
  17.503   */
  17.504  void
  17.505 -gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset)
  17.506 +gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset)
  17.507  {
  17.508      g_return_if_fail (file_local != NULL);
  17.509  
  17.510 -    gmyth_file_set_offset( GMYTH_FILE( file_local ), offset );
  17.511 +    gmyth_file_set_offset (GMYTH_FILE (file_local), offset);
  17.512  }
  17.513 -
    18.1 --- a/gmyth/src/gmyth_file_local.h	Tue May 22 19:21:42 2007 +0100
    18.2 +++ b/gmyth/src/gmyth_file_local.h	Wed May 23 16:11:29 2007 +0100
    18.3 @@ -9,23 +9,23 @@
    18.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    18.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    18.6   *
    18.7 - *//*
    18.8 - * 
    18.9 - * This program is free software; you can redistribute it and/or modify
   18.10 - * it under the terms of the GNU Lesser General Public License as published by
   18.11 - * the Free Software Foundation; either version 2 of the License, or
   18.12 - * (at your option) any later version.
   18.13 - *
   18.14 - * This program is distributed in the hope that it will be useful,
   18.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18.17 - * GNU General Public License for more details.
   18.18 - *
   18.19 - * You should have received a copy of the GNU Lesser General Public License
   18.20 - * along with this program; if not, write to the Free Software
   18.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18.22 - */
   18.23 - 
   18.24 +          *//*
   18.25 +       * 
   18.26 +       * This program is free software; you can redistribute it and/or modify
   18.27 +       * it under the terms of the GNU Lesser General Public License as published by
   18.28 +       * the Free Software Foundation; either version 2 of the License, or
   18.29 +       * (at your option) any later version.
   18.30 +       *
   18.31 +       * This program is distributed in the hope that it will be useful,
   18.32 +       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.33 +       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18.34 +       * GNU General Public License for more details.
   18.35 +       *
   18.36 +       * You should have received a copy of the GNU Lesser General Public License
   18.37 +       * along with this program; if not, write to the Free Software
   18.38 +       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18.39 +       */
   18.40 +
   18.41  #ifndef __GMYTH_FILE_LOCAL_H__
   18.42  #define __GMYTH_FILE_LOCAL_H__
   18.43  
   18.44 @@ -44,52 +44,49 @@
   18.45  #include <unistd.h>
   18.46  
   18.47  G_BEGIN_DECLS
   18.48 -
   18.49  #define GMYTH_FILE_LOCAL_TYPE               (gmyth_file_local_get_type ())
   18.50  #define GMYTH_FILE_LOCAL(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocal))
   18.51  #define GMYTH_FILE_LOCAL_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
   18.52  #define IS_GMYTH_FILE_LOCAL(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_FILE_LOCAL_TYPE))
   18.53  #define IS_GMYTH_FILE_LOCAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE))
   18.54  #define GMYTH_FILE_LOCAL_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
   18.55 -
   18.56 -typedef struct _GMythFileLocal         GMythFileLocal;
   18.57 -typedef struct _GMythFileLocalClass    GMythFileLocalClass;
   18.58 -typedef struct _GMythFileLocalPrivate  GMythFileLocalPrivate;
   18.59 +typedef struct _GMythFileLocal GMythFileLocal;
   18.60 +typedef struct _GMythFileLocalClass GMythFileLocalClass;
   18.61 +typedef struct _GMythFileLocalPrivate GMythFileLocalPrivate;
   18.62  
   18.63  struct _GMythFileLocal
   18.64  {
   18.65 -	GMythFile          parent;
   18.66 +    GMythFile parent;
   18.67  };
   18.68  
   18.69  struct _GMythFileLocalClass
   18.70  {
   18.71 -	GMythFileClass     parent_class;
   18.72 +    GMythFileClass parent_class;
   18.73  };
   18.74  
   18.75  
   18.76 -GType               gmyth_file_local_get_type        (void);
   18.77 -GMythFileLocal*     gmyth_file_local_new             (GMythBackendInfo *backend_info);
   18.78 -GMythFileLocal*     gmyth_file_local_new_with_uri    (const gchar* uri);
   18.79 -gchar*              gmyth_file_local_get_file_name   (GMythFileLocal *file_local);
   18.80 -void                gmyth_file_local_set_file_name   (GMythFileLocal *file_local, const gchar* filename);
   18.81 -gboolean            gmyth_file_local_open            (GMythFileLocal *file_local);
   18.82 -void                gmyth_file_local_close           (GMythFileLocal *file_local);
   18.83 -gboolean            gmyth_file_local_is_open         (GMythFileLocal *file_local);
   18.84 +GType gmyth_file_local_get_type (void);
   18.85 +GMythFileLocal *gmyth_file_local_new (GMythBackendInfo * backend_info);
   18.86 +GMythFileLocal *gmyth_file_local_new_with_uri (const gchar * uri);
   18.87 +gchar *gmyth_file_local_get_file_name (GMythFileLocal * file_local);
   18.88 +void gmyth_file_local_set_file_name (GMythFileLocal * file_local,
   18.89 +    const gchar * filename);
   18.90 +gboolean gmyth_file_local_open (GMythFileLocal * file_local);
   18.91 +void gmyth_file_local_close (GMythFileLocal * file_local);
   18.92 +gboolean gmyth_file_local_is_open (GMythFileLocal * file_local);
   18.93 +
   18.94  GMythFileReadResult
   18.95 -                    gmyth_file_local_read            (GMythFileLocal *file_local, 
   18.96 -                                                         GByteArray *data, 
   18.97 -                                                         gint size, 
   18.98 -                                                         gboolean read_unlimited);
   18.99 +gmyth_file_local_read (GMythFileLocal * file_local,
  18.100 +    GByteArray * data, gint size, gboolean read_unlimited);
  18.101  
  18.102 -gint64              gmyth_file_local_seek           (GMythFileLocal *file_local, 
  18.103 -                                                         gint64 pos, GSeekType whence);
  18.104 +gint64 gmyth_file_local_seek (GMythFileLocal * file_local,
  18.105 +    gint64 pos, GSeekType whence);
  18.106  
  18.107 -guint64             gmyth_file_local_get_filesize   (GMythFileLocal *file_local);
  18.108 -void                gmyth_file_local_set_filesize   (GMythFileLocal *file, guint64 filesize);
  18.109 +guint64 gmyth_file_local_get_filesize (GMythFileLocal * file_local);
  18.110 +void gmyth_file_local_set_filesize (GMythFileLocal * file, guint64 filesize);
  18.111  
  18.112 -gint64              gmyth_file_local_get_offset     (GMythFileLocal *file_local);
  18.113 -void                gmyth_file_local_set_offset     (GMythFileLocal *file_local, gint64 offset);
  18.114 +gint64 gmyth_file_local_get_offset (GMythFileLocal * file_local);
  18.115 +void gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset);
  18.116  
  18.117  G_END_DECLS
  18.118 -
  18.119  #endif /* __GMYTH_FILE_LOCAL_H__ */
    19.1 --- a/gmyth/src/gmyth_file_transfer.c	Tue May 22 19:21:42 2007 +0100
    19.2 +++ b/gmyth/src/gmyth_file_transfer.c	Wed May 23 16:11:29 2007 +0100
    19.3 @@ -9,27 +9,27 @@
    19.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    19.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    19.6   *
    19.7 -          *//*
    19.8 -       * 
    19.9 -       * This program is free software; you can redistribute it and/or modify
   19.10 -       * it under the terms of the GNU Lesser General Public License as published by
   19.11 -       * the Free Software Foundation; either version 2 of the License, or
   19.12 -       * (at your option) any later version.
   19.13 -       *
   19.14 -       * This program is distributed in the hope that it will be useful,
   19.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.17 -       * GNU General Public License for more details.
   19.18 -       *
   19.19 -       * You should have received a copy of the GNU Lesser General Public License
   19.20 -       * along with this program; if not, write to the Free Software
   19.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19.22 -       *
   19.23 -       * GStreamer MythTV plug-in properties:
   19.24 -       * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
   19.25 -       * - path (qurl - remote file to be opened)
   19.26 -       * - port number *   
   19.27 -       */
   19.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   19.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   19.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   19.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   19.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   19.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   19.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   19.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   19.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   19.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   19.40 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   19.41 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   19.42 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19.43 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   19.44 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GStreamer MythTV plug-in properties:
   19.45 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
   19.46 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - path (qurl - remote file to be opened)
   19.47 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - port number *   
   19.48 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   19.49  
   19.50  #ifdef HAVE_CONFIG_H
   19.51  #include "config.h"
   19.52 @@ -62,41 +62,40 @@
   19.53      (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferPrivate))
   19.54  
   19.55  enum myth_sock_types
   19.56 -    {
   19.57 -        GMYTH_PLAYBACK_TYPE = 0,
   19.58 -        GMYTH_MONITOR_TYPE,
   19.59 -        GMYTH_FILETRANSFER_TYPE,
   19.60 -        GMYTH_RINGBUFFER_TYPE
   19.61 -    };
   19.62 +{
   19.63 +    GMYTH_PLAYBACK_TYPE = 0,
   19.64 +    GMYTH_MONITOR_TYPE,
   19.65 +    GMYTH_FILETRANSFER_TYPE,
   19.66 +    GMYTH_RINGBUFFER_TYPE
   19.67 +};
   19.68  
   19.69  struct _GMythFileTransferPrivate
   19.70 -    {
   19.71 -        GMythRecorder *recorder;
   19.72 +{
   19.73 +    GMythRecorder *recorder;
   19.74  
   19.75 -        gboolean do_next_program_chain;
   19.76 -        gboolean disposed;
   19.77 -        gboolean livetv_wait;
   19.78 +    gboolean do_next_program_chain;
   19.79 +    gboolean disposed;
   19.80 +    gboolean livetv_wait;
   19.81  
   19.82 -        /* MythTV version number */
   19.83 -        gint mythtv_version;
   19.84 +    /* MythTV version number */
   19.85 +    gint mythtv_version;
   19.86  
   19.87 -        /* socket descriptors */
   19.88 -        GMythSocket *control_sock;
   19.89 -        GMythSocket *sock;
   19.90 -        GMutex *mutex;
   19.91 -        gint file_id;
   19.92 -    };
   19.93 +    /* socket descriptors */
   19.94 +    GMythSocket *control_sock;
   19.95 +    GMythSocket *sock;
   19.96 +    GMutex *mutex;
   19.97 +    gint file_id;
   19.98 +};
   19.99  
  19.100  static void gmyth_file_transfer_class_init (GMythFileTransferClass * klass);
  19.101  static void gmyth_file_transfer_init (GMythFileTransfer * object);
  19.102  static void gmyth_file_transfer_dispose (GObject * object);
  19.103  static void gmyth_file_transfer_finalize (GObject * object);
  19.104  static void _file_transfer_program_info_changed (GMythFileTransfer * transfer,
  19.105 -                                                 gint msg_code,
  19.106 -                                                 gpointer livetv_recorder);
  19.107 +    gint msg_code, gpointer livetv_recorder);
  19.108  static gboolean _connect_to_backend (GMythFileTransfer * transfer);
  19.109  static gboolean _control_acquire_context (GMythFileTransfer * transfer,
  19.110 -                                          gboolean do_wait);
  19.111 +    gboolean do_wait);
  19.112  static gboolean _control_release_context (GMythFileTransfer * transfer);
  19.113  
  19.114  G_DEFINE_TYPE (GMythFileTransfer, gmyth_file_transfer, GMYTH_FILE_TYPE)
  19.115 @@ -118,11 +117,11 @@
  19.116  
  19.117      gtransfer_class->program_info_changed_handler_signal_id =
  19.118          g_signal_new ("program-info-changed",
  19.119 -                      G_TYPE_FROM_CLASS (gtransfer_class),
  19.120 -                      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
  19.121 -                      G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
  19.122 -                      gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2,
  19.123 -                      G_TYPE_INT, G_TYPE_POINTER);
  19.124 +        G_TYPE_FROM_CLASS (gtransfer_class),
  19.125 +        G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
  19.126 +        G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
  19.127 +        gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2,
  19.128 +        G_TYPE_INT, G_TYPE_POINTER);
  19.129  
  19.130  }
  19.131  
  19.132 @@ -135,8 +134,8 @@
  19.133      transfer->priv->mutex = g_mutex_new ();
  19.134  
  19.135      g_signal_connect (G_OBJECT (transfer), "program-info-changed",
  19.136 -                      (GCallback) (GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->
  19.137 -                                   program_info_changed_handler), NULL);
  19.138 +        (GCallback) (GMYTH_FILE_TRANSFER_GET_CLASS
  19.139 +            (transfer)->program_info_changed_handler), NULL);
  19.140  }
  19.141  
  19.142  static void
  19.143 @@ -149,8 +148,7 @@
  19.144  
  19.145      priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
  19.146  
  19.147 -    if (priv->disposed)
  19.148 -    {
  19.149 +    if (priv->disposed) {
  19.150          /* If dispose did already run, return. */
  19.151          return;
  19.152      }
  19.153 @@ -158,26 +156,22 @@
  19.154      /* Make sure dispose does not run twice. */
  19.155      priv->disposed = TRUE;
  19.156  
  19.157 -    if (priv->mutex != NULL)
  19.158 -    {
  19.159 +    if (priv->mutex != NULL) {
  19.160          g_mutex_free (priv->mutex);
  19.161          priv->mutex = NULL;
  19.162      }
  19.163  
  19.164 -    if (priv->control_sock != NULL)
  19.165 -    {
  19.166 +    if (priv->control_sock != NULL) {
  19.167          g_object_unref (priv->control_sock);
  19.168          priv->control_sock = NULL;
  19.169      }
  19.170  
  19.171 -    if (priv->sock != NULL)
  19.172 -    {
  19.173 +    if (priv->sock != NULL) {
  19.174          g_object_unref (priv->sock);
  19.175          priv->sock = NULL;
  19.176      }
  19.177  
  19.178 -    if (priv->recorder != NULL)
  19.179 -    {
  19.180 +    if (priv->recorder != NULL) {
  19.181          g_object_unref (priv->recorder);
  19.182          priv->recorder = NULL;
  19.183      }
  19.184 @@ -205,12 +199,13 @@
  19.185  gmyth_file_transfer_new (GMythBackendInfo * backend_info)
  19.186  {
  19.187      GMythFileTransfer *transfer = g_object_new (GMYTH_FILE_TRANSFER_TYPE,
  19.188 -                                                "backend-info", backend_info,
  19.189 -                                                NULL);
  19.190 +        "backend-info", backend_info,
  19.191 +        NULL);
  19.192 +
  19.193      //GValue val = {0,};    
  19.194      //backend_info = g_object_ref( backend_info );
  19.195      gmyth_debug ("Creating FileTransfer BackendInfo hostname = %s",
  19.196 -                 gmyth_backend_info_get_hostname (backend_info));
  19.197 +        gmyth_backend_info_get_hostname (backend_info));
  19.198      //GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri (uri_str);
  19.199      //g_value_init (&val, G_TYPE_OBJECT);
  19.200      //g_value_set_object (&val, backend_info);    
  19.201 @@ -269,36 +264,33 @@
  19.202      g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE);
  19.203  
  19.204      priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
  19.205 -    
  19.206 +
  19.207      gmyth_debug ("Opening the FileTransfer... (%s)", filename);
  19.208  
  19.209      g_object_set (GMYTH_FILE (transfer), "filename", filename, NULL);
  19.210  
  19.211      /* configure the control socket */
  19.212 -    if (TRUE/*priv->control_sock == NULL*/)
  19.213 -    {
  19.214 -        if (!_connect_to_backend (transfer))
  19.215 -        {
  19.216 +    if (TRUE /*priv->control_sock == NULL */ ) {
  19.217 +        if (!_connect_to_backend (transfer)) {
  19.218              gmyth_debug ("Connection to backend failed (Control Socket).");
  19.219              ret = FALSE;
  19.220          }
  19.221  
  19.222 -	if (priv->do_next_program_chain) {
  19.223 -            priv->do_next_program_chain = FALSE; // fixme
  19.224 -	    gmyth_debug ("New file available before the current file was opened");
  19.225 +        if (priv->do_next_program_chain) {
  19.226 +            priv->do_next_program_chain = FALSE;    // fixme
  19.227 +            gmyth_debug
  19.228 +                ("New file available before the current file was opened");
  19.229              GMythProgramInfo *prog_info =
  19.230                  gmyth_recorder_get_current_program_info (priv->recorder);
  19.231  
  19.232              if (prog_info != NULL && prog_info->pathname != NULL
  19.233                  && strlen (prog_info->pathname->str) > 0
  19.234                  && g_ascii_strcasecmp (prog_info->pathname->str,
  19.235 -                                       gmyth_file_get_file_name (GMYTH_FILE
  19.236 -                                                                 (transfer))) !=
  19.237 -                0)
  19.238 +                    gmyth_file_get_file_name (GMYTH_FILE (transfer)))
  19.239 +                != 0)
  19.240                  ret =
  19.241                      gmyth_file_transfer_open (transfer,
  19.242 -                                              g_strrstr (prog_info->pathname->
  19.243 -                                                         str, "/"));
  19.244 +                    g_strrstr (prog_info->pathname->str, "/"));
  19.245  
  19.246              if (prog_info != NULL)
  19.247                  g_object_unref (prog_info);
  19.248 @@ -307,21 +299,20 @@
  19.249                  gmyth_debug ("Cannot change to the next program info!");
  19.250              else
  19.251                  gmyth_debug ("OK!!! MOVED to the next program info [%s]!",
  19.252 -                             gmyth_file_get_file_name (GMYTH_FILE (transfer)));
  19.253 +                    gmyth_file_get_file_name (GMYTH_FILE (transfer)));
  19.254  
  19.255 -	} else {
  19.256 -	    gmyth_debug ("XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX");
  19.257 -	    gmyth_debug ("None new file found. We continue with the same file opened before");
  19.258 -	}
  19.259 +        } else {
  19.260 +            gmyth_debug ("XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX");
  19.261 +            gmyth_debug
  19.262 +                ("None new file found. We continue with the same file opened before");
  19.263 +        }
  19.264  
  19.265 -    }
  19.266 -    else
  19.267 -    {
  19.268 +    } else {
  19.269          gmyth_debug ("Remote transfer control socket already created.");
  19.270      }
  19.271  
  19.272      gmyth_debug ("Got file with size = %lld.\n",
  19.273 -                 gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.274 +        gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.275  
  19.276      return ret;
  19.277  }
  19.278 @@ -352,8 +343,7 @@
  19.279  
  19.280      /* Creates the control socket */
  19.281  
  19.282 -    if (priv->control_sock != NULL)
  19.283 -    {
  19.284 +    if (priv->control_sock != NULL) {
  19.285          g_object_unref (priv->control_sock);
  19.286          priv->control_sock = NULL;
  19.287      }
  19.288 @@ -363,9 +353,7 @@
  19.289      priv->control_sock = gmyth_socket_new ();
  19.290      // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version 
  19.291      if (!gmyth_socket_connect_to_backend (priv->control_sock,
  19.292 -                                          backend_info->hostname,
  19.293 -                                          backend_info->port, TRUE))
  19.294 -    {
  19.295 +            backend_info->hostname, backend_info->port, TRUE)) {
  19.296  
  19.297          g_object_unref (priv->control_sock);
  19.298          priv->control_sock = NULL;
  19.299 @@ -373,22 +361,21 @@
  19.300      }
  19.301  
  19.302      /* Creates the data socket */
  19.303 -    if (priv->sock != NULL)
  19.304 -    {
  19.305 +    if (priv->sock != NULL) {
  19.306          g_object_unref (priv->sock);
  19.307          priv->sock = NULL;
  19.308      }
  19.309  
  19.310      priv->sock = gmyth_socket_new ();
  19.311      gmyth_socket_connect (priv->sock, backend_info->hostname,
  19.312 -                          backend_info->port);
  19.313 -    gmyth_debug ("Connecting file transfer... (%s, %d)", backend_info->hostname,
  19.314 -                 backend_info->port);
  19.315 +        backend_info->port);
  19.316 +    gmyth_debug ("Connecting file transfer... (%s, %d)",
  19.317 +        backend_info->hostname, backend_info->port);
  19.318  
  19.319      strlist = gmyth_string_list_new ();
  19.320      hostname = gmyth_socket_get_local_hostname ();
  19.321      gmyth_debug ("[%s] MythTV version (from backend) = %d.\n", __FUNCTION__,
  19.322 -                 priv->control_sock->mythtv_version);
  19.323 +        priv->control_sock->mythtv_version);
  19.324      if (priv->control_sock->mythtv_version > 26)
  19.325          g_string_printf (base_str, "ANN FileTransfer %s 1 -1", hostname->str);
  19.326      else
  19.327 @@ -396,8 +383,7 @@
  19.328  
  19.329      gmyth_string_list_append_string (strlist, base_str);
  19.330      gmyth_string_list_append_char_array (strlist,
  19.331 -                                         gmyth_file_get_file_name (GMYTH_FILE
  19.332 -                                                                   (transfer)));
  19.333 +        gmyth_file_get_file_name (GMYTH_FILE (transfer)));
  19.334  
  19.335      gmyth_socket_write_stringlist (priv->sock, strlist);
  19.336  
  19.337 @@ -410,17 +396,16 @@
  19.338  
  19.339      /* Myth URI stream file size - decoded using two 8-bytes sequences (64 bits/long long types) */
  19.340      gmyth_file_set_filesize (GMYTH_FILE (transfer),
  19.341 -                             gmyth_string_list_get_int64 (strlist, 2));
  19.342 +        gmyth_string_list_get_int64 (strlist, 2));
  19.343  
  19.344      gmyth_debug ("***** Received: recordernum = %d, filesize = %"
  19.345 -                 G_GUINT64_FORMAT "\n", priv->file_id,
  19.346 -                 gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.347 +        G_GUINT64_FORMAT "\n", priv->file_id,
  19.348 +        gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.349  
  19.350 -    if (gmyth_file_get_filesize (GMYTH_FILE (transfer)) < 0)
  19.351 -    {
  19.352 +    if (gmyth_file_get_filesize (GMYTH_FILE (transfer)) < 0) {
  19.353          gmyth_debug
  19.354              ("Got filesize equals to %llu is lesser than 0 [invalid stream file]\n",
  19.355 -             gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.356 +            gmyth_file_get_filesize (GMYTH_FILE (transfer)));
  19.357          g_object_unref (priv->sock);
  19.358          priv->sock = NULL;
  19.359          ret = FALSE;
  19.360 @@ -450,13 +435,12 @@
  19.361   */
  19.362  void
  19.363  gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer *
  19.364 -                                                      transfer, gint msg_code,
  19.365 -                                                      gpointer live_tv_recorder)
  19.366 +    transfer, gint msg_code, gpointer live_tv_recorder)
  19.367  {
  19.368      gmyth_debug ("Calling signal handler... [FILE_TRANSFER]");
  19.369  
  19.370 -    g_signal_emit (transfer, GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id, 0,       /* details */
  19.371 -                   msg_code, live_tv_recorder);
  19.372 +    g_signal_emit (transfer, GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id, 0,   /* details */
  19.373 +        msg_code, live_tv_recorder);
  19.374  
  19.375  }
  19.376  
  19.377 @@ -528,8 +512,7 @@
  19.378      gmyth_string_list_append_string (strlist, query);
  19.379      gmyth_string_list_append_char_array (strlist, "DONE");
  19.380  
  19.381 -    if (gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist) <= 0)
  19.382 -    {
  19.383 +    if (gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist) <= 0) {
  19.384          // fixme: time out???
  19.385          gmyth_debug ("Remote file timeout.\n");
  19.386      }
  19.387 @@ -537,14 +520,12 @@
  19.388      g_string_free (query, TRUE);
  19.389      g_object_unref (strlist);
  19.390  
  19.391 -    if (priv->sock)
  19.392 -    {
  19.393 +    if (priv->sock) {
  19.394          g_object_unref (priv->sock);
  19.395          priv->sock = NULL;
  19.396      }
  19.397  
  19.398 -    if (priv->control_sock)
  19.399 -    {
  19.400 +    if (priv->control_sock) {
  19.401          g_object_unref (priv->control_sock);
  19.402          priv->control_sock = NULL;
  19.403      }
  19.404 @@ -563,7 +544,7 @@
  19.405   */
  19.406  gint64
  19.407  gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos,
  19.408 -                          gint whence)
  19.409 +    gint whence)
  19.410  {
  19.411      GMythStringList *strlist = gmyth_string_list_new ();
  19.412      GMythFileTransferPrivate *priv;
  19.413 @@ -591,15 +572,15 @@
  19.414          gmyth_string_list_append_uint64 (strlist, pos);
  19.415      else
  19.416          gmyth_string_list_append_uint64 (strlist,
  19.417 -                                         gmyth_file_get_offset (GMYTH_FILE
  19.418 -                                                                (transfer)));
  19.419 +            gmyth_file_get_offset (GMYTH_FILE (transfer)));
  19.420  
  19.421      gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist);
  19.422  
  19.423      gint64 retval = gmyth_string_list_get_int64 (strlist, 0);
  19.424 +
  19.425      gmyth_file_set_offset (GMYTH_FILE (transfer), retval);
  19.426      gmyth_debug ("Got reading position pointer from the streaming = %lld\n",
  19.427 -                 retval);
  19.428 +        retval);
  19.429  
  19.430      g_object_unref (strlist);
  19.431      g_string_free (query, TRUE);
  19.432 @@ -666,7 +647,7 @@
  19.433   */
  19.434  GMythFileReadResult
  19.435  gmyth_file_transfer_read (GMythFileTransfer * transfer, GByteArray * data,
  19.436 -                          gint size, gboolean read_unlimited)
  19.437 +    gint size, gboolean read_unlimited)
  19.438  {
  19.439      gint bytes_sent = 0;
  19.440      gsize bytes_read = 0;
  19.441 @@ -702,19 +683,17 @@
  19.442      io_status = g_io_channel_set_encoding (io_channel, NULL, &error);
  19.443      if (io_status == G_IO_STATUS_NORMAL)
  19.444          gmyth_debug ("[%s] Setting encoding to binary data socket).\n",
  19.445 -                     __FUNCTION__);
  19.446 +            __FUNCTION__);
  19.447  
  19.448      io_cond = g_io_channel_get_buffer_condition (io_channel);
  19.449  
  19.450      io_cond_control = g_io_channel_get_buffer_condition (io_channel);
  19.451 -    if (priv->sock == NULL || (io_status == G_IO_STATUS_ERROR))
  19.452 -    {
  19.453 +    if (priv->sock == NULL || (io_status == G_IO_STATUS_ERROR)) {
  19.454          g_printerr ("gmyth_file_transfer_read(): Called with no raw socket.\n");
  19.455          return GMYTH_FILE_READ_ERROR;
  19.456      }
  19.457  
  19.458 -    if (priv->control_sock == NULL || (io_status_control == G_IO_STATUS_ERROR))
  19.459 -    {
  19.460 +    if (priv->control_sock == NULL || (io_status_control == G_IO_STATUS_ERROR)) {
  19.461          g_printerr
  19.462              ("gmyth_file_transfer_read(): Called with no control socket.\n");
  19.463          return GMYTH_FILE_READ_ERROR;
  19.464 @@ -729,11 +708,10 @@
  19.465      gmyth_string_list_append_char_array (strlist, query->str);
  19.466      gmyth_string_list_append_char_array (strlist, "REQUEST_BLOCK");
  19.467      gmyth_string_list_append_int (strlist, size - total_read);
  19.468 -    
  19.469 -    guint iter_count = 1;
  19.470  
  19.471 -    do
  19.472 -    {
  19.473 +    guint iter_count = 3;
  19.474 +
  19.475 +    do {
  19.476          bytes_sent = 0;
  19.477  
  19.478          // Request the block to the backend
  19.479 @@ -746,33 +724,28 @@
  19.480          // Receives the backand answer    
  19.481          gmyth_socket_read_stringlist (priv->control_sock, ret_strlist);
  19.482  
  19.483 -        if (ret_strlist != NULL && gmyth_string_list_length (ret_strlist) > 0)
  19.484 -        {
  19.485 +        if (ret_strlist != NULL && gmyth_string_list_length (ret_strlist) > 0) {
  19.486              bytes_sent = gmyth_string_list_get_int (ret_strlist, 0);    // -1 on backend error
  19.487              gmyth_debug ("[%s] got SENT buffer message = %d\n", __FUNCTION__,
  19.488 -                         bytes_sent);
  19.489 +                bytes_sent);
  19.490          }
  19.491  
  19.492 -        if (read_unlimited && (bytes_sent == 0))
  19.493 -        {
  19.494 +        if (read_unlimited && (bytes_sent == 0)) {
  19.495              g_usleep (300);
  19.496          }
  19.497  
  19.498 -	--iter_count;
  19.499 +        --iter_count;
  19.500  
  19.501      }
  19.502      while (read_unlimited && (bytes_sent == 0) && iter_count > 0);
  19.503  
  19.504 -    if (bytes_sent > 0)
  19.505 -    {
  19.506 +    if (bytes_sent > 0) {
  19.507          gchar *data_buffer = g_new0 (gchar, bytes_sent);
  19.508 +
  19.509          io_status = g_io_channel_read_chars (io_channel,
  19.510 -                                             data_buffer,
  19.511 -                                             (gsize) bytes_sent,
  19.512 -                                             &bytes_read, &error);
  19.513 +            data_buffer, (gsize) bytes_sent, &bytes_read, &error);
  19.514  
  19.515 -        if (io_status != G_IO_STATUS_NORMAL)
  19.516 -        {
  19.517 +        if (io_status != G_IO_STATUS_NORMAL) {
  19.518              gmyth_debug ("Error on io_channel");
  19.519              g_free (data_buffer);
  19.520              g_object_unref (strlist);
  19.521 @@ -783,45 +756,37 @@
  19.522          /* append new data to the increasing byte array */
  19.523          data =
  19.524              g_byte_array_append (data, (const guint8 *) data_buffer,
  19.525 -                                 bytes_read);
  19.526 +            bytes_read);
  19.527          gmyth_file_set_offset (GMYTH_FILE (transfer),
  19.528 -                               gmyth_file_get_offset (GMYTH_FILE (transfer)) +
  19.529 -                               bytes_read);
  19.530 +            gmyth_file_get_offset (GMYTH_FILE (transfer)) + bytes_read);
  19.531  
  19.532          if (!read_unlimited
  19.533              && (gmyth_file_get_filesize (GMYTH_FILE (transfer)) > 0)
  19.534              && (gmyth_file_get_offset (GMYTH_FILE (transfer)) ==
  19.535 -                gmyth_file_get_filesize (GMYTH_FILE (transfer))))
  19.536 -        {
  19.537 +                gmyth_file_get_filesize (GMYTH_FILE (transfer)))) {
  19.538              retval = GMYTH_FILE_READ_EOF;
  19.539              goto error;
  19.540          }
  19.541  
  19.542          g_free (data_buffer);
  19.543 -    }
  19.544 -    else
  19.545 -    {
  19.546 +    } else {
  19.547          retval = GMYTH_FILE_READ_ERROR;
  19.548      }
  19.549  
  19.550 -    if (strlist != NULL)
  19.551 -    {
  19.552 +    if (strlist != NULL) {
  19.553          g_object_unref (strlist);
  19.554          strlist = NULL;
  19.555      }
  19.556  
  19.557 -    if (ret_strlist != NULL)
  19.558 -    {
  19.559 +    if (ret_strlist != NULL) {
  19.560          g_object_unref (ret_strlist);
  19.561          ret_strlist = NULL;
  19.562      }
  19.563  
  19.564 -    if (read_unlimited && (bytes_sent == 0))
  19.565 -    {
  19.566 +    if (read_unlimited && (bytes_sent == 0)) {
  19.567          gmyth_debug ("Trying to move to the next program chain...");
  19.568 -        if (priv->recorder != NULL && priv->do_next_program_chain)
  19.569 -        {
  19.570 -	    priv->do_next_program_chain = FALSE;
  19.571 +        if (priv->recorder != NULL && priv->do_next_program_chain) {
  19.572 +            priv->do_next_program_chain = FALSE;
  19.573              retval = GMYTH_FILE_READ_NEXT_PROG_CHAIN;
  19.574              GMythProgramInfo *prog_info =
  19.575                  gmyth_recorder_get_current_program_info (priv->recorder);
  19.576 @@ -829,19 +794,17 @@
  19.577              if (prog_info != NULL && prog_info->pathname != NULL
  19.578                  && strlen (prog_info->pathname->str) > 0
  19.579                  && g_ascii_strcasecmp (prog_info->pathname->str,
  19.580 -                                       gmyth_file_get_file_name (GMYTH_FILE
  19.581 -                                                                 (transfer))) !=
  19.582 -                0)
  19.583 -		
  19.584 -		/* releasing context got at this function starting... */
  19.585 -		_control_release_context (transfer);
  19.586 -                ret =
  19.587 -                    gmyth_file_transfer_open (transfer,
  19.588 -                                              g_strrstr (prog_info->pathname->
  19.589 -                                                         str, "/"));
  19.590 -		_control_acquire_context (transfer, TRUE);
  19.591 -		/* acquiring context released at this function stopping... */
  19.592 - 
  19.593 +                    gmyth_file_get_file_name (GMYTH_FILE (transfer)))
  19.594 +                != 0)
  19.595 +
  19.596 +                /* releasing context got at this function starting... */
  19.597 +                _control_release_context (transfer);
  19.598 +            ret =
  19.599 +                gmyth_file_transfer_open (transfer,
  19.600 +                g_strrstr (prog_info->pathname->str, "/"));
  19.601 +            _control_acquire_context (transfer, TRUE);
  19.602 +            /* acquiring context released at this function stopping... */
  19.603 +
  19.604              if (prog_info != NULL)
  19.605                  g_object_unref (prog_info);
  19.606  
  19.607 @@ -849,34 +812,32 @@
  19.608                  gmyth_debug ("Cannot change to the next program info!");
  19.609              else
  19.610                  gmyth_debug ("OK!!! MOVED to the next program info [%s]!",
  19.611 -                             gmyth_file_get_file_name (GMYTH_FILE (transfer)));
  19.612 +                    gmyth_file_get_file_name (GMYTH_FILE (transfer)));
  19.613          }
  19.614  
  19.615 -    } /* if */
  19.616 -
  19.617 +    }
  19.618 +    /* if */
  19.619    error:
  19.620  
  19.621      _control_release_context (transfer);
  19.622      g_string_free (query, TRUE);
  19.623  
  19.624 -    if (error != NULL)
  19.625 -    {
  19.626 +    if (error != NULL) {
  19.627          gmyth_debug ("Cleaning-up ERROR: %s [msg = %s, code = %d]\n",
  19.628 -                     __FUNCTION__, error->message, error->code);
  19.629 +            __FUNCTION__, error->message, error->code);
  19.630          g_error_free (error);
  19.631      }
  19.632  
  19.633      if (total_read > 0)
  19.634          gmyth_file_set_offset (GMYTH_FILE (transfer),
  19.635 -                               gmyth_file_get_offset (GMYTH_FILE (transfer)) +
  19.636 -                               total_read);
  19.637 +            gmyth_file_get_offset (GMYTH_FILE (transfer)) + total_read);
  19.638  
  19.639      return retval;
  19.640  }
  19.641  
  19.642  static void
  19.643  _file_transfer_program_info_changed (GMythFileTransfer * transfer,
  19.644 -                                     gint msg_code, gpointer livetv_recorder)
  19.645 +    gint msg_code, gpointer livetv_recorder)
  19.646  {
  19.647      GMythRecorder *recorder;
  19.648      GMythFileTransferPrivate *priv;
  19.649 @@ -888,10 +849,9 @@
  19.650      recorder = GMYTH_RECORDER (livetv_recorder);
  19.651      gmyth_debug
  19.652          ("Program info changed! ( file transfer orig. = %p, ptr. = [%s] )",
  19.653 -         transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]");
  19.654 +        transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]");
  19.655  
  19.656 -    if (NULL != recorder)
  19.657 -    {
  19.658 +    if (NULL != recorder) {
  19.659          gmyth_debug
  19.660              ("YES, the requested program info movement on the LiveTV transfer is authentical!");
  19.661      }
  19.662 @@ -932,18 +892,18 @@
  19.663      gmyth_string_list_append_int (strlist, fast);
  19.664  
  19.665      gint strlist_len = gmyth_socket_sendreceive_stringlist (priv->control_sock,
  19.666 -                                                            strlist);
  19.667 +        strlist);
  19.668  
  19.669      if (strlist_len > 0)
  19.670          gmyth_debug ("Yes, timeout was changed: %s.",
  19.671 -                     gmyth_string_list_get_char_array (strlist, 0));
  19.672 +            gmyth_string_list_get_char_array (strlist, 0));
  19.673      else
  19.674          gmyth_debug ("Timeout cannot be changed!");
  19.675  
  19.676      _control_release_context (transfer);
  19.677  
  19.678      gmyth_debug ("%s setting timeout flag of this file transfer = %s\n",
  19.679 -                 strlist_len > 0 ? "Yes," : "NOT", fast ? "FAST" : "NOT FAST");
  19.680 +        strlist_len > 0 ? "Yes," : "NOT", fast ? "FAST" : "NOT FAST");
  19.681  
  19.682      g_object_unref (strlist);
  19.683  
    20.1 --- a/gmyth/src/gmyth_file_transfer.h	Tue May 22 19:21:42 2007 +0100
    20.2 +++ b/gmyth/src/gmyth_file_transfer.h	Wed May 23 16:11:29 2007 +0100
    20.3 @@ -9,22 +9,22 @@
    20.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    20.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    20.6   *
    20.7 -          *//*
    20.8 -       * 
    20.9 -       * This program is free software; you can redistribute it and/or modify
   20.10 -       * it under the terms of the GNU Lesser General Public License as published by
   20.11 -       * the Free Software Foundation; either version 2 of the License, or
   20.12 -       * (at your option) any later version.
   20.13 -       *
   20.14 -       * This program is distributed in the hope that it will be useful,
   20.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20.17 -       * GNU General Public License for more details.
   20.18 -       *
   20.19 -       * You should have received a copy of the GNU Lesser General Public License
   20.20 -       * along with this program; if not, write to the Free Software
   20.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   20.22 -       */
   20.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   20.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   20.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   20.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   20.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   20.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   20.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   20.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   20.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   20.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   20.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   20.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   20.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   20.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   20.39  
   20.40  #ifndef __GMYTH_FILE_TRANSFER_H__
   20.41  #define __GMYTH_FILE_TRANSFER_H__
   20.42 @@ -56,47 +56,43 @@
   20.43  typedef struct _GMythFileTransferPrivate GMythFileTransferPrivate;
   20.44  
   20.45  struct _GMythFileTransfer
   20.46 -    {
   20.47 -        GMythFile parent;
   20.48 -        GMythFileTransferPrivate *priv;
   20.49 -    };
   20.50 +{
   20.51 +    GMythFile parent;
   20.52 +    GMythFileTransferPrivate *priv;
   20.53 +};
   20.54  
   20.55  struct _GMythFileTransferClass
   20.56 -    {
   20.57 -        GMythFileClass parent_class;
   20.58 +{
   20.59 +    GMythFileClass parent_class;
   20.60  
   20.61 -        /* callbacks */
   20.62 -        guint program_info_changed_handler_signal_id;
   20.63 +    /* callbacks */
   20.64 +    guint program_info_changed_handler_signal_id;
   20.65  
   20.66 -        /* signal default handlers */
   20.67 -        void (*program_info_changed_handler) (GMythFileTransfer * transfer,
   20.68 -                                              gint msg_code,
   20.69 -                                              gpointer livetv_recorder);
   20.70 -    };
   20.71 +    /* signal default handlers */
   20.72 +    void (*program_info_changed_handler) (GMythFileTransfer * transfer,
   20.73 +        gint msg_code, gpointer livetv_recorder);
   20.74 +};
   20.75  
   20.76  
   20.77  GType gmyth_file_transfer_get_type (void);
   20.78  GMythFileTransfer *gmyth_file_transfer_new (GMythBackendInfo * backend_info);
   20.79  gchar *gmyth_file_transfer_get_file_name (GMythFileTransfer * transfer);
   20.80  gboolean gmyth_file_transfer_open (GMythFileTransfer * transfer,
   20.81 -                                   const gchar * filename);
   20.82 +    const gchar * filename);
   20.83  void gmyth_file_transfer_close (GMythFileTransfer * transfer);
   20.84  gboolean gmyth_file_transfer_is_open (GMythFileTransfer * transfer);
   20.85 +
   20.86  GMythFileReadResult
   20.87  gmyth_file_transfer_read (GMythFileTransfer * transfer,
   20.88 -                          GByteArray * data,
   20.89 -                          gint size, gboolean read_unlimited);
   20.90 -gint64 gmyth_file_transfer_seek (GMythFileTransfer * transfer,
   20.91 -                                 guint64 pos, gint whence);
   20.92 +    GByteArray * data, gint size, gboolean read_unlimited);
   20.93 +gint64 gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos,
   20.94 +    gint whence);
   20.95  gboolean gmyth_file_transfer_settimeout (GMythFileTransfer * transfer,
   20.96 -                                         gboolean fast);
   20.97 +    gboolean fast);
   20.98  guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer * transfer);
   20.99  
  20.100  void gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer *
  20.101 -                                                           transfer,
  20.102 -                                                           gint msg_code,
  20.103 -                                                           gpointer
  20.104 -                                                           live_tv_recorder);
  20.105 +    transfer, gint msg_code, gpointer live_tv_recorder);
  20.106  
  20.107  G_END_DECLS
  20.108  #endif /* __GMYTH_FILE_TRANSFER_H__ */
    21.1 --- a/gmyth/src/gmyth_http.c	Tue May 22 19:21:42 2007 +0100
    21.2 +++ b/gmyth/src/gmyth_http.c	Wed May 23 16:11:29 2007 +0100
    21.3 @@ -24,7 +24,7 @@
    21.4   * along with this program; if not, write to the Free Software
    21.5   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    21.6   */
    21.7 - 
    21.8 +
    21.9  #ifdef HAVE_CONFIG_H
   21.10  #include "config.h"
   21.11  #endif
   21.12 @@ -40,44 +40,45 @@
   21.13  #include "gmyth_socket.h"
   21.14  
   21.15  xmlXPathObjectPtr
   21.16 -getnodeset(xmlDocPtr doc, xmlChar *xpath)
   21.17 +getnodeset (xmlDocPtr doc, xmlChar * xpath)
   21.18  {
   21.19  
   21.20      xmlXPathContextPtr context;
   21.21      xmlXPathObjectPtr result;
   21.22  
   21.23 -    context = xmlXPathNewContext(doc);
   21.24 -    result = xmlXPathEvalExpression(xpath, context);
   21.25 +    context = xmlXPathNewContext (doc);
   21.26 +    result = xmlXPathEvalExpression (xpath, context);
   21.27  
   21.28 -    if(xmlXPathNodeSetIsEmpty(result->nodesetval))
   21.29 -    {
   21.30 -        g_fprintf(stderr, "Error: No result at XPath\n");
   21.31 +    if (xmlXPathNodeSetIsEmpty (result->nodesetval)) {
   21.32 +        g_fprintf (stderr, "Error: No result at XPath\n");
   21.33          return NULL;
   21.34      }
   21.35  
   21.36 -    xmlXPathFreeContext(context);
   21.37 +    xmlXPathFreeContext (context);
   21.38      return result;
   21.39  }
   21.40  
   21.41  
   21.42 -xmlDocPtr XMLParse (const char *content, int length)
   21.43 +xmlDocPtr
   21.44 +XMLParse (const char *content, int length)
   21.45  {
   21.46 -    xmlDocPtr doc; /* the resulting document tree */
   21.47 +    xmlDocPtr doc;              /* the resulting document tree */
   21.48  
   21.49 -    doc = xmlReadMemory(content, length, NULL, NULL, 0);
   21.50 -    if (doc == NULL)
   21.51 -    {
   21.52 -        g_fprintf(stderr, "Error: Failed to parse XML document\n");
   21.53 +    doc = xmlReadMemory (content, length, NULL, NULL, 0);
   21.54 +    if (doc == NULL) {
   21.55 +        g_fprintf (stderr, "Error: Failed to parse XML document\n");
   21.56          return NULL;
   21.57      }
   21.58  
   21.59      return doc;
   21.60  }
   21.61  
   21.62 -xmlXPathObjectPtr getXPath (xmlChar *xpath, xmlDocPtr doc)
   21.63 +xmlXPathObjectPtr
   21.64 +getXPath (xmlChar * xpath, xmlDocPtr doc)
   21.65  {
   21.66      xmlXPathObjectPtr result;
   21.67 -    result = getnodeset(doc, xpath);
   21.68 +
   21.69 +    result = getnodeset (doc, xpath);
   21.70      return result;
   21.71  }
   21.72  
   21.73 @@ -87,45 +88,47 @@
   21.74   * @param nodeTab A pointer to a node inside the XML
   21.75   * @return A GSList containing a list of all the programs
   21.76   */
   21.77 -GSList* get_Program_List(xmlNodePtr node)
   21.78 +GSList *
   21.79 +get_Program_List (xmlNodePtr node)
   21.80  {
   21.81 -  GSList* program_list = NULL;
   21.82 +    GSList *program_list = NULL;
   21.83  
   21.84 -  while (node != NULL)
   21.85 -    {
   21.86 -      if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
   21.87 -      {
   21.88 -        GMythProgram* program = (GMythProgram*)\
   21.89 -            g_malloc(sizeof(struct _GMythProgram));
   21.90 +    while (node != NULL) {
   21.91 +        if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
   21.92 +            GMythProgram *program = (GMythProgram *)
   21.93 +                g_malloc (sizeof (struct _GMythProgram));
   21.94  
   21.95 -        program->title = g_strdup((char *)\
   21.96 -                        xmlGetProp(node, (xmlChar *)"title"));
   21.97 +            program->title = g_strdup ((char *)
   21.98 +                xmlGetProp (node, (xmlChar *) "title"));
   21.99  
  21.100 -        program->subtitle = g_strdup((char *)\
  21.101 -                        xmlGetProp(node, (xmlChar *)"subtitle"));
  21.102 +            program->subtitle = g_strdup ((char *)
  21.103 +                xmlGetProp (node, (xmlChar *)
  21.104 +                    "subtitle"));
  21.105  
  21.106 -        program->catType = g_strdup((char *)\
  21.107 -                        xmlGetProp(node, (xmlChar *)"catType"));
  21.108 +            program->catType = g_strdup ((char *)
  21.109 +                xmlGetProp (node, (xmlChar *)
  21.110 +                    "catType"));
  21.111  
  21.112 -        program->category = g_strdup((char *)\
  21.113 -                        xmlGetProp(node, (xmlChar *)"category"));
  21.114 +            program->category = g_strdup ((char *)
  21.115 +                xmlGetProp (node, (xmlChar *)
  21.116 +                    "category"));
  21.117  
  21.118 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\
  21.119 -            "%d", &(program->repeat));
  21.120 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"),
  21.121 +                "%d", &(program->repeat));
  21.122  
  21.123 -        program->startTime = gmyth_util_string_to_time_val \
  21.124 -                    ((char *)xmlGetProp(node,(xmlChar *)"startTime"));
  21.125 +            program->startTime = gmyth_util_string_to_time_val
  21.126 +                ((char *) xmlGetProp (node, (xmlChar *) "startTime"));
  21.127  
  21.128 -        program->endTime = gmyth_util_string_to_time_val \
  21.129 -                    ((char *)xmlGetProp(node,(xmlChar *)"endTime"));
  21.130 +            program->endTime = gmyth_util_string_to_time_val
  21.131 +                ((char *) xmlGetProp (node, (xmlChar *) "endTime"));
  21.132  
  21.133 -        program_list = g_slist_append(program_list, program);
  21.134 -      }
  21.135 +            program_list = g_slist_append (program_list, program);
  21.136 +        }
  21.137  
  21.138 -      node = node->next;
  21.139 +        node = node->next;
  21.140      }
  21.141  
  21.142 -  return program_list;
  21.143 +    return program_list;
  21.144  }
  21.145  
  21.146  /** Retrieves the Channel List from the ProgramGuide
  21.147 @@ -134,38 +137,39 @@
  21.148   * @param epg The struct where is the current epg
  21.149   * @return The epg from "param" updated
  21.150   */
  21.151 -void get_Channel_List (xmlNodePtr node, GMythEpg* epg)
  21.152 +void
  21.153 +get_Channel_List (xmlNodePtr node, GMythEpg * epg)
  21.154  {
  21.155 -  epg->channelList = NULL;
  21.156 +    epg->channelList = NULL;
  21.157  
  21.158 -  while (node != NULL) {
  21.159 +    while (node != NULL) {
  21.160  
  21.161 -    if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
  21.162 -    {
  21.163 -      GMythChannel* channel = (GMythChannel*)g_malloc\
  21.164 -                                (sizeof(struct _GMythChannel));
  21.165 +        if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
  21.166 +            GMythChannel *channel = (GMythChannel *) g_malloc
  21.167 +                (sizeof (struct _GMythChannel));
  21.168  
  21.169 -      channel->channelName = g_strdup((char *)\
  21.170 -                      xmlGetProp(node,\
  21.171 -                         (xmlChar *)"channelName"));
  21.172 +            channel->channelName = g_strdup ((char *)
  21.173 +                xmlGetProp (node, (xmlChar *)
  21.174 +                    "channelName"));
  21.175  
  21.176 -      channel->chanNum = g_strdup((char *)\
  21.177 -                      xmlGetProp(node, (xmlChar *)"chanNum"));
  21.178 +            channel->chanNum = g_strdup ((char *)
  21.179 +                xmlGetProp (node, (xmlChar *)
  21.180 +                    "chanNum"));
  21.181  
  21.182 -      sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\
  21.183 -          "%d", &(channel->chanId));
  21.184 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"),
  21.185 +                "%d", &(channel->chanId));
  21.186  
  21.187 -      sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\
  21.188 -          "%d", &(channel->callSign));
  21.189 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"),
  21.190 +                "%d", &(channel->callSign));
  21.191  
  21.192 -      channel->programList = get_Program_List(node->children);
  21.193 +            channel->programList = get_Program_List (node->children);
  21.194  
  21.195 -      epg->channelList = g_slist_append(epg->channelList, channel);
  21.196 +            epg->channelList = g_slist_append (epg->channelList, channel);
  21.197  
  21.198 +        }
  21.199 +
  21.200 +        node = node->next;
  21.201      }
  21.202 -
  21.203 -    node=node->next;
  21.204 -  }
  21.205  }
  21.206  
  21.207  /** Retrieves the properties from the ProgramGuide
  21.208 @@ -174,43 +178,45 @@
  21.209   * @param epg The struct where is the current epg
  21.210   * @return The epg from "param" updated
  21.211   */
  21.212 -void get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg* epg)
  21.213 +void
  21.214 +get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg * epg)
  21.215  {
  21.216  
  21.217      xmlNode *ptr = nodeTab->children->next->children;
  21.218 -    epg->startTime = gmyth_util_string_to_time_val ((char *)ptr->content);
  21.219 +
  21.220 +    epg->startTime = gmyth_util_string_to_time_val ((char *) ptr->content);
  21.221  
  21.222      ptr = ptr->parent->next->next->children;
  21.223 -    epg->endTime = gmyth_util_string_to_time_val ((char *)ptr->content);
  21.224 +    epg->endTime = gmyth_util_string_to_time_val ((char *) ptr->content);
  21.225  
  21.226      ptr = ptr->parent->next->next->children;
  21.227 -    sscanf ((char *)ptr->content, "%d", &(epg->startChanId));
  21.228 +    sscanf ((char *) ptr->content, "%d", &(epg->startChanId));
  21.229  
  21.230      ptr = ptr->parent->next->next->children;
  21.231 -    sscanf ((char *)ptr->content, "%d", &(epg->endChanId));
  21.232 +    sscanf ((char *) ptr->content, "%d", &(epg->endChanId));
  21.233  
  21.234      ptr = ptr->parent->next->next->children;
  21.235 -    sscanf ((char *)ptr->content, "%d", &(epg->numOfChannels));
  21.236 +    sscanf ((char *) ptr->content, "%d", &(epg->numOfChannels));
  21.237  
  21.238      ptr = ptr->parent->next->next->children;
  21.239 -    sscanf ((char *)ptr->content, "%d", &(epg->details));
  21.240 +    sscanf ((char *) ptr->content, "%d", &(epg->details));
  21.241  
  21.242      ptr = ptr->parent->next->next->children;
  21.243 -    sscanf ((char *)ptr->content, "%d", &(epg->totalCount));
  21.244 +    sscanf ((char *) ptr->content, "%d", &(epg->totalCount));
  21.245  
  21.246      ptr = ptr->parent->next->next->children;
  21.247 -    epg->asOf = gmyth_util_string_to_time_val ((char *)ptr->content);
  21.248 +    epg->asOf = gmyth_util_string_to_time_val ((char *) ptr->content);
  21.249  
  21.250      ptr = ptr->parent->next->next->children;
  21.251 -    epg->version = g_strdup((char *)ptr->content);
  21.252 +    epg->version = g_strdup ((char *) ptr->content);
  21.253  
  21.254      ptr = ptr->parent->next->next->children;
  21.255 -    sscanf ((char *)ptr->content, "%d", &(epg->protoVer));
  21.256 +    sscanf ((char *) ptr->content, "%d", &(epg->protoVer));
  21.257  
  21.258      ptr = ptr->parent->next->next->children;
  21.259      // go to Channel section and retrieve Channels and Programs
  21.260 -    if ( epg->numOfChannels > 0 )
  21.261 -        get_Channel_List(ptr, epg);
  21.262 +    if (epg->numOfChannels > 0)
  21.263 +        get_Channel_List (ptr, epg);
  21.264      else
  21.265          epg->channelList = NULL;
  21.266  }
  21.267 @@ -220,24 +226,24 @@
  21.268   * @param doc An XML document (xmlDocPtr)
  21.269   * @return The epg
  21.270   */
  21.271 -void getEpg (xmlDocPtr doc, GMythEpg* epg)
  21.272 +void
  21.273 +getEpg (xmlDocPtr doc, GMythEpg * epg)
  21.274  {
  21.275      xmlXPathObjectPtr result;
  21.276      xmlNodeSetPtr nodeset;
  21.277      xmlChar *keyword;
  21.278  
  21.279      int i;
  21.280 -    result = getXPath((xmlChar *)"/*", doc);
  21.281  
  21.282 -    if (result)
  21.283 -    {
  21.284 +    result = getXPath ((xmlChar *) "/*", doc);
  21.285 +
  21.286 +    if (result) {
  21.287          nodeset = result->nodesetval;
  21.288 -        for (i=0; i < nodeset->nodeNr; i++)
  21.289 -        {
  21.290 -            keyword = (xmlChar*)nodeset->nodeTab[i]->name;
  21.291 -            if (g_ascii_strcasecmp((char *)keyword, "GetProgramGuideResponse") == 0)
  21.292 -            {
  21.293 -                get_ProgramGuide_Properties(nodeset->nodeTab[i], epg);
  21.294 +        for (i = 0; i < nodeset->nodeNr; i++) {
  21.295 +            keyword = (xmlChar *) nodeset->nodeTab[i]->name;
  21.296 +            if (g_ascii_strcasecmp
  21.297 +                ((char *) keyword, "GetProgramGuideResponse") == 0) {
  21.298 +                get_ProgramGuide_Properties (nodeset->nodeTab[i], epg);
  21.299                  break;
  21.300              }
  21.301          }
  21.302 @@ -253,120 +259,130 @@
  21.303   * @param doc An XML document (xmlDocPtr)
  21.304   * @return The epg
  21.305   */
  21.306 -GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo *backend_info, \
  21.307 -                  GTimeVal* StartTime, GTimeVal* EndTime, \
  21.308 -                  gint StartChanId, gint NumOfChannels, \
  21.309 -                  gchar* Details)
  21.310 +GMythEpg
  21.311 +gmyth_http_retrieve_epg (GMythBackendInfo * backend_info,
  21.312 +    GTimeVal * StartTime, GTimeVal * EndTime,
  21.313 +    gint StartChanId, gint NumOfChannels, gchar * Details)
  21.314  {
  21.315      GMythEpg epg;
  21.316      MemoryStruct chunk;
  21.317  
  21.318 -    chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
  21.319 -    chunk.size = 0;    /* no data at this point */
  21.320 +    chunk.memory = NULL;        /* we expect realloc(NULL, size) to work */
  21.321 +    chunk.size = 0;             /* no data at this point */
  21.322  
  21.323 -    gchar* starttime;
  21.324 -    starttime = (gchar*)xmlURIEscapeStr( (const xmlChar*)gmyth_util_time_to_mythformat_from_time_val(StartTime), NULL );
  21.325 +    gchar *starttime;
  21.326  
  21.327 -    gchar* endtime;
  21.328 -    endtime = (gchar*)xmlURIEscapeStr( (const xmlChar*)gmyth_util_time_to_mythformat_from_time_val(EndTime), NULL );
  21.329 +    starttime = (gchar *) xmlURIEscapeStr ((const xmlChar *)
  21.330 +        gmyth_util_time_to_mythformat_from_time_val (StartTime), NULL);
  21.331  
  21.332 -    GString* command = g_string_new("");
  21.333 -    g_string_printf(command, "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d" \
  21.334 -            "&NumOfChannels=%d&Details=%s", starttime, endtime, \
  21.335 -            StartChanId, NumOfChannels, Details );
  21.336 -    gmyth_debug ( "HTTP Request command = %s\n", command->str );
  21.337 +    gchar *endtime;
  21.338  
  21.339 -    chunk = gmyth_http_request(backend_info, command);
  21.340 -    if (chunk.memory != NULL)
  21.341 -    {
  21.342 -        xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
  21.343 -        getEpg(doc, &epg);
  21.344 -        free(chunk.memory);
  21.345 +    endtime = (gchar *) xmlURIEscapeStr ((const xmlChar *)
  21.346 +        gmyth_util_time_to_mythformat_from_time_val (EndTime), NULL);
  21.347 +
  21.348 +    GString *command = g_string_new ("");
  21.349 +
  21.350 +    g_string_printf (command,
  21.351 +        "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d"
  21.352 +        "&NumOfChannels=%d&Details=%s", starttime, endtime,
  21.353 +        StartChanId, NumOfChannels, Details);
  21.354 +    gmyth_debug ("HTTP Request command = %s\n", command->str);
  21.355 +
  21.356 +    chunk = gmyth_http_request (backend_info, command);
  21.357 +    if (chunk.memory != NULL) {
  21.358 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
  21.359 +
  21.360 +        getEpg (doc, &epg);
  21.361 +        free (chunk.memory);
  21.362      }
  21.363  
  21.364      return epg;
  21.365  }
  21.366  
  21.367  
  21.368 -GMythRecorded_Recording 
  21.369 +GMythRecorded_Recording
  21.370  retrieve_recorded_recording (xmlNodePtr node)
  21.371  {
  21.372      GMythRecorded_Recording recording;
  21.373  
  21.374 -    if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
  21.375 -    {
  21.376 +    if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
  21.377  
  21.378 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupInType"),\
  21.379 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupInType"),
  21.380              "%d", &(recording.dupInType));
  21.381  
  21.382 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"dupMethod"),\
  21.383 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupMethod"),
  21.384              "%d", &(recording.dupMethod));
  21.385  
  21.386 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"recStatus"),\
  21.387 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "recStatus"),
  21.388              "%d", &(recording.recStatus));
  21.389  
  21.390 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"encoderId"),\
  21.391 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "encoderId"),
  21.392              "%d", &(recording.encoderId));
  21.393  
  21.394 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"recordId"),\
  21.395 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "recordId"),
  21.396              "%d", &(recording.recordId));
  21.397  
  21.398 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"recType"),\
  21.399 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "recType"),
  21.400              "%d", &(recording.recType));
  21.401  
  21.402 -        recording.playGroup = g_strdup((char *)\
  21.403 -                        xmlGetProp(node, (xmlChar *)"playGroup"));
  21.404 +        recording.playGroup = g_strdup ((char *)
  21.405 +            xmlGetProp (node, (xmlChar *)
  21.406 +                "playGroup"));
  21.407  
  21.408 -        recording.recGroup = g_strdup((char *)\
  21.409 -                        xmlGetProp(node, (xmlChar *)"recGroup"));
  21.410 +        recording.recGroup = g_strdup ((char *)
  21.411 +            xmlGetProp (node, (xmlChar *)
  21.412 +                "recGroup"));
  21.413  
  21.414 -        recording.recProfile = g_strdup((char *)\
  21.415 -                        xmlGetProp(node, (xmlChar *)"recProfile"));
  21.416 +        recording.recProfile = g_strdup ((char *)
  21.417 +            xmlGetProp (node, (xmlChar *)
  21.418 +                "recProfile"));
  21.419  
  21.420 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"recPriority"),\
  21.421 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "recPriority"),
  21.422              "%d", &(recording.recPriority));
  21.423  
  21.424 -        recording.recStartTs = gmyth_util_string_to_time_val\
  21.425 -        ((char *)xmlGetProp(node, (xmlChar *)"recStartTs"));
  21.426 +        recording.recStartTs = gmyth_util_string_to_time_val
  21.427 +            ((char *) xmlGetProp (node, (xmlChar *) "recStartTs"));
  21.428  
  21.429 -        recording.recEndTs = gmyth_util_string_to_time_val\
  21.430 -        ((char *)xmlGetProp(node, (xmlChar *)"recEndTs"));
  21.431 +        recording.recEndTs = gmyth_util_string_to_time_val
  21.432 +            ((char *) xmlGetProp (node, (xmlChar *) "recEndTs"));
  21.433      }
  21.434  
  21.435      return recording;
  21.436  }
  21.437  
  21.438  
  21.439 -GMythRecorded_Channel retrieve_recorded_channel (xmlNodePtr node)
  21.440 +GMythRecorded_Channel
  21.441 +retrieve_recorded_channel (xmlNodePtr node)
  21.442  {
  21.443      GMythRecorded_Channel channel;
  21.444  
  21.445 -    if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
  21.446 -    {
  21.447 +    if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
  21.448  
  21.449 -        channel.chanFilters = g_strdup((char *)\
  21.450 -                        xmlGetProp(node, (xmlChar *)"chanFilters"));
  21.451 +        channel.chanFilters = g_strdup ((char *)
  21.452 +            xmlGetProp (node, (xmlChar *)
  21.453 +                "chanFilters"));
  21.454  
  21.455 -        channel.channelName = g_strdup((char *)\
  21.456 -                    xmlGetProp(node, (xmlChar *)"channelName"));
  21.457 +        channel.channelName = g_strdup ((char *)
  21.458 +            xmlGetProp (node, (xmlChar *)
  21.459 +                "channelName"));
  21.460  
  21.461 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanNum"),\
  21.462 -                "%d", &(channel.chanNum));
  21.463 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanNum"),
  21.464 +            "%d", &(channel.chanNum));
  21.465  
  21.466 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"sourceId"),\
  21.467 -                "%d", &(channel.sourceId));
  21.468 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "sourceId"),
  21.469 +            "%d", &(channel.sourceId));
  21.470  
  21.471 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"commFree"),\
  21.472 -                "%d", &(channel.commFree));
  21.473 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "commFree"),
  21.474 +            "%d", &(channel.commFree));
  21.475  
  21.476 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"inputId"),\
  21.477 -                "%d", &(channel.inputId));
  21.478 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "inputId"),
  21.479 +            "%d", &(channel.inputId));
  21.480  
  21.481 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"chanId"),\
  21.482 -                "%d", &(channel.chanId));
  21.483 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"),
  21.484 +            "%d", &(channel.chanId));
  21.485  
  21.486 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"callSign"),\
  21.487 -                "%d", &(channel.callSign));
  21.488 +        sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"),
  21.489 +            "%d", &(channel.callSign));
  21.490      }
  21.491  
  21.492      return channel;
  21.493 @@ -380,72 +396,78 @@
  21.494   * @param recorded The struct where is the current epg
  21.495   * @return list with all the recorded programs
  21.496   */
  21.497 -GSList* get_Recorded_Programs(xmlNodePtr node)
  21.498 +GSList *
  21.499 +get_Recorded_Programs (xmlNodePtr node)
  21.500  {
  21.501 -    GSList* programList = NULL;
  21.502 +    GSList *programList = NULL;
  21.503  
  21.504      while (node != NULL) {
  21.505  
  21.506 -        if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
  21.507 -        {
  21.508 +        if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
  21.509  
  21.510 -        GMythRecorded_Program* program = (GMythRecorded_Program*)g_malloc\
  21.511 -                                            (sizeof(struct _GMythRecorded_Program));
  21.512 +            GMythRecorded_Program *program = (GMythRecorded_Program *)
  21.513 +                g_malloc (sizeof (struct _GMythRecorded_Program));
  21.514  
  21.515 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"programFlags"),\
  21.516 -            "%d", &(program->programFlags));
  21.517 +            sscanf ((char *)
  21.518 +                xmlGetProp (node, (xmlChar *) "programFlags"), "%d",
  21.519 +                &(program->programFlags));
  21.520  
  21.521 -        program->title = g_strdup((char *)\
  21.522 -                        xmlGetProp(node, (xmlChar *)"title"));
  21.523 +            program->title = g_strdup ((char *)
  21.524 +                xmlGetProp (node, (xmlChar *) "title"));
  21.525  
  21.526 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"programId"),\
  21.527 -                        "%d", &(program->programId));
  21.528 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "programId"),
  21.529 +                "%d", &(program->programId));
  21.530  
  21.531 -        program->catType = g_strdup((char *)\
  21.532 -                        xmlGetProp(node, (xmlChar *)"catType"));
  21.533 +            program->catType = g_strdup ((char *)
  21.534 +                xmlGetProp (node, (xmlChar *)
  21.535 +                    "catType"));
  21.536  
  21.537 -        program->category = g_strdup((char *)\
  21.538 -                        xmlGetProp(node, (xmlChar *)"category"));
  21.539 +            program->category = g_strdup ((char *)
  21.540 +                xmlGetProp (node, (xmlChar *)
  21.541 +                    "category"));
  21.542  
  21.543 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"seriesId"),\
  21.544 -            "%d", &(program->seriesId));
  21.545 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "seriesId"),
  21.546 +                "%d", &(program->seriesId));
  21.547  
  21.548  
  21.549 -        program->startTime = gmyth_util_string_to_time_val\
  21.550 -        ((char *)xmlGetProp(node, (xmlChar *)"startTime"));
  21.551 +            program->startTime = gmyth_util_string_to_time_val
  21.552 +                ((char *) xmlGetProp (node, (xmlChar *) "startTime"));
  21.553  
  21.554 -        program->endTime = gmyth_util_string_to_time_val\
  21.555 -        ((char *)xmlGetProp(node, (xmlChar *)"endTime"));
  21.556 +            program->endTime = gmyth_util_string_to_time_val
  21.557 +                ((char *) xmlGetProp (node, (xmlChar *) "endTime"));
  21.558  
  21.559 -        program->lastModified = gmyth_util_string_to_time_val\
  21.560 -        ((char *)xmlGetProp(node, (xmlChar *)"lastModified"));
  21.561 +            program->lastModified = gmyth_util_string_to_time_val ((char *)
  21.562 +                xmlGetProp (node, (xmlChar *) "lastModified"));
  21.563  
  21.564 -        /* TODO: FIX ME at gmyth_util
  21.565 -        program->asOf = gmyth_util_string_to_time_val\
  21.566 -        ((char *)xmlGetProp(node, (xmlChar *)"airdate"));*/
  21.567 +            /* TODO: FIX ME at gmyth_util
  21.568 +               program->asOf = gmyth_util_string_to_time_val\
  21.569 +               ((char *)xmlGetProp(node, (xmlChar *)"airdate")); */
  21.570  
  21.571 -        program->subTitle = g_strdup((char *)\
  21.572 -                        xmlGetProp(node, (xmlChar *)"subTitle"));
  21.573 +            program->subTitle = g_strdup ((char *)
  21.574 +                xmlGetProp (node, (xmlChar *)
  21.575 +                    "subTitle"));
  21.576  
  21.577 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"stars"),\
  21.578 -            "%d", &(program->stars));
  21.579 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "stars"),
  21.580 +                "%d", &(program->stars));
  21.581  
  21.582 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"repeat"),\
  21.583 -            "%d", &(program->repeat));
  21.584 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"),
  21.585 +                "%d", &(program->repeat));
  21.586  
  21.587 -        sscanf ((char *)xmlGetProp(node, (xmlChar *)"fileSize"),\
  21.588 -            "%d", &(program->repeat));
  21.589 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "fileSize"),
  21.590 +                "%d", &(program->repeat));
  21.591  
  21.592 -        program->hostname = g_strdup((char *)\
  21.593 -                        xmlGetProp(node, (xmlChar *)"hostname"));
  21.594 +            program->hostname = g_strdup ((char *)
  21.595 +                xmlGetProp (node, (xmlChar *)
  21.596 +                    "hostname"));
  21.597  
  21.598 -        program->channel = retrieve_recorded_channel(node->children);
  21.599 +            program->channel = retrieve_recorded_channel (node->children);
  21.600  
  21.601 -        // Skip the \n
  21.602 -        program->recording = retrieve_recorded_recording(node->children->next->next);
  21.603 +            // Skip the \n
  21.604 +            program->recording =
  21.605 +                retrieve_recorded_recording (node->children->next->next);
  21.606  
  21.607 -        // add to the list
  21.608 -        programList = g_slist_append(programList, program);
  21.609 +            // add to the list
  21.610 +            programList = g_slist_append (programList, program);
  21.611          }
  21.612  
  21.613          node = node->next;
  21.614 @@ -460,25 +482,26 @@
  21.615   * @param recorded The struct where is the current epg
  21.616   * @return "recorded" from "param" updated
  21.617   */
  21.618 -void get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded* recorded)
  21.619 +void
  21.620 +get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded * recorded)
  21.621  {
  21.622      xmlNode *ptr = nodeTab->children->next->children;
  21.623 -    sscanf ((char *)ptr->content, "%d", &(recorded->totalCount));
  21.624 +
  21.625 +    sscanf ((char *) ptr->content, "%d", &(recorded->totalCount));
  21.626  
  21.627  
  21.628      ptr = ptr->parent->next->next->children;
  21.629 -    recorded->asOf = gmyth_util_string_to_time_val \
  21.630 -        ((char *)ptr->content);
  21.631 +    recorded->asOf = gmyth_util_string_to_time_val ((char *) ptr->content);
  21.632  
  21.633      ptr = ptr->parent->next->next->children;
  21.634 -    recorded->version = g_strdup((char *)ptr->content);
  21.635 +    recorded->version = g_strdup ((char *) ptr->content);
  21.636  
  21.637      ptr = ptr->parent->next->next->children;
  21.638 -    sscanf ((char *)ptr->content, "%d", &(recorded->protoVer));
  21.639 +    sscanf ((char *) ptr->content, "%d", &(recorded->protoVer));
  21.640  
  21.641      ptr = ptr->parent->next->next->children;
  21.642 -    if ( recorded->totalCount > 0)
  21.643 -        recorded->programList = get_Recorded_Programs(ptr->children);
  21.644 +    if (recorded->totalCount > 0)
  21.645 +        recorded->programList = get_Recorded_Programs (ptr->children);
  21.646  
  21.647  }
  21.648  
  21.649 @@ -488,27 +511,27 @@
  21.650   * @param doc An XML document (xmlDocPtr)
  21.651   * @return The recorded var updated
  21.652   */
  21.653 -void getRecorded(xmlDocPtr doc, GMythRecorded* recorded)
  21.654 +void
  21.655 +getRecorded (xmlDocPtr doc, GMythRecorded * recorded)
  21.656  {
  21.657      xmlXPathObjectPtr result;
  21.658      xmlNodeSetPtr nodeset;
  21.659      xmlChar *keyword;
  21.660  
  21.661      int i;
  21.662 -    result = getXPath((xmlChar *)"/*", doc);
  21.663  
  21.664 -    if (result)
  21.665 -    {
  21.666 +    result = getXPath ((xmlChar *) "/*", doc);
  21.667 +
  21.668 +    if (result) {
  21.669          nodeset = result->nodesetval;
  21.670 -        for (i=0; i < nodeset->nodeNr; i++)
  21.671 -        {
  21.672 -           keyword = (xmlChar*)nodeset->nodeTab[i]->name;
  21.673 -           if (g_ascii_strcasecmp((char *)keyword, "GetRecordedResponse") == 0)
  21.674 -           {
  21.675 -               get_Recorded_Properties(nodeset->nodeTab[i], recorded);
  21.676 -               break;
  21.677 -           }
  21.678 -    }
  21.679 +        for (i = 0; i < nodeset->nodeNr; i++) {
  21.680 +            keyword = (xmlChar *) nodeset->nodeTab[i]->name;
  21.681 +            if (g_ascii_strcasecmp
  21.682 +                ((char *) keyword, "GetRecordedResponse") == 0) {
  21.683 +                get_Recorded_Properties (nodeset->nodeTab[i], recorded);
  21.684 +                break;
  21.685 +            }
  21.686 +        }
  21.687          xmlXPathFreeObject (result);
  21.688      }
  21.689  
  21.690 @@ -518,7 +541,8 @@
  21.691  /** Function to retrieve the files that are recorded
  21.692   *
  21.693   */
  21.694 -GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info)
  21.695 +GMythRecorded
  21.696 +gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info)
  21.697  {
  21.698      GMythRecorded recorded;
  21.699      MemoryStruct chunk;
  21.700 @@ -526,15 +550,16 @@
  21.701      chunk.memory = NULL;
  21.702      chunk.size = 0;
  21.703  
  21.704 -    GString* command = g_string_new("");
  21.705 -    g_string_printf(command, "GetRecorded");
  21.706 +    GString *command = g_string_new ("");
  21.707  
  21.708 -    chunk = gmyth_http_request(backend_info, command);
  21.709 -    if (chunk.memory != NULL)
  21.710 -    {
  21.711 -        xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
  21.712 -        getRecorded(doc, &recorded);
  21.713 -        free(chunk.memory);
  21.714 +    g_string_printf (command, "GetRecorded");
  21.715 +
  21.716 +    chunk = gmyth_http_request (backend_info, command);
  21.717 +    if (chunk.memory != NULL) {
  21.718 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
  21.719 +
  21.720 +        getRecorded (doc, &recorded);
  21.721 +        free (chunk.memory);
  21.722      }
  21.723  
  21.724      return recorded;
  21.725 @@ -545,13 +570,14 @@
  21.726  /** Function to retrieve jobqueue status
  21.727   *
  21.728   */
  21.729 -gint gmyth_http_retrieve_job_status (GMythBackendInfo *backend_info,
  21.730 -                                          gint chanid, GTimeVal* start)
  21.731 +gint
  21.732 +gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info,
  21.733 +    gint chanid, GTimeVal * start)
  21.734  {
  21.735      gint status = 0;
  21.736      gint count = 0;
  21.737      gint temp_chanid = 0;
  21.738 -    GTimeVal* temp_start = NULL;
  21.739 +    GTimeVal *temp_start = NULL;
  21.740      int i;
  21.741  
  21.742      xmlXPathObjectPtr result;
  21.743 @@ -562,46 +588,44 @@
  21.744      chunk.memory = NULL;
  21.745      chunk.size = 0;
  21.746  
  21.747 -    GString* command = g_string_new("");
  21.748 -    g_string_printf(command, "GetStatus");
  21.749 +    GString *command = g_string_new ("");
  21.750  
  21.751 -    chunk = gmyth_http_request(backend_info, command);
  21.752 +    g_string_printf (command, "GetStatus");
  21.753  
  21.754 -    if (chunk.memory != NULL)
  21.755 -    {
  21.756 -        xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
  21.757 +    chunk = gmyth_http_request (backend_info, command);
  21.758  
  21.759 -        result = getXPath((xmlChar*)"/Status/JobQueue", doc);
  21.760 -        if (result)
  21.761 -        {
  21.762 +    if (chunk.memory != NULL) {
  21.763 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
  21.764 +
  21.765 +        result = getXPath ((xmlChar *) "/Status/JobQueue", doc);
  21.766 +        if (result) {
  21.767              nodeset = result->nodesetval;
  21.768              node = nodeset->nodeTab[0];
  21.769 -            sscanf((char *)xmlGetProp(node, (xmlChar*)"count"),\
  21.770 -                                      "%d", &count);
  21.771 +            sscanf ((char *) xmlGetProp (node, (xmlChar *) "count"),
  21.772 +                "%d", &count);
  21.773  
  21.774 -            if (count > 0)
  21.775 -            {
  21.776 +            if (count > 0) {
  21.777  
  21.778                  // Get the first child
  21.779                  node = node->children->next;
  21.780  
  21.781 -                for (i = 0; i < count; i++)
  21.782 -                {
  21.783 +                for (i = 0; i < count; i++) {
  21.784  
  21.785 -                    sscanf((char *)xmlGetProp(node, (xmlChar*)"chanId"),\
  21.786 -                           "%d", &temp_chanid);
  21.787 +                    sscanf ((char *)
  21.788 +                        xmlGetProp (node, (xmlChar *) "chanId"), "%d",
  21.789 +                        &temp_chanid);
  21.790  
  21.791 -                    if (chanid == temp_chanid)
  21.792 -                    {
  21.793 -                        temp_start = gmyth_util_string_to_time_val \
  21.794 -                            ((char *)xmlGetProp(node,(xmlChar *)"startTime"));
  21.795 +                    if (chanid == temp_chanid) {
  21.796 +                        temp_start = gmyth_util_string_to_time_val ((char *)
  21.797 +                            xmlGetProp (node, (xmlChar *)
  21.798 +                                "startTime"));
  21.799  
  21.800 -                        if ( (temp_start->tv_sec == start->tv_sec) &&
  21.801 -                             (temp_start->tv_usec == start->tv_usec) )
  21.802 -                            sscanf((char *)xmlGetProp(node, (xmlChar*)"status"),\
  21.803 -                                   "%d", &status);
  21.804 +                        if ((temp_start->tv_sec == start->tv_sec) &&
  21.805 +                            (temp_start->tv_usec == start->tv_usec))
  21.806 +                            sscanf ((char *)
  21.807 +                                xmlGetProp (node,
  21.808 +                                    (xmlChar *) "status"), "%d", &status);
  21.809                      }
  21.810 -
  21.811                      // Escape "text" node
  21.812                      node = node->next->next;
  21.813                  }
  21.814 @@ -610,7 +634,7 @@
  21.815          }
  21.816  
  21.817          xmlXPathFreeObject (result);
  21.818 -        free(chunk.memory);
  21.819 +        free (chunk.memory);
  21.820  
  21.821      }
  21.822  
  21.823 @@ -626,43 +650,42 @@
  21.824   * @param hostname the hostname that the key is set up
  21.825   * @return the value of the key
  21.826   */
  21.827 -gchar* gmyth_http_retrieve_setting (GMythBackendInfo *backend_info,\
  21.828 -                                  gchar* key, gchar* hostname)
  21.829 +gchar *
  21.830 +gmyth_http_retrieve_setting (GMythBackendInfo * backend_info,
  21.831 +    gchar * key, gchar * hostname)
  21.832  {
  21.833      xmlXPathObjectPtr result;
  21.834      xmlNodeSetPtr nodeset;
  21.835      xmlChar *keyword;
  21.836      MemoryStruct chunk;
  21.837 -    gchar* value = NULL;
  21.838 +    gchar *value = NULL;
  21.839  
  21.840      chunk.memory = NULL;
  21.841      chunk.size = 0;
  21.842  
  21.843 -    GString* command = g_string_new("");
  21.844 -    g_string_printf(command, "GetSetting?Key=%s&HostName=%s&Default=NULL", \
  21.845 -                    key, hostname);
  21.846 +    GString *command = g_string_new ("");
  21.847  
  21.848 -    chunk = gmyth_http_request(backend_info, command);
  21.849 +    g_string_printf (command, "GetSetting?Key=%s&HostName=%s&Default=NULL",
  21.850 +        key, hostname);
  21.851  
  21.852 -    if (chunk.memory != NULL)
  21.853 -    {
  21.854 -      xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
  21.855 +    chunk = gmyth_http_request (backend_info, command);
  21.856  
  21.857 -      result = getXPath((xmlChar *)"/GetSettingResponse/Values/*", doc);
  21.858 +    if (chunk.memory != NULL) {
  21.859 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
  21.860  
  21.861 -      if (result)
  21.862 -      {
  21.863 -        nodeset = result->nodesetval;
  21.864 -        keyword = (xmlChar*)nodeset->nodeTab[0]->name;
  21.865 -        if (g_ascii_strcasecmp((char *)keyword, "Value") == 0)
  21.866 -        {
  21.867 -            // Here we have the value
  21.868 -            value = (gchar*)nodeset->nodeTab[0]->children->content;
  21.869 +        result = getXPath ((xmlChar *) "/GetSettingResponse/Values/*", doc);
  21.870 +
  21.871 +        if (result) {
  21.872 +            nodeset = result->nodesetval;
  21.873 +            keyword = (xmlChar *) nodeset->nodeTab[0]->name;
  21.874 +            if (g_ascii_strcasecmp ((char *) keyword, "Value") == 0) {
  21.875 +                // Here we have the value
  21.876 +                value = (gchar *) nodeset->nodeTab[0]->children->content;
  21.877 +            }
  21.878 +            xmlXPathFreeObject (result);
  21.879          }
  21.880 -        xmlXPathFreeObject (result);
  21.881 -      }
  21.882  
  21.883 -      free(chunk.memory);
  21.884 +        free (chunk.memory);
  21.885      }
  21.886  
  21.887      return value;
  21.888 @@ -674,8 +697,8 @@
  21.889   * @param id the profile's id that you want to delete
  21.890   * @return 0 if OK
  21.891   */
  21.892 -gint rec_profile_common(GMythBackendInfo *backend_info,
  21.893 -                        GString* command)
  21.894 +gint
  21.895 +rec_profile_common (GMythBackendInfo * backend_info, GString * command)
  21.896  {
  21.897      xmlXPathObjectPtr result;
  21.898      xmlNodeSetPtr nodeset;
  21.899 @@ -687,26 +710,24 @@
  21.900  
  21.901      int ret = -1;
  21.902  
  21.903 -    chunk = gmyth_http_request(backend_info, command);
  21.904 +    chunk = gmyth_http_request (backend_info, command);
  21.905  
  21.906 -    if (chunk.memory != NULL)
  21.907 -    {
  21.908 -    xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
  21.909 +    if (chunk.memory != NULL) {
  21.910 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
  21.911  
  21.912 -    result = getXPath((xmlChar *)"/*", doc);
  21.913 +        result = getXPath ((xmlChar *) "/*", doc);
  21.914  
  21.915 -    if (result)
  21.916 -    {
  21.917 -        nodeset = result->nodesetval;
  21.918 -        keyword = (xmlChar*)nodeset->nodeTab[0]->name;
  21.919 +        if (result) {
  21.920 +            nodeset = result->nodesetval;
  21.921 +            keyword = (xmlChar *) nodeset->nodeTab[0]->name;
  21.922  
  21.923 -        if (g_ascii_strcasecmp((char *)keyword, "Success") == 0)
  21.924 -            ret = 0;
  21.925 +            if (g_ascii_strcasecmp ((char *) keyword, "Success") == 0)
  21.926 +                ret = 0;
  21.927  
  21.928 -        xmlXPathFreeObject (result);
  21.929 -    }
  21.930 +            xmlXPathFreeObject (result);
  21.931 +        }
  21.932  
  21.933 -    free(chunk.memory);
  21.934 +        free (chunk.memory);
  21.935      }
  21.936  
  21.937      return ret;
  21.938 @@ -719,15 +740,16 @@
  21.939   * @param id the profile's id that you want to delete
  21.940   * @return 0 if OK
  21.941   */
  21.942 -gint gmyth_http_del_rec_profile (GMythBackendInfo *backend_info,
  21.943 -                                 gint id)
  21.944 +gint
  21.945 +gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id)
  21.946  {
  21.947  
  21.948 -    GString* command = g_string_new("");
  21.949 -    g_string_printf(command, "delRecProfiles?id=%d", id);
  21.950 +    GString *command = g_string_new ("");
  21.951  
  21.952 +    g_string_printf (command, "delRecProfiles?id=%d", id);
  21.953  
  21.954 -    return rec_profile_common(backend_info, command);
  21.955 +
  21.956 +    return rec_profile_common (backend_info, command);
  21.957  }
  21.958  
  21.959  /** Function to create recording profiles
  21.960 @@ -739,69 +761,68 @@
  21.961   * @param acodec the name of the audo codec you want to use
  21.962   * @return 0 if OK
  21.963   */
  21.964 -gint gmyth_http_create_rec_profile (GMythBackendInfo *backend_info,
  21.965 -                                    GMythRecProfile* profile)
  21.966 +gint
  21.967 +gmyth_http_create_rec_profile (GMythBackendInfo * backend_info,
  21.968 +    GMythRecProfile * profile)
  21.969  {
  21.970  
  21.971      if (profile->name != NULL && profile->group != NULL &&
  21.972 -        profile->vcodec && profile->acodec && profile->options != NULL)
  21.973 -    {
  21.974 -        GString* command = g_string_new("");
  21.975 -        g_string_printf(command, "createRecProfiles?profilename=%s&"\
  21.976 -                                 "groupname=%s&vcodec=%s&acodec=%s&"\
  21.977 -                                 "transcodelossless=%d&transcoderesize=%d&"\
  21.978 -                                 "width=%d&height=%d&rtjpegquality=%d&"\
  21.979 -                                 "rtjpeglumafilter=%d&rtjpegchromafilter=%d&"\
  21.980 -                                 "mpeg4bitrate=%d&mpeg4maxquality=%d&"\
  21.981 -                                 "mpeg4minquality=%d&mpeg4qualdiff=%d&"\
  21.982 -                                 "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&"\
  21.983 -                                 "mpeg4option4mv=%d&mpeg4optionidct=%d&"\
  21.984 -                                 "mpeg4optionime=%d&hardwaremjpegquality=%d&"\
  21.985 -                                 "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&"\
  21.986 -                                 "mpeg2streamtype=%s&mpeg2aspectratio=%s&"\
  21.987 -                                 "mpeg2bitrate=%d&mpeg2maxbitrate=%d&"\
  21.988 -                                 "samplerate=%d&mp3quality=%d&"\
  21.989 -                                 "volume=%d&mpeg2audtype=%s&"\
  21.990 -                                 "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&"\
  21.991 -                                 "mpeg2audvolume=%d",
  21.992 -                                 profile->name, profile->group,
  21.993 -                                 profile->vcodec, profile->acodec,
  21.994 -                                 profile->options->transcodelossless,
  21.995 -                                 profile->options->transcoderesize,
  21.996 -                                 profile->options->width,
  21.997 -                                 profile->options->height,
  21.998 -                                 profile->options->rtjpegquality,
  21.999 -                                 profile->options->rtjpeglumafilter,
 21.1000 -                                 profile->options->rtjpegchromafilter,
 21.1001 -                                 profile->options->mpeg4bitrate,
 21.1002 -                                 profile->options->mpeg4maxquality,
 21.1003 -                                 profile->options->mpeg4minquality,
 21.1004 -                                 profile->options->mpeg4qualdiff,
 21.1005 -                                 profile->options->mpeg4scalebitrate,
 21.1006 -                                 profile->options->mpeg4optionvhq,
 21.1007 -                                 profile->options->mpeg4option4mv,
 21.1008 -                                 profile->options->mpeg4optionidct,
 21.1009 -                                 profile->options->mpeg4optionime,
 21.1010 -                                 profile->options->hardwaremjpegquality,
 21.1011 -                                 profile->options->hardwaremjpeghdecimation,
 21.1012 -                                 profile->options->hardwaremjpegvdecimation,
 21.1013 -                                 profile->options->mpeg2streamtype,
 21.1014 -                                 profile->options->mpeg2aspectratio,
 21.1015 -                                 profile->options->mpeg2bitrate,
 21.1016 -                                 profile->options->mpeg2maxbitrate,
 21.1017 -                                 profile->options->samplerate,
 21.1018 -                                 profile->options->mp3quality,
 21.1019 -                                 profile->options->volume,
 21.1020 -                                 profile->options->mpeg2audtype,
 21.1021 -                                 profile->options->mpeg2audbitratel1,
 21.1022 -                                 profile->options->mpeg2audbitratel2,
 21.1023 -                                 profile->options->mpeg2audvolume
 21.1024 -                                );
 21.1025 +        profile->vcodec && profile->acodec && profile->options != NULL) {
 21.1026 +        GString *command = g_string_new ("");
 21.1027  
 21.1028 +        g_string_printf (command, "createRecProfiles?profilename=%s&"
 21.1029 +            "groupname=%s&vcodec=%s&acodec=%s&"
 21.1030 +            "transcodelossless=%d&transcoderesize=%d&"
 21.1031 +            "width=%d&height=%d&rtjpegquality=%d&"
 21.1032 +            "rtjpeglumafilter=%d&rtjpegchromafilter=%d&"
 21.1033 +            "mpeg4bitrate=%d&mpeg4maxquality=%d&"
 21.1034 +            "mpeg4minquality=%d&mpeg4qualdiff=%d&"
 21.1035 +            "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&"
 21.1036 +            "mpeg4option4mv=%d&mpeg4optionidct=%d&"
 21.1037 +            "mpeg4optionime=%d&hardwaremjpegquality=%d&"
 21.1038 +            "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&"
 21.1039 +            "mpeg2streamtype=%s&mpeg2aspectratio=%s&"
 21.1040 +            "mpeg2bitrate=%d&mpeg2maxbitrate=%d&"
 21.1041 +            "samplerate=%d&mp3quality=%d&"
 21.1042 +            "volume=%d&mpeg2audtype=%s&"
 21.1043 +            "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&"
 21.1044 +            "mpeg2audvolume=%d",
 21.1045 +            profile->name, profile->group,
 21.1046 +            profile->vcodec, profile->acodec,
 21.1047 +            profile->options->transcodelossless,
 21.1048 +            profile->options->transcoderesize,
 21.1049 +            profile->options->width,
 21.1050 +            profile->options->height,
 21.1051 +            profile->options->rtjpegquality,
 21.1052 +            profile->options->rtjpeglumafilter,
 21.1053 +            profile->options->rtjpegchromafilter,
 21.1054 +            profile->options->mpeg4bitrate,
 21.1055 +            profile->options->mpeg4maxquality,
 21.1056 +            profile->options->mpeg4minquality,
 21.1057 +            profile->options->mpeg4qualdiff,
 21.1058 +            profile->options->mpeg4scalebitrate,
 21.1059 +            profile->options->mpeg4optionvhq,
 21.1060 +            profile->options->mpeg4option4mv,
 21.1061 +            profile->options->mpeg4optionidct,
 21.1062 +            profile->options->mpeg4optionime,
 21.1063 +            profile->options->hardwaremjpegquality,
 21.1064 +            profile->options->hardwaremjpeghdecimation,
 21.1065 +            profile->options->hardwaremjpegvdecimation,
 21.1066 +            profile->options->mpeg2streamtype,
 21.1067 +            profile->options->mpeg2aspectratio,
 21.1068 +            profile->options->mpeg2bitrate,
 21.1069 +            profile->options->mpeg2maxbitrate,
 21.1070 +            profile->options->samplerate,
 21.1071 +            profile->options->mp3quality,
 21.1072 +            profile->options->volume,
 21.1073 +            profile->options->mpeg2audtype,
 21.1074 +            profile->options->mpeg2audbitratel1,
 21.1075 +            profile->options->mpeg2audbitratel2,
 21.1076 +            profile->options->mpeg2audvolume);
 21.1077  
 21.1078 -        return rec_profile_common(backend_info, command);
 21.1079 -    }
 21.1080 -    else
 21.1081 +
 21.1082 +        return rec_profile_common (backend_info, command);
 21.1083 +    } else
 21.1084          return -1;
 21.1085  }
 21.1086  
 21.1087 @@ -811,69 +832,69 @@
 21.1088   * @param groupname the name of group you want to retrieve
 21.1089   * @return the list of profiles
 21.1090   */
 21.1091 -GSList* gmyth_http_retrieve_rec_profiles (GMythBackendInfo *backend_info,\
 21.1092 -                                         gchar* groupname)
 21.1093 +GSList *
 21.1094 +gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info,
 21.1095 +    gchar * groupname)
 21.1096  {
 21.1097      xmlXPathObjectPtr result;
 21.1098      xmlNodeSetPtr nodeset;
 21.1099      xmlChar *keyword;
 21.1100      MemoryStruct chunk;
 21.1101 -    GSList* profiles = NULL;
 21.1102 +    GSList *profiles = NULL;
 21.1103  
 21.1104      chunk.memory = NULL;
 21.1105      chunk.size = 0;
 21.1106  
 21.1107 -    GString* command = g_string_new("");
 21.1108 -    g_string_printf(command, "GetRecProfiles?groupname=%s", groupname);
 21.1109 +    GString *command = g_string_new ("");
 21.1110  
 21.1111 -    chunk = gmyth_http_request(backend_info, command);
 21.1112 +    g_string_printf (command, "GetRecProfiles?groupname=%s", groupname);
 21.1113  
 21.1114 -    if (chunk.memory != NULL)
 21.1115 -    {
 21.1116 -      xmlDocPtr doc = XMLParse(chunk.memory, strlen(chunk.memory));
 21.1117 +    chunk = gmyth_http_request (backend_info, command);
 21.1118  
 21.1119 -      result = getXPath((xmlChar *)"/*", doc);
 21.1120 +    if (chunk.memory != NULL) {
 21.1121 +        xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
 21.1122  
 21.1123 -      if (result)
 21.1124 -      {
 21.1125 -        nodeset = result->nodesetval;
 21.1126 -        keyword = (xmlChar*)nodeset->nodeTab[0]->name;
 21.1127 +        result = getXPath ((xmlChar *) "/*", doc);
 21.1128  
 21.1129 -        if (g_ascii_strcasecmp((char *)keyword, "Profiles") == 0)
 21.1130 -        {
 21.1131 -            xmlNodePtr node = nodeset->nodeTab[0]->children->next;
 21.1132 -            GMythRecProfile* profile;
 21.1133 +        if (result) {
 21.1134 +            nodeset = result->nodesetval;
 21.1135 +            keyword = (xmlChar *) nodeset->nodeTab[0]->name;
 21.1136  
 21.1137 -            while (node != NULL)
 21.1138 -            {
 21.1139 -                if (g_ascii_strcasecmp((char *)node->name, "text") != 0)
 21.1140 -                {
 21.1141 -                    profile = gmyth_recprofile_new();
 21.1142 +            if (g_ascii_strcasecmp ((char *) keyword, "Profiles") == 0) {
 21.1143 +                xmlNodePtr node = nodeset->nodeTab[0]->children->next;
 21.1144 +                GMythRecProfile *profile;
 21.1145  
 21.1146 -                    sscanf ((char *)xmlGetProp(node, (xmlChar *)\
 21.1147 -                                    "id"), "%d", &(profile->id));
 21.1148 +                while (node != NULL) {
 21.1149 +                    if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
 21.1150 +                        profile = gmyth_recprofile_new ();
 21.1151  
 21.1152 -                    profile->name = g_strdup((char *)\
 21.1153 -                                        xmlGetProp(node, (xmlChar *)"name"));
 21.1154 +                        sscanf ((char *) xmlGetProp (node, (xmlChar *)
 21.1155 +                                "id"), "%d", &(profile->id));
 21.1156  
 21.1157 -                    profile->vcodec = g_strdup((char *)\
 21.1158 -                                        xmlGetProp(node, (xmlChar *)"vcodec"));
 21.1159 +                        profile->name = g_strdup ((char *)
 21.1160 +                            xmlGetProp (node, (xmlChar *)
 21.1161 +                                "name"));
 21.1162  
 21.1163 -                    profile->acodec = g_strdup((char *)\
 21.1164 -                                        xmlGetProp(node, (xmlChar *)"acodec"));
 21.1165 +                        profile->vcodec = g_strdup ((char *)
 21.1166 +                            xmlGetProp (node, (xmlChar *)
 21.1167 +                                "vcodec"));
 21.1168  
 21.1169 -                    profile->group = g_strdup(groupname);
 21.1170 +                        profile->acodec = g_strdup ((char *)
 21.1171 +                            xmlGetProp (node, (xmlChar *)
 21.1172 +                                "acodec"));
 21.1173  
 21.1174 -                    profiles = g_slist_append(profiles, profile);
 21.1175 +                        profile->group = g_strdup (groupname);
 21.1176 +
 21.1177 +                        profiles = g_slist_append (profiles, profile);
 21.1178 +                    }
 21.1179 +                    node = node->next;
 21.1180                  }
 21.1181 -                node = node->next;
 21.1182 +
 21.1183              }
 21.1184 +            xmlXPathFreeObject (result);
 21.1185 +        }
 21.1186  
 21.1187 -        }
 21.1188 -        xmlXPathFreeObject (result);
 21.1189 -      }
 21.1190 -
 21.1191 -      free(chunk.memory);
 21.1192 +        free (chunk.memory);
 21.1193      }
 21.1194  
 21.1195      return profiles;
 21.1196 @@ -882,26 +903,26 @@
 21.1197  
 21.1198  
 21.1199  /* Aux functions got from libcurl */
 21.1200 -void *myrealloc (void *ptr, size_t size)
 21.1201 +void *
 21.1202 +myrealloc (void *ptr, size_t size)
 21.1203  {
 21.1204      /* There might be a realloc() out there that doesn't like reallocing
 21.1205 -        NULL pointers, so we take care of it here */
 21.1206 -    if(ptr)
 21.1207 -        return realloc(ptr, size);
 21.1208 +       NULL pointers, so we take care of it here */
 21.1209 +    if (ptr)
 21.1210 +        return realloc (ptr, size);
 21.1211      else
 21.1212 -        return malloc(size);
 21.1213 +        return malloc (size);
 21.1214  }
 21.1215  
 21.1216  size_t
 21.1217  WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data)
 21.1218  {
 21.1219      size_t realsize = size * nmemb;
 21.1220 -    MemoryStruct *mem = (struct _MemoryStruct *)data;
 21.1221 +    MemoryStruct *mem = (struct _MemoryStruct *) data;
 21.1222  
 21.1223 -    mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
 21.1224 -    if (mem->memory)
 21.1225 -    {
 21.1226 -        memcpy(&(mem->memory[mem->size]), ptr, realsize);
 21.1227 +    mem->memory = (char *) myrealloc (mem->memory, mem->size + realsize + 1);
 21.1228 +    if (mem->memory) {
 21.1229 +        memcpy (&(mem->memory[mem->size]), ptr, realsize);
 21.1230          mem->size += realsize;
 21.1231          mem->memory[mem->size] = 0;
 21.1232      }
 21.1233 @@ -915,63 +936,59 @@
 21.1234   * @return A string with the response from the server
 21.1235   *          NULL if there is no response.
 21.1236   */
 21.1237 -MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, \
 21.1238 -                                 GString *command)
 21.1239 +MemoryStruct
 21.1240 +gmyth_http_request (GMythBackendInfo * backend_info, GString * command)
 21.1241  {
 21.1242      LIBXML_TEST_VERSION
 21.1243 +        size_t size = strlen (backend_info->hostname) +
 21.1244 +        strlen (command->str) + 20;
 21.1245  
 21.1246 -    size_t size = strlen(backend_info->hostname) + \
 21.1247 -      strlen(command->str) + 20;
 21.1248 -
 21.1249 -    gchar *URL = (gchar *)g_malloc(sizeof(gchar)*size);
 21.1250 -    gchar *mid = (gchar *)g_malloc(sizeof(gchar)*6);
 21.1251 +    gchar *URL = (gchar *) g_malloc (sizeof (gchar) * size);
 21.1252 +    gchar *mid = (gchar *) g_malloc (sizeof (gchar) * 6);
 21.1253  
 21.1254      mid = "";
 21.1255  
 21.1256 -    if ( g_ascii_strcasecmp(command->str, "GetStatus") && \
 21.1257 -         g_ascii_strcasecmp(command->str, "GetStatusHTML") )
 21.1258 -    {
 21.1259 +    if (g_ascii_strcasecmp (command->str, "GetStatus") &&
 21.1260 +        g_ascii_strcasecmp (command->str, "GetStatusHTML")) {
 21.1261          mid = "Myth/";
 21.1262      }
 21.1263  
 21.1264 -    g_snprintf(URL, size, "http://%s:%d/%s%s", \
 21.1265 -           backend_info->hostname, \
 21.1266 -           backend_info->status_port, \
 21.1267 -           mid, command->str);
 21.1268 +    g_snprintf (URL, size, "http://%s:%d/%s%s",
 21.1269 +        backend_info->hostname, backend_info->status_port, mid, command->str);
 21.1270  
 21.1271      CURL *curl_handle;
 21.1272  
 21.1273      MemoryStruct chunk;
 21.1274  
 21.1275 -    chunk.memory=NULL; /* we expect realloc(NULL, size) to work */
 21.1276 -    chunk.size = 0;    /* no data at this point */
 21.1277 +    chunk.memory = NULL;        /* we expect realloc(NULL, size) to work */
 21.1278 +    chunk.size = 0;             /* no data at this point */
 21.1279  
 21.1280 -    curl_global_init(CURL_GLOBAL_ALL);
 21.1281 +    curl_global_init (CURL_GLOBAL_ALL);
 21.1282  
 21.1283      /* init the curl session */
 21.1284 -    curl_handle = curl_easy_init();
 21.1285 +    curl_handle = curl_easy_init ();
 21.1286  
 21.1287      /* specify URL to get */
 21.1288 -    curl_easy_setopt(curl_handle, CURLOPT_URL, URL);
 21.1289 +    curl_easy_setopt (curl_handle, CURLOPT_URL, URL);
 21.1290  
 21.1291      /* send all data to this function  */
 21.1292 -    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
 21.1293 +    curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
 21.1294  
 21.1295      /* we pass our 'chunk' struct to the callback function */
 21.1296 -    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
 21.1297 +    curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, (void *) &chunk);
 21.1298  
 21.1299      /* some servers don't like requests that are made without a user-agent
 21.1300 -        field, so we provide one */
 21.1301 -    curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
 21.1302 +       field, so we provide one */
 21.1303 +    curl_easy_setopt (curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
 21.1304  
 21.1305      /* set timeout */
 21.1306 -    curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
 21.1307 +    curl_easy_setopt (curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
 21.1308  
 21.1309      /* get it! */
 21.1310 -    curl_easy_perform(curl_handle);
 21.1311 +    curl_easy_perform (curl_handle);
 21.1312  
 21.1313      /* cleanup curl stuff */
 21.1314 -    curl_easy_cleanup(curl_handle);
 21.1315 +    curl_easy_cleanup (curl_handle);
 21.1316  
 21.1317      return chunk;
 21.1318  }
    22.1 --- a/gmyth/src/gmyth_http.h	Tue May 22 19:21:42 2007 +0100
    22.2 +++ b/gmyth/src/gmyth_http.h	Wed May 23 16:11:29 2007 +0100
    22.3 @@ -46,9 +46,7 @@
    22.4  #include <curl/easy.h>
    22.5  
    22.6  G_BEGIN_DECLS
    22.7 -
    22.8  #define MYTH_PORT_STATUS 6544
    22.9 -
   22.10  #define JOB_UNKNOWN   0x0000
   22.11  #define JOB_QUEUED    0x0001
   22.12  #define JOB_PENDING   0x0002
   22.13 @@ -59,7 +57,6 @@
   22.14  #define JOB_RETRY     0x0007
   22.15  #define JOB_ERRORING  0x0008
   22.16  #define JOB_ABORTING  0x0009
   22.17 -
   22.18  // JOB_DONE is a mask to indicate the job is done
   22.19  // whatever the status is
   22.20  #define JOB_DONE      0x0100
   22.21 @@ -67,15 +64,14 @@
   22.22  #define JOB_ABORTED   0x0120
   22.23  #define JOB_ERRORED   0x0130
   22.24  #define JOB_CANCELLED 0x0140
   22.25 -
   22.26  typedef struct _GMythRecorded_Recording GMythRecorded_Recording;
   22.27 -typedef struct _GMythRecorded_Channel   GMythRecorded_Channel;
   22.28 -typedef struct _GMythRecorded_Program   GMythRecorded_Program;
   22.29 -typedef struct _GMythRecorded   GMythRecorded;
   22.30 -typedef struct _GMythProgram    GMythProgram;
   22.31 -typedef struct _GMythChannel	GMythChannel;
   22.32 -typedef struct _GMythEpg	    GMythEpg;
   22.33 -typedef struct _MemoryStruct    MemoryStruct;
   22.34 +typedef struct _GMythRecorded_Channel GMythRecorded_Channel;
   22.35 +typedef struct _GMythRecorded_Program GMythRecorded_Program;
   22.36 +typedef struct _GMythRecorded GMythRecorded;
   22.37 +typedef struct _GMythProgram GMythProgram;
   22.38 +typedef struct _GMythChannel GMythChannel;
   22.39 +typedef struct _GMythEpg GMythEpg;
   22.40 +typedef struct _MemoryStruct MemoryStruct;
   22.41  
   22.42  struct _MemoryStruct
   22.43  {
   22.44 @@ -85,37 +81,37 @@
   22.45  
   22.46  struct _GMythProgram
   22.47  {
   22.48 -    gchar* title;
   22.49 -    gchar* subtitle;
   22.50 -    gchar* catType;
   22.51 -    gchar* category;
   22.52 -    gint	repeat;
   22.53 -    GTimeVal* startTime;
   22.54 -    GTimeVal* endTime;
   22.55 +    gchar *title;
   22.56 +    gchar *subtitle;
   22.57 +    gchar *catType;
   22.58 +    gchar *category;
   22.59 +    gint repeat;
   22.60 +    GTimeVal *startTime;
   22.61 +    GTimeVal *endTime;
   22.62  };
   22.63  
   22.64  struct _GMythChannel
   22.65  {
   22.66 -    gchar* channelName;
   22.67 -    gchar* chanNum;
   22.68 +    gchar *channelName;
   22.69 +    gchar *chanNum;
   22.70      gint chanId;
   22.71      gint callSign;
   22.72 -    GSList* programList;
   22.73 +    GSList *programList;
   22.74  };
   22.75  
   22.76  struct _GMythEpg
   22.77  {
   22.78      gint startChanId;
   22.79      gint endChanId;
   22.80 -    gchar* version;
   22.81 +    gchar *version;
   22.82      gint protoVer;
   22.83      gint totalCount;
   22.84      gint numOfChannels;
   22.85 -    GTimeVal* asOf;
   22.86 -    GTimeVal* startTime;
   22.87 -    GTimeVal* endTime;
   22.88 +    GTimeVal *asOf;
   22.89 +    GTimeVal *startTime;
   22.90 +    GTimeVal *endTime;
   22.91      gint details;
   22.92 -    GSList* channelList;
   22.93 +    GSList *channelList;
   22.94  };
   22.95  
   22.96  
   22.97 @@ -123,23 +119,23 @@
   22.98  {
   22.99      gint dupInType;
  22.100      gint dupMethod;
  22.101 -    gchar* playGroup;
  22.102 -    gchar* recGroup;
  22.103 -    gchar* recProfile;
  22.104 +    gchar *playGroup;
  22.105 +    gchar *recGroup;
  22.106 +    gchar *recProfile;
  22.107      gint recPriority;
  22.108      gint recStatus;
  22.109      gint encoderId;
  22.110      gint recordId;
  22.111      gint recType;
  22.112 -    GTimeVal* recStartTs;
  22.113 -    GTimeVal* recEndTs;
  22.114 +    GTimeVal *recStartTs;
  22.115 +    GTimeVal *recEndTs;
  22.116  };
  22.117  
  22.118  
  22.119  struct _GMythRecorded_Channel
  22.120  {
  22.121 -    gchar* chanFilters;
  22.122 -    gchar* channelName;
  22.123 +    gchar *chanFilters;
  22.124 +    gchar *channelName;
  22.125      gint chanNum;
  22.126      gint sourceId;
  22.127      gint commFree;
  22.128 @@ -152,56 +148,56 @@
  22.129  struct _GMythRecorded_Program
  22.130  {
  22.131      gint programFlags;
  22.132 -    gchar* title;
  22.133 +    gchar *title;
  22.134      gint programId;
  22.135 -    gchar* catType;
  22.136 -    gchar* category;
  22.137 +    gchar *catType;
  22.138 +    gchar *category;
  22.139      gint seriesId;
  22.140 -    GTimeVal* startTime;
  22.141 -    GTimeVal* endTime;
  22.142 -    GTimeVal* airdate; //?
  22.143 -    GTimeVal* lastModified;
  22.144 -    gchar* subTitle;
  22.145 +    GTimeVal *startTime;
  22.146 +    GTimeVal *endTime;
  22.147 +    GTimeVal *airdate;          //?
  22.148 +    GTimeVal *lastModified;
  22.149 +    gchar *subTitle;
  22.150      gint stars;
  22.151      gint repeat;
  22.152      gint fileSize;
  22.153 -    gchar* hostname;
  22.154 +    gchar *hostname;
  22.155      GMythRecorded_Channel channel;
  22.156      GMythRecorded_Recording recording;
  22.157  };
  22.158  
  22.159  struct _GMythRecorded
  22.160  {
  22.161 -    gchar* version;
  22.162 +    gchar *version;
  22.163      gint protoVer;
  22.164      gint totalCount;
  22.165 -    GTimeVal* asOf;
  22.166 -    GSList* programList;
  22.167 +    GTimeVal *asOf;
  22.168 +    GSList *programList;
  22.169  };
  22.170  
  22.171  
  22.172 -gint gmyth_http_retrieve_job_status (GMythBackendInfo *backend_info, \
  22.173 -                                          gint chanid, GTimeVal* start);
  22.174 +gint gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info,
  22.175 +    gint chanid, GTimeVal * start);
  22.176  
  22.177 -gchar* gmyth_http_retrieve_setting (GMythBackendInfo *backend_info,\
  22.178 -                                    gchar* key, gchar* hostname);
  22.179 +gchar *gmyth_http_retrieve_setting (GMythBackendInfo * backend_info,
  22.180 +    gchar * key, gchar * hostname);
  22.181  
  22.182 -GMythEpg gmyth_http_retrieve_epg(GMythBackendInfo *backend_info, \
  22.183 -                      GTimeVal* StartTime, GTimeVal* EndTime, \
  22.184 -                      gint StartChanId, gint NumOfChannels, gchar* Details);
  22.185 +GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo * backend_info,
  22.186 +    GTimeVal * StartTime, GTimeVal * EndTime,
  22.187 +    gint StartChanId, gint NumOfChannels, gchar * Details);
  22.188  
  22.189 -GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo *backend_info);
  22.190 +GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info);
  22.191  
  22.192 -GSList* gmyth_http_retrieve_rec_profiles (GMythBackendInfo *backend_info,\
  22.193 -                                         gchar* groupname);
  22.194 +GSList *gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info,
  22.195 +    gchar * groupname);
  22.196  
  22.197 -gint gmyth_http_create_rec_profile (GMythBackendInfo *backend_info,\
  22.198 -                                    GMythRecProfile* profile);
  22.199 +gint gmyth_http_create_rec_profile (GMythBackendInfo * backend_info,
  22.200 +    GMythRecProfile * profile);
  22.201  
  22.202 -gint gmyth_http_del_rec_profile (GMythBackendInfo *backend_info, gint id);
  22.203 +gint gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id);
  22.204  
  22.205 -MemoryStruct gmyth_http_request (GMythBackendInfo *backend_info, GString *command);
  22.206 +MemoryStruct gmyth_http_request (GMythBackendInfo * backend_info,
  22.207 +    GString * command);
  22.208  
  22.209  G_END_DECLS
  22.210 -
  22.211  #endif /* __GMYTH_HTTP_H__ */
    23.1 --- a/gmyth/src/gmyth_jobqueue.c	Tue May 22 19:21:42 2007 +0100
    23.2 +++ b/gmyth/src/gmyth_jobqueue.c	Wed May 23 16:11:29 2007 +0100
    23.3 @@ -23,7 +23,7 @@
    23.4   * along with this program; if not, write to the Free Software
    23.5   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23.6   */
    23.7 - 
    23.8 +
    23.9  #ifdef HAVE_CONFIG_H
   23.10  #include "config.h"
   23.11  #endif
   23.12 @@ -39,12 +39,14 @@
   23.13   * @return gboolean - result of connection
   23.14   *
   23.15   */
   23.16 -static GMythSocket*
   23.17 -backend_connect (GMythBackendInfo *backend_info)
   23.18 +static GMythSocket *
   23.19 +backend_connect (GMythBackendInfo * backend_info)
   23.20  {
   23.21      GMythSocket *socket = gmyth_socket_new ();
   23.22 +
   23.23      if (gmyth_socket_connect_to_backend (socket,
   23.24 -            gmyth_backend_info_get_hostname (backend_info),
   23.25 +            gmyth_backend_info_get_hostname
   23.26 +            (backend_info),
   23.27              gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
   23.28          gmyth_debug ("Backend socket connection success");
   23.29          return socket;
   23.30 @@ -66,28 +68,28 @@
   23.31   * @return the value returned by the backend
   23.32   *
   23.33   */
   23.34 -static gchar* send_command(GMythSocket *socket, gchar* action,
   23.35 -                      gchar* job, gint chanid, gchar* starttime,
   23.36 -                      gchar* options)
   23.37 +static gchar *
   23.38 +send_command (GMythSocket * socket, gchar * action,
   23.39 +    gchar * job, gint chanid, gchar * starttime, gchar * options)
   23.40  {
   23.41 -    GString* command = g_string_new ("");
   23.42 -    GString* ret_str;
   23.43 -    gchar* ret;
   23.44 +    GString *command = g_string_new ("");
   23.45 +    GString *ret_str;
   23.46 +    gchar *ret;
   23.47  
   23.48 -    GMythStringList *retlist = gmyth_string_list_new();
   23.49 +    GMythStringList *retlist = gmyth_string_list_new ();
   23.50  
   23.51 -    g_string_printf(command, "JOBQUEUE %s %s %d %s %s", action, job,
   23.52 -                    chanid, starttime, options);
   23.53 +    g_string_printf (command, "JOBQUEUE %s %s %d %s %s", action, job,
   23.54 +        chanid, starttime, options);
   23.55  
   23.56      gmyth_string_list_append_string (retlist, command);
   23.57      gmyth_socket_write_stringlist (socket, retlist);
   23.58  
   23.59      // receive answer
   23.60      gmyth_socket_read_stringlist (socket, retlist);
   23.61 -    ret_str = gmyth_string_list_get_string(retlist, 0);
   23.62 +    ret_str = gmyth_string_list_get_string (retlist, 0);
   23.63  
   23.64      //ret = ret_str->str;
   23.65 -    ret = g_string_free( ret_str, FALSE);
   23.66 +    ret = g_string_free (ret_str, FALSE);
   23.67      g_string_free (command, TRUE);
   23.68  
   23.69      gmyth_string_list_clear_all (retlist);
   23.70 @@ -104,12 +106,13 @@
   23.71   * @return 0 if success and -1 if error
   23.72   *
   23.73   */
   23.74 -static gboolean test_result(gchar* ret, gchar* value)
   23.75 +static gboolean
   23.76 +test_result (gchar * ret, gchar * value)
   23.77  {
   23.78 -    if (g_ascii_strcasecmp(ret, value) == 0) {
   23.79 +    if (g_ascii_strcasecmp (ret, value) == 0) {
   23.80          return TRUE;
   23.81      } else {
   23.82 -        gmyth_debug("JobQueue Error: %s", ret);
   23.83 +        gmyth_debug ("JobQueue Error: %s", ret);
   23.84          return FALSE;
   23.85      }
   23.86  }
   23.87 @@ -121,30 +124,30 @@
   23.88   * @return TRUE if the job was added, FALSE if not
   23.89   *
   23.90   */
   23.91 -gboolean gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job)
   23.92 +gboolean
   23.93 +gmyth_jobqueue_add_job (GMythTranscoder * transcode, gchar * job)
   23.94  {
   23.95      GMythSocket *socket = backend_connect (transcode->backend_info);
   23.96      gboolean res = FALSE;
   23.97  
   23.98      if (socket != NULL) {
   23.99 -        GString* options = g_string_new ("");
  23.100 -        gchar* ret = NULL;
  23.101 +        GString *options = g_string_new ("");
  23.102 +        gchar *ret = NULL;
  23.103  
  23.104 -        if (g_ascii_strcasecmp(job, "JOB_TRANSCODE") == 0)
  23.105 -        {
  23.106 +        if (g_ascii_strcasecmp (job, "JOB_TRANSCODE") == 0) {
  23.107              if (transcode->cutlist)
  23.108 -                g_string_append(options, " JOB_USE_CUTLIST");
  23.109 +                g_string_append (options, " JOB_USE_CUTLIST");
  23.110  
  23.111              if (transcode->output)
  23.112 -                g_string_append_printf(options, " JOB_OUTPUT %s",\
  23.113 -                                       transcode->output_filename);
  23.114 +                g_string_append_printf (options, " JOB_OUTPUT %s",
  23.115 +                    transcode->output_filename);
  23.116  
  23.117              if (transcode->profile != NULL)
  23.118 -                g_string_append_printf(options, " %s", transcode->profile);
  23.119 +                g_string_append_printf (options, " %s", transcode->profile);
  23.120          }
  23.121 -        ret = send_command(socket, "ADD", job, transcode->chanid,
  23.122 -                                    transcode->starttime, options->str);
  23.123 -        res = test_result(ret, "JOBQUEUE_OK");
  23.124 +        ret = send_command (socket, "ADD", job, transcode->chanid,
  23.125 +            transcode->starttime, options->str);
  23.126 +        res = test_result (ret, "JOBQUEUE_OK");
  23.127          gmyth_socket_close_connection (socket);
  23.128  
  23.129          g_object_unref (socket);
  23.130 @@ -155,7 +158,7 @@
  23.131              g_free (ret);
  23.132  
  23.133      } else {
  23.134 -        gmyth_debug("JobQueue Connection Failed");
  23.135 +        gmyth_debug ("JobQueue Connection Failed");
  23.136      }
  23.137  
  23.138      return res;
  23.139 @@ -169,26 +172,27 @@
  23.140   * @return the value of the key
  23.141   *
  23.142   */
  23.143 -gboolean gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action,
  23.144 -                                gchar* job)
  23.145 +gboolean
  23.146 +gmyth_jobqueue_change_cmd (GMythTranscoder * transcode, gchar * action,
  23.147 +    gchar * job)
  23.148  {
  23.149 -    GMythSocket *socket = backend_connect(transcode->backend_info);
  23.150 +    GMythSocket *socket = backend_connect (transcode->backend_info);
  23.151      gboolean res = FALSE;
  23.152  
  23.153      if (socket != NULL) {
  23.154 -        gchar* ret = send_command(socket, action, job,
  23.155 -                                  transcode->chanid,
  23.156 -                                  transcode->starttime, "");
  23.157 +        gchar *ret = send_command (socket, action, job,
  23.158 +            transcode->chanid,
  23.159 +            transcode->starttime, "");
  23.160  
  23.161 -        res = test_result(ret, "JOBQUEUE_CHANGED_CMD_OK");
  23.162 +        res = test_result (ret, "JOBQUEUE_CHANGED_CMD_OK");
  23.163  
  23.164 -	gmyth_socket_close_connection (socket);
  23.165 +        gmyth_socket_close_connection (socket);
  23.166          g_object_unref (socket);
  23.167  
  23.168 -        g_free(ret);
  23.169 +        g_free (ret);
  23.170  
  23.171      } else {
  23.172 -        gmyth_debug("JobQueue Connection Failed");
  23.173 +        gmyth_debug ("JobQueue Connection Failed");
  23.174      }
  23.175  
  23.176      return res;
    24.1 --- a/gmyth/src/gmyth_jobqueue.h	Tue May 22 19:21:42 2007 +0100
    24.2 +++ b/gmyth/src/gmyth_jobqueue.h	Wed May 23 16:11:29 2007 +0100
    24.3 @@ -43,11 +43,9 @@
    24.4  #include "gmyth_util.h"
    24.5  
    24.6  G_BEGIN_DECLS
    24.7 -
    24.8 -gboolean gmyth_jobqueue_add_job (GMythTranscoder* transcoder, gchar* job);
    24.9 -gboolean gmyth_jobqueue_change_cmd (GMythTranscoder* transcoder, gchar* action,
   24.10 -                                gchar* job);
   24.11 +    gboolean gmyth_jobqueue_add_job (GMythTranscoder * transcoder, gchar * job);
   24.12 +gboolean gmyth_jobqueue_change_cmd (GMythTranscoder * transcoder,
   24.13 +    gchar * action, gchar * job);
   24.14  
   24.15  G_END_DECLS
   24.16 -
   24.17  #endif /* __GMYTH_JOBQUEUE_H__ */
    25.1 --- a/gmyth/src/gmyth_livetv.c	Tue May 22 19:21:42 2007 +0100
    25.2 +++ b/gmyth/src/gmyth_livetv.c	Wed May 23 16:11:29 2007 +0100
    25.3 @@ -8,22 +8,22 @@
    25.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    25.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    25.6   *
    25.7 -          *//*
    25.8 -       * 
    25.9 -       * This program is free software; you can redistribute it and/or modify
   25.10 -       * it under the terms of the GNU Lesser General Public License as published by
   25.11 -       * the Free Software Foundation; either version 2 of the License, or
   25.12 -       * (at your option) any later version.
   25.13 -       *
   25.14 -       * This program is distributed in the hope that it will be useful,
   25.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   25.17 -       * GNU General Public License for more details.
   25.18 -       *
   25.19 -       * You should have received a copy of the GNU Lesser General Public License
   25.20 -       * along with this program; if not, write to the Free Software
   25.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25.22 -       */
   25.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   25.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   25.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   25.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   25.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   25.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   25.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   25.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   25.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   25.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   25.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   25.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   25.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   25.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   25.39  
   25.40  #ifdef HAVE_CONFIG_H
   25.41  #include "config.h"
   25.42 @@ -91,8 +91,7 @@
   25.43      GMythLiveTV *livetv = GMYTH_LIVETV (object);
   25.44  
   25.45  
   25.46 -    if (livetv->disposed)
   25.47 -    {
   25.48 +    if (livetv->disposed) {
   25.49          /* If dispose did already run, return. */
   25.50          return;
   25.51      }
   25.52 @@ -100,67 +99,57 @@
   25.53      /* Make sure dispose does not run twice. */
   25.54      livetv->disposed = TRUE;
   25.55  
   25.56 -    if (livetv->monitor != NULL)
   25.57 -    {
   25.58 +    if (livetv->monitor != NULL) {
   25.59          g_object_unref (livetv->monitor);
   25.60          livetv->monitor = NULL;
   25.61      }
   25.62  
   25.63 -    if (livetv->file != NULL)
   25.64 -    {
   25.65 +    if (livetv->file != NULL) {
   25.66          g_object_unref (livetv->file);
   25.67          livetv->file = NULL;
   25.68      }
   25.69  
   25.70  
   25.71 -    if (livetv->recorder != NULL)
   25.72 -    {
   25.73 +    if (livetv->recorder != NULL) {
   25.74          //gmyth_recorder_close(livetv->recorder);
   25.75          g_object_unref (livetv->recorder);
   25.76          livetv->recorder = NULL;
   25.77      }
   25.78  
   25.79 -    if (livetv->socket != NULL)
   25.80 -    {
   25.81 +    if (livetv->socket != NULL) {
   25.82          g_object_unref (livetv->socket);
   25.83          livetv->socket = NULL;
   25.84      }
   25.85  
   25.86 -    if (livetv->tvchain != NULL)
   25.87 -    {
   25.88 +    if (livetv->tvchain != NULL) {
   25.89          g_object_unref (livetv->tvchain);
   25.90          livetv->tvchain = NULL;
   25.91      }
   25.92  
   25.93  
   25.94 -    if (livetv->proginfo != NULL)
   25.95 -    {
   25.96 +    if (livetv->proginfo != NULL) {
   25.97          g_object_unref (livetv->proginfo);
   25.98          livetv->proginfo = NULL;
   25.99      }
  25.100  
  25.101 -    if (livetv->backend_info != NULL)
  25.102 -    {
  25.103 +    if (livetv->backend_info != NULL) {
  25.104          g_object_unref (livetv->backend_info);
  25.105          livetv->backend_info = NULL;
  25.106      }
  25.107  
  25.108  
  25.109 -    if (livetv->uri != NULL)
  25.110 -    {
  25.111 +    if (livetv->uri != NULL) {
  25.112          g_object_unref (livetv->uri);
  25.113          livetv->uri = NULL;
  25.114      }
  25.115  
  25.116 -    if (livetv->mutex != NULL)
  25.117 -    {
  25.118 +    if (livetv->mutex != NULL) {
  25.119          g_mutex_free (livetv->mutex);
  25.120          livetv->mutex = NULL;
  25.121      }
  25.122  
  25.123  
  25.124 -    if (livetv->local_hostname != NULL)
  25.125 -    {
  25.126 +    if (livetv->local_hostname != NULL) {
  25.127          g_string_free (livetv->local_hostname, TRUE);
  25.128          livetv->local_hostname = NULL;
  25.129      }
  25.130 @@ -204,105 +193,94 @@
  25.131   */
  25.132  static void
  25.133  gmyth_livetv_monitor_signal_handler (GMythMonitorHandler * monitor,
  25.134 -                                     gint msg_code, gchar * message,
  25.135 -                                     gpointer user_data)
  25.136 +    gint msg_code, gchar * message, gpointer user_data)
  25.137  {
  25.138      GMythLiveTV *live_tv = GMYTH_LIVETV (user_data);
  25.139  
  25.140      gmyth_debug
  25.141          ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n",
  25.142 -         message, msg_code, live_tv != NULL ? "" : "NULL",
  25.143 -         user_data != NULL ? "" : "NULL");
  25.144 +        message, msg_code, live_tv != NULL ? "" : "NULL",
  25.145 +        user_data != NULL ? "" : "NULL");
  25.146  
  25.147 -    if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file))
  25.148 -    {
  25.149 +    if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file)) {
  25.150          gmyth_debug ("LiveTV_obj is equals to NULL!!!");
  25.151          return;
  25.152      }
  25.153  
  25.154 -    switch (msg_code)
  25.155 -    {
  25.156 +    switch (msg_code) {
  25.157  
  25.158          case GMYTH_BACKEND_PROGRAM_INFO_CHANGED:
  25.159 -            {
  25.160 +        {
  25.161 +            gmyth_debug
  25.162 +                ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
  25.163 +                "TV Chain ID is the same as the old one...\n", message);
  25.164 +            if (g_ascii_strcasecmp
  25.165 +                (message,
  25.166 +                    (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
  25.167                  gmyth_debug
  25.168 -                    ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
  25.169 -                     "TV Chain ID is the same as the old one...\n", message);
  25.170 -                if (g_ascii_strcasecmp
  25.171 -                    (message,
  25.172 -                     (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0)
  25.173 -                {
  25.174 +                    ("OK!!! MOVED to the next program chain [actual == %s]!",
  25.175 +                    (gmyth_tvchain_get_id (live_tv->tvchain))->str);
  25.176 +                /* advertises the FileTransfer about the program info changed */
  25.177 +                if (live_tv->file != NULL) {
  25.178                      gmyth_debug
  25.179 -                        ("OK!!! MOVED to the next program chain [actual == %s]!",
  25.180 -                         (gmyth_tvchain_get_id (live_tv->tvchain))->str);
  25.181 -                    /* advertises the FileTransfer about the program info changed */
  25.182 -                    if (live_tv->file != NULL)
  25.183 -                    {
  25.184 -                        gmyth_debug
  25.185 -                            ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]");
  25.186 +                        ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]");
  25.187  
  25.188 -                        gmyth_file_transfer_emit_program_info_changed_signal
  25.189 -                            (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
  25.190 -                             (gpointer) (live_tv->recorder));
  25.191 +                    gmyth_file_transfer_emit_program_info_changed_signal
  25.192 +                        (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
  25.193 +                        (gpointer) (live_tv->recorder));
  25.194  
  25.195 -                        /* gmyth_livetv_monitor_handler_stop( live_tv ); */
  25.196 -                    }
  25.197 -                    else
  25.198 -                        gmyth_debug
  25.199 -                            ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
  25.200 -                }
  25.201 -                break;
  25.202 -            }
  25.203 -        case GMYTH_BACKEND_DONE_RECORDING:
  25.204 -            {
  25.205 -                gmyth_debug
  25.206 -                    ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
  25.207 -                     "TV Chain ID is the same as the old one...\n", message);
  25.208 -                if (g_ascii_strcasecmp
  25.209 -                    (message,
  25.210 -                     (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0)
  25.211 -                {
  25.212 -                    gmyth_debug
  25.213 -                        ("OK!!! MOVED to the next program chain [actual == %s]!",
  25.214 -                         (gmyth_tvchain_get_id (live_tv->tvchain))->str);
  25.215 -                    /* advertises the FileTransfer about the program info changed */
  25.216 -                    if (live_tv->file != NULL)
  25.217 -                    {
  25.218 -                        gmyth_debug
  25.219 -                            ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]");
  25.220 -
  25.221 -                        gmyth_file_transfer_emit_program_info_changed_signal
  25.222 -                            (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
  25.223 -                             (gpointer) (live_tv->recorder));
  25.224 -
  25.225 -                    }
  25.226 -                    else
  25.227 -                        gmyth_debug
  25.228 -                            ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
  25.229 -                }
  25.230 -                break;
  25.231 -            }
  25.232 -        case GMYTH_BACKEND_STOP_LIVETV:
  25.233 -            {
  25.234 -                gmyth_debug
  25.235 -                    ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the "
  25.236 -                     "LiveTV...\n", message);
  25.237 -                /* stops the LiveTV */
  25.238 -                if (live_tv != NULL)
  25.239 -                {
  25.240 -                    gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]");
  25.241 -
  25.242 -                    g_object_unref (live_tv);
  25.243 -                }
  25.244 -                else
  25.245 +                    /* gmyth_livetv_monitor_handler_stop( live_tv ); */
  25.246 +                } else
  25.247                      gmyth_debug
  25.248                          ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
  25.249 +            }
  25.250 +            break;
  25.251 +        }
  25.252 +        case GMYTH_BACKEND_DONE_RECORDING:
  25.253 +        {
  25.254 +            gmyth_debug
  25.255 +                ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
  25.256 +                "TV Chain ID is the same as the old one...\n", message);
  25.257 +            if (g_ascii_strcasecmp
  25.258 +                (message,
  25.259 +                    (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
  25.260 +                gmyth_debug
  25.261 +                    ("OK!!! MOVED to the next program chain [actual == %s]!",
  25.262 +                    (gmyth_tvchain_get_id (live_tv->tvchain))->str);
  25.263 +                /* advertises the FileTransfer about the program info changed */
  25.264 +                if (live_tv->file != NULL) {
  25.265 +                    gmyth_debug
  25.266 +                        ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]");
  25.267  
  25.268 -                break;
  25.269 +                    gmyth_file_transfer_emit_program_info_changed_signal
  25.270 +                        (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
  25.271 +                        (gpointer) (live_tv->recorder));
  25.272 +
  25.273 +                } else
  25.274 +                    gmyth_debug
  25.275 +                        ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
  25.276              }
  25.277 +            break;
  25.278 +        }
  25.279 +        case GMYTH_BACKEND_STOP_LIVETV:
  25.280 +        {
  25.281 +            gmyth_debug
  25.282 +                ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the "
  25.283 +                "LiveTV...\n", message);
  25.284 +            /* stops the LiveTV */
  25.285 +            if (live_tv != NULL) {
  25.286 +                gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]");
  25.287 +
  25.288 +                g_object_unref (live_tv);
  25.289 +            } else
  25.290 +                gmyth_debug
  25.291 +                    ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
  25.292 +
  25.293 +            break;
  25.294 +        }
  25.295          default:
  25.296              break;
  25.297 -    } /* switch (Monitor Handler messages) */
  25.298 +    }                           /* switch (Monitor Handler messages) */
  25.299  
  25.300  }
  25.301  
  25.302 @@ -320,8 +298,7 @@
  25.303  {
  25.304      gboolean res = TRUE;
  25.305  
  25.306 -    if (livetv->monitor != NULL)
  25.307 -    {
  25.308 +    if (livetv->monitor != NULL) {
  25.309          g_object_unref (livetv->monitor);
  25.310          livetv->monitor = NULL;
  25.311      }
  25.312 @@ -330,27 +307,21 @@
  25.313  
  25.314      res =
  25.315          gmyth_monitor_handler_open (livetv->monitor,
  25.316 -                                    livetv->backend_info->hostname,
  25.317 -                                    livetv->backend_info->port);
  25.318 +        livetv->backend_info->hostname, livetv->backend_info->port);
  25.319  
  25.320 -    if (res == TRUE)
  25.321 -    {
  25.322 +    if (res == TRUE) {
  25.323          gmyth_debug
  25.324              ("Connect MythTV Monitor event socket! Trying to start the message handler...");
  25.325  
  25.326          res = gmyth_monitor_handler_start (livetv->monitor);
  25.327  
  25.328 -        if (res)
  25.329 -        {
  25.330 +        if (res) {
  25.331              gmyth_debug
  25.332                  ("MythTV Monitor event socket connected and listening!");
  25.333              g_signal_connect (G_OBJECT (livetv->monitor),
  25.334 -                              "backend-events-handler",
  25.335 -                              (GCallback) gmyth_livetv_monitor_signal_handler,
  25.336 -                              livetv);
  25.337 -        }
  25.338 -        else
  25.339 -        {
  25.340 +                "backend-events-handler", (GCallback)
  25.341 +                gmyth_livetv_monitor_signal_handler, livetv);
  25.342 +        } else {
  25.343              gmyth_debug
  25.344                  ("Problems when trying to start MythTV Monitor event socket!");
  25.345              goto error;
  25.346 @@ -375,8 +346,7 @@
  25.347  gmyth_livetv_monitor_handler_stop (GMythLiveTV * livetv)
  25.348  {
  25.349  
  25.350 -    if (livetv->monitor != NULL)
  25.351 -    {
  25.352 +    if (livetv->monitor != NULL) {
  25.353          g_object_unref (livetv->monitor);
  25.354          livetv->monitor = NULL;
  25.355      }
  25.356 @@ -388,6 +358,7 @@
  25.357  gmyth_livetv_create_remote_url (GMythLiveTV * livetv)
  25.358  {
  25.359      gchar *uri = g_strdup ("");
  25.360 +
  25.361      gmyth_backend_info_get_remote_h
  25.362          //gmyth_backend(livetv->backend_info)
  25.363          return uri;
  25.364 @@ -413,19 +384,16 @@
  25.365  
  25.366      g_return_val_if_fail (livetv != NULL, FALSE);
  25.367  
  25.368 -    if (NULL == livetv->socket)
  25.369 -    {
  25.370 +    if (NULL == livetv->socket) {
  25.371          livetv->socket = gmyth_socket_new ();
  25.372  
  25.373          /* FIME: Implement this at gmyth_socket */
  25.374          res =
  25.375              gmyth_socket_connect_to_backend (livetv->socket,
  25.376 -                                             livetv->backend_info->hostname,
  25.377 -                                             livetv->backend_info->port, TRUE);
  25.378 -        if (!res)
  25.379 -        {
  25.380 +            livetv->backend_info->hostname, livetv->backend_info->port, TRUE);
  25.381 +        if (!res) {
  25.382              gmyth_debug ("[%s] LiveTV can not connect to backend",
  25.383 -                         __FUNCTION__);
  25.384 +                __FUNCTION__);
  25.385              res = FALSE;
  25.386              goto error;
  25.387          }
  25.388 @@ -437,8 +405,7 @@
  25.389  
  25.390      livetv->local_hostname = gmyth_socket_get_local_hostname ();
  25.391  
  25.392 -    if (livetv->local_hostname == NULL)
  25.393 -    {
  25.394 +    if (livetv->local_hostname == NULL) {
  25.395          g_warning ("livetv could not retrieve the local hostname");
  25.396          res = FALSE;
  25.397          goto error;
  25.398 @@ -446,14 +413,12 @@
  25.399          gmyth_debug ("Local hostname: %s", livetv->local_hostname->str);
  25.400      }
  25.401  
  25.402 -    if (livetv->recorder != NULL)
  25.403 -    {
  25.404 +    if (livetv->recorder != NULL) {
  25.405          g_object_unref (livetv->recorder);
  25.406          livetv->recorder = NULL;
  25.407      }
  25.408  
  25.409 -    if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0)
  25.410 -    {
  25.411 +    if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0) {
  25.412          gmyth_debug ("No free remote encoder available.");
  25.413          res = FALSE;
  25.414          goto error;
  25.415 @@ -463,8 +428,7 @@
  25.416      livetv->recorder = remote_request_next_free_recorder (livetv->socket, -1);
  25.417      gmyth_socket_close_connection (livetv->socket);
  25.418  
  25.419 -    if (NULL == livetv->recorder)
  25.420 -    {
  25.421 +    if (NULL == livetv->recorder) {
  25.422          gmyth_debug ("[%s] None remote encoder available", __FUNCTION__);
  25.423          res = FALSE;
  25.424          goto error;
  25.425 @@ -472,8 +436,7 @@
  25.426  
  25.427      /* Init remote encoder. Opens its control socket. */
  25.428      res = gmyth_recorder_setup (livetv->recorder);
  25.429 -    if (!res)
  25.430 -    {
  25.431 +    if (!res) {
  25.432          gmyth_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
  25.433          res = FALSE;
  25.434          goto error;
  25.435 @@ -483,61 +446,54 @@
  25.436      livetv->tvchain = gmyth_tvchain_new ();
  25.437      gmyth_tvchain_initialize (livetv->tvchain, livetv->backend_info);
  25.438  
  25.439 -    if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL)
  25.440 -    {
  25.441 +    if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL) {
  25.442          res = FALSE;
  25.443          goto error;
  25.444      }
  25.445 -
  25.446      // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
  25.447      res = gmyth_recorder_spawntv (livetv->recorder,
  25.448 -                                  gmyth_tvchain_get_id (livetv->tvchain));
  25.449 -    if (!res)
  25.450 -    {
  25.451 +        gmyth_tvchain_get_id (livetv->tvchain));
  25.452 +    if (!res) {
  25.453          gmyth_debug ("[%s] Fail while spawn tv\n", __FUNCTION__);
  25.454          res = FALSE;
  25.455          goto error;
  25.456      }
  25.457  
  25.458 -    if (res == TRUE)
  25.459 -    {
  25.460 +    if (res == TRUE) {
  25.461          /* loop finished, set the max tries variable to zero again... */
  25.462          gint wait_to_transfer = 0;
  25.463  
  25.464          while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
  25.465 -               (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
  25.466 +            (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
  25.467              g_usleep (300);
  25.468  
  25.469 -        if (channel != NULL)
  25.470 -        {
  25.471 +        if (channel != NULL) {
  25.472              /* Pauses remote encoder. */
  25.473              res = gmyth_recorder_pause_recording (livetv->recorder);
  25.474 -            if (!res)
  25.475 -            {
  25.476 +            if (!res) {
  25.477                  gmyth_debug ("[%s] Fail while pausing remote encoder\n",
  25.478 -                             __FUNCTION__);
  25.479 +                    __FUNCTION__);
  25.480                  res = FALSE;
  25.481                  goto error;
  25.482              }
  25.483  
  25.484 -            if (gmyth_recorder_check_channel_name (livetv->recorder, channel))
  25.485 -            {
  25.486 -                if (gmyth_recorder_set_channel_name (livetv->recorder, channel))
  25.487 -                {
  25.488 +            if (gmyth_recorder_check_channel_name (livetv->recorder, channel)) {
  25.489 +                if (gmyth_recorder_set_channel_name (livetv->recorder, channel)) {
  25.490                      gmyth_debug ("Channel changed!!! [%s].\n", channel);
  25.491                  }
  25.492              }
  25.493  
  25.494 -        }                       /* if - changes the channel number */
  25.495 -        /* sleep (5); *//* FIXME: this is evil (tpm) */
  25.496 +        }
  25.497 +        /* if - changes the channel number */
  25.498 +        /* sleep (5); */
  25.499 +        /* FIXME: this is evil (tpm) */
  25.500      }
  25.501  
  25.502      /* DEBUG message */
  25.503      GMythProgramInfo *prog_info =
  25.504          gmyth_recorder_get_current_program_info (livetv->recorder);
  25.505  
  25.506 -    if (NULL == prog_info)
  25.507 -    {
  25.508 +    if (NULL == prog_info) {
  25.509          gmyth_debug ("ProgramInfo is equals to NULL!!!");
  25.510  
  25.511          gint i;
  25.512 @@ -550,59 +506,55 @@
  25.513           * changing channels until we find a valid one, or until
  25.514           * we decide to give up.
  25.515           */
  25.516 -        for (i = 1; i < 1000; i++)
  25.517 -        {
  25.518 +        for (i = 1; i < 1000; i++) {
  25.519              if (channame != NULL)
  25.520                  g_free (channame);
  25.521              channame = g_strdup_printf ("%d", i);
  25.522 -            if (gmyth_recorder_set_channel_name (livetv->recorder, channame) <
  25.523 -                0)
  25.524 -            {
  25.525 +            if (gmyth_recorder_set_channel_name (livetv->recorder, channame)
  25.526 +                < 0) {
  25.527                  continue;
  25.528              }
  25.529              prog_info =
  25.530                  gmyth_recorder_get_next_program_info (livetv->recorder,
  25.531 -                                                      BROWSE_DIRECTION_UP);
  25.532 +                BROWSE_DIRECTION_UP);
  25.533              gmyth_program_info_print (prog_info);
  25.534              if (prog_info != NULL)
  25.535                  break;
  25.536          }
  25.537  
  25.538 -    }                           /* if - Program Info */
  25.539 +    }
  25.540  
  25.541 +    /* if - Program Info */
  25.542      /* prints program info data text */
  25.543      gmyth_debug ("New ProgramInfo...\n");
  25.544      gmyth_program_info_print (prog_info);
  25.545  
  25.546      /* check if the program chain could be obtained from the MythTV protocol message */
  25.547 -    if (prog_info != NULL)
  25.548 -    {
  25.549 +    if (prog_info != NULL) {
  25.550          gmyth_backend_info_set_username (livetv->tvchain->backend_info,
  25.551 -                                         "mythtv");
  25.552 +            "mythtv");
  25.553          gmyth_backend_info_set_password (livetv->tvchain->backend_info,
  25.554 -                                         "mythtv");
  25.555 +            "mythtv");
  25.556          gmyth_backend_info_set_db_name (livetv->tvchain->backend_info,
  25.557 -                                        "mythconverg");
  25.558 +            "mythconverg");
  25.559          GList *prog_list =
  25.560              gmyth_tvchain_get_program_info_from_channel (livetv->tvchain,
  25.561 -                                                         channel);
  25.562 +            channel);
  25.563          GMythProgramInfo *ch_prog = NULL;
  25.564 -        if (prog_list != NULL && g_list_length (prog_list) > 0)
  25.565 -        {
  25.566 +
  25.567 +        if (prog_list != NULL && g_list_length (prog_list) > 0) {
  25.568              ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0);
  25.569              gmyth_debug ("Channel program info (from a list with size = %d)!",
  25.570 -                         g_list_length (prog_list));
  25.571 +                g_list_length (prog_list));
  25.572              gmyth_program_info_print (ch_prog);
  25.573          }
  25.574  
  25.575          gmyth_debug ("Program Info: %s\n",
  25.576 -                     gmyth_program_info_to_string (prog_info));
  25.577 +            gmyth_program_info_to_string (prog_info));
  25.578          livetv->proginfo = prog_info;
  25.579          /* testing change channel */
  25.580          //gmyth_recorder_spawntv_no_tvchain( livetv->recorder );
  25.581 -    }
  25.582 -    else
  25.583 -    {
  25.584 +    } else {
  25.585  
  25.586          /* check for the program info in the TV program chain could be obtained 
  25.587             from the MythTV MySQL database */
  25.588 @@ -610,8 +562,7 @@
  25.589          /* Reload all TV chain from Mysql database. */
  25.590          gmyth_tvchain_reload_all (livetv->tvchain);
  25.591  
  25.592 -        if (livetv->tvchain == NULL)
  25.593 -        {
  25.594 +        if (livetv->tvchain == NULL) {
  25.595              res = FALSE;
  25.596              goto error;
  25.597          }
  25.598 @@ -619,19 +570,16 @@
  25.599          /* Get program info from database using chanid and starttime */
  25.600          livetv->proginfo =
  25.601              gmyth_tvchain_get_program_at (livetv->tvchain,
  25.602 -                                          tvchain_curr_index++);
  25.603 -        if (livetv->proginfo == NULL)
  25.604 -        {
  25.605 +            tvchain_curr_index++);
  25.606 +        if (livetv->proginfo == NULL) {
  25.607              gmyth_debug ("LiveTV not successfully started.\n");
  25.608              res = FALSE;
  25.609              goto error;
  25.610 -        }
  25.611 -        else
  25.612 -        {
  25.613 +        } else {
  25.614              res = TRUE;
  25.615              gmyth_debug
  25.616                  ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n",
  25.617 -                 livetv->proginfo->pathname->str);
  25.618 +                livetv->proginfo->pathname->str);
  25.619          }
  25.620  
  25.621      }
  25.622 @@ -641,8 +589,7 @@
  25.623  
  25.624      g_mutex_unlock (livetv->mutex);
  25.625  
  25.626 -    if (!gmyth_livetv_monitor_handler_start (livetv))
  25.627 -    {
  25.628 +    if (!gmyth_livetv_monitor_handler_start (livetv)) {
  25.629          res = FALSE;
  25.630          gmyth_debug ("LiveTV MONITOR handler error on setup!");
  25.631          goto error;
  25.632 @@ -661,37 +608,33 @@
  25.633  
  25.634      if (livetv->local_hostname != NULL) {
  25.635          g_string_free (livetv->local_hostname, TRUE);
  25.636 -		livetv->local_hostname = NULL;
  25.637 -	}
  25.638 +        livetv->local_hostname = NULL;
  25.639 +    }
  25.640  
  25.641      gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
  25.642  
  25.643 -    if (livetv->recorder != NULL)
  25.644 -    {
  25.645 +    if (livetv->recorder != NULL) {
  25.646          g_object_unref (livetv->recorder);
  25.647          livetv->recorder = NULL;
  25.648      }
  25.649  
  25.650      gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
  25.651  
  25.652 -    if (livetv->tvchain != NULL)
  25.653 -    {
  25.654 +    if (livetv->tvchain != NULL) {
  25.655          g_object_unref (livetv->tvchain);
  25.656          livetv->tvchain = NULL;
  25.657      }
  25.658  
  25.659      gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
  25.660  
  25.661 -    if (livetv->proginfo != NULL)
  25.662 -    {
  25.663 +    if (livetv->proginfo != NULL) {
  25.664          g_object_unref (livetv->proginfo);
  25.665          livetv->proginfo = NULL;
  25.666      }
  25.667  
  25.668      gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
  25.669  
  25.670 -    if (livetv->monitor != NULL)
  25.671 -    {
  25.672 +    if (livetv->monitor != NULL) {
  25.673          g_object_unref (livetv->monitor);
  25.674          livetv->monitor = NULL;
  25.675      }
  25.676 @@ -718,10 +661,9 @@
  25.677  static gboolean
  25.678  gmyth_livetv_setup_recorder (GMythLiveTV * livetv, gint channel)
  25.679  {
  25.680 -    return gmyth_livetv_setup_recorder_channel_name (livetv, (channel != -1) ?
  25.681 -                                                     g_strdup_printf ("%d",
  25.682 -                                                                      channel) :
  25.683 -                                                     NULL);
  25.684 +    return gmyth_livetv_setup_recorder_channel_name (livetv,
  25.685 +        (channel != -1) ? g_strdup_printf ("%d", channel)
  25.686 +        : NULL);
  25.687  }
  25.688  
  25.689  /**
  25.690 @@ -790,8 +732,7 @@
  25.691      gboolean res = TRUE;
  25.692      GMythProgramInfo *prog_info = NULL;
  25.693  
  25.694 -    if (!livetv->setup_done)
  25.695 -    {
  25.696 +    if (!livetv->setup_done) {
  25.697          gmyth_debug ("Call the setup function first!");
  25.698          goto error;
  25.699      }
  25.700 @@ -799,34 +740,28 @@
  25.701      gmyth_debug ("Current ProgramInfo...\n");
  25.702      prog_info = gmyth_recorder_get_current_program_info (livetv->recorder);
  25.703  
  25.704 -    if (prog_info != NULL)
  25.705 -    {
  25.706 +    if (prog_info != NULL) {
  25.707          livetv->proginfo = prog_info;
  25.708 -    }
  25.709 -    else
  25.710 -    {
  25.711 +    } else {
  25.712          gmyth_debug
  25.713              ("ProgramInfo equals to NULL!!! Getting the next program info...");
  25.714          prog_info =
  25.715              gmyth_recorder_get_next_program_info (livetv->recorder,
  25.716 -                                                  BROWSE_DIRECTION_RIGHT);
  25.717 +            BROWSE_DIRECTION_RIGHT);
  25.718          livetv->proginfo = prog_info;
  25.719      }
  25.720      /* prints program info data text */
  25.721      gmyth_program_info_print (prog_info);
  25.722  
  25.723 -    if (prog_info != NULL)
  25.724 -    {
  25.725 +    if (prog_info != NULL) {
  25.726          res = TRUE;
  25.727          livetv->proginfo = prog_info;
  25.728          gmyth_debug
  25.729              ("GMythLiveTV: All requests to backend to start TV were OK, program info changed.");
  25.730 -    }
  25.731 -    else
  25.732 -    {
  25.733 +    } else {
  25.734          gmyth_debug
  25.735              ("[%s] LiveTV not successfully started on the next program chain.\n",
  25.736 -             __FUNCTION__);
  25.737 +            __FUNCTION__);
  25.738          goto error;
  25.739      }
  25.740  
  25.741 @@ -841,20 +776,17 @@
  25.742  
  25.743      g_string_free (livetv->local_hostname, TRUE);
  25.744  
  25.745 -    if (livetv->recorder != NULL)
  25.746 -    {
  25.747 +    if (livetv->recorder != NULL) {
  25.748          g_object_unref (livetv->recorder);
  25.749          livetv->recorder = NULL;
  25.750      }
  25.751  
  25.752 -    if (livetv->tvchain != NULL)
  25.753 -    {
  25.754 +    if (livetv->tvchain != NULL) {
  25.755          g_object_unref (livetv->tvchain);
  25.756          livetv->tvchain = NULL;
  25.757      }
  25.758  
  25.759 -    if (livetv->proginfo != NULL)
  25.760 -    {
  25.761 +    if (livetv->proginfo != NULL) {
  25.762          g_object_unref (livetv->proginfo);
  25.763          livetv->proginfo = NULL;
  25.764      }
  25.765 @@ -879,8 +811,7 @@
  25.766      if (NULL == livetv)
  25.767          goto done;
  25.768  
  25.769 -    if (!livetv->setup_done)
  25.770 -    {
  25.771 +    if (!livetv->setup_done) {
  25.772          gmyth_debug
  25.773              ("Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!");
  25.774          goto done;
  25.775 @@ -888,55 +819,48 @@
  25.776  
  25.777      if (livetv->proginfo != NULL)
  25.778          gmyth_debug ("URI path (from program info) = %s.\n",
  25.779 -                     livetv->proginfo->pathname->str);
  25.780 +            livetv->proginfo->pathname->str);
  25.781      else
  25.782          gmyth_debug ("URI path (from URI) = %s.\n", livetv->uri->uri->str);
  25.783  
  25.784      g_mutex_lock (livetv->mutex);
  25.785  
  25.786 -    if (livetv->file != NULL)
  25.787 -    {
  25.788 +    if (livetv->file != NULL) {
  25.789          /*gmyth_file_transfer_close( livetv->file ); */
  25.790          g_object_unref (livetv->file);
  25.791          livetv->file = NULL;
  25.792      }
  25.793  
  25.794 -    if (livetv->uri != NULL)
  25.795 -    {
  25.796 +    if (livetv->uri != NULL) {
  25.797          gmyth_debug
  25.798              ("URI is not NULL, creating from the ProgramInfo pathname... (%s)",
  25.799 -             livetv->proginfo->pathname->str);
  25.800 +            livetv->proginfo->pathname->str);
  25.801          livetv->uri->path = g_string_erase (livetv->uri->path, 0, -1);
  25.802          livetv->uri->path =
  25.803              g_string_new (g_strrstr (livetv->proginfo->pathname->str, "/"));
  25.804 -    }
  25.805 -    else
  25.806 -    {
  25.807 +    } else {
  25.808          gmyth_debug
  25.809              ("URI is NULL, creating from the ProgramInfo pathname... (%s)",
  25.810 -             livetv->proginfo->pathname->str);
  25.811 +            livetv->proginfo->pathname->str);
  25.812          livetv->uri =
  25.813              gmyth_uri_new_with_value (livetv->proginfo->pathname->str);
  25.814      }
  25.815  
  25.816 -    if (NULL == livetv->uri)
  25.817 -    {
  25.818 +    if (NULL == livetv->uri) {
  25.819          gmyth_debug ("Couldn't parse the URI to start LiveTV! [ uri = %s ]",
  25.820 -                     livetv->proginfo->pathname->str);
  25.821 +            livetv->proginfo->pathname->str);
  25.822          goto done;
  25.823      }
  25.824  
  25.825      if (gmyth_uri_is_local_file (livetv->uri))
  25.826          livetv->file = GMYTH_FILE (gmyth_file_local_new (livetv->backend_info));
  25.827 -    else
  25.828 -    {
  25.829 +    else {
  25.830          livetv->file =
  25.831              GMYTH_FILE (gmyth_file_transfer_new (livetv->backend_info));
  25.832          /* gmyth_file_transfer_settimeout( GMYTH_FILE_TRANSFER(livetv->file), TRUE ); */
  25.833      }
  25.834  
  25.835 -    if (NULL == livetv->file)
  25.836 -    {
  25.837 +    if (NULL == livetv->file) {
  25.838          gmyth_debug
  25.839              ("Error: couldn't create the FileTransfer from LiveTV source!");
  25.840          goto done;
  25.841 @@ -945,7 +869,7 @@
  25.842      g_object_ref (livetv->file);
  25.843  
  25.844      g_mutex_unlock (livetv->mutex);
  25.845 -    
  25.846 +
  25.847      /* Do some locking procedure with the Monitor Handler messages... */
  25.848  
  25.849    done:
  25.850 @@ -971,19 +895,16 @@
  25.851  {
  25.852      gmyth_debug ("Stopping the LiveTV...\n");
  25.853  
  25.854 -    if (livetv->is_livetv)
  25.855 -    {
  25.856 -        if (!gmyth_recorder_stop_livetv (livetv->recorder))
  25.857 -        {
  25.858 +    if (livetv->is_livetv) {
  25.859 +        if (!gmyth_recorder_stop_livetv (livetv->recorder)) {
  25.860              gmyth_debug ("[%s] Error while stoping remote encoder",
  25.861 -                         __FUNCTION__);
  25.862 +                __FUNCTION__);
  25.863          }
  25.864  
  25.865 -        if (!gmyth_recorder_finish_recording (livetv->recorder))
  25.866 -        {
  25.867 +        if (!gmyth_recorder_finish_recording (livetv->recorder)) {
  25.868              gmyth_debug
  25.869                  ("[%s] Error while finishing recording on remote encoder",
  25.870 -                 __FUNCTION__);
  25.871 +                __FUNCTION__);
  25.872          }
  25.873      }
  25.874  }
    26.1 --- a/gmyth/src/gmyth_livetv.h	Tue May 22 19:21:42 2007 +0100
    26.2 +++ b/gmyth/src/gmyth_livetv.h	Wed May 23 16:11:29 2007 +0100
    26.3 @@ -8,22 +8,22 @@
    26.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    26.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    26.6   *
    26.7 -          *//*
    26.8 -       * 
    26.9 -       * This program is free software; you can redistribute it and/or modify
   26.10 -       * it under the terms of the GNU Lesser General Public License as published by
   26.11 -       * the Free Software Foundation; either version 2 of the License, or
   26.12 -       * (at your option) any later version.
   26.13 -       *
   26.14 -       * This program is distributed in the hope that it will be useful,
   26.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26.17 -       * GNU General Public License for more details.
   26.18 -       *
   26.19 -       * You should have received a copy of the GNU Lesser General Public License
   26.20 -       * along with this program; if not, write to the Free Software
   26.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   26.22 -       */
   26.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   26.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   26.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   26.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   26.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   26.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   26.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   26.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   26.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   26.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   26.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   26.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   26.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   26.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   26.39  
   26.40  #ifndef GMYTH_LIVETV_H_
   26.41  #define GMYTH_LIVETV_H_
   26.42 @@ -49,37 +49,37 @@
   26.43  typedef struct _GMythLiveTVClass GMythLiveTVClass;
   26.44  
   26.45  struct _GMythLiveTVClass
   26.46 -    {
   26.47 -        GObjectClass parent_class;
   26.48 +{
   26.49 +    GObjectClass parent_class;
   26.50  
   26.51 -        /* callbacks */
   26.52 -    };
   26.53 +    /* callbacks */
   26.54 +};
   26.55  
   26.56  struct _GMythLiveTV
   26.57 -    {
   26.58 -        GObject parent;
   26.59 +{
   26.60 +    GObject parent;
   26.61  
   26.62 -        GMythSocket *socket;
   26.63 +    GMythSocket *socket;
   26.64  
   26.65 -        GString *local_hostname;
   26.66 +    GString *local_hostname;
   26.67  
   26.68 -        GMythBackendInfo *backend_info;
   26.69 +    GMythBackendInfo *backend_info;
   26.70  
   26.71 -        GMythRecorder *recorder;
   26.72 -        GMythTVChain *tvchain;
   26.73 -        GMythProgramInfo *proginfo;
   26.74 +    GMythRecorder *recorder;
   26.75 +    GMythTVChain *tvchain;
   26.76 +    GMythProgramInfo *proginfo;
   26.77  
   26.78 -        GMythFile *file;
   26.79 +    GMythFile *file;
   26.80  
   26.81 -        GMythMonitorHandler *monitor;
   26.82 -        GMythURI *uri;
   26.83 +    GMythMonitorHandler *monitor;
   26.84 +    GMythURI *uri;
   26.85  
   26.86 -        gboolean is_livetv;
   26.87 -        gboolean setup_done;
   26.88 +    gboolean is_livetv;
   26.89 +    gboolean setup_done;
   26.90  
   26.91 -        GMutex *mutex;
   26.92 -        gboolean disposed;
   26.93 -    };
   26.94 +    GMutex *mutex;
   26.95 +    gboolean disposed;
   26.96 +};
   26.97  
   26.98  GType gmyth_livetv_get_type (void);
   26.99  
  26.100 @@ -91,7 +91,7 @@
  26.101  gboolean gmyth_livetv_setup (GMythLiveTV * livetv);
  26.102  gboolean gmyth_livetv_channel_setup (GMythLiveTV * livetv, gint channel);
  26.103  gboolean gmyth_livetv_channel_name_setup (GMythLiveTV * livetv,
  26.104 -                                          gchar * channel);
  26.105 +    gchar * channel);
  26.106  gboolean gmyth_livetv_next_program_chain (GMythLiveTV * livetv);
  26.107  
  26.108  GMythFile *gmyth_livetv_create_file_transfer (GMythLiveTV * livetv);
    27.1 --- a/gmyth/src/gmyth_monitor_handler.c	Tue May 22 19:21:42 2007 +0100
    27.2 +++ b/gmyth/src/gmyth_monitor_handler.c	Wed May 23 16:11:29 2007 +0100
    27.3 @@ -9,27 +9,27 @@
    27.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    27.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    27.6   *
    27.7 -          *//*
    27.8 -       * 
    27.9 -       * This program is free software; you can redistribute it and/or modify
   27.10 -       * it under the terms of the GNU Lesser General Public License as published by
   27.11 -       * the Free Software Foundation; either version 2 of the License, or
   27.12 -       * (at your option) any later version.
   27.13 -       *
   27.14 -       * This program is distributed in the hope that it will be useful,
   27.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.17 -       * GNU General Public License for more details.
   27.18 -       *
   27.19 -       * You should have received a copy of the GNU Lesser General Public License
   27.20 -       * along with this program; if not, write to the Free Software
   27.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.22 -       *
   27.23 -       * GStreamer MythTV plug-in properties:
   27.24 -       * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
   27.25 -       * - path (qurl - remote file to be opened)
   27.26 -       * - port number *   
   27.27 -       */
   27.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   27.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   27.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   27.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   27.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   27.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   27.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   27.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   27.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   27.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   27.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   27.40 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   27.41 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   27.42 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.43 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   27.44 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GStreamer MythTV plug-in properties:
   27.45 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
   27.46 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - path (qurl - remote file to be opened)
   27.47 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * - port number *   
   27.48 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   27.49  
   27.50  #ifdef HAVE_CONFIG_H
   27.51  #include "config.h"
   27.52 @@ -72,8 +72,7 @@
   27.53  gpointer gmyth_monitor_handler_listener (gpointer data);
   27.54  
   27.55  static void gmyth_monitor_handler_default_listener (GMythMonitorHandler *
   27.56 -                                                    monitor, gint msg_code,
   27.57 -                                                    gchar * message);
   27.58 +    monitor, gint msg_code, gchar * message);
   27.59  
   27.60  static void gmyth_monitor_handler_class_init (GMythMonitorHandlerClass * klass);
   27.61  static void gmyth_monitor_handler_init (GMythMonitorHandler * object);
   27.62 @@ -82,10 +81,10 @@
   27.63  static void gmyth_monitor_handler_finalize (GObject * object);
   27.64  
   27.65  static gboolean gmyth_connect_to_backend_monitor (GMythMonitorHandler *
   27.66 -                                                  monitor);
   27.67 +    monitor);
   27.68  
   27.69  static gboolean gmyth_monitor_handler_setup (GMythMonitorHandler * monitor,
   27.70 -                                             GIOChannel * channel);
   27.71 +    GIOChannel * channel);
   27.72  
   27.73  void gmyth_monitor_handler_close (GMythMonitorHandler * monitor);
   27.74  
   27.75 @@ -104,11 +103,11 @@
   27.76  
   27.77      gmonitor_class->backend_events_handler_signal_id =
   27.78          g_signal_new ("backend-events-handler",
   27.79 -                      G_TYPE_FROM_CLASS (gmonitor_class),
   27.80 -                      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
   27.81 -                      G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
   27.82 -                      gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2,
   27.83 -                      G_TYPE_INT, G_TYPE_STRING);
   27.84 +        G_TYPE_FROM_CLASS (gmonitor_class),
   27.85 +        G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
   27.86 +        G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
   27.87 +        gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2,
   27.88 +        G_TYPE_INT, G_TYPE_STRING);
   27.89  
   27.90      gmonitor_class->backend_events_handler =
   27.91          gmyth_monitor_handler_default_listener;
   27.92 @@ -141,42 +140,39 @@
   27.93  gmyth_monitor_handler_dispose (GObject * object)
   27.94  {
   27.95      GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object);
   27.96 +
   27.97      gmyth_monitor_handler_close (monitor);
   27.98  
   27.99      monitor->allow_msgs_listener = FALSE;
  27.100  
  27.101 -    if (monitor->th != NULL)
  27.102 -    {
  27.103 -    	gboolean *ret = (gboolean*)g_thread_join( monitor->th );
  27.104 -	if ( *ret == FALSE )
  27.105 -		gmyth_debug ( "Error closing GThread listener socket!" );
  27.106 -	else
  27.107 -		gmyth_debug ( "Closed GThread listener socket." );
  27.108 -	//g_object_unref( monitor->th );
  27.109 +    if (monitor->th != NULL) {
  27.110 +        gboolean *ret = (gboolean *) g_thread_join (monitor->th);
  27.111 +
  27.112 +        if (*ret == FALSE)
  27.113 +            gmyth_debug ("Error closing GThread listener socket!");
  27.114 +        else
  27.115 +            gmyth_debug ("Closed GThread listener socket.");
  27.116 +        //g_object_unref( monitor->th );
  27.117      }
  27.118  
  27.119      /* mutex to control access to the event socket consumer thread */
  27.120 -    if (monitor->mutex != NULL)
  27.121 -    {
  27.122 +    if (monitor->mutex != NULL) {
  27.123          //g_mutex_unlock( monitor->mutex );
  27.124          g_mutex_free (monitor->mutex);
  27.125          monitor->mutex = NULL;
  27.126      }
  27.127  
  27.128 -    if (monitor->event_sock != NULL)
  27.129 -    {
  27.130 +    if (monitor->event_sock != NULL) {
  27.131          g_object_unref (monitor->event_sock);
  27.132          monitor->event_sock = NULL;
  27.133      }
  27.134  
  27.135 -    if (monitor->hostname != NULL)
  27.136 -    {
  27.137 +    if (monitor->hostname != NULL) {
  27.138          g_free (monitor->hostname);
  27.139          monitor->hostname = NULL;
  27.140      }
  27.141  
  27.142 -    if (monitor->backend_msgs != NULL)
  27.143 -    {
  27.144 +    if (monitor->backend_msgs != NULL) {
  27.145          g_hash_table_destroy (monitor->backend_msgs);
  27.146          monitor->backend_msgs = NULL;
  27.147      }
  27.148 @@ -210,7 +206,7 @@
  27.149  {
  27.150      GMythMonitorHandler *monitor =
  27.151          GMYTH_MONITOR_HANDLER (g_object_new
  27.152 -                               (GMYTH_MONITOR_HANDLER_TYPE, FALSE));
  27.153 +        (GMYTH_MONITOR_HANDLER_TYPE, FALSE));
  27.154  
  27.155      return monitor;
  27.156  }
  27.157 @@ -259,8 +255,7 @@
  27.158      monitor->allow_msgs_listener = FALSE;
  27.159  
  27.160  #if 0
  27.161 -    if (monitor->monitor_th != NULL)
  27.162 -    {
  27.163 +    if (monitor->monitor_th != NULL) {
  27.164          g_thread_pool_free (monitor->monitor_th, TRUE, FALSE);
  27.165          //g_thread_exit( monitor->monitor_th );
  27.166          /*if ( monitor->monitor_th != NULL )
  27.167 @@ -268,8 +263,7 @@
  27.168          monitor->monitor_th = NULL;
  27.169      }
  27.170  
  27.171 -    if (monitor->event_sock != NULL)
  27.172 -    {
  27.173 +    if (monitor->event_sock != NULL) {
  27.174          gmyth_socket_close_connection (monitor->event_sock);
  27.175      }
  27.176  #endif
  27.177 @@ -288,14 +282,13 @@
  27.178   */
  27.179  gboolean
  27.180  gmyth_monitor_handler_open (GMythMonitorHandler * monitor,
  27.181 -                            const gchar * hostname, gint port)
  27.182 +    const gchar * hostname, gint port)
  27.183  {
  27.184      gboolean ret = TRUE;
  27.185  
  27.186      g_return_val_if_fail (hostname != NULL, FALSE);
  27.187  
  27.188 -    if (monitor->hostname != NULL)
  27.189 -    {
  27.190 +    if (monitor->hostname != NULL) {
  27.191          g_free (monitor->hostname);
  27.192          monitor->hostname = NULL;
  27.193      }
  27.194 @@ -304,30 +297,26 @@
  27.195      monitor->port = port;
  27.196  
  27.197      gmyth_debug ("Monitor event socket --- hostname: %s, port %d\n",
  27.198 -                 monitor->hostname, monitor->port);
  27.199 +        monitor->hostname, monitor->port);
  27.200  
  27.201 -    if ( NULL != monitor->event_sock)
  27.202 -    {
  27.203 -    	g_object_unref( monitor->event_sock );
  27.204 -  	monitor->event_sock = NULL;
  27.205 +    if (NULL != monitor->event_sock) {
  27.206 +        g_object_unref (monitor->event_sock);
  27.207 +        monitor->event_sock = NULL;
  27.208      }
  27.209  
  27.210      /* configure the event socket */
  27.211 -    if (NULL == monitor->event_sock)
  27.212 -    {
  27.213 -        if (!gmyth_connect_to_backend_monitor (monitor))
  27.214 -        {
  27.215 +    if (NULL == monitor->event_sock) {
  27.216 +        if (!gmyth_connect_to_backend_monitor (monitor)) {
  27.217              gmyth_debug ("Connection to backend failed (Event Socket)!");
  27.218              ret = FALSE;
  27.219 +        } else {
  27.220 +            gmyth_debug
  27.221 +                ("Remote monitor event socket had been succesfully created. (io_fd == %d)\n",
  27.222 +                g_io_channel_unix_get_fd (monitor->event_sock->sd_io_ch));
  27.223          }
  27.224 -        else
  27.225 -	{
  27.226 -	    gmyth_debug ( "Remote monitor event socket had been succesfully created. (io_fd == %d)\n", 
  27.227 -	    	g_io_channel_unix_get_fd( monitor->event_sock->sd_io_ch ) );
  27.228 -	}
  27.229 -    } else
  27.230 -    {
  27.231 -    	gmyth_debug ("ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n");
  27.232 +    } else {
  27.233 +        gmyth_debug
  27.234 +            ("ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n");
  27.235      }
  27.236  
  27.237      return ret;
  27.238 @@ -346,77 +335,64 @@
  27.239   */
  27.240  static gint
  27.241  gmyth_monitor_handler_is_backend_message (GMythMonitorHandler * monitor,
  27.242 -                                          GMythStringList * strlist,
  27.243 -                                          gchar ** back_msg_action)
  27.244 +    GMythStringList * strlist, gchar ** back_msg_action)
  27.245  {
  27.246      gint msg_type = GMYTH_BACKEND_NO_MESSAGE;
  27.247      GString *back_msg = NULL;
  27.248  
  27.249 -    if (gmyth_string_list_length (strlist) > 0)
  27.250 -    {
  27.251 +    if (gmyth_string_list_length (strlist) > 0) {
  27.252  
  27.253          back_msg = gmyth_string_list_get_string (strlist, 0);
  27.254          if (back_msg != NULL && back_msg->str != NULL &&
  27.255 -            strstr (back_msg->str, "BACKEND") != NULL)
  27.256 -        {
  27.257 +            strstr (back_msg->str, "BACKEND") != NULL) {
  27.258              gmyth_debug ("MONITOR HANDLER - Received backend message = %s",
  27.259 -                         back_msg->str);
  27.260 +                back_msg->str);
  27.261              *back_msg_action = gmyth_string_list_get_char_array (strlist, 1);
  27.262  
  27.263 -            if (back_msg_action != NULL)
  27.264 -            {
  27.265 +            if (back_msg_action != NULL) {
  27.266  
  27.267                  if (g_strstr_len
  27.268                      (*back_msg_action, strlen (*back_msg_action),
  27.269 -                     "LIVETV_CHAIN")
  27.270 +                        "LIVETV_CHAIN")
  27.271                      || g_strstr_len (*back_msg_action,
  27.272 -                                     strlen (*back_msg_action),
  27.273 -                                     "RECORDING_LIST_CHANGE")
  27.274 +                        strlen (*back_msg_action), "RECORDING_LIST_CHANGE")
  27.275                      || g_strstr_len (*back_msg_action,
  27.276 -                                     strlen (*back_msg_action),
  27.277 -                                     "SCHEDULE_CHANGE")
  27.278 +                        strlen (*back_msg_action), "SCHEDULE_CHANGE")
  27.279                      || g_strstr_len (*back_msg_action,
  27.280 -                                     strlen (*back_msg_action), "LIVETV_WATCH"))
  27.281 -                {
  27.282 +                        strlen (*back_msg_action), "LIVETV_WATCH")) {
  27.283                      gmyth_debug
  27.284                          ("MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s",
  27.285 -                         *back_msg_action);
  27.286 +                        *back_msg_action);
  27.287                      msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED;
  27.288 -                }
  27.289 -                else if (g_strstr_len
  27.290 -                         (*back_msg_action, strlen (*back_msg_action),
  27.291 -                          "DONE_RECORDING"))
  27.292 -                {
  27.293 +                } else if (g_strstr_len
  27.294 +                    (*back_msg_action, strlen (*back_msg_action),
  27.295 +                        "DONE_RECORDING")) {
  27.296                      gmyth_debug
  27.297                          ("MONITOR: message type == GMYTH_BACKEND_DONE_RECORDING, msg = %s",
  27.298 -                         *back_msg_action);
  27.299 +                        *back_msg_action);
  27.300                      msg_type = GMYTH_BACKEND_DONE_RECORDING;
  27.301 -                }
  27.302 -                else if (g_strstr_len
  27.303 -                         (*back_msg_action, strlen (*back_msg_action), "QUIT"))
  27.304 -                {
  27.305 +                } else if (g_strstr_len
  27.306 +                    (*back_msg_action, strlen (*back_msg_action), "QUIT")) {
  27.307                      gmyth_debug
  27.308                          ("MONITOR: message type == GMYTH_BACKEND_STOP_LIVETV, msg = %s",
  27.309 -                         *back_msg_action);
  27.310 +                        *back_msg_action);
  27.311                      msg_type = GMYTH_BACKEND_STOP_LIVETV;
  27.312                  }
  27.313  
  27.314                  /* g_hash_table_insert ( monitor->backend_msgs,
  27.315                     &(monitor->actual_index), *back_msg_action ); */
  27.316  
  27.317 -            } /*  if  */
  27.318 -
  27.319 -        } /* if */
  27.320 -
  27.321 -        if (back_msg != NULL)
  27.322 -        {
  27.323 +            }
  27.324 +            /*  if  */
  27.325 +        }
  27.326 +        /* if */
  27.327 +        if (back_msg != NULL) {
  27.328              g_string_free (back_msg, TRUE);
  27.329              back_msg = NULL;
  27.330          }
  27.331  
  27.332 -    }                           /* if - Does Monitor got any message from backend? */
  27.333 -    else
  27.334 -    {
  27.335 +    } /* if - Does Monitor got any message from backend? */
  27.336 +    else {
  27.337          *back_msg_action = g_strdup ("");
  27.338      }
  27.339  
  27.340 @@ -426,11 +402,11 @@
  27.341  
  27.342  static void
  27.343  gmyth_monitor_handler_default_listener (GMythMonitorHandler * monitor,
  27.344 -                                        gint msg_code, gchar * message)
  27.345 +    gint msg_code, gchar * message)
  27.346  {
  27.347      //assert( message!= NULL );  
  27.348      gmyth_debug ("DEFAULT Signal handler ( msg = %s, code = %d )\n",
  27.349 -                 message, msg_code);
  27.350 +        message, msg_code);
  27.351  }
  27.352  
  27.353  static void
  27.354 @@ -453,76 +429,70 @@
  27.355  {
  27.356      GMythMonitorHandler *monitor = (GMythMonitorHandler *) data;
  27.357      guint recv = 0;
  27.358 -    gboolean *ret = g_new0( gboolean, 1 );
  27.359 +    gboolean *ret = g_new0 (gboolean, 1);
  27.360      gsize len = 0;
  27.361      GIOChannel *io_channel = monitor->event_sock->sd_io_ch;
  27.362 -    GIOCondition io_cond = g_io_channel_get_buffer_condition( io_channel );
  27.363 +    GIOCondition io_cond = g_io_channel_get_buffer_condition (io_channel);
  27.364      static guint count = 0;
  27.365  
  27.366      *ret = TRUE;
  27.367  
  27.368 -    gmyth_debug ( "Entering MONITOR handler listener..." );
  27.369 +    gmyth_debug ("Entering MONITOR handler listener...");
  27.370  
  27.371      myth_control_acquire_context (monitor, TRUE);
  27.372  
  27.373 -    if ((io_cond & G_IO_HUP) != 0)
  27.374 -    {
  27.375 +    if ((io_cond & G_IO_HUP) != 0) {
  27.376          *ret = FALSE;
  27.377          goto clean_up;
  27.378      }
  27.379  
  27.380      GMythStringList *strlist = NULL;
  27.381  
  27.382 -    if (NULL == io_channel)
  27.383 -    {
  27.384 +    if (NULL == io_channel) {
  27.385          gmyth_debug ("Monitor socket is NULL! (GIOChannel)");
  27.386          *ret = FALSE;
  27.387          goto clean_up;
  27.388      }
  27.389  
  27.390 -    while (monitor->allow_msgs_listener)
  27.391 -    {
  27.392 +    while (monitor->allow_msgs_listener) {
  27.393          ++count;
  27.394  
  27.395          gmyth_debug ("%d - Listening on Monitor socket...!\n", count);
  27.396  
  27.397 -        do
  27.398 -        {
  27.399 +        do {
  27.400  
  27.401              gint bytes_sent = 0;
  27.402  
  27.403              strlist = gmyth_string_list_new ();
  27.404  
  27.405 -            if (monitor->event_sock != NULL)
  27.406 -            {
  27.407 +            if (monitor->event_sock != NULL) {
  27.408  
  27.409                  len =
  27.410                      gmyth_socket_read_stringlist (monitor->event_sock, strlist);
  27.411  
  27.412                  if ((len > 0) && strlist != NULL
  27.413 -                    && gmyth_string_list_length (strlist) > 0)
  27.414 -                {
  27.415 -                    bytes_sent = gmyth_string_list_get_int (strlist, 0);        // -1 on backend error
  27.416 +                    && gmyth_string_list_length (strlist) > 0) {
  27.417 +                    bytes_sent = gmyth_string_list_get_int (strlist, 0);    // -1 on backend error
  27.418  
  27.419                      gmyth_debug
  27.420                          ("[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n",
  27.421 -                         __FUNCTION__, len);
  27.422 +                        __FUNCTION__, len);
  27.423  
  27.424                      recv += len;
  27.425  
  27.426                      /* debug purpose: prints out all the string list elements */
  27.427                      g_list_foreach (strlist->glist,
  27.428 -                                    (GFunc) gmyth_monitor_handler_print, NULL);
  27.429 +                        (GFunc) gmyth_monitor_handler_print, NULL);
  27.430  
  27.431                      gchar *back_msg_action = g_new0 (gchar, 1);
  27.432                      gint msg_type =
  27.433                          gmyth_monitor_handler_is_backend_message (monitor,
  27.434 -                                                                  strlist,
  27.435 -                                                                  &back_msg_action);
  27.436 +                        strlist,
  27.437 +                        &back_msg_action);
  27.438  
  27.439                      if (monitor != NULL && msg_type != GMYTH_BACKEND_NO_MESSAGE)
  27.440                          g_signal_emit (monitor, GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id, 0, /* details */
  27.441 -                                       msg_type, back_msg_action);
  27.442 +                            msg_type, back_msg_action);
  27.443  
  27.444                      if (back_msg_action != NULL)
  27.445                          g_free (back_msg_action);
  27.446 @@ -531,29 +501,28 @@
  27.447  
  27.448              }
  27.449  
  27.450 -            if (strlist != NULL)
  27.451 -            {
  27.452 +            if (strlist != NULL) {
  27.453                  g_object_unref (strlist);
  27.454                  strlist = NULL;
  27.455              }
  27.456  
  27.457              io_cond = g_io_channel_get_buffer_condition (io_channel);
  27.458  
  27.459 -	    g_usleep( 500 );
  27.460 +            g_usleep (500);
  27.461  
  27.462          }
  27.463          while (recv <= 0 && ((io_cond & G_IO_HUP) == 0));
  27.464  
  27.465          gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv);
  27.466  
  27.467 -    } /* main GThread while */
  27.468 +    }                           /* main GThread while */
  27.469  
  27.470    clean_up:
  27.471      myth_control_release_context (monitor);
  27.472  
  27.473 -    g_thread_exit( ret );
  27.474 +    g_thread_exit (ret);
  27.475  
  27.476 -    return (gpointer)ret;
  27.477 +    return (gpointer) ret;
  27.478  
  27.479  }
  27.480  
  27.481 @@ -574,9 +543,7 @@
  27.482  
  27.483      /* Connects the socket, send Mythtv ANN Monitor and verify Mythtv protocol version */
  27.484      if (!gmyth_socket_connect_to_backend_events (monitor->event_sock,
  27.485 -                                                 monitor->hostname,
  27.486 -                                                 monitor->port, FALSE))
  27.487 -    {
  27.488 +            monitor->hostname, monitor->port, FALSE)) {
  27.489          g_object_unref (monitor->event_sock);
  27.490          monitor->event_sock = NULL;
  27.491          ret = FALSE;
  27.492 @@ -597,29 +564,26 @@
  27.493   */
  27.494  static gboolean
  27.495  gmyth_monitor_handler_setup (GMythMonitorHandler * monitor,
  27.496 -                             GIOChannel * channel)
  27.497 +    GIOChannel * channel)
  27.498  {
  27.499      gboolean ret = TRUE;
  27.500  
  27.501 -    if (channel != NULL)
  27.502 -    {
  27.503 +    if (channel != NULL) {
  27.504          monitor->allow_msgs_listener = TRUE;
  27.505  
  27.506 -        monitor->th = g_thread_create ( (GThreadFunc)gmyth_monitor_handler_listener,
  27.507 -                                       monitor, TRUE, NULL );
  27.508 -	gmyth_debug( "MONITOR GThread created!" );
  27.509 -    }
  27.510 -    else
  27.511 -    {
  27.512 +        monitor->th =
  27.513 +            g_thread_create ((GThreadFunc) gmyth_monitor_handler_listener,
  27.514 +            monitor, TRUE, NULL);
  27.515 +        gmyth_debug ("MONITOR GThread created!");
  27.516 +    } else {
  27.517          ret = FALSE;
  27.518          goto cleanup;
  27.519      }
  27.520  
  27.521 -    if (NULL == monitor->th)
  27.522 -    {
  27.523 +    if (NULL == monitor->th) {
  27.524          gmyth_debug
  27.525              ("[%s] Error adding GThread listener function to the IO control channel!\n",
  27.526 -             __FUNCTION__);
  27.527 +            __FUNCTION__);
  27.528          ret = FALSE;
  27.529          goto cleanup;
  27.530      }
  27.531 @@ -641,30 +605,26 @@
  27.532  {
  27.533      gboolean ret = TRUE;
  27.534  
  27.535 -    if ( !( ret = g_thread_supported ()) ) 
  27.536 -    {
  27.537 -    	gmyth_debug( "Thread system wasn't initialized, starting NOW!!!" );
  27.538 -    	g_thread_init (NULL);
  27.539 +    if (!(ret = g_thread_supported ())) {
  27.540 +        gmyth_debug ("Thread system wasn't initialized, starting NOW!!!");
  27.541 +        g_thread_init (NULL);
  27.542      }
  27.543  
  27.544      ret = gmyth_monitor_handler_setup (monitor, monitor->event_sock->sd_io_ch);
  27.545 -    if (ret)
  27.546 -    {
  27.547 +    if (ret) {
  27.548          gmyth_debug
  27.549              ("\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n",
  27.550 -             __FUNCTION__, g_thread_self ());
  27.551 -    }
  27.552 -    else
  27.553 -    {
  27.554 +            __FUNCTION__, g_thread_self ());
  27.555 +    } else {
  27.556          gmyth_debug
  27.557              ("\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n",
  27.558 -             __FUNCTION__, g_thread_self ());
  27.559 +            __FUNCTION__, g_thread_self ());
  27.560          ret = FALSE;
  27.561      }
  27.562  
  27.563      gmyth_debug
  27.564          ("[%s] Watch listener function over the IO control channel? %s!!!\n",
  27.565 -         __FUNCTION__, (ret == TRUE ? "YES" : "NO"));
  27.566 +        __FUNCTION__, (ret == TRUE ? "YES" : "NO"));
  27.567  
  27.568      return ret;
  27.569  }
    28.1 --- a/gmyth/src/gmyth_monitor_handler.h	Tue May 22 19:21:42 2007 +0100
    28.2 +++ b/gmyth/src/gmyth_monitor_handler.h	Wed May 23 16:11:29 2007 +0100
    28.3 @@ -10,22 +10,22 @@
    28.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    28.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    28.6   *
    28.7 -          *//*
    28.8 -       * 
    28.9 -       * This program is free software; you can redistribute it and/or modify
   28.10 -       * it under the terms of the GNU Lesser General Public License as published by
   28.11 -       * the Free Software Foundation; either version 2 of the License, or
   28.12 -       * (at your option) any later version.
   28.13 -       *
   28.14 -       * This program is distributed in the hope that it will be useful,
   28.15 -       * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.16 -       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.17 -       * GNU General Public License for more details.
   28.18 -       *
   28.19 -       * You should have received a copy of the GNU Lesser General Public License
   28.20 -       * along with this program; if not, write to the Free Software
   28.21 -       * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   28.22 -       */
   28.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   28.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   28.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   28.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   28.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   28.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   28.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   28.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   28.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   28.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   28.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   28.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   28.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   28.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   28.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   28.39  
   28.40  #ifndef __GMYTH_MONITOR_HANDLER_H__
   28.41  #define __GMYTH_MONITOR_HANDLER_H__
   28.42 @@ -52,62 +52,62 @@
   28.43  #define GMYTH_MONITOR_HANDLER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
   28.44  #define GMYTHTV_MONITOR_HANDLER_READ_ERROR	-314
   28.45      enum
   28.46 -    {
   28.47 -        GMYTH_BACKEND_NO_MESSAGE = 0,
   28.48 -        GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
   28.49 -        GMYTH_BACKEND_DONE_RECORDING,
   28.50 -        GMYTH_BACKEND_STOP_LIVETV
   28.51 -    };
   28.52 +{
   28.53 +    GMYTH_BACKEND_NO_MESSAGE = 0,
   28.54 +    GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
   28.55 +    GMYTH_BACKEND_DONE_RECORDING,
   28.56 +    GMYTH_BACKEND_STOP_LIVETV
   28.57 +};
   28.58  
   28.59  typedef struct _GMythMonitorHandler GMythMonitorHandler;
   28.60  typedef struct _GMythMonitorHandlerClass GMythMonitorHandlerClass;
   28.61  
   28.62  struct _GMythMonitorHandlerClass
   28.63 -    {
   28.64 -        GObjectClass parent_class;
   28.65 +{
   28.66 +    GObjectClass parent_class;
   28.67  
   28.68 -        /* callbacks */
   28.69 -        guint backend_events_handler_signal_id;
   28.70 +    /* callbacks */
   28.71 +    guint backend_events_handler_signal_id;
   28.72  
   28.73 -        /* signal default handlers */
   28.74 -        void (*backend_events_handler) (GMythMonitorHandler * monitor,
   28.75 -                                        gint msg_code, gchar * message);
   28.76 -    };
   28.77 +    /* signal default handlers */
   28.78 +    void (*backend_events_handler) (GMythMonitorHandler * monitor,
   28.79 +        gint msg_code, gchar * message);
   28.80 +};
   28.81  
   28.82  struct _GMythMonitorHandler
   28.83 -    {
   28.84 -        GObject parent;
   28.85 +{
   28.86 +    GObject parent;
   28.87  
   28.88 -        /* MythTV version number */
   28.89 -        gint mythtv_version;
   28.90 +    /* MythTV version number */
   28.91 +    gint mythtv_version;
   28.92  
   28.93 -        /* socket descriptors */
   28.94 -        GMythSocket *event_sock;
   28.95 +    /* socket descriptors */
   28.96 +    GMythSocket *event_sock;
   28.97  
   28.98 -        gpointer (*gmyth_monitor_handler_listener) (gpointer data);
   28.99 +      gpointer (*gmyth_monitor_handler_listener) (gpointer data);
  28.100  
  28.101 -        gchar *hostname;
  28.102 -        gint port;
  28.103 +    gchar *hostname;
  28.104 +    gint port;
  28.105  
  28.106 -        gint64 actual_index;
  28.107 +    gint64 actual_index;
  28.108  
  28.109 -        gboolean allow_msgs_listener;
  28.110 +    gboolean allow_msgs_listener;
  28.111  
  28.112 -        /* stores the messages coming from the backend */
  28.113 -        GHashTable *backend_msgs;
  28.114 +    /* stores the messages coming from the backend */
  28.115 +    GHashTable *backend_msgs;
  28.116  
  28.117 -        GMutex *mutex;
  28.118 -	
  28.119 -	GThread *th;
  28.120 +    GMutex *mutex;
  28.121  
  28.122 -    };
  28.123 +    GThread *th;
  28.124 +
  28.125 +};
  28.126  
  28.127  GType gmyth_monitor_handler_get_type (void);
  28.128  
  28.129  GMythMonitorHandler *gmyth_monitor_handler_new (void);
  28.130  
  28.131  gboolean gmyth_monitor_handler_open (GMythMonitorHandler * monitor,
  28.132 -                                     const gchar * hostname, gint port);
  28.133 +    const gchar * hostname, gint port);
  28.134  
  28.135  gboolean gmyth_monitor_handler_start (GMythMonitorHandler * monitor);
  28.136  
    29.1 --- a/gmyth/src/gmyth_programinfo.c	Tue May 22 19:21:42 2007 +0100
    29.2 +++ b/gmyth/src/gmyth_programinfo.c	Wed May 23 16:11:29 2007 +0100
    29.3 @@ -10,26 +10,26 @@
    29.4   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    29.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    29.6   *
    29.7 - *//*
    29.8 - * 
    29.9 - * This program is free software; you can redistribute it and/or modify
   29.10 - * it under the terms of the GNU Lesser General Public License as published by
   29.11 - * the Free Software Foundation; either version 2 of the License, or
   29.12 - * (at your option) any later version.
   29.13 - *
   29.14 - * This program is distributed in the hope that it will be useful,
   29.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   29.17 - * GNU General Public License for more details.
   29.18 - *
   29.19 - * You should have received a copy of the GNU Lesser General Public License
   29.20 - * along with this program; if not, write to the Free Software
   29.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.22 - *
   29.23 - */
   29.24 - 
   29.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   29.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   29.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   29.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   29.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   29.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   29.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   29.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   29.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   29.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   29.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   29.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   29.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   29.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.40 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   29.41 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   29.42 +
   29.43  #ifdef HAVE_CONFIG_H
   29.44 -    #include "config.h"
   29.45 +#include "config.h"
   29.46  #endif
   29.47  
   29.48  #include <stdlib.h>
   29.49 @@ -40,37 +40,36 @@
   29.50  #include "gmyth_util.h"
   29.51  #include "gmyth_debug.h"
   29.52  
   29.53 -static void gmyth_program_info_class_init   (GMythProgramInfoClass *klass);
   29.54 -static void gmyth_program_info_init         (GMythProgramInfo *object);
   29.55 +static void gmyth_program_info_class_init (GMythProgramInfoClass * klass);
   29.56 +static void gmyth_program_info_init (GMythProgramInfo * object);
   29.57  
   29.58 -static void gmyth_program_info_dispose  (GObject *object);
   29.59 -static void gmyth_program_info_finalize (GObject *object);
   29.60 +static void gmyth_program_info_dispose (GObject * object);
   29.61 +static void gmyth_program_info_finalize (GObject * object);
   29.62  
   29.63 -G_DEFINE_TYPE(GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
   29.64 -    
   29.65 -static const gchar* gmyth_program_info_non_null_value( const GString *str );
   29.66 +G_DEFINE_TYPE (GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
   29.67 +     static const gchar *gmyth_program_info_non_null_value (const GString *
   29.68 +    str);
   29.69  
   29.70 -static void
   29.71 -gmyth_program_info_class_init (GMythProgramInfoClass *klass)
   29.72 +     static void gmyth_program_info_class_init (GMythProgramInfoClass * klass)
   29.73  {
   29.74      GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   29.75 -	
   29.76 -    gobject_class->dispose  = gmyth_program_info_dispose;
   29.77 -    gobject_class->finalize = gmyth_program_info_finalize;	
   29.78 +
   29.79 +    gobject_class->dispose = gmyth_program_info_dispose;
   29.80 +    gobject_class->finalize = gmyth_program_info_finalize;
   29.81  }
   29.82  
   29.83  static void
   29.84 -gmyth_program_info_init (GMythProgramInfo *gmyth_program_info)
   29.85 -{ 
   29.86 +gmyth_program_info_init (GMythProgramInfo * gmyth_program_info)
   29.87 +{
   29.88      gmyth_program_info->chancommfree = 0;
   29.89  
   29.90 -	/** A flag informing if the program has video or not. */    
   29.91 +        /** A flag informing if the program has video or not. */
   29.92      gmyth_program_info->isVideo = FALSE;
   29.93      gmyth_program_info->lenMins = 0;
   29.94 -  
   29.95 +
   29.96      gmyth_program_info->stars = 0.0f;
   29.97      gmyth_program_info->repeat = 0;
   29.98 -  
   29.99 +
  29.100      gmyth_program_info->hasAirDate = FALSE;
  29.101  
  29.102      gmyth_program_info->spread = 0;
  29.103 @@ -80,8 +79,8 @@
  29.104      gmyth_program_info->reactivate = 0;
  29.105  
  29.106      gmyth_program_info->recordid = 0;
  29.107 -    gmyth_program_info->parentid = 0;   
  29.108 -  
  29.109 +    gmyth_program_info->parentid = 0;
  29.110 +
  29.111      /** The backend video source id associated to this program.*/
  29.112      gmyth_program_info->sourceid = 0;
  29.113      /** the backend input id associated to this program.*/
  29.114 @@ -98,140 +97,140 @@
  29.115  
  29.116      gmyth_program_info->recpriority = 0;
  29.117  
  29.118 -	/** The file size of the recorded program.*/
  29.119 +        /** The file size of the recorded program.*/
  29.120      gmyth_program_info->filesize = -1;
  29.121  }
  29.122  
  29.123  static void
  29.124 -gmyth_program_info_dispose  (GObject *object)
  29.125 +gmyth_program_info_dispose (GObject * object)
  29.126  {
  29.127 -    GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object);
  29.128 +    GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO (object);
  29.129  
  29.130 -    if ( gmyth_program_info->chanid != NULL ) {
  29.131 -	g_string_free( gmyth_program_info->chanid, TRUE );
  29.132 -	gmyth_program_info->chanid = NULL;
  29.133 +    if (gmyth_program_info->chanid != NULL) {
  29.134 +        g_string_free (gmyth_program_info->chanid, TRUE);
  29.135 +        gmyth_program_info->chanid = NULL;
  29.136      }
  29.137 -  
  29.138 +
  29.139      /** The program start time. */
  29.140 -    g_free( gmyth_program_info->startts);
  29.141 +    g_free (gmyth_program_info->startts);
  29.142  
  29.143      /** The program end time. */
  29.144 -  	g_free( gmyth_program_info->endts );
  29.145 -  
  29.146 +    g_free (gmyth_program_info->endts);
  29.147 +
  29.148      /** The recording schedule start time. */
  29.149 -  	g_free( gmyth_program_info->recstartts );
  29.150 -  
  29.151 +    g_free (gmyth_program_info->recstartts);
  29.152 +
  29.153      /** The recording schedule end time */
  29.154 -  	g_free(gmyth_program_info->recendts);
  29.155 -  
  29.156 +    g_free (gmyth_program_info->recendts);
  29.157 +
  29.158      /** The program title. */
  29.159 -    if (gmyth_program_info->title != NULL ) {
  29.160 -        g_string_free(gmyth_program_info->title, TRUE);
  29.161 +    if (gmyth_program_info->title != NULL) {
  29.162 +        g_string_free (gmyth_program_info->title, TRUE);
  29.163          gmyth_program_info->title = NULL;
  29.164      }
  29.165 -  
  29.166 +
  29.167      /** The program subtitle. */
  29.168 -    if (gmyth_program_info->subtitle != NULL ) {
  29.169 -        g_string_free(gmyth_program_info->subtitle, TRUE );
  29.170 +    if (gmyth_program_info->subtitle != NULL) {
  29.171 +        g_string_free (gmyth_program_info->subtitle, TRUE);
  29.172          gmyth_program_info->subtitle = NULL;
  29.173      }
  29.174  
  29.175      /** The program description. */
  29.176 -    if ( gmyth_program_info->description != NULL ) {
  29.177 -        g_string_free( gmyth_program_info->description, TRUE );
  29.178 +    if (gmyth_program_info->description != NULL) {
  29.179 +        g_string_free (gmyth_program_info->description, TRUE);
  29.180          gmyth_program_info->description = NULL;
  29.181      }
  29.182 -  	
  29.183 +
  29.184      /** The program category. */
  29.185 -    if ( gmyth_program_info->category != NULL ) {
  29.186 -        g_string_free( gmyth_program_info->category, TRUE );
  29.187 +    if (gmyth_program_info->category != NULL) {
  29.188 +        g_string_free (gmyth_program_info->category, TRUE);
  29.189          gmyth_program_info->category = NULL;
  29.190      }
  29.191 -  
  29.192 -    if ( gmyth_program_info->chanstr != NULL ) {
  29.193 -        g_string_free( gmyth_program_info->chanstr, TRUE );
  29.194 +
  29.195 +    if (gmyth_program_info->chanstr != NULL) {
  29.196 +        g_string_free (gmyth_program_info->chanstr, TRUE);
  29.197          gmyth_program_info->chanstr = NULL;
  29.198      }
  29.199 -    
  29.200 -    if ( gmyth_program_info->chansign != NULL ) {
  29.201 -        g_string_free( gmyth_program_info->chansign, TRUE );
  29.202 +
  29.203 +    if (gmyth_program_info->chansign != NULL) {
  29.204 +        g_string_free (gmyth_program_info->chansign, TRUE);
  29.205          gmyth_program_info->chansign = NULL;
  29.206      }
  29.207 -  
  29.208 +
  29.209      /** The associated channel name. */
  29.210 -    if ( gmyth_program_info->channame != NULL ) {
  29.211 -        g_string_free( gmyth_program_info->channame, TRUE );
  29.212 +    if (gmyth_program_info->channame != NULL) {
  29.213 +        g_string_free (gmyth_program_info->channame, TRUE);
  29.214          gmyth_program_info->channame = NULL;
  29.215      }
  29.216  
  29.217 -    if ( gmyth_program_info->chanOutputFilters != NULL ) {
  29.218 -        g_string_free( gmyth_program_info->chanOutputFilters, TRUE );
  29.219 +    if (gmyth_program_info->chanOutputFilters != NULL) {
  29.220 +        g_string_free (gmyth_program_info->chanOutputFilters, TRUE);
  29.221          gmyth_program_info->chanOutputFilters = NULL;
  29.222      }
  29.223 -  
  29.224 -    if ( gmyth_program_info->seriesid != NULL ) {
  29.225 -        g_string_free( gmyth_program_info->seriesid, TRUE );
  29.226 +
  29.227 +    if (gmyth_program_info->seriesid != NULL) {
  29.228 +        g_string_free (gmyth_program_info->seriesid, TRUE);
  29.229          gmyth_program_info->chanOutputFilters = NULL;
  29.230      }
  29.231 -  
  29.232 +
  29.233      /** The program unique id. */
  29.234 -    if ( gmyth_program_info->programid != NULL ) {
  29.235 -        g_string_free( gmyth_program_info->programid, TRUE );
  29.236 +    if (gmyth_program_info->programid != NULL) {
  29.237 +        g_string_free (gmyth_program_info->programid, TRUE);
  29.238          gmyth_program_info->programid = NULL;
  29.239      }
  29.240 -  
  29.241 -    if ( gmyth_program_info->catType != NULL ) {
  29.242 -        g_string_free( gmyth_program_info->catType, TRUE );
  29.243 +
  29.244 +    if (gmyth_program_info->catType != NULL) {
  29.245 +        g_string_free (gmyth_program_info->catType, TRUE);
  29.246          gmyth_program_info->catType = NULL;
  29.247      }
  29.248  
  29.249 -    if ( gmyth_program_info->sortTitle != NULL ) {
  29.250 -        g_string_free( gmyth_program_info->sortTitle, TRUE );
  29.251 +    if (gmyth_program_info->sortTitle != NULL) {
  29.252 +        g_string_free (gmyth_program_info->sortTitle, TRUE);
  29.253          gmyth_program_info->sortTitle = NULL;
  29.254      }
  29.255 -  
  29.256 -    if ( gmyth_program_info->year != NULL ) {
  29.257 -        g_string_free( gmyth_program_info->year, TRUE );
  29.258 +
  29.259 +    if (gmyth_program_info->year != NULL) {
  29.260 +        g_string_free (gmyth_program_info->year, TRUE);
  29.261          gmyth_program_info->year = NULL;
  29.262      }
  29.263 -  
  29.264 -    g_free( gmyth_program_info->originalAirDate);
  29.265 -    
  29.266 -    g_free( gmyth_program_info->lastmodified );
  29.267 -  
  29.268 -    g_free( gmyth_program_info->lastInUseTime );
  29.269 -  
  29.270 -    if ( gmyth_program_info->schedulerid != NULL ) {
  29.271 -        g_string_free( gmyth_program_info->schedulerid, TRUE );
  29.272 +
  29.273 +    g_free (gmyth_program_info->originalAirDate);
  29.274 +
  29.275 +    g_free (gmyth_program_info->lastmodified);
  29.276 +
  29.277 +    g_free (gmyth_program_info->lastInUseTime);
  29.278 +
  29.279 +    if (gmyth_program_info->schedulerid != NULL) {
  29.280 +        g_string_free (gmyth_program_info->schedulerid, TRUE);
  29.281          gmyth_program_info->schedulerid = NULL;
  29.282      }
  29.283  
  29.284 -    if ( gmyth_program_info->recgroup != NULL ) {
  29.285 -        g_string_free( gmyth_program_info->recgroup, TRUE );
  29.286 +    if (gmyth_program_info->recgroup != NULL) {
  29.287 +        g_string_free (gmyth_program_info->recgroup, TRUE);
  29.288          gmyth_program_info->recgroup = NULL;
  29.289      }
  29.290 -  
  29.291 -    if ( gmyth_program_info->playgroup != NULL ) {
  29.292 -        g_string_free( gmyth_program_info->playgroup, TRUE );
  29.293 +
  29.294 +    if (gmyth_program_info->playgroup != NULL) {
  29.295 +        g_string_free (gmyth_program_info->playgroup, TRUE);
  29.296          gmyth_program_info->playgroup = NULL;
  29.297      }
  29.298 -  
  29.299 +
  29.300      /** The file name of the recorded program.*/
  29.301 -    if ( gmyth_program_info->pathname != NULL) {
  29.302 -        g_string_free( gmyth_program_info->pathname, TRUE );
  29.303 +    if (gmyth_program_info->pathname != NULL) {
  29.304 +        g_string_free (gmyth_program_info->pathname, TRUE);
  29.305          gmyth_program_info->pathname = NULL;
  29.306      }
  29.307  
  29.308 -    if ( gmyth_program_info->hostname != NULL ) {
  29.309 -        g_string_free( gmyth_program_info->hostname, TRUE );
  29.310 +    if (gmyth_program_info->hostname != NULL) {
  29.311 +        g_string_free (gmyth_program_info->hostname, TRUE);
  29.312          gmyth_program_info->hostname = NULL;
  29.313      }
  29.314 -   
  29.315 -	G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
  29.316 +
  29.317 +    G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
  29.318  }
  29.319  
  29.320  static void
  29.321 -gmyth_program_info_finalize (GObject *object)
  29.322 +gmyth_program_info_finalize (GObject * object)
  29.323  {
  29.324      g_signal_handlers_destroy (object);
  29.325  
  29.326 @@ -243,11 +242,11 @@
  29.327   * 
  29.328   * @return a new instance of GMythProgramInfo.
  29.329   */
  29.330 -GMythProgramInfo*
  29.331 +GMythProgramInfo *
  29.332  gmyth_program_info_new (void)
  29.333  {
  29.334 -    GMythProgramInfo *program_info = 
  29.335 -        GMYTH_PROGRAM_INFO (g_object_new(GMYTH_PROGRAM_INFO_TYPE, NULL));
  29.336 +    GMythProgramInfo *program_info =
  29.337 +        GMYTH_PROGRAM_INFO (g_object_new (GMYTH_PROGRAM_INFO_TYPE, NULL));
  29.338  
  29.339      return program_info;
  29.340  }
  29.341 @@ -262,71 +261,68 @@
  29.342   * 
  29.343   * @return a GMythStringList with the program info fields.
  29.344   */
  29.345 -GMythStringList*
  29.346 -gmyth_program_info_to_string_list (GMythProgramInfo *prog, GMythStringList *slist)
  29.347 +GMythStringList *
  29.348 +gmyth_program_info_to_string_list (GMythProgramInfo * prog,
  29.349 +    GMythStringList * slist)
  29.350  {
  29.351      g_return_val_if_fail (prog != NULL, NULL);
  29.352      g_return_val_if_fail (slist != NULL, NULL);
  29.353  
  29.354 -    gmyth_string_list_append_string (slist, prog->title); /* 0 */
  29.355 -    gmyth_string_list_append_string (slist, prog->subtitle); /* 1 */
  29.356 +    gmyth_string_list_append_string (slist, prog->title);   /* 0 */
  29.357 +    gmyth_string_list_append_string (slist, prog->subtitle);    /* 1 */
  29.358      gmyth_string_list_append_string (slist, prog->description); /* 2 */
  29.359 -    gmyth_string_list_append_string (slist, prog->category); /* 3 */
  29.360 -    gmyth_string_list_append_string (slist, prog->chanid); /* 4 */
  29.361 +    gmyth_string_list_append_string (slist, prog->category);    /* 3 */
  29.362 +    gmyth_string_list_append_string (slist, prog->chanid);  /* 4 */
  29.363      gmyth_string_list_append_string (slist, prog->chanstr); /* 5 */
  29.364 -    gmyth_string_list_append_string (slist, prog->chansign); /* 6 */
  29.365 -    gmyth_string_list_append_string (slist, prog->channame); /* 7 */
  29.366 -    gmyth_string_list_append_string (slist, prog->pathname); /* 8 */
  29.367 -    gmyth_string_list_append_int64 (slist, 0); /* 9 */
  29.368 +    gmyth_string_list_append_string (slist, prog->chansign);    /* 6 */
  29.369 +    gmyth_string_list_append_string (slist, prog->channame);    /* 7 */
  29.370 +    gmyth_string_list_append_string (slist, prog->pathname);    /* 8 */
  29.371 +    gmyth_string_list_append_int64 (slist, 0);  /* 9 */
  29.372  
  29.373      // fixme
  29.374      //gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
  29.375      //gmyth_string_list_append_int (slist, 0); /* 10 */
  29.376  
  29.377      if (prog->startts)
  29.378 -        gmyth_string_list_append_int (slist, prog->startts->tv_sec);  /* 11 */ //DATETIME_TO_LIST(startts)
  29.379 +        gmyth_string_list_append_int (slist, prog->startts->tv_sec);    /* 11 *///DATETIME_TO_LIST(startts)
  29.380      else
  29.381 -	    gmyth_string_list_append_int (slist, 0);
  29.382 -    
  29.383 +        gmyth_string_list_append_int (slist, 0);
  29.384 +
  29.385      if (prog->endts)
  29.386 -        gmyth_string_list_append_int (slist, prog->endts->tv_sec);  /* 12 */ //DATETIME_TO_LIST(endts)
  29.387 +        gmyth_string_list_append_int (slist, prog->endts->tv_sec);  /* 12 *///DATETIME_TO_LIST(endts)
  29.388      else
  29.389 -    	gmyth_string_list_append_int (slist, 0);
  29.390 +        gmyth_string_list_append_int (slist, 0);
  29.391  
  29.392 -    gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
  29.393 -    gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
  29.394 +    gmyth_string_list_append_int (slist, prog->duplicate);  /* 13 */
  29.395 +    gmyth_string_list_append_int (slist, prog->shareable);  /* 14 */
  29.396      gmyth_string_list_append_int (slist, prog->findid); /* 15 */
  29.397 -    gmyth_string_list_append_string (slist, prog->hostname); /* 16 */
  29.398 -    gmyth_string_list_append_int (slist, prog->sourceid); /* 17 */
  29.399 +    gmyth_string_list_append_string (slist, prog->hostname);    /* 16 */
  29.400 +    gmyth_string_list_append_int (slist, prog->sourceid);   /* 17 */
  29.401      gmyth_string_list_append_int (slist, prog->cardid); /* 18 */
  29.402 -    gmyth_string_list_append_int (slist, prog->inputid); /* 19 */
  29.403 -    gmyth_string_list_append_int (slist, prog->recpriority); /* 20 */
  29.404 -    gmyth_string_list_append_int (slist, 0 /*prog->recstatus*/); /* 21 */
  29.405 -    gmyth_string_list_append_int (slist, prog->recordid); /* 22 */
  29.406 -    gmyth_string_list_append_int (slist, 0 /*prog->rectype*/); /* 23 */
  29.407 -    gmyth_string_list_append_int (slist, 0 /*prog->dupin*/); /* 24 */
  29.408 -    gmyth_string_list_append_int (slist, 0 /*prog->dupmethod*/); /* 25 */
  29.409 -    gmyth_string_list_append_int (slist, 
  29.410 -            prog->recstartts != NULL ? prog->recstartts->tv_sec : 0);  /* 26 */ //DATETIME_TO_LIST(recstartts)
  29.411 -    gmyth_string_list_append_int (slist, 
  29.412 -            prog->recendts != NULL ? prog->recendts->tv_sec : 0);  /* 27 */ //DATETIME_TO_LIST(recendts)
  29.413 +    gmyth_string_list_append_int (slist, prog->inputid);    /* 19 */
  29.414 +    gmyth_string_list_append_int (slist, prog->recpriority);    /* 20 */
  29.415 +    gmyth_string_list_append_int (slist, 0 /*prog->recstatus */ );  /* 21 */
  29.416 +    gmyth_string_list_append_int (slist, prog->recordid);   /* 22 */
  29.417 +    gmyth_string_list_append_int (slist, 0 /*prog->rectype */ );    /* 23 */
  29.418 +    gmyth_string_list_append_int (slist, 0 /*prog->dupin */ );  /* 24 */
  29.419 +    gmyth_string_list_append_int (slist, 0 /*prog->dupmethod */ );  /* 25 */
  29.420 +    gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0);  /* 26 *///DATETIME_TO_LIST(recstartts)
  29.421 +    gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0);  /* 27 *///DATETIME_TO_LIST(recendts)
  29.422      gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
  29.423 -    gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
  29.424 -    gmyth_string_list_append_char_array (slist, "Default"); /* 30 */ //prog->(recgroup != "") ? recgroup : "Default")
  29.425 -    gmyth_string_list_append_int (slist, prog->chancommfree); /* 31 */
  29.426 -    gmyth_string_list_append_string (slist, prog->chanOutputFilters); /* 32 */
  29.427 -    gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
  29.428 -    gmyth_string_list_append_string (slist, prog->programid); /* 34 */
  29.429 -    gmyth_string_list_append_char_array (slist, ""); /* 35 */
  29.430 -    gmyth_string_list_append_int (slist, 
  29.431 -            prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0);  /* 36 */ //DATETIME_TO_LIST(lastmodified)
  29.432 -    gmyth_string_list_append_int (slist, 0);  /* 37 */ //FLOAT_TO_LIST(stars)
  29.433 -    gmyth_string_list_append_int (slist, 
  29.434 -            prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0);  /* 38 */ //DATETIME_TO_LIST(QDateTime(originalAirDate))
  29.435 +    gmyth_string_list_append_int (slist, prog->programflags);   /* 29 */
  29.436 +    gmyth_string_list_append_char_array (slist, "Default"); /* 30 *///prog->(recgroup != "") ? recgroup : "Default")
  29.437 +    gmyth_string_list_append_int (slist, prog->chancommfree);   /* 31 */
  29.438 +    gmyth_string_list_append_string (slist, prog->chanOutputFilters);   /* 32 */
  29.439 +    gmyth_string_list_append_string (slist, prog->seriesid);    /* 33 */
  29.440 +    gmyth_string_list_append_string (slist, prog->programid);   /* 34 */
  29.441 +    gmyth_string_list_append_char_array (slist, "");    /* 35 */
  29.442 +    gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0);  /* 36 *///DATETIME_TO_LIST(lastmodified)
  29.443 +    gmyth_string_list_append_int (slist, 0);    /* 37 *///FLOAT_TO_LIST(stars)
  29.444 +    gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0);    /* 38 *///DATETIME_TO_LIST(QDateTime(originalAirDate))
  29.445      gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
  29.446 -    gmyth_string_list_append_char_array (slist, "Default");  /* 40 */ //prog->(playgroup != "") ? playgroup : "Default")
  29.447 -    gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
  29.448 -   
  29.449 +    gmyth_string_list_append_char_array (slist, "Default"); /* 40 *///prog->(playgroup != "") ? playgroup : "Default")
  29.450 +    gmyth_string_list_append_int (slist, prog->recpriority2);   /* 41 */
  29.451 +
  29.452      return slist;
  29.453  }
  29.454  
  29.455 @@ -338,76 +334,71 @@
  29.456   * 
  29.457   * @return a GMythProgramInfo representing the string list got from network.
  29.458   */
  29.459 -GMythProgramInfo*
  29.460 -gmyth_program_info_from_string_list_from_pos ( GMythStringList *slist, guint pos )
  29.461 +GMythProgramInfo *
  29.462 +gmyth_program_info_from_string_list_from_pos (GMythStringList * slist,
  29.463 +    guint pos)
  29.464  {
  29.465 -    GMythProgramInfo *prog = gmyth_program_info_new();
  29.466 +    GMythProgramInfo *prog = gmyth_program_info_new ();
  29.467  
  29.468 -    g_return_val_if_fail (slist != NULL && 
  29.469 -            gmyth_string_list_get_string (slist, pos) != NULL, NULL);
  29.470 +    g_return_val_if_fail (slist != NULL &&
  29.471 +        gmyth_string_list_get_string (slist, pos) != NULL, NULL);
  29.472  
  29.473 -    prog->title = gmyth_string_list_get_string (slist, pos);    
  29.474 -    prog->subtitle = gmyth_string_list_get_string (slist, pos+1);
  29.475 -    prog->description = gmyth_string_list_get_string (slist, pos+2);
  29.476 -    prog->category = gmyth_string_list_get_string (slist, pos+3);
  29.477 -    prog->chanid = gmyth_string_list_get_string (slist, pos+4);
  29.478 -    prog->channame = gmyth_string_list_get_string (slist, pos+5);
  29.479 -    prog->chanstr = gmyth_string_list_get_string (slist, pos+6);    
  29.480 -    prog->chansign = gmyth_string_list_get_string (slist, pos+7);    
  29.481 -    prog->pathname = gmyth_string_list_get_string (slist, pos+8);
  29.482 -    
  29.483 -    prog->filesize = gmyth_string_list_get_int64 (slist, pos+9);
  29.484 -    
  29.485 -    gmyth_debug( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n", 
  29.486 -                gmyth_program_info_non_null_value( prog->title ), 
  29.487 -                gmyth_program_info_non_null_value( prog->subtitle ), 
  29.488 -                gmyth_program_info_non_null_value( prog->description ), 
  29.489 -                gmyth_program_info_non_null_value( prog->category ), 
  29.490 -                gmyth_program_info_non_null_value( prog->chanid ), 
  29.491 -                gmyth_program_info_non_null_value( prog->channame ), 
  29.492 -                gmyth_program_info_non_null_value( prog->chanstr ), 
  29.493 -                gmyth_program_info_non_null_value( prog->chansign ), 
  29.494 -                gmyth_program_info_non_null_value( prog->pathname ), 
  29.495 -                gmyth_string_list_get_int (slist, pos+11) );    
  29.496 -    
  29.497 -    prog->startts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.498 -                        (time_t)gmyth_string_list_get_int (slist, pos+11) ))->str ); //DATETIME_TO_LIST(startts)
  29.499 -    prog->endts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.500 -                        (time_t)gmyth_string_list_get_int (slist, pos+12) ))->str ); //DATETIME_TO_LIST(endts)
  29.501 -    prog->duplicate = gmyth_string_list_get_int (slist, pos+13);
  29.502 -    prog->shareable = gmyth_string_list_get_int (slist, pos+14);
  29.503 -    prog->findid = gmyth_string_list_get_int (slist, pos+15);
  29.504 -    prog->hostname = gmyth_string_list_get_string (slist, pos+16);
  29.505 -    prog->sourceid = gmyth_string_list_get_int (slist, pos+17);
  29.506 -    prog->cardid = gmyth_string_list_get_int (slist, pos+18);
  29.507 -    prog->inputid = gmyth_string_list_get_int (slist, pos+19);
  29.508 -    prog->recpriority = gmyth_string_list_get_int (slist, pos+20);
  29.509 -    prog->reactivate = gmyth_string_list_get_int (slist, pos+21);
  29.510 -    prog->recordid = gmyth_string_list_get_int (slist, pos+22);
  29.511 -    gmyth_string_list_get_int (slist, pos+23);
  29.512 -    gmyth_string_list_get_int (slist, pos+24);
  29.513 -    gmyth_string_list_get_int (slist, pos+25);
  29.514 -    prog->recstartts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.515 -                        (time_t)gmyth_string_list_get_int (slist, pos+26) ))->str ); //DATETIME_TO_LIST(recstartts)
  29.516 -    prog->recendts = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.517 -                        (time_t)gmyth_string_list_get_int (slist, pos+27) ))->str ); //DATETIME_TO_LIST(recendts)
  29.518 -    prog->repeat = gmyth_string_list_get_int (slist, pos+28);
  29.519 -    prog->programflags = gmyth_string_list_get_int (slist, pos+29);
  29.520 -    prog->recgroup = gmyth_string_list_get_string (slist, pos+30); //prog->(recgroup != "") ? recgroup : "Default")
  29.521 -    prog->chancommfree = gmyth_string_list_get_int (slist, pos+31);
  29.522 -    prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos+32);
  29.523 -    prog->seriesid = gmyth_string_list_get_string (slist, pos+33);
  29.524 -    prog->programid = gmyth_string_list_get_string (slist, pos+34);
  29.525 -    gmyth_string_list_get_string (slist, pos+35);
  29.526 -    prog->lastmodified = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.527 -                        (time_t)gmyth_string_list_get_int (slist, pos+36) ))->str ); //DATETIME_TO_LIST(lastmodified)
  29.528 -    gmyth_string_list_get_int (slist, pos+37); //FLOAT_TO_LIST(stars)
  29.529 -    prog->originalAirDate = gmyth_util_string_to_time_val( (gmyth_util_time_to_isoformat( 
  29.530 -                        (time_t)gmyth_string_list_get_int (slist, pos+38) ))->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
  29.531 -    prog->hasAirDate = gmyth_string_list_get_int (slist, pos+39);
  29.532 -    prog->playgroup = gmyth_string_list_get_string (slist, pos+40); //prog->(playgroup != "") ? playgroup : "Default")
  29.533 -    prog->recpriority2 = gmyth_string_list_get_int (slist, pos+41);
  29.534 -   
  29.535 +    prog->title = gmyth_string_list_get_string (slist, pos);
  29.536 +    prog->subtitle = gmyth_string_list_get_string (slist, pos + 1);
  29.537 +    prog->description = gmyth_string_list_get_string (slist, pos + 2);
  29.538 +    prog->category = gmyth_string_list_get_string (slist, pos + 3);
  29.539 +    prog->chanid = gmyth_string_list_get_string (slist, pos + 4);
  29.540 +    prog->channame = gmyth_string_list_get_string (slist, pos + 5);
  29.541 +    prog->chanstr = gmyth_string_list_get_string (slist, pos + 6);
  29.542 +    prog->chansign = gmyth_string_list_get_string (slist, pos + 7);
  29.543 +    prog->pathname = gmyth_string_list_get_string (slist, pos + 8);
  29.544 +
  29.545 +    prog->filesize = gmyth_string_list_get_int64 (slist, pos + 9);
  29.546 +
  29.547 +    gmyth_debug ("Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n",
  29.548 +        gmyth_program_info_non_null_value (prog->title),
  29.549 +        gmyth_program_info_non_null_value (prog->subtitle),
  29.550 +        gmyth_program_info_non_null_value (prog->description),
  29.551 +        gmyth_program_info_non_null_value (prog->category),
  29.552 +        gmyth_program_info_non_null_value (prog->chanid),
  29.553 +        gmyth_program_info_non_null_value (prog->channame),
  29.554 +        gmyth_program_info_non_null_value (prog->chanstr),
  29.555 +        gmyth_program_info_non_null_value (prog->chansign),
  29.556 +        gmyth_program_info_non_null_value (prog->pathname),
  29.557 +        gmyth_string_list_get_int (slist, pos + 11));
  29.558 +
  29.559 +    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)
  29.560 +    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)
  29.561 +    prog->duplicate = gmyth_string_list_get_int (slist, pos + 13);
  29.562 +    prog->shareable = gmyth_string_list_get_int (slist, pos + 14);
  29.563 +    prog->findid = gmyth_string_list_get_int (slist, pos + 15);
  29.564 +    prog->hostname = gmyth_string_list_get_string (slist, pos + 16);
  29.565 +    prog->sourceid = gmyth_string_list_get_int (slist, pos + 17);
  29.566 +    prog->cardid = gmyth_string_list_get_int (slist, pos + 18);
  29.567 +    prog->inputid = gmyth_string_list_get_int (slist, pos + 19);
  29.568 +    prog->recpriority = gmyth_string_list_get_int (slist, pos + 20);
  29.569 +    prog->reactivate = gmyth_string_list_get_int (slist, pos + 21);
  29.570 +    prog->recordid = gmyth_string_list_get_int (slist, pos + 22);
  29.571 +    gmyth_string_list_get_int (slist, pos + 23);
  29.572 +    gmyth_string_list_get_int (slist, pos + 24);
  29.573 +    gmyth_string_list_get_int (slist, pos + 25);
  29.574 +    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)
  29.575 +    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)
  29.576 +    prog->repeat = gmyth_string_list_get_int (slist, pos + 28);
  29.577 +    prog->programflags = gmyth_string_list_get_int (slist, pos + 29);
  29.578 +    prog->recgroup = gmyth_string_list_get_string (slist, pos + 30);    //prog->(recgroup != "") ? recgroup : "Default")
  29.579 +    prog->chancommfree = gmyth_string_list_get_int (slist, pos + 31);
  29.580 +    prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos + 32);
  29.581 +    prog->seriesid = gmyth_string_list_get_string (slist, pos + 33);
  29.582 +    prog->programid = gmyth_string_list_get_string (slist, pos + 34);
  29.583 +    gmyth_string_list_get_string (slist, pos + 35);
  29.584 +    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)
  29.585 +    gmyth_string_list_get_int (slist, pos + 37);    //FLOAT_TO_LIST(stars)
  29.586 +    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))
  29.587 +    prog->hasAirDate = gmyth_string_list_get_int (slist, pos + 39);
  29.588 +    prog->playgroup = gmyth_string_list_get_string (slist, pos + 40);   //prog->(playgroup != "") ? playgroup : "Default")
  29.589 +    prog->recpriority2 = gmyth_string_list_get_int (slist, pos + 41);
  29.590 +
  29.591      return prog;
  29.592  }
  29.593  
  29.594 @@ -418,15 +409,15 @@
  29.595   * 
  29.596   * @return a GMythProgramInfo representing the string list got from network.
  29.597   */
  29.598 -GMythProgramInfo*
  29.599 -gmyth_program_info_from_string_list ( GMythStringList *slist )
  29.600 +GMythProgramInfo *
  29.601 +gmyth_program_info_from_string_list (GMythStringList * slist)
  29.602  {
  29.603      GMythProgramInfo *prog = NULL;
  29.604  
  29.605      g_return_val_if_fail (slist != NULL, NULL);
  29.606 -    
  29.607 -    prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 );
  29.608 -   
  29.609 +
  29.610 +    prog = gmyth_program_info_from_string_list_from_pos (slist, 0);
  29.611 +
  29.612      return prog;
  29.613  }
  29.614  
  29.615 @@ -437,51 +428,52 @@
  29.616   * 
  29.617   * @return a GMythProgramInfo representing the string list got from network.
  29.618   */
  29.619 -GMythProgramInfo*
  29.620 -gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist )
  29.621 +GMythProgramInfo *
  29.622 +gmyth_program_info_from_string_list_next_prog (GMythStringList * slist)
  29.623  {
  29.624 -    GMythProgramInfo *prog = gmyth_program_info_new();
  29.625 +    GMythProgramInfo *prog = gmyth_program_info_new ();
  29.626  
  29.627      g_return_val_if_fail (slist != NULL, NULL);
  29.628 -    
  29.629 +
  29.630      /*    
  29.631 -    {Home Improvement[]:[]No, No, Godot[]:[]
  29.632 -     US sitcom about a DIY-obsessed father of three. When 
  29.633 -     Tim tries to sell off his extra ticket for an ice hockey game, he is arrested as a tout.[]:[]
  29.634 -     Sitcom[]:[]2007-04-18T15:30:00[]:[]2007-04-18T16:00:00[]:[]ABC1[]:[]
  29.635 -     /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] }
  29.636 -    */
  29.637 +       {Home Improvement[]:[]No, No, Godot[]:[]
  29.638 +       US sitcom about a DIY-obsessed father of three. When 
  29.639 +       Tim tries to sell off his extra ticket for an ice hockey game, he is arrested as a tout.[]:[]
  29.640 +       Sitcom[]:[]2007-04-18T15:30:00[]:[]2007-04-18T16:00:00[]:[]ABC1[]:[]
  29.641 +       /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] }
  29.642 +     */
  29.643  
  29.644      prog->title = gmyth_string_list_get_string (slist, 0);
  29.645      prog->subtitle = gmyth_string_list_get_string (slist, 1);
  29.646      prog->description = gmyth_string_list_get_string (slist, 2);
  29.647      prog->category = gmyth_string_list_get_string (slist, 3);
  29.648 -    prog->startts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 4) ); //DATETIME_TO_LIST(startts)
  29.649 -    prog->endts = gmyth_util_string_to_time_val( gmyth_string_list_get_char_array (slist, 5) ); //DATETIME_TO_LIST(endts)
  29.650 +    prog->startts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 4));    //DATETIME_TO_LIST(startts)
  29.651 +    prog->endts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 5));  //DATETIME_TO_LIST(endts)
  29.652      prog->channame = gmyth_string_list_get_string (slist, 6);
  29.653      prog->chansign = gmyth_string_list_get_string (slist, 7);
  29.654 -    prog->chanstr = gmyth_string_list_get_string (slist, 8);    
  29.655 +    prog->chanstr = gmyth_string_list_get_string (slist, 8);
  29.656      prog->chanid = gmyth_string_list_get_string (slist, 9);
  29.657      prog->filesize = gmyth_string_list_get_int64 (slist, 10);
  29.658 -        
  29.659 -    gmyth_debug( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n", 
  29.660 -                gmyth_program_info_non_null_value( prog->title ), 
  29.661 -                gmyth_program_info_non_null_value( prog->subtitle ), 
  29.662 -                gmyth_program_info_non_null_value( prog->description ), 
  29.663 -                gmyth_program_info_non_null_value( prog->category ), 
  29.664 -                gmyth_program_info_non_null_value( prog->chanid ), 
  29.665 -                gmyth_program_info_non_null_value( prog->channame ), 
  29.666 -                gmyth_program_info_non_null_value( prog->chanstr ), 
  29.667 -                gmyth_program_info_non_null_value( prog->chansign ), 
  29.668 -                gmyth_program_info_non_null_value( prog->pathname ) );    
  29.669 -    
  29.670 +
  29.671 +    gmyth_debug ("NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n",
  29.672 +        gmyth_program_info_non_null_value (prog->title),
  29.673 +        gmyth_program_info_non_null_value (prog->subtitle),
  29.674 +        gmyth_program_info_non_null_value (prog->description),
  29.675 +        gmyth_program_info_non_null_value (prog->category),
  29.676 +        gmyth_program_info_non_null_value (prog->chanid),
  29.677 +        gmyth_program_info_non_null_value (prog->channame),
  29.678 +        gmyth_program_info_non_null_value (prog->chanstr),
  29.679 +        gmyth_program_info_non_null_value (prog->chansign),
  29.680 +        gmyth_program_info_non_null_value (prog->pathname));
  29.681 +
  29.682      return prog;
  29.683  }
  29.684  
  29.685 -static const gchar*
  29.686 -gmyth_program_info_non_null_value( const GString *str )
  29.687 +static const gchar *
  29.688 +gmyth_program_info_non_null_value (const GString * str)
  29.689  {
  29.690 -	return ( str != NULL && str->str != NULL && strlen( str->str ) > 0 ? str->str : " " );
  29.691 +    return (str != NULL && str->str != NULL
  29.692 +        && strlen (str->str) > 0 ? str->str : " ");
  29.693  }
  29.694  
  29.695  /**
  29.696 @@ -491,52 +483,45 @@
  29.697   * 
  29.698   * @return a string representing the program info.
  29.699   */
  29.700 -const gchar*
  29.701 -gmyth_program_info_to_string( const GMythProgramInfo* prog )
  29.702 +const gchar *
  29.703 +gmyth_program_info_to_string (const GMythProgramInfo * prog)
  29.704  {
  29.705 -    return g_strdup_printf( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "\
  29.706 -        "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"\
  29.707 -        "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "\
  29.708 -        "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"\
  29.709 -        "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "\
  29.710 -        "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"\
  29.711 +    return
  29.712 +        g_strdup_printf
  29.713 +        ("Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "
  29.714 +        "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"
  29.715 +        "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "
  29.716 +        "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"
  29.717 +        "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "
  29.718 +        "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"
  29.719          "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
  29.720 -        "Play Group: %s.\n", 
  29.721 -        gmyth_program_info_non_null_value( prog->title ), 
  29.722 -        gmyth_program_info_non_null_value( prog->subtitle ),    
  29.723 -        gmyth_program_info_non_null_value( prog->description ),
  29.724 -        gmyth_program_info_non_null_value( prog->category ),
  29.725 -		gmyth_program_info_non_null_value( prog->chanid ),
  29.726 -        gmyth_program_info_non_null_value( prog->channame ),
  29.727 -        gmyth_program_info_non_null_value( prog->chanstr ),    
  29.728 -        gmyth_program_info_non_null_value( prog->chansign ),    
  29.729 -        gmyth_program_info_non_null_value( prog->pathname ),
  29.730 -        prog->filesize,
  29.731 -        gmyth_util_time_to_string_from_time_val( prog->startts), 
  29.732 -        gmyth_util_time_to_string_from_time_val( prog->endts), 
  29.733 -        prog->duplicate,
  29.734 -        prog->shareable,
  29.735 -        prog->findid,
  29.736 -        gmyth_program_info_non_null_value( prog->hostname ),
  29.737 -        prog->sourceid,
  29.738 -        prog->cardid,
  29.739 -        prog->inputid,
  29.740 -        prog->recpriority,
  29.741 -        prog->reactivate,
  29.742 +        "Play Group: %s.\n",
  29.743 +        gmyth_program_info_non_null_value (prog->title),
  29.744 +        gmyth_program_info_non_null_value (prog->subtitle),
  29.745 +        gmyth_program_info_non_null_value (prog->description),
  29.746 +        gmyth_program_info_non_null_value (prog->category),
  29.747 +        gmyth_program_info_non_null_value (prog->chanid),
  29.748 +        gmyth_program_info_non_null_value (prog->channame),
  29.749 +        gmyth_program_info_non_null_value (prog->chanstr),
  29.750 +        gmyth_program_info_non_null_value (prog->chansign),
  29.751 +        gmyth_program_info_non_null_value (prog->pathname), prog->filesize,
  29.752 +        gmyth_util_time_to_string_from_time_val (prog->startts),
  29.753 +        gmyth_util_time_to_string_from_time_val (prog->endts),
  29.754 +        prog->duplicate, prog->shareable, prog->findid,
  29.755 +        gmyth_program_info_non_null_value (prog->hostname), prog->sourceid,
  29.756 +        prog->cardid, prog->inputid, prog->recpriority, prog->reactivate,
  29.757          prog->recordid,
  29.758 -        gmyth_util_time_to_string_from_time_val(prog->recstartts),
  29.759 -        gmyth_util_time_to_string_from_time_val(prog->recendts),
  29.760 -        prog->repeat,
  29.761 -        prog->programflags,
  29.762 -        gmyth_program_info_non_null_value( prog->recgroup ),
  29.763 +        gmyth_util_time_to_string_from_time_val (prog->recstartts),
  29.764 +        gmyth_util_time_to_string_from_time_val (prog->recendts),
  29.765 +        prog->repeat, prog->programflags,
  29.766 +        gmyth_program_info_non_null_value (prog->recgroup),
  29.767          prog->chancommfree,
  29.768 -        gmyth_program_info_non_null_value( prog->chanOutputFilters ),
  29.769 -        gmyth_program_info_non_null_value( prog->seriesid ),
  29.770 -        gmyth_program_info_non_null_value( prog->programid ),
  29.771 -        gmyth_util_time_to_string_from_time_val(prog->lastmodified),
  29.772 -        gmyth_util_time_to_string_from_time_val(prog->originalAirDate),
  29.773 -        prog->hasAirDate,
  29.774 -        gmyth_program_info_non_null_value(prog->playgroup) );
  29.775 +        gmyth_program_info_non_null_value (prog->chanOutputFilters),
  29.776 +        gmyth_program_info_non_null_value (prog->seriesid),
  29.777 +        gmyth_program_info_non_null_value (prog->programid),
  29.778 +        gmyth_util_time_to_string_from_time_val (prog->lastmodified),
  29.779 +        gmyth_util_time_to_string_from_time_val (prog->originalAirDate),
  29.780 +        prog->hasAirDate, gmyth_program_info_non_null_value (prog->playgroup));
  29.781  }
  29.782  
  29.783  /**
  29.784 @@ -548,14 +533,17 @@
  29.785   * @return <code>true</code>, if the program infos are equals.
  29.786   */
  29.787  gboolean
  29.788 -gmyth_program_info_is_equals( const GMythProgramInfo* prog1, const GMythProgramInfo* prog2 )
  29.789 +gmyth_program_info_is_equals (const GMythProgramInfo * prog1,
  29.790 +    const GMythProgramInfo * prog2)
  29.791  {
  29.792 -    if ( ( strcmp( gmyth_program_info_non_null_value( prog1->title ), 
  29.793 -            gmyth_program_info_non_null_value( prog2->title ) ) == 0 ) ||
  29.794 -         ( strcmp( gmyth_program_info_non_null_value( prog1->pathname ), 
  29.795 -            gmyth_program_info_non_null_value( prog2->pathname ) ) == 0 ) )
  29.796 +    if ((strcmp (gmyth_program_info_non_null_value (prog1->title),
  29.797 +                gmyth_program_info_non_null_value (prog2->title)) == 0)
  29.798 +        ||
  29.799 +        (strcmp
  29.800 +            (gmyth_program_info_non_null_value (prog1->pathname),
  29.801 +                gmyth_program_info_non_null_value (prog2->pathname)) == 0))
  29.802          return TRUE;
  29.803      else
  29.804          return FALSE;
  29.805  
  29.806 -}
  29.807 \ No newline at end of file
  29.808 +}
    30.1 --- a/gmyth/src/gmyth_programinfo.h	Tue May 22 19:21:42 2007 +0100
    30.2 +++ b/gmyth/src/gmyth_programinfo.h	Wed May 23 16:11:29 2007 +0100
    30.3 @@ -10,23 +10,23 @@
    30.4   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    30.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    30.6   *
    30.7 - *//*
    30.8 - * 
    30.9 - * This program is free software; you can redistribute it and/or modify
   30.10 - * it under the terms of the GNU Lesser General Public License as published by
   30.11 - * the Free Software Foundation; either version 2 of the License, or
   30.12 - * (at your option) any later version.
   30.13 - *
   30.14 - * This program is distributed in the hope that it will be useful,
   30.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   30.17 - * GNU General Public License for more details.
   30.18 - *
   30.19 - * You should have received a copy of the GNU Lesser General Public License
   30.20 - * along with this program; if not, write to the Free Software
   30.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   30.22 - *
   30.23 - */
   30.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   30.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   30.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   30.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   30.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   30.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   30.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   30.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   30.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   30.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   30.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   30.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   30.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   30.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   30.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   30.40 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   30.41  
   30.42  #ifndef _GMYTH_PROGRAMINFO_H
   30.43  #define _GMYTH_PROGRAMINFO_H
   30.44 @@ -37,22 +37,20 @@
   30.45  #include "gmyth_stringlist.h"
   30.46  
   30.47  G_BEGIN_DECLS
   30.48 -
   30.49  #define GMYTH_PROGRAM_INFO_TYPE               (gmyth_program_info_get_type ())
   30.50  #define GMYTH_PROGRAM_INFO(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfo))
   30.51  #define GMYTH_PROGRAM_INFO_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfoClass))
   30.52  #define IS_GMYTH_PROGRAM_INFO(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_PROGRAM_INFO_TYPE))
   30.53  #define IS_GMYTH_PROGRAM_INFO_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_PROGRAM_INFO_TYPE))
   30.54  #define GMYTH_PROGRAM_INFO_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_PROGRAM_INFO_TYPE, GMythProgramInfoClass))
   30.55 -
   30.56 -typedef struct _GMythProgramInfo         GMythProgramInfo;
   30.57 -typedef struct _GMythProgramInfoClass    GMythProgramInfoClass;
   30.58 +typedef struct _GMythProgramInfo GMythProgramInfo;
   30.59 +typedef struct _GMythProgramInfoClass GMythProgramInfoClass;
   30.60  
   30.61  struct _GMythProgramInfoClass
   30.62  {
   30.63 -  GObjectClass parent_class;
   30.64 +    GObjectClass parent_class;
   30.65  
   30.66 -  /* callbacks */
   30.67 +    /* callbacks */
   30.68  };
   30.69  
   30.70  /**
   30.71 @@ -63,19 +61,19 @@
   30.72  struct _GMythProgramInfo
   30.73  {
   30.74      GObject parent;
   30.75 -    
   30.76 +
   30.77      /** The channel unique ID. */
   30.78      GString *chanid;
   30.79 -  
   30.80 +
   30.81      /** The program start time. */
   30.82 -    GTimeVal* startts;
   30.83 +    GTimeVal *startts;
   30.84      /** The program end time. */
   30.85 -    GTimeVal* endts;
   30.86 +    GTimeVal *endts;
   30.87      /** The recording schedule start time. */
   30.88 -    GTimeVal* recstartts;
   30.89 +    GTimeVal *recstartts;
   30.90      /** The recording schedule end time */
   30.91 -    GTimeVal* recendts;
   30.92 -  
   30.93 +    GTimeVal *recendts;
   30.94 +
   30.95      /** The program title. */
   30.96      GString *title;
   30.97      /** The program subtitle. */
   30.98 @@ -84,44 +82,44 @@
   30.99      GString *description;
  30.100      /** The program category. */
  30.101      GString *category;
  30.102 -  
  30.103 +
  30.104      GString *chanstr;
  30.105      GString *chansign;
  30.106      /** The associated channel name. */
  30.107      GString *channame;
  30.108      gint chancommfree;
  30.109      GString *chanOutputFilters;
  30.110 -  
  30.111 +
  30.112      GString *seriesid;
  30.113      /** The program unique id. */
  30.114      GString *programid;
  30.115      GString *catType;
  30.116  
  30.117 -    GString *sortTitle;  
  30.118 +    GString *sortTitle;
  30.119  
  30.120 -	/** A flag informing if the program has video or not. */    
  30.121 +        /** A flag informing if the program has video or not. */
  30.122      gboolean isVideo;
  30.123      gint lenMins;
  30.124 -  
  30.125 -    GString *year;    
  30.126 +
  30.127 +    GString *year;
  30.128      gdouble stars;
  30.129      gint repeat;
  30.130 -  
  30.131 -    GTimeVal* originalAirDate;
  30.132 -    GTimeVal* lastmodified;
  30.133 -    GTimeVal* lastInUseTime;
  30.134 -  
  30.135 +
  30.136 +    GTimeVal *originalAirDate;
  30.137 +    GTimeVal *lastmodified;
  30.138 +    GTimeVal *lastInUseTime;
  30.139 +
  30.140      gboolean hasAirDate;
  30.141  
  30.142      gint spread;
  30.143      gint startCol;
  30.144  
  30.145      gint recpriority2;
  30.146 -    gint reactivate;    
  30.147 +    gint reactivate;
  30.148  
  30.149      gint recordid;
  30.150 -    gint parentid;   
  30.151 -  
  30.152 +    gint parentid;
  30.153 +
  30.154      /** The backend video source id associated to this program.*/
  30.155      gint sourceid;
  30.156      /** the backend input id associated to this program.*/
  30.157 @@ -131,7 +129,7 @@
  30.158      gboolean shareable;
  30.159      gboolean duplicate;
  30.160  
  30.161 -    GString * schedulerid;
  30.162 +    GString *schedulerid;
  30.163      gint findid;
  30.164  
  30.165      gint programflags;
  30.166 @@ -141,32 +139,33 @@
  30.167      GString *playgroup;
  30.168      gint recpriority;
  30.169  
  30.170 -	/** The file size of the recorded program.*/
  30.171 +        /** The file size of the recorded program.*/
  30.172      gint64 filesize;
  30.173 -  
  30.174 +
  30.175      /** The file name of the recorded program.*/
  30.176      GString *pathname;
  30.177      GString *hostname;
  30.178  };
  30.179  
  30.180 -GType     			gmyth_program_info_type (void);
  30.181 +GType gmyth_program_info_type (void);
  30.182  
  30.183 -GMythProgramInfo* 	gmyth_program_info_new (void);
  30.184 +GMythProgramInfo *gmyth_program_info_new (void);
  30.185  
  30.186 -GMythStringList*	gmyth_program_info_to_string_list (GMythProgramInfo *prog, 
  30.187 -                                                       GMythStringList *slist);
  30.188 +GMythStringList *gmyth_program_info_to_string_list (GMythProgramInfo * prog,
  30.189 +    GMythStringList * slist);
  30.190  
  30.191 -GMythProgramInfo*   gmyth_program_info_from_string_list_from_pos (GMythStringList *slist, guint pos);
  30.192 +GMythProgramInfo *gmyth_program_info_from_string_list_from_pos (GMythStringList
  30.193 +    * slist, guint pos);
  30.194  
  30.195 -GMythProgramInfo* 	gmyth_program_info_from_string_list (GMythStringList *slist);
  30.196 +GMythProgramInfo *gmyth_program_info_from_string_list (GMythStringList * slist);
  30.197  
  30.198 -GMythProgramInfo*   gmyth_program_info_from_string_list_next_prog ( GMythStringList *slist );
  30.199 +GMythProgramInfo
  30.200 +    * gmyth_program_info_from_string_list_next_prog (GMythStringList * slist);
  30.201  
  30.202 -const gchar*		gmyth_program_info_to_string( const GMythProgramInfo* prog );
  30.203 +const gchar *gmyth_program_info_to_string (const GMythProgramInfo * prog);
  30.204  
  30.205 -gboolean            gmyth_program_info_is_equals( const GMythProgramInfo* prog1, 
  30.206 -                                                  const GMythProgramInfo* prog2 );
  30.207 +gboolean gmyth_program_info_is_equals (const GMythProgramInfo * prog1,
  30.208 +    const GMythProgramInfo * prog2);
  30.209  
  30.210  G_END_DECLS
  30.211 -
  30.212  #endif /*_GMYTH_PROGRAMINFO_H*/
    31.1 --- a/gmyth/src/gmyth_query.c	Tue May 22 19:21:42 2007 +0100
    31.2 +++ b/gmyth/src/gmyth_query.c	Wed May 23 16:11:29 2007 +0100
    31.3 @@ -9,23 +9,23 @@
    31.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    31.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    31.6   *
    31.7 - *//*
    31.8 - * 
    31.9 - * This program is free software; you can redistribute it and/or modify
   31.10 - * it under the terms of the GNU Lesser General Public License as published by
   31.11 - * the Free Software Foundation; either version 2 of the License, or
   31.12 - * (at your option) any later version.
   31.13 - *
   31.14 - * This program is distributed in the hope that it will be useful,
   31.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   31.17 - * GNU General Public License for more details.
   31.18 - *
   31.19 - * You should have received a copy of the GNU Lesser General Public License
   31.20 - * along with this program; if not, write to the Free Software
   31.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31.22 - */
   31.23 - 
   31.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   31.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   31.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   31.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   31.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   31.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   31.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   31.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   31.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   31.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   31.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   31.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   31.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   31.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   31.40 +
   31.41  #ifdef HAVE_CONFIG_H
   31.42  #include "config.h"
   31.43  #endif
   31.44 @@ -37,29 +37,27 @@
   31.45  #include "gmyth_query.h"
   31.46  #include "gmyth_debug.h"
   31.47  
   31.48 -static void gmyth_query_class_init          (GMythQueryClass *klass);
   31.49 -static void gmyth_query_init                (GMythQuery *object);
   31.50 +static void gmyth_query_class_init (GMythQueryClass * klass);
   31.51 +static void gmyth_query_init (GMythQuery * object);
   31.52  
   31.53 -static void gmyth_query_dispose  (GObject *object);
   31.54 -static void gmyth_query_finalize (GObject *object);
   31.55 +static void gmyth_query_dispose (GObject * object);
   31.56 +static void gmyth_query_finalize (GObject * object);
   31.57  
   31.58 -static void gmyth_query_print_error (MYSQL *conn, char *message);
   31.59 +static void gmyth_query_print_error (MYSQL * conn, char *message);
   31.60  
   31.61 -G_DEFINE_TYPE(GMythQuery, gmyth_query, G_TYPE_OBJECT)
   31.62 -    
   31.63 -static void
   31.64 -gmyth_query_class_init (GMythQueryClass *klass)
   31.65 +G_DEFINE_TYPE (GMythQuery, gmyth_query, G_TYPE_OBJECT)
   31.66 +     static void gmyth_query_class_init (GMythQueryClass * klass)
   31.67  {
   31.68      GObjectClass *gobject_class;
   31.69  
   31.70      gobject_class = (GObjectClass *) klass;
   31.71 -	
   31.72 -    gobject_class->dispose  = gmyth_query_dispose;
   31.73 -    gobject_class->finalize = gmyth_query_finalize;	
   31.74 +
   31.75 +    gobject_class->dispose = gmyth_query_dispose;
   31.76 +    gobject_class->finalize = gmyth_query_finalize;
   31.77  }
   31.78  
   31.79  static void
   31.80 -gmyth_query_init (GMythQuery *gmyth_query)
   31.81 +gmyth_query_init (GMythQuery * gmyth_query)
   31.82  {
   31.83      gmyth_query->backend_info = NULL;
   31.84  
   31.85 @@ -67,14 +65,14 @@
   31.86      gmyth_query->conn = mysql_init (NULL);
   31.87  
   31.88      if (!(gmyth_query->conn))
   31.89 -    	g_warning ("[%s] MSQL structure not initialized", __FUNCTION__);
   31.90 +        g_warning ("[%s] MSQL structure not initialized", __FUNCTION__);
   31.91  }
   31.92  
   31.93  static void
   31.94 -gmyth_query_dispose  (GObject *object)
   31.95 +gmyth_query_dispose (GObject * object)
   31.96  {
   31.97      GMythQuery *gmyth_query = GMYTH_QUERY (object);
   31.98 -    
   31.99 +
  31.100      if (gmyth_query->conn != NULL) {
  31.101          gmyth_query_disconnect (gmyth_query);
  31.102      }
  31.103 @@ -83,12 +81,12 @@
  31.104          g_object_unref (gmyth_query->backend_info);
  31.105          gmyth_query->backend_info = NULL;
  31.106      }
  31.107 -    
  31.108 +
  31.109      G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object);
  31.110  }
  31.111  
  31.112  static void
  31.113 -gmyth_query_finalize (GObject *object)
  31.114 +gmyth_query_finalize (GObject * object)
  31.115  {
  31.116      g_signal_handlers_destroy (object);
  31.117  
  31.118 @@ -99,28 +97,28 @@
  31.119   * 
  31.120   * @return a new instance of GMythQuery.
  31.121   */
  31.122 -GMythQuery*
  31.123 +GMythQuery *
  31.124  gmyth_query_new ()
  31.125  {
  31.126 -    GMythQuery *sql_query = GMYTH_QUERY (g_object_new(GMYTH_QUERY_TYPE, NULL));
  31.127 +    GMythQuery *sql_query = GMYTH_QUERY (g_object_new (GMYTH_QUERY_TYPE, NULL));
  31.128  
  31.129      return sql_query;
  31.130  }
  31.131  
  31.132  gboolean
  31.133 -gmyth_query_connect_with_timeout (GMythQuery *gmyth_query, 
  31.134 -		GMythBackendInfo *backend_info, guint timeout)
  31.135 +gmyth_query_connect_with_timeout (GMythQuery * gmyth_query,
  31.136 +    GMythBackendInfo * backend_info, guint timeout)
  31.137  {
  31.138 -    assert(gmyth_query);    
  31.139 +    assert (gmyth_query);
  31.140  
  31.141      if (gmyth_query->conn == NULL) {
  31.142 -	gmyth_query->conn = mysql_init (NULL);
  31.143 +        gmyth_query->conn = mysql_init (NULL);
  31.144      }
  31.145  
  31.146      if (timeout != 0) {
  31.147          /* sets connection timeout */
  31.148 -        mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT, 
  31.149 -                       (gchar*) &timeout);
  31.150 +        mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT,
  31.151 +            (gchar *) & timeout);
  31.152      }
  31.153  
  31.154      return gmyth_query_connect (gmyth_query, backend_info);
  31.155 @@ -133,42 +131,43 @@
  31.156   * @return true if connection was success, false if failed.
  31.157   */
  31.158  gboolean
  31.159 -gmyth_query_connect (GMythQuery *gmyth_query, GMythBackendInfo *backend_info) 
  31.160 +gmyth_query_connect (GMythQuery * gmyth_query, GMythBackendInfo * backend_info)
  31.161  {
  31.162 -    assert(gmyth_query);
  31.163 +    assert (gmyth_query);
  31.164      g_return_val_if_fail (backend_info != NULL, FALSE);
  31.165      g_return_val_if_fail (backend_info->hostname != NULL, FALSE);
  31.166      g_return_val_if_fail (backend_info->username != NULL, FALSE);
  31.167      g_return_val_if_fail (backend_info->password != NULL, FALSE);
  31.168      g_return_val_if_fail (backend_info->db_name != NULL, FALSE);
  31.169 -    
  31.170 +
  31.171      if (gmyth_query->backend_info != NULL) {
  31.172          g_object_unref (gmyth_query->backend_info);
  31.173      }
  31.174      gmyth_query->backend_info = g_object_ref (backend_info);
  31.175  
  31.176      if (gmyth_query->conn == NULL) {
  31.177 -	gmyth_query->conn = mysql_init (NULL);
  31.178 -    }
  31.179 -    
  31.180 -    /* connect to server */
  31.181 -    if (mysql_real_connect (gmyth_query->conn, 
  31.182 -                    	    gmyth_query->backend_info->hostname, 
  31.183 -                            gmyth_query->backend_info->username,
  31.184 -            	            gmyth_query->backend_info->password,
  31.185 -        	            gmyth_query->backend_info->db_name, 
  31.186 -                            0, NULL, 0) == NULL) {            	
  31.187 -        gmyth_query_print_error (gmyth_query->conn, "mysql_real_connect() failed");
  31.188 -		return FALSE;
  31.189 +        gmyth_query->conn = mysql_init (NULL);
  31.190      }
  31.191  
  31.192 -    gmyth_debug ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "\
  31.193 -    			"password = %s, db name = %s)", __FUNCTION__, 
  31.194 -    			gmyth_query->backend_info->hostname, 
  31.195 -                gmyth_query->backend_info->username,
  31.196 -	    		gmyth_query->backend_info->password, 
  31.197 -                gmyth_query->backend_info->db_name );
  31.198 -    
  31.199 +    /* connect to server */
  31.200 +    if (mysql_real_connect (gmyth_query->conn,
  31.201 +            gmyth_query->backend_info->hostname,
  31.202 +            gmyth_query->backend_info->username,
  31.203 +            gmyth_query->backend_info->password,
  31.204 +            gmyth_query->backend_info->db_name, 0, NULL, 0) == NULL) {
  31.205 +        gmyth_query_print_error (gmyth_query->conn,
  31.206 +            "mysql_real_connect() failed");
  31.207 +        return FALSE;
  31.208 +    }
  31.209 +
  31.210 +    gmyth_debug
  31.211 +        ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "
  31.212 +        "password = %s, db name = %s)", __FUNCTION__,
  31.213 +        gmyth_query->backend_info->hostname,
  31.214 +        gmyth_query->backend_info->username,
  31.215 +        gmyth_query->backend_info->password,
  31.216 +        gmyth_query->backend_info->db_name);
  31.217 +
  31.218      return TRUE;
  31.219  }
  31.220  
  31.221 @@ -178,32 +177,31 @@
  31.222   * @return true if disconnection was success, false if failed.
  31.223   */
  31.224  gboolean
  31.225 -gmyth_query_disconnect (GMythQuery *gmyth_query) 
  31.226 +gmyth_query_disconnect (GMythQuery * gmyth_query)
  31.227  {
  31.228      g_return_val_if_fail (gmyth_query != NULL, FALSE);
  31.229      g_return_val_if_fail (gmyth_query->conn != NULL, FALSE);
  31.230 -    
  31.231 +
  31.232      /* TODO: Check how to return error */
  31.233      gmyth_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__);
  31.234  
  31.235      mysql_close (gmyth_query->conn);
  31.236      gmyth_query->conn = NULL;
  31.237  
  31.238 -    return TRUE;	
  31.239 +    return TRUE;
  31.240  }
  31.241  
  31.242  static void
  31.243 -gmyth_query_print_error (MYSQL *conn, char *message)
  31.244 +gmyth_query_print_error (MYSQL * conn, char *message)
  31.245  {
  31.246      gmyth_debug ("%s", message);
  31.247 -    
  31.248 +
  31.249      if (conn != NULL) {
  31.250  #if MYSQL_VERSION_ID >= 40101
  31.251          gmyth_debug ("Error %u (%s): %s\n",
  31.252 -                mysql_errno (conn), mysql_sqlstate(conn), mysql_error (conn));
  31.253 +            mysql_errno (conn), mysql_sqlstate (conn), mysql_error (conn));
  31.254  #else
  31.255 -        gmyth_debug ("Error %u: %s\n",
  31.256 -               mysql_errno (conn), mysql_error (conn));
  31.257 +        gmyth_debug ("Error %u: %s\n", mysql_errno (conn), mysql_error (conn));
  31.258  #endif
  31.259      }
  31.260  }
  31.261 @@ -218,19 +216,20 @@
  31.262   * @param stmt_str the query text.
  31.263   * @return the MYSQL_RES result pointer or NULL if any error happens.
  31.264   */
  31.265 -MYSQL_RES*
  31.266 -gmyth_query_process_statement (GMythQuery *gmyth_query, char *stmt_str)
  31.267 +MYSQL_RES *
  31.268 +gmyth_query_process_statement (GMythQuery * gmyth_query, char *stmt_str)
  31.269  {
  31.270 -    assert(gmyth_query);
  31.271 -    
  31.272 +    assert (gmyth_query);
  31.273 +
  31.274      gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str);
  31.275  
  31.276      if (gmyth_query == NULL)
  31.277 -    	return NULL;
  31.278 -    
  31.279 +        return NULL;
  31.280 +
  31.281      /* the statement failed */
  31.282      if (mysql_query (gmyth_query->conn, stmt_str) != 0) {
  31.283 -        gmyth_query_print_error (gmyth_query->conn, "Could not execute statement");
  31.284 +        gmyth_query_print_error (gmyth_query->conn,
  31.285 +            "Could not execute statement");
  31.286          return NULL;
  31.287      }
  31.288  
  31.289 @@ -238,19 +237,21 @@
  31.290      return mysql_store_result (gmyth_query->conn);
  31.291  }
  31.292  
  31.293 -MYSQL_RES*
  31.294 -gmyth_query_process_statement_with_increment (GMythQuery *gmyth_query, char *stmt_str, gulong *id)
  31.295 +MYSQL_RES *
  31.296 +gmyth_query_process_statement_with_increment (GMythQuery * gmyth_query,
  31.297 +    char *stmt_str, gulong * id)
  31.298  {
  31.299 -    assert(gmyth_query);
  31.300 -   
  31.301 +    assert (gmyth_query);
  31.302 +
  31.303      gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str);
  31.304  
  31.305      if (gmyth_query == NULL)
  31.306          return NULL;
  31.307 -   
  31.308 +
  31.309      /* the statement failed */
  31.310      if (mysql_query (gmyth_query->conn, stmt_str) != 0) {
  31.311 -        gmyth_query_print_error (gmyth_query->conn, "Could not execute statement");
  31.312 +        gmyth_query_print_error (gmyth_query->conn,
  31.313 +            "Could not execute statement");
  31.314          return NULL;
  31.315      }
  31.316  
  31.317 @@ -259,4 +260,3 @@
  31.318      /* the statement succeeded; determine whether it returned data */
  31.319      return mysql_store_result (gmyth_query->conn);
  31.320  }
  31.321 -
    32.1 --- a/gmyth/src/gmyth_query.h	Tue May 22 19:21:42 2007 +0100
    32.2 +++ b/gmyth/src/gmyth_query.h	Wed May 23 16:11:29 2007 +0100
    32.3 @@ -9,22 +9,22 @@
    32.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    32.5   * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
    32.6   *
    32.7 - *//*
    32.8 - * 
    32.9 - * This program is free software; you can redistribute it and/or modify
   32.10 - * it under the terms of the GNU Lesser General Public License as published by
   32.11 - * the Free Software Foundation; either version 2 of the License, or
   32.12 - * (at your option) any later version.
   32.13 - *
   32.14 - * This program is distributed in the hope that it will be useful,
   32.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   32.17 - * GNU General Public License for more details.
   32.18 - *
   32.19 - * You should have received a copy of the GNU Lesser General Public License
   32.20 - * along with this program; if not, write to the Free Software
   32.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   32.22 - */
   32.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   32.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   32.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   32.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   32.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   32.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   32.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   32.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   32.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   32.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   32.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   32.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   32.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   32.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   32.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   32.39  
   32.40  #ifndef __GMYTH_QUERY_H__
   32.41  #define __GMYTH_QUERY_H__
   32.42 @@ -37,17 +37,14 @@
   32.43  #include "gmyth_backendinfo.h"
   32.44  
   32.45  G_BEGIN_DECLS
   32.46 -
   32.47  #define GMYTH_QUERY_TYPE               (gmyth_query_get_type ())
   32.48  #define GMYTH_QUERY(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_QUERY_TYPE, GMythQuery))
   32.49  #define GMYTH_QUERY_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_QUERY_TYPE, GMythQueryClass))
   32.50  #define IS_GMYTH_QUERY(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_QUERY_TYPE))
   32.51  #define IS_GMYTH_QUERY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_QUERY_TYPE))
   32.52  #define GMYTH_QUERY_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_QUERY_TYPE, GMythQueryClass))
   32.53 -
   32.54 -
   32.55 -typedef struct _GMythQuery         GMythQuery;
   32.56 -typedef struct _GMythQueryClass    GMythQueryClass;
   32.57 +typedef struct _GMythQuery GMythQuery;
   32.58 +typedef struct _GMythQueryClass GMythQueryClass;
   32.59  
   32.60  struct _GMythQueryClass
   32.61  {
   32.62 @@ -60,29 +57,27 @@
   32.63  struct _GMythQuery
   32.64  {
   32.65      GObject parent;
   32.66 -  
   32.67 +
   32.68      GMythBackendInfo *backend_info;
   32.69  
   32.70      /* pointer to connection handler */
   32.71 -    MYSQL *conn;  
   32.72 +    MYSQL *conn;
   32.73  };
   32.74  
   32.75  
   32.76 -GType       gmyth_query_get_type (void);
   32.77 +GType gmyth_query_get_type (void);
   32.78  
   32.79 -GMythQuery* gmyth_query_new (void);
   32.80 -MYSQL_RES * gmyth_query_process_statement (GMythQuery *gmyth_query,
   32.81 -                                           gchar *stmt_str);
   32.82 -MYSQL_RES*
   32.83 -gmyth_query_process_statement_with_increment (GMythQuery *gmyth_query, char *stmt_str, gulong *id);
   32.84 +GMythQuery *gmyth_query_new (void);
   32.85 +MYSQL_RES *gmyth_query_process_statement (GMythQuery * gmyth_query,
   32.86 +    gchar * stmt_str);
   32.87 +MYSQL_RES *gmyth_query_process_statement_with_increment (GMythQuery *
   32.88 +    gmyth_query, char *stmt_str, gulong * id);
   32.89  
   32.90 -gboolean    gmyth_query_connect (GMythQuery *gmyth_query,
   32.91 -                                 GMythBackendInfo *backend_info);
   32.92 -gboolean    gmyth_query_connect_with_timeout (GMythQuery *gmyth_query,
   32.93 -                                 GMythBackendInfo *backend_info,
   32.94 -                                 guint timeout);
   32.95 -gboolean    gmyth_query_disconnect (GMythQuery *gmyth_query);
   32.96 +gboolean gmyth_query_connect (GMythQuery * gmyth_query,
   32.97 +    GMythBackendInfo * backend_info);
   32.98 +gboolean gmyth_query_connect_with_timeout (GMythQuery * gmyth_query,
   32.99 +    GMythBackendInfo * backend_info, guint timeout);
  32.100 +gboolean gmyth_query_disconnect (GMythQuery * gmyth_query);
  32.101  
  32.102  G_END_DECLS
  32.103 -
  32.104  #endif /* __GMYTH_QUERY_H__ */
    33.1 --- a/gmyth/src/gmyth_recorder.c	Tue May 22 19:21:42 2007 +0100
    33.2 +++ b/gmyth/src/gmyth_recorder.c	Wed May 23 16:11:29 2007 +0100
    33.3 @@ -11,22 +11,22 @@
    33.4   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    33.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    33.6   *
    33.7 - *//*
    33.8 - * 
    33.9 - * This program is free software; you can redistribute it and/or modify
   33.10 - * it under the terms of the GNU Lesser General Public License as published by
   33.11 - * the Free Software Foundation; either version 2 of the License, or
   33.12 - * (at your option) any later version.
   33.13 - *
   33.14 - * This program is distributed in the hope that it will be useful,
   33.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   33.17 - * GNU General Public License for more details.
   33.18 - *
   33.19 - * You should have received a copy of the GNU Lesser General Public License
   33.20 - * along with this program; if not, write to the Free Software
   33.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   33.22 - */
   33.23 +                                                                                                                                                                                                                                                                                                                                                                                              *//*
   33.24 +                                                                                                                                                                                                 * 
   33.25 +                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   33.26 +                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   33.27 +                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   33.28 +                                                                                                                                                                                                 * (at your option) any later version.
   33.29 +                                                                                                                                                                                                 *
   33.30 +                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   33.31 +                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.32 +                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   33.33 +                                                                                                                                                                                                 * GNU General Public License for more details.
   33.34 +                                                                                                                                                                                                 *
   33.35 +                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   33.36 +                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   33.37 +                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   33.38 +                                                                                                                                                                                                 */
   33.39  
   33.40  #ifdef HAVE_CONFIG_H
   33.41  #include "config.h"
   33.42 @@ -43,77 +43,74 @@
   33.43  
   33.44  #define	 GMYTHTV_RECORDER_HEADER			"QUERY_RECORDER"
   33.45  
   33.46 -static void gmyth_recorder_class_init(GMythRecorderClass *klass);
   33.47 -static void gmyth_recorder_init(GMythRecorder *object);
   33.48 +static void gmyth_recorder_class_init (GMythRecorderClass * klass);
   33.49 +static void gmyth_recorder_init (GMythRecorder * object);
   33.50  
   33.51 -static void gmyth_recorder_dispose(GObject *object);
   33.52 -static void gmyth_recorder_finalize(GObject *object);
   33.53 +static void gmyth_recorder_dispose (GObject * object);
   33.54 +static void gmyth_recorder_finalize (GObject * object);
   33.55  
   33.56 -G_DEFINE_TYPE(GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
   33.57 -
   33.58 -static void
   33.59 -gmyth_recorder_class_init (GMythRecorderClass *klass)
   33.60 +G_DEFINE_TYPE (GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
   33.61 +     static void gmyth_recorder_class_init (GMythRecorderClass * klass)
   33.62  {
   33.63      GObjectClass *gobject_class;
   33.64  
   33.65      gobject_class = (GObjectClass *) klass;
   33.66 -	
   33.67 -    gobject_class->dispose  = gmyth_recorder_dispose;
   33.68 -    gobject_class->finalize = gmyth_recorder_finalize;	
   33.69 +
   33.70 +    gobject_class->dispose = gmyth_recorder_dispose;
   33.71 +    gobject_class->finalize = gmyth_recorder_finalize;
   33.72  }
   33.73  
   33.74  static void
   33.75 -gmyth_recorder_init(GMythRecorder *gmyth_remote_encoder) 
   33.76 +gmyth_recorder_init (GMythRecorder * gmyth_remote_encoder)
   33.77  {
   33.78  }
   33.79  
   33.80  static void
   33.81 -gmyth_recorder_dispose(GObject *object) 
   33.82 +gmyth_recorder_dispose (GObject * object)
   33.83  {
   33.84 -    GMythRecorder *recorder=  GMYTH_RECORDER(object);
   33.85 +    GMythRecorder *recorder = GMYTH_RECORDER (object);
   33.86  
   33.87 -    gmyth_recorder_close(recorder);
   33.88 +    gmyth_recorder_close (recorder);
   33.89  
   33.90 -    if ( recorder->mutex != NULL) {
   33.91 -        g_mutex_free(recorder->mutex);
   33.92 +    if (recorder->mutex != NULL) {
   33.93 +        g_mutex_free (recorder->mutex);
   33.94          recorder->mutex = NULL;
   33.95      }
   33.96 -    
   33.97 -    if ( recorder->myth_socket != NULL) {
   33.98 -        g_object_unref(recorder->myth_socket);
   33.99 +
  33.100 +    if (recorder->myth_socket != NULL) {
  33.101 +        g_object_unref (recorder->myth_socket);
  33.102          recorder->myth_socket = NULL;
  33.103      }
  33.104 -    
  33.105 -    if ( recorder->progs_info_list != NULL )
  33.106 +
  33.107 +    if (recorder->progs_info_list != NULL)
  33.108          gmyth_free_program_list (recorder->progs_info_list);
  33.109 -    
  33.110 -    if ( recorder->hostname != NULL )
  33.111 +
  33.112 +    if (recorder->hostname != NULL)
  33.113          g_string_free (recorder->hostname, TRUE);
  33.114  
  33.115      G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
  33.116  }
  33.117  
  33.118  static void
  33.119 -gmyth_recorder_finalize(GObject *object) 
  33.120 +gmyth_recorder_finalize (GObject * object)
  33.121  {
  33.122 -    g_signal_handlers_destroy(object);
  33.123 +    g_signal_handlers_destroy (object);
  33.124  
  33.125      G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
  33.126  }
  33.127  
  33.128  void
  33.129 -gmyth_recorder_close(GMythRecorder *recorder) 
  33.130 +gmyth_recorder_close (GMythRecorder * recorder)
  33.131  {
  33.132 -    if ( recorder != NULL && recorder->recorder_num != -1 )
  33.133 -    {
  33.134 -        g_mutex_lock( recorder->mutex );
  33.135 +    if (recorder != NULL && recorder->recorder_num != -1) {
  33.136 +        g_mutex_lock (recorder->mutex);
  33.137  
  33.138 -        gmyth_recorder_stop_playing(recorder);
  33.139 -        gmyth_recorder_stop_livetv(recorder);
  33.140 -        gmyth_recorder_finish_recording(recorder);
  33.141 -        gmyth_recorder_free_tuner(recorder);
  33.142 +        gmyth_recorder_stop_playing (recorder);
  33.143 +        gmyth_recorder_stop_livetv (recorder);
  33.144 +        gmyth_recorder_finish_recording (recorder);
  33.145 +        gmyth_recorder_free_tuner (recorder);
  33.146  
  33.147 -        g_mutex_unlock( recorder->mutex );
  33.148 +        g_mutex_unlock (recorder->mutex);
  33.149      }
  33.150  }
  33.151  
  33.152 @@ -121,18 +118,18 @@
  33.153   * 
  33.154   * @return a new instance of GMythRecorder.
  33.155   */
  33.156 -GMythRecorder*
  33.157 -gmyth_recorder_new(int num, GString *hostname, gshort port) 
  33.158 +GMythRecorder *
  33.159 +gmyth_recorder_new (int num, GString * hostname, gshort port)
  33.160  {
  33.161 -    GMythRecorder *encoder=  
  33.162 -        GMYTH_RECORDER ( g_object_new (GMYTH_RECORDER_TYPE, FALSE ) );
  33.163 +    GMythRecorder *encoder =
  33.164 +        GMYTH_RECORDER (g_object_new (GMYTH_RECORDER_TYPE, FALSE));
  33.165  
  33.166      encoder->recorder_num = num;
  33.167 -    encoder->hostname = g_string_new(hostname->str);
  33.168 +    encoder->hostname = g_string_new (hostname->str);
  33.169      encoder->port = port;
  33.170 -    
  33.171 -    encoder->mutex = g_mutex_new();
  33.172 -    
  33.173 +
  33.174 +    encoder->mutex = g_mutex_new ();
  33.175 +
  33.176      encoder->progs_info_list = NULL;
  33.177  
  33.178      return encoder;
  33.179 @@ -145,22 +142,22 @@
  33.180   * @return TRUE if successfull, FALSE if any error happens.
  33.181   */
  33.182  gboolean
  33.183 -gmyth_recorder_setup(GMythRecorder *recorder) 
  33.184 +gmyth_recorder_setup (GMythRecorder * recorder)
  33.185  {
  33.186      assert (recorder);
  33.187 -    gmyth_debug ("[%s] Creating socket and connecting to backend", __FUNCTION__);
  33.188 +    gmyth_debug ("[%s] Creating socket and connecting to backend",
  33.189 +        __FUNCTION__);
  33.190  
  33.191      if (recorder->myth_socket == NULL) {
  33.192          recorder->myth_socket = gmyth_socket_new ();
  33.193  
  33.194 -        if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, 
  33.195 -                        recorder->hostname->str,
  33.196 -                        recorder->port, TRUE ) ) {
  33.197 +        if (!gmyth_socket_connect_to_backend (recorder->myth_socket,
  33.198 +                recorder->hostname->str, recorder->port, TRUE)) {
  33.199              gmyth_debug ("GMythRemoteEncoder: Connection to backend failed");
  33.200              return FALSE;
  33.201          }
  33.202      } else {
  33.203 -        gmyth_debug("Remote encoder socket already created\n");
  33.204 +        gmyth_debug ("Remote encoder socket already created\n");
  33.205      }
  33.206  
  33.207      return TRUE;
  33.208 @@ -174,19 +171,20 @@
  33.209   * @return true if success, false if any error happens.
  33.210   */
  33.211  gboolean
  33.212 -gmyth_recorder_spawntv(GMythRecorder *recorder, GString *tvchain_id) 
  33.213 +gmyth_recorder_spawntv (GMythRecorder * recorder, GString * tvchain_id)
  33.214  {
  33.215      GMythStringList *str_list;
  33.216 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.217 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.218      gboolean ret = TRUE;
  33.219  
  33.220 -    gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__, tvchain_id->str);
  33.221 +    gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__,
  33.222 +        tvchain_id->str);
  33.223  
  33.224      str_list = gmyth_string_list_new ();
  33.225 -    
  33.226 -    g_mutex_lock( recorder->mutex );
  33.227  
  33.228 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.229 +    g_mutex_lock (recorder->mutex);
  33.230 +
  33.231 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.232  
  33.233      gmyth_string_list_append_string (str_list, tmp_str);
  33.234      g_string_free (tmp_str, TRUE);
  33.235 @@ -201,20 +199,22 @@
  33.236      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.237  
  33.238      if (tmp_str == NULL) {
  33.239 -        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
  33.240 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
  33.241 +            tmp_str->str);
  33.242          ret = FALSE;
  33.243          goto cleanup;
  33.244      }
  33.245  
  33.246      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.247 -        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
  33.248 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
  33.249 +            tmp_str->str);
  33.250          ret = FALSE;
  33.251          goto cleanup;
  33.252      }
  33.253  
  33.254 -cleanup:
  33.255 -    g_mutex_unlock( recorder->mutex );
  33.256 -    
  33.257 +  cleanup:
  33.258 +    g_mutex_unlock (recorder->mutex);
  33.259 +
  33.260      g_string_free (tmp_str, TRUE);
  33.261      g_object_unref (str_list);
  33.262  
  33.263 @@ -230,18 +230,19 @@
  33.264   * @return true if success, false if any error happens.
  33.265   */
  33.266  gboolean
  33.267 -gmyth_recorder_spawntv_no_tvchain(GMythRecorder *recorder) {
  33.268 +gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder)
  33.269 +{
  33.270      GMythStringList *str_list;
  33.271 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.272 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.273      gboolean ret = TRUE;
  33.274  
  33.275      gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__);
  33.276  
  33.277      str_list = gmyth_string_list_new ();
  33.278 -    
  33.279 -    g_mutex_lock( recorder->mutex );
  33.280  
  33.281 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.282 +    g_mutex_lock (recorder->mutex);
  33.283 +
  33.284 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.285  
  33.286      gmyth_string_list_append_string (str_list, tmp_str);
  33.287      g_string_free (tmp_str, TRUE);
  33.288 @@ -253,20 +254,22 @@
  33.289      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.290  
  33.291      if (tmp_str == NULL) {
  33.292 -        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);         
  33.293 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
  33.294 +            tmp_str->str);
  33.295          ret = FALSE;
  33.296          goto cleanup;
  33.297      }
  33.298  
  33.299      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.300 -        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__, tmp_str->str);
  33.301 +        gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
  33.302 +            tmp_str->str);
  33.303          ret = FALSE;
  33.304          goto cleanup;
  33.305      }
  33.306  
  33.307 -cleanup:    
  33.308 -    g_mutex_unlock( recorder->mutex );
  33.309 -    
  33.310 +  cleanup:
  33.311 +    g_mutex_unlock (recorder->mutex);
  33.312 +
  33.313      g_string_free (tmp_str, TRUE);
  33.314      g_object_unref (str_list);
  33.315  
  33.316 @@ -279,33 +282,35 @@
  33.317   * @return true if success, false if any error happens.
  33.318   */
  33.319  gboolean
  33.320 -gmyth_recorder_stop_livetv(GMythRecorder *recorder) {
  33.321 +gmyth_recorder_stop_livetv (GMythRecorder * recorder)
  33.322 +{
  33.323      GMythStringList *str_list;
  33.324 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.325 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.326      gboolean ret = TRUE;
  33.327  
  33.328      gmyth_debug ("[%s]", __FUNCTION__);
  33.329  
  33.330      str_list = gmyth_string_list_new ();
  33.331 -    
  33.332 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.333 +
  33.334 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.335  
  33.336      gmyth_string_list_append_string (str_list, tmp_str);
  33.337      g_string_free (tmp_str, TRUE);
  33.338  
  33.339 -    gmyth_string_list_append_char_array( str_list, "STOP_LIVETV" );
  33.340 +    gmyth_string_list_append_char_array (str_list, "STOP_LIVETV");
  33.341  
  33.342      gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
  33.343  
  33.344      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.345  
  33.346      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.347 -        gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__, tmp_str->str);
  33.348 +        gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__,
  33.349 +            tmp_str->str);
  33.350          ret = FALSE;
  33.351          goto cleanup;
  33.352      }
  33.353  
  33.354 -cleanup:
  33.355 +  cleanup:
  33.356      g_string_free (tmp_str, TRUE);
  33.357      g_object_unref (str_list);
  33.358  
  33.359 @@ -319,18 +324,20 @@
  33.360   * @return TRUE if success, FALSE if any error happens.
  33.361   */
  33.362  gboolean
  33.363 -gmyth_recorder_send_frontend_ready_command(GMythRecorder *recorder) {
  33.364 +gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder)
  33.365 +{
  33.366      GMythStringList *str_list;
  33.367 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.368 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.369      gboolean ret = TRUE;
  33.370  
  33.371 -    gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__, recorder->recorder_num );
  33.372 +    gmyth_debug ("[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__,
  33.373 +        recorder->recorder_num);
  33.374  
  33.375      str_list = gmyth_string_list_new ();
  33.376 -    
  33.377 -    g_mutex_lock( recorder->mutex );
  33.378  
  33.379 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.380 +    g_mutex_lock (recorder->mutex);
  33.381 +
  33.382 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.383  
  33.384      gmyth_string_list_append_string (str_list, tmp_str);
  33.385      g_string_free (tmp_str, TRUE);
  33.386 @@ -342,20 +349,22 @@
  33.387      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.388  
  33.389      if (tmp_str == NULL) {
  33.390 -        gmyth_debug ("[%s] FRONTEND_READY command request couldn't returns, reason: %s", 
  33.391 -                __FUNCTION__, tmp_str->str);
  33.392 +        gmyth_debug
  33.393 +            ("[%s] FRONTEND_READY command request couldn't returns, reason: %s",
  33.394 +            __FUNCTION__, tmp_str->str);
  33.395          ret = FALSE;
  33.396          goto cleanup;
  33.397      }
  33.398  
  33.399      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.400 -        gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__, tmp_str->str);
  33.401 +        gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__,
  33.402 +            tmp_str->str);
  33.403          ret = FALSE;
  33.404          goto cleanup;
  33.405      }
  33.406  
  33.407 -cleanup:
  33.408 -    g_mutex_unlock( recorder->mutex );
  33.409 +  cleanup:
  33.410 +    g_mutex_unlock (recorder->mutex);
  33.411      g_string_free (tmp_str, TRUE);
  33.412      g_object_unref (str_list);
  33.413  
  33.414 @@ -370,19 +379,19 @@
  33.415   * @return true if success, false if any error happens.
  33.416   */
  33.417  gboolean
  33.418 -gmyth_recorder_check_channel_name(GMythRecorder *recorder,
  33.419 -        gchar* channel) {
  33.420 +gmyth_recorder_check_channel_name (GMythRecorder * recorder, gchar * channel)
  33.421 +{
  33.422      GMythStringList *str_list;
  33.423 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.424 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.425      gboolean ret = TRUE;
  33.426  
  33.427      gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
  33.428  
  33.429      str_list = gmyth_string_list_new ();
  33.430 -    
  33.431 -    g_mutex_lock( recorder->mutex );
  33.432  
  33.433 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.434 +    g_mutex_lock (recorder->mutex);
  33.435 +
  33.436 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.437  
  33.438      gmyth_string_list_append_string (str_list, tmp_str);
  33.439      g_string_free (tmp_str, TRUE);
  33.440 @@ -396,19 +405,22 @@
  33.441      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.442  
  33.443      if (tmp_str == NULL) {
  33.444 -        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
  33.445 +        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
  33.446 +            tmp_str->str);
  33.447          ret = FALSE;
  33.448          goto cleanup;
  33.449      }
  33.450  
  33.451 -    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0 || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0 ) {
  33.452 -        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
  33.453 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0
  33.454 +        || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0) {
  33.455 +        gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
  33.456 +            tmp_str->str);
  33.457          ret = FALSE;
  33.458          goto cleanup;
  33.459      }
  33.460  
  33.461 -cleanup:
  33.462 -    g_mutex_unlock( recorder->mutex );
  33.463 +  cleanup:
  33.464 +    g_mutex_unlock (recorder->mutex);
  33.465      g_string_free (tmp_str, TRUE);
  33.466      g_object_unref (str_list);
  33.467  
  33.468 @@ -423,8 +435,9 @@
  33.469   * @return true if success, false if any error happens.
  33.470   */
  33.471  gboolean
  33.472 -gmyth_recorder_check_channel(GMythRecorder *recorder, gint channel) {
  33.473 -    return gmyth_recorder_check_channel_name( recorder, g_strdup_printf( "%d",
  33.474 +gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel)
  33.475 +{
  33.476 +    return gmyth_recorder_check_channel_name (recorder, g_strdup_printf ("%d",
  33.477              channel));
  33.478  }
  33.479  
  33.480 @@ -436,24 +449,25 @@
  33.481   * @return true if success, false if any error happens.
  33.482   */
  33.483  gboolean
  33.484 -gmyth_recorder_set_channel(GMythRecorder *recorder, gint channel) {
  33.485 +gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel)
  33.486 +{
  33.487      GMythStringList *str_list;
  33.488 -    GString *tmp_str = g_string_new(GMYTHTV_RECORDER_HEADER);
  33.489 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.490      gboolean ret = TRUE;
  33.491  
  33.492      gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
  33.493  
  33.494      str_list = gmyth_string_list_new ();
  33.495 -    
  33.496 -    g_mutex_lock( recorder->mutex );
  33.497  
  33.498 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.499 +    g_mutex_lock (recorder->mutex);
  33.500 +
  33.501 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.502  
  33.503      gmyth_string_list_append_string (str_list, tmp_str);
  33.504      g_string_free (tmp_str, TRUE);
  33.505  
  33.506      gmyth_string_list_append_char_array (str_list, "SET_CHANNEL");
  33.507 -    
  33.508 +
  33.509      gmyth_string_list_append_int (str_list, channel);
  33.510  
  33.511      gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
  33.512 @@ -461,19 +475,21 @@
  33.513      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.514  
  33.515      if (tmp_str == NULL) {
  33.516 -        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
  33.517 +        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__,
  33.518 +            tmp_str->str);
  33.519          ret = FALSE;
  33.520          goto cleanup;
  33.521      }
  33.522  
  33.523      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.524 -        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__, tmp_str->str);
  33.525 +        gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__,
  33.526 +            tmp_str->str);
  33.527          ret = FALSE;
  33.528          goto cleanup;
  33.529      }
  33.530  
  33.531 -cleanup:
  33.532 -    g_mutex_unlock( recorder->mutex );
  33.533 +  cleanup:
  33.534 +    g_mutex_unlock (recorder->mutex);
  33.535      g_string_free (tmp_str, TRUE);
  33.536      g_object_unref (str_list);
  33.537  
  33.538 @@ -488,19 +504,21 @@
  33.539   * @return true if success, false if any error happens.
  33.540   */
  33.541  gboolean
  33.542 -gmyth_recorder_set_channel_name(GMythRecorder *recorder,
  33.543 -        const gchar* channel) {
  33.544 +gmyth_recorder_set_channel_name (GMythRecorder * recorder,
  33.545 +    const gchar * channel)
  33.546 +{
  33.547      GMythStringList *str_list;
  33.548 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
  33.549 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.550      gboolean ret = TRUE;
  33.551  
  33.552 -    gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__, channel);
  33.553 +    gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__,
  33.554 +        channel);
  33.555  
  33.556      str_list = gmyth_string_list_new ();
  33.557 -    
  33.558 -    g_mutex_lock( recorder->mutex );
  33.559  
  33.560 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.561 +    g_mutex_lock (recorder->mutex);
  33.562 +
  33.563 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.564  
  33.565      gmyth_string_list_append_string (str_list, tmp_str);
  33.566      g_string_free (tmp_str, TRUE);
  33.567 @@ -513,19 +531,23 @@
  33.568      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.569  
  33.570      if (tmp_str == NULL) {
  33.571 -        gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!", __FUNCTION__);
  33.572 +        gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!",
  33.573 +            __FUNCTION__);
  33.574          ret = FALSE;
  33.575          goto cleanup;
  33.576      }
  33.577  
  33.578 -    if (tmp_str!= NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2) /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */) {
  33.579 -        g_warning ("[%s] SET_CHANNEL name request returned not ok", __FUNCTION__);
  33.580 +    if (tmp_str != NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2)
  33.581 +        /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */
  33.582 +        ) {
  33.583 +        g_warning ("[%s] SET_CHANNEL name request returned not ok",
  33.584 +            __FUNCTION__);
  33.585          ret = FALSE;
  33.586          goto cleanup;
  33.587      }
  33.588  
  33.589 -cleanup:
  33.590 -    g_mutex_unlock( recorder->mutex );
  33.591 +  cleanup:
  33.592 +    g_mutex_unlock (recorder->mutex);
  33.593      g_string_free (tmp_str, TRUE);
  33.594      g_object_unref (str_list);
  33.595  
  33.596 @@ -548,19 +570,21 @@
  33.597   * @return true if success, false if any error happens.
  33.598   */
  33.599  gboolean
  33.600 -gmyth_recorder_change_channel(GMythRecorder *recorder,
  33.601 -        const GMythRecorderChannelChangeDirection direction) {
  33.602 +gmyth_recorder_change_channel (GMythRecorder * recorder,
  33.603 +    const GMythRecorderChannelChangeDirection direction)
  33.604 +{
  33.605      GMythStringList *str_list;
  33.606 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
  33.607 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.608      gboolean ret = TRUE;
  33.609  
  33.610 -    gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u", __FUNCTION__, direction);
  33.611 +    gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u",
  33.612 +        __FUNCTION__, direction);
  33.613  
  33.614      str_list = gmyth_string_list_new ();
  33.615 -    
  33.616 -    g_mutex_lock( recorder->mutex );
  33.617  
  33.618 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.619 +    g_mutex_lock (recorder->mutex);
  33.620 +
  33.621 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.622  
  33.623      gmyth_string_list_append_string (str_list, tmp_str);
  33.624      g_string_free (tmp_str, TRUE);
  33.625 @@ -573,19 +597,22 @@
  33.626      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.627  
  33.628      if (tmp_str == NULL) {
  33.629 -        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str );
  33.630 +        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s",
  33.631 +            __FUNCTION__, tmp_str->str);
  33.632          ret = FALSE;
  33.633          goto cleanup;
  33.634      }
  33.635  
  33.636 -    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) || g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 ) {
  33.637 -        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s", __FUNCTION__, tmp_str->str);
  33.638 +    if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)
  33.639 +        || g_ascii_strtoull (tmp_str->str, NULL, 10) == 0) {
  33.640 +        gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s",
  33.641 +            __FUNCTION__, tmp_str->str);
  33.642          ret = FALSE;
  33.643          goto cleanup;
  33.644      }
  33.645  
  33.646 -cleanup:
  33.647 -    g_mutex_unlock( recorder->mutex );
  33.648 +  cleanup:
  33.649 +    g_mutex_unlock (recorder->mutex);
  33.650      g_string_free (tmp_str, TRUE);
  33.651      g_object_unref (str_list);
  33.652  
  33.653 @@ -599,28 +626,27 @@
  33.654   * 
  33.655   * @return a GList* instance with all the channel names.
  33.656   */
  33.657 -GList*
  33.658 -gmyth_recorder_get_channel_list(GMythRecorder *recorder ) {
  33.659 -    
  33.660 -    GList* channel_list = NULL;
  33.661 -    gchar* channel = NULL;
  33.662 +GList *
  33.663 +gmyth_recorder_get_channel_list (GMythRecorder * recorder)
  33.664 +{
  33.665 +
  33.666 +    GList *channel_list = NULL;
  33.667 +    gchar *channel = NULL;
  33.668      guint i;
  33.669 -    
  33.670 -    for ( i = 0; i < 1000; i++ )
  33.671 -    {
  33.672 -        channel = g_strdup_printf( "%u", i );
  33.673 -        
  33.674 -        if ( gmyth_recorder_check_channel_name( recorder, channel ) )
  33.675 -        {
  33.676 -            channel_list = g_list_append( channel_list, g_strdup( channel ) );
  33.677 +
  33.678 +    for (i = 0; i < 1000; i++) {
  33.679 +        channel = g_strdup_printf ("%u", i);
  33.680 +
  33.681 +        if (gmyth_recorder_check_channel_name (recorder, channel)) {
  33.682 +            channel_list = g_list_append (channel_list, g_strdup (channel));
  33.683          }
  33.684 -        
  33.685 -    } /* for - channel list */
  33.686 -    
  33.687 -    g_free( channel );
  33.688 -    
  33.689 +
  33.690 +    }                           /* for - channel list */
  33.691 +
  33.692 +    g_free (channel);
  33.693 +
  33.694      return channel_list;
  33.695 -    
  33.696 +
  33.697  }
  33.698  
  33.699  /** Send a PAUSE command request to the backend, to pause streaming on another 
  33.700 @@ -630,18 +656,19 @@
  33.701   * @return true if success, false if any error happens.
  33.702   */
  33.703  gboolean
  33.704 -gmyth_recorder_pause_recording( GMythRecorder *recorder) {
  33.705 +gmyth_recorder_pause_recording (GMythRecorder * recorder)
  33.706 +{
  33.707      GMythStringList *str_list;
  33.708 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
  33.709 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.710      gboolean ret = TRUE;
  33.711  
  33.712      gmyth_debug ("[%s] PAUSE", __FUNCTION__);
  33.713  
  33.714      str_list = gmyth_string_list_new ();
  33.715 -    
  33.716 -    g_mutex_lock( recorder->mutex );
  33.717  
  33.718 -    g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
  33.719 +    g_mutex_lock (recorder->mutex);
  33.720 +
  33.721 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.722  
  33.723      gmyth_string_list_append_string (str_list, tmp_str);
  33.724      g_string_free (tmp_str, TRUE);
  33.725 @@ -653,40 +680,44 @@
  33.726      tmp_str = gmyth_string_list_get_string (str_list, 0);
  33.727  
  33.728      if (tmp_str == NULL) {
  33.729 -        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
  33.730 +        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__,
  33.731 +            tmp_str->str);
  33.732          ret = FALSE;
  33.733          goto cleanup;
  33.734      }
  33.735  
  33.736      if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
  33.737 -        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__, tmp_str->str);
  33.738 +        gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__,
  33.739 +            tmp_str->str);
  33.740          ret = FALSE;
  33.741          goto cleanup;
  33.742      }
  33.743  
  33.744 -cleanup:
  33.745 -    g_mutex_unlock( recorder->mutex );
  33.746 +  cleanup:
  33.747 +    g_mutex_unlock (recorder->mutex);
  33.748      g_string_free (tmp_str, TRUE);
  33.749      g_object_unref (str_list);
  33.750  
  33.751      return ret;
  33.752  }
  33.753  
  33.754 -static gboolean 
  33.755 -gmyth_recorder_find_if_program_exists( GMythRecorder* recorder, GMythProgramInfo* prog )
  33.756 +static gboolean
  33.757 +gmyth_recorder_find_if_program_exists (GMythRecorder * recorder,
  33.758 +    GMythProgramInfo * prog)
  33.759  {
  33.760      GList *lst = NULL;
  33.761 -    
  33.762 -    g_return_val_if_fail( recorder != NULL && recorder->progs_info_list != NULL, FALSE );
  33.763 -    
  33.764 -    for ( lst = recorder->progs_info_list; lst != NULL; lst = g_list_next( lst ) )
  33.765 -    {
  33.766 -        gmyth_debug ( "Got program info from list = [%s]", 
  33.767 -                gmyth_program_info_to_string( (GMythProgramInfo*)lst->data ) );
  33.768 -        if ( gmyth_program_info_is_equals ( prog, (GMythProgramInfo*)lst->data ) )
  33.769 +
  33.770 +    g_return_val_if_fail (recorder != NULL
  33.771 +        && recorder->progs_info_list != NULL, FALSE);
  33.772 +
  33.773 +    for (lst = recorder->progs_info_list; lst != NULL; lst = g_list_next (lst)) {
  33.774 +        gmyth_debug ("Got program info from list = [%s]",
  33.775 +            gmyth_program_info_to_string ((GMythProgramInfo *)
  33.776 +                lst->data));
  33.777 +        if (gmyth_program_info_is_equals (prog, (GMythProgramInfo *) lst->data))
  33.778              return TRUE;
  33.779      }
  33.780 -    
  33.781 +
  33.782      return FALSE;
  33.783  }
  33.784  
  33.785 @@ -697,53 +728,54 @@
  33.786   * @return The actual program info.
  33.787   */
  33.788  GMythProgramInfo *
  33.789 -gmyth_recorder_get_current_program_info(GMythRecorder *recorder) 
  33.790 +gmyth_recorder_get_current_program_info (GMythRecorder * recorder)
  33.791  {
  33.792      GMythStringList *str_list = NULL;
  33.793      GMythProgramInfo *program_info = NULL;
  33.794 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
  33.795 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.796  
  33.797 -    str_list = gmyth_string_list_new();
  33.798 -    
  33.799 -    g_mutex_lock( recorder->mutex );
  33.800 +    str_list = gmyth_string_list_new ();
  33.801  
  33.802 -    g_string_append_printf( tmp_str, " %d", recorder->recorder_num);
  33.803 +    g_mutex_lock (recorder->mutex);
  33.804  
  33.805 -    gmyth_string_list_append_string(str_list, tmp_str);
  33.806 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
  33.807  
  33.808 -    if ( recorder->myth_socket->mythtv_version >= 26)
  33.809 +    gmyth_string_list_append_string (str_list, tmp_str);
  33.810 +
  33.811 +    if (recorder->myth_socket->mythtv_version >= 26)
  33.812          gmyth_string_list_append_char_array (str_list, "GET_CURRENT_RECORDING");
  33.813      else
  33.814          gmyth_string_list_append_char_array (str_list, "GET_PROGRAM_INFO");
  33.815  
  33.816 -    gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list);
  33.817 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
  33.818  
  33.819      if (str_list == NULL) {
  33.820 -        gmyth_debug(
  33.821 -                "[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!",
  33.822 -                __FUNCTION__);        
  33.823 +        gmyth_debug
  33.824 +            ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!",
  33.825 +            __FUNCTION__);
  33.826          goto cleanup;
  33.827      }
  33.828  
  33.829 -    program_info = gmyth_program_info_from_string_list( str_list );
  33.830 +    program_info = gmyth_program_info_from_string_list (str_list);
  33.831  
  33.832 -    if ( NULL == program_info || NULL == program_info->pathname || program_info->pathname->len <= 0) {
  33.833 -        gmyth_debug(
  33.834 -                "GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!");
  33.835 -        
  33.836 +    if (NULL == program_info || NULL == program_info->pathname
  33.837 +        || program_info->pathname->len <= 0) {
  33.838 +        gmyth_debug
  33.839 +            ("GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!");
  33.840 +
  33.841          if (program_info)
  33.842 -            g_object_unref(program_info);
  33.843 +            g_object_unref (program_info);
  33.844  
  33.845 -         program_info = NULL;
  33.846 +        program_info = NULL;
  33.847  
  33.848 -         goto cleanup;
  33.849 +        goto cleanup;
  33.850      }
  33.851 -    
  33.852 -    if ( !gmyth_recorder_find_if_program_exists( recorder, program_info ) )
  33.853 -        recorder->progs_info_list = g_list_append( recorder->progs_info_list, 
  33.854 -                                                    g_object_ref(program_info) );
  33.855 -cleanup:
  33.856 -    g_mutex_unlock( recorder->mutex );
  33.857 +
  33.858 +    if (!gmyth_recorder_find_if_program_exists (recorder, program_info))
  33.859 +        recorder->progs_info_list = g_list_append (recorder->progs_info_list,
  33.860 +            g_object_ref (program_info));
  33.861 +  cleanup:
  33.862 +    g_mutex_unlock (recorder->mutex);
  33.863      g_string_free (tmp_str, TRUE);
  33.864      g_object_unref (str_list);
  33.865  
  33.866 @@ -757,68 +789,73 @@
  33.867   * @return The GMythRecorder instance.
  33.868   */
  33.869  GMythRecorder *
  33.870 -gmyth_recorder_get_recorder_from_num( gint rec_id) 
  33.871 +gmyth_recorder_get_recorder_from_num (gint rec_id)
  33.872  {
  33.873 -    GMythRecorder* recorder=  NULL;
  33.874 +    GMythRecorder *recorder = NULL;
  33.875      GMythStringList *str_list;
  33.876 -    GString *tmp_str = g_string_new( "GET_RECORDER_FROM_NUM");
  33.877 +    GString *tmp_str = g_string_new ("GET_RECORDER_FROM_NUM");
  33.878      gint command_size = 0;
  33.879  
  33.880 -    gchar *recorder_host=  NULL;
  33.881 +    gchar *recorder_host = NULL;
  33.882      gint recorder_port;
  33.883  
  33.884 -    str_list = gmyth_string_list_new();
  33.885 +    str_list = gmyth_string_list_new ();
  33.886  
  33.887      /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */
  33.888 -    
  33.889 -    g_mutex_lock( recorder->mutex );
  33.890  
  33.891 -    gmyth_string_list_append_string(str_list, tmp_str);
  33.892 +    g_mutex_lock (recorder->mutex);
  33.893  
  33.894 -    gmyth_string_list_append_int(str_list, rec_id);
  33.895 +    gmyth_string_list_append_string (str_list, tmp_str);
  33.896  
  33.897 -    command_size = gmyth_socket_sendreceive_stringlist(recorder->myth_socket,
  33.898 -            str_list);
  33.899 +    gmyth_string_list_append_int (str_list, rec_id);
  33.900 +
  33.901 +    command_size = gmyth_socket_sendreceive_stringlist (recorder->myth_socket,
  33.902 +        str_list);
  33.903  
  33.904      if (str_list == NULL) {
  33.905 -        gmyth_debug(
  33.906 -                "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
  33.907 -                __FUNCTION__, rec_id);
  33.908 +        gmyth_debug
  33.909 +            ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
  33.910 +            __FUNCTION__, rec_id);
  33.911          return NULL;
  33.912      }
  33.913  
  33.914 -    if ( command_size > 0) {
  33.915 -        recorder_host = gmyth_string_list_get_char_array( str_list, 0 );
  33.916 -        recorder_port = gmyth_string_list_get_int( str_list, 1);
  33.917 +    if (command_size > 0) {
  33.918 +        recorder_host = gmyth_string_list_get_char_array (str_list, 0);
  33.919 +        recorder_port = gmyth_string_list_get_int (str_list, 1);
  33.920  
  33.921 -        if ( g_strstr_len( recorder_host, strlen(recorder_host), "nohost")!= NULL) {
  33.922 -            gmyth_debug( "No available recorder with the recorder ID number %d!", rec_id );
  33.923 +        if (g_strstr_len (recorder_host, strlen (recorder_host), "nohost")
  33.924 +            != NULL) {
  33.925 +            gmyth_debug
  33.926 +                ("No available recorder with the recorder ID number %d!",
  33.927 +                rec_id);
  33.928          } else {
  33.929  
  33.930 -            recorder = gmyth_recorder_new( rec_id,
  33.931 -                    g_string_new( recorder_host), (gshort)recorder_port);
  33.932 +            recorder = gmyth_recorder_new (rec_id,
  33.933 +                g_string_new (recorder_host), (gshort) recorder_port);
  33.934  
  33.935 -            if ( NULL == recorder) {
  33.936 -                gmyth_debug(
  33.937 -                        "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
  33.938 -                        __FUNCTION__, rec_id);
  33.939 -                g_object_unref(recorder);
  33.940 +            if (NULL == recorder) {
  33.941 +                gmyth_debug
  33.942 +                    ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
  33.943 +                    __FUNCTION__, rec_id);
  33.944 +                g_object_unref (recorder);
  33.945                  return NULL;
  33.946              }
  33.947  
  33.948          }
  33.949  
  33.950      } else {
  33.951 -        gmyth_debug( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!", rec_id );
  33.952 +        gmyth_debug
  33.953 +            ("Cannot find a valuable recorder with the recorder ID number %d, backend server error!",
  33.954 +            rec_id);
  33.955      }
  33.956 -    
  33.957 -    g_mutex_unlock( recorder->mutex );
  33.958  
  33.959 -    g_object_unref(str_list);
  33.960 +    g_mutex_unlock (recorder->mutex);
  33.961  
  33.962 -    g_string_free(tmp_str, TRUE);
  33.963 +    g_object_unref (str_list);
  33.964  
  33.965 -    g_free( recorder_host);
  33.966 +    g_string_free (tmp_str, TRUE);
  33.967 +
  33.968 +    g_free (recorder_host);
  33.969  
  33.970      return recorder;
  33.971  
  33.972 @@ -834,81 +871,86 @@
  33.973   * @return The GMythProgramInfo next program info instance.
  33.974   */
  33.975  GMythProgramInfo *
  33.976 -gmyth_recorder_get_next_program_info( GMythRecorder *recorder, 
  33.977 -        const GMythRecorderBrowseDirection direction) {
  33.978 -    GMythProgramInfo* actual_proginfo=  NULL;
  33.979 -    GMythProgramInfo* program_info=  NULL;
  33.980 +gmyth_recorder_get_next_program_info (GMythRecorder * recorder,
  33.981 +    const GMythRecorderBrowseDirection direction)
  33.982 +{
  33.983 +    GMythProgramInfo *actual_proginfo = NULL;
  33.984 +    GMythProgramInfo *program_info = NULL;
  33.985      GMythStringList *str_list;
  33.986 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER);
  33.987 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
  33.988  
  33.989 -    gchar *date =  NULL;
  33.990 +    gchar *date = NULL;
  33.991      struct tm *tm = NULL;
  33.992      time_t t;
  33.993  
  33.994 -    actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
  33.995 +    actual_proginfo = gmyth_recorder_get_current_program_info (recorder);
  33.996  
  33.997 -    str_list = gmyth_string_list_new();
  33.998 -    
  33.999 -    g_mutex_lock( recorder->mutex );
 33.1000 +    str_list = gmyth_string_list_new ();
 33.1001  
 33.1002 -    g_string_append_printf( tmp_str, " %d", recorder->recorder_num);
 33.1003 +    g_mutex_lock (recorder->mutex);
 33.1004  
 33.1005 -    t = time(NULL);
 33.1006 -    tm = localtime(&t);
 33.1007 -    date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
 33.1008 -            tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
 33.1009 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
 33.1010  
 33.1011 -    gmyth_string_list_append_string(str_list, tmp_str);
 33.1012 -    gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO");
 33.1013 -    gmyth_string_list_append_string(str_list, actual_proginfo->channame);
 33.1014 -    gmyth_string_list_append_string(str_list, actual_proginfo->chanid);
 33.1015 -    gmyth_string_list_append_int(str_list, direction);
 33.1016 -    gmyth_string_list_append_char_array(str_list, date);
 33.1017 +    t = time (NULL);
 33.1018 +    tm = localtime (&t);
 33.1019 +    date = g_strdup_printf ("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
 33.1020 +        tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
 33.1021  
 33.1022 -    if ( gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list)> 0) {
 33.1023 +    gmyth_string_list_append_string (str_list, tmp_str);
 33.1024 +    gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO");
 33.1025 +    gmyth_string_list_append_string (str_list, actual_proginfo->channame);
 33.1026 +    gmyth_string_list_append_string (str_list, actual_proginfo->chanid);
 33.1027 +    gmyth_string_list_append_int (str_list, direction);
 33.1028 +    gmyth_string_list_append_char_array (str_list, date);
 33.1029 +
 33.1030 +    if (gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list)
 33.1031 +        > 0) {
 33.1032  
 33.1033          if (str_list == NULL) {
 33.1034 -            gmyth_debug(
 33.1035 -                    "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
 33.1036 -                    __FUNCTION__);
 33.1037 +            gmyth_debug
 33.1038 +                ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
 33.1039 +                __FUNCTION__);
 33.1040              goto done;
 33.1041          }
 33.1042 -        program_info = gmyth_program_info_from_string_list_next_prog(str_list);
 33.1043 +        program_info = gmyth_program_info_from_string_list_next_prog (str_list);
 33.1044  
 33.1045 -        if ( NULL == program_info) {
 33.1046 -            gmyth_debug(
 33.1047 -                    "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
 33.1048 -                    __FUNCTION__);
 33.1049 -            g_object_unref(program_info);
 33.1050 +        if (NULL == program_info) {
 33.1051 +            gmyth_debug
 33.1052 +                ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
 33.1053 +                __FUNCTION__);
 33.1054 +            g_object_unref (program_info);
 33.1055              goto done;
 33.1056          }
 33.1057  
 33.1058 -        if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
 33.1059 -        ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) {
 33.1060 -            gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str );
 33.1061 +        if (                    /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) && */
 33.1062 +            (program_info->chansign != NULL
 33.1063 +                && strlen (program_info->chansign->str) > 0)) {
 33.1064 +            gmyth_debug ("OK!!! Got the next program info... [%s].",
 33.1065 +                program_info->chansign->str);
 33.1066          } else {
 33.1067 -            gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" );
 33.1068 -            g_object_unref(program_info);
 33.1069 +            gmyth_debug
 33.1070 +                ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!");
 33.1071 +            g_object_unref (program_info);
 33.1072              program_info = NULL;
 33.1073          }
 33.1074  
 33.1075 -    } /* if */
 33.1076 +    }
 33.1077 +    /* if */
 33.1078 +  done:
 33.1079  
 33.1080 -done:
 33.1081 -    
 33.1082 -    g_mutex_unlock( recorder->mutex );
 33.1083 -    
 33.1084 -    if ( actual_proginfo != NULL )
 33.1085 -        g_object_unref(actual_proginfo);
 33.1086 -    
 33.1087 -    if ( str_list != NULL )
 33.1088 -        g_object_unref(str_list);
 33.1089 -    
 33.1090 -    if ( tmp_str != NULL )
 33.1091 -        g_string_free(tmp_str, TRUE);
 33.1092 +    g_mutex_unlock (recorder->mutex);
 33.1093  
 33.1094 -    if ( date != NULL )
 33.1095 -        g_free(date);
 33.1096 +    if (actual_proginfo != NULL)
 33.1097 +        g_object_unref (actual_proginfo);
 33.1098 +
 33.1099 +    if (str_list != NULL)
 33.1100 +        g_object_unref (str_list);
 33.1101 +
 33.1102 +    if (tmp_str != NULL)
 33.1103 +        g_string_free (tmp_str, TRUE);
 33.1104 +
 33.1105 +    if (date != NULL)
 33.1106 +        g_free (date);
 33.1107      //if ( tm != NULL)
 33.1108      //    g_free (tm);
 33.1109  
 33.1110 @@ -923,85 +965,92 @@
 33.1111   * @return The GMythProgramInfo next program info instance.
 33.1112   */
 33.1113  GMythProgramInfo *
 33.1114 -gmyth_recorder_get_program_info_from_channel_name( GMythRecorder *recorder, 
 33.1115 -        const gchar* channel ) {
 33.1116 +gmyth_recorder_get_program_info_from_channel_name (GMythRecorder * recorder,
 33.1117 +    const gchar * channel)
 33.1118 +{
 33.1119      //GMythProgramInfo* actual_proginfo=  NULL;
 33.1120 -    GMythProgramInfo* program_info=  NULL;
 33.1121 +    GMythProgramInfo *program_info = NULL;
 33.1122      GMythStringList *str_list;
 33.1123 -    GString *tmp_str = g_string_new( GMYTHTV_RECORDER_HEADER );
 33.1124 -    
 33.1125 -    /*
 33.1126 -    gchar *date =  NULL;
 33.1127 -    struct tm *tm = NULL;
 33.1128 -    time_t t;
 33.1129 -    
 33.1130 -    actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
 33.1131 -    */
 33.1132 -    
 33.1133 -    str_list = gmyth_string_list_new();    
 33.1134 -    
 33.1135 -    g_mutex_lock( recorder->mutex );
 33.1136 -
 33.1137 -    g_string_append_printf( tmp_str, " %d", recorder->recorder_num );
 33.1138 +    GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
 33.1139  
 33.1140      /*
 33.1141 -    t = time(NULL);
 33.1142 -    tm = localtime(&t);
 33.1143 -    date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
 33.1144 -            tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
 33.1145 -    */
 33.1146 +       gchar *date =  NULL;
 33.1147 +       struct tm *tm = NULL;
 33.1148 +       time_t t;
 33.1149  
 33.1150 -    gmyth_string_list_append_string(str_list, tmp_str);
 33.1151 -    gmyth_string_list_append_char_array(str_list, "GET_NEXT_PROGRAM_INFO");
 33.1152 -    gmyth_string_list_append_char_array(str_list, channel);
 33.1153 -    gmyth_string_list_append_char_array(str_list, "0");
 33.1154 -    gmyth_string_list_append_int(str_list, BROWSE_DIRECTION_UP);
 33.1155 -    gmyth_string_list_append_char_array(str_list, "0");
 33.1156 -    
 33.1157 +       actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
 33.1158 +     */
 33.1159 +
 33.1160 +    str_list = gmyth_string_list_new ();
 33.1161 +
 33.1162 +    g_mutex_lock (recorder->mutex);
 33.1163 +
 33.1164 +    g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
 33.1165 +
 33.1166 +    /*
 33.1167 +       t = time(NULL);
 33.1168 +       tm = localtime(&t);
 33.1169 +       date = g_strdup_printf("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
 33.1170 +       tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
 33.1171 +     */
 33.1172 +
 33.1173 +    gmyth_string_list_append_string (str_list, tmp_str);
 33.1174 +    gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO");
 33.1175 +    gmyth_string_list_append_char_array (str_list, channel);
 33.1176 +    gmyth_string_list_append_char_array (str_list, "0");
 33.1177 +    gmyth_string_list_append_int (str_list, BROWSE_DIRECTION_UP);
 33.1178 +    gmyth_string_list_append_char_array (str_list, "0");
 33.1179 +
 33.1180      do {
 33.1181  
 33.1182 -      if ( str_list != NULL && 
 33.1183 -              gmyth_socket_sendreceive_stringlist(recorder->myth_socket, str_list) > 0 ) {
 33.1184 -  
 33.1185 -          if (str_list == NULL) {
 33.1186 -              gmyth_debug(
 33.1187 -                      "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
 33.1188 -                      __FUNCTION__);
 33.1189 -              goto done;
 33.1190 -          }
 33.1191 -          program_info = gmyth_program_info_from_string_list_next_prog(str_list);
 33.1192 -  
 33.1193 -          if ( NULL == program_info) {
 33.1194 -              gmyth_debug(
 33.1195 -                      "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
 33.1196 -                      __FUNCTION__);
 33.1197 -              g_object_unref(program_info);
 33.1198 -              goto done;
 33.1199 -          }
 33.1200 -  
 33.1201 -          if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) &&*/
 33.1202 -          ( program_info->chansign != NULL && strlen( program_info->chansign->str ) > 0 )) {
 33.1203 -              gmyth_debug( "OK!!! Got the next program info... [%s].", program_info->chansign->str );
 33.1204 -          } else {
 33.1205 -              gmyth_debug ("GET_NEXT_PROGRAM_INFO request returned. Error getting "
 33.1206 -                      "next program info, it is equals to NULL!!!" );
 33.1207 -              g_object_unref(program_info);
 33.1208 -              program_info = NULL;
 33.1209 -          }
 33.1210 -  
 33.1211 -      } /* if */
 33.1212 -    
 33.1213 -    } while ( str_list != NULL );
 33.1214 +        if (str_list != NULL &&
 33.1215 +            gmyth_socket_sendreceive_stringlist (recorder->myth_socket,
 33.1216 +                str_list) > 0) {
 33.1217  
 33.1218 -done:
 33.1219 -    
 33.1220 -    g_mutex_unlock( recorder->mutex );
 33.1221 -    
 33.1222 -    if ( str_list != NULL )
 33.1223 -        g_object_unref(str_list);
 33.1224 -    
 33.1225 -    if ( tmp_str != NULL )
 33.1226 -        g_string_free(tmp_str, TRUE);
 33.1227 +            if (str_list == NULL) {
 33.1228 +                gmyth_debug
 33.1229 +                    ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
 33.1230 +                    __FUNCTION__);
 33.1231 +                goto done;
 33.1232 +            }
 33.1233 +            program_info =
 33.1234 +                gmyth_program_info_from_string_list_next_prog (str_list);
 33.1235 +
 33.1236 +            if (NULL == program_info) {
 33.1237 +                gmyth_debug
 33.1238 +                    ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
 33.1239 +                    __FUNCTION__);
 33.1240 +                g_object_unref (program_info);
 33.1241 +                goto done;
 33.1242 +            }
 33.1243 +
 33.1244 +            if (                /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0  ) && */
 33.1245 +                (program_info->chansign != NULL
 33.1246 +                    && strlen (program_info->chansign->str) > 0)) {
 33.1247 +                gmyth_debug ("OK!!! Got the next program info... [%s].",
 33.1248 +                    program_info->chansign->str);
 33.1249 +            } else {
 33.1250 +                gmyth_debug
 33.1251 +                    ("GET_NEXT_PROGRAM_INFO request returned. Error getting "
 33.1252 +                    "next program info, it is equals to NULL!!!");
 33.1253 +                g_object_unref (program_info);
 33.1254 +                program_info = NULL;
 33.1255 +            }
 33.1256 +
 33.1257 +        }
 33.1258 +        /* if */
 33.1259 +    }
 33.1260 +    while (str_list != NULL);
 33.1261 +
 33.1262 +  done:
 33.1263 +
 33.1264 +    g_mutex_unlock (recorder->mutex);
 33.1265 +
 33.1266 +    if (str_list != NULL)
 33.1267 +        g_object_unref (str_list);
 33.1268 +
 33.1269 +    if (tmp_str != NULL)
 33.1270 +        g_string_free (tmp_str, TRUE);
 33.1271  
 33.1272      return program_info;
 33.1273  }
 33.1274 @@ -1014,36 +1063,38 @@
 33.1275   * @return The position, in bytes, of the offset to the read header.
 33.1276   */
 33.1277  gint64
 33.1278 -gmyth_recorder_get_file_position( GMythRecorder *recorder) {
 33.1279 +gmyth_recorder_get_file_position (GMythRecorder * recorder)
 33.1280 +{
 33.1281      gint64 pos = 0;
 33.1282 -    GString *query = g_string_new( GMYTHTV_RECORDER_HEADER);
 33.1283 +    GString *query = g_string_new (GMYTHTV_RECORDER_HEADER);
 33.1284  
 33.1285 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1286 -    
 33.1287 -    g_mutex_lock( recorder->mutex );
 33.1288 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1289  
 33.1290 -    g_string_append_printf( query, " %d", recorder->recorder_num);
 33.1291 +    g_mutex_lock (recorder->mutex);
 33.1292  
 33.1293 -    gmyth_string_list_append_string(str_list, query);
 33.1294 -    gmyth_string_list_append_char_array( str_list, "GET_FILE_POSITION");
 33.1295 +    g_string_append_printf (query, " %d", recorder->recorder_num);
 33.1296  
 33.1297 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1298 +    gmyth_string_list_append_string (str_list, query);
 33.1299 +    gmyth_string_list_append_char_array (str_list, "GET_FILE_POSITION");
 33.1300  
 33.1301 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1302 -        GString *str=  NULL;
 33.1303 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL)
 33.1304 -            pos = gmyth_string_list_get_int64 ( str_list, 0);
 33.1305 -        g_string_free( str, TRUE );
 33.1306 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1307 +
 33.1308 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1309 +        GString *str = NULL;
 33.1310 +
 33.1311 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
 33.1312 +            && strstr (str->str, "bad") == NULL)
 33.1313 +            pos = gmyth_string_list_get_int64 (str_list, 0);
 33.1314 +        g_string_free (str, TRUE);
 33.1315      }
 33.1316 +#ifndef GMYTHTV_ENABLE_DEBUG
 33.1317 +    gmyth_debug ("[%s] Got file position = %lld\n", __FUNCTION__, pos);
 33.1318 +#endif
 33.1319  
 33.1320 -#ifndef GMYTHTV_ENABLE_DEBUG
 33.1321 -    gmyth_debug( "[%s] Got file position = %lld\n", __FUNCTION__, pos);
 33.1322 -#endif
 33.1323 -    
 33.1324 -    g_mutex_unlock( recorder->mutex );
 33.1325 +    g_mutex_unlock (recorder->mutex);
 33.1326  
 33.1327 -    if (str_list!=NULL)
 33.1328 -        g_object_unref(str_list);
 33.1329 +    if (str_list != NULL)
 33.1330 +        g_object_unref (str_list);
 33.1331  
 33.1332      g_string_free (query, TRUE);
 33.1333  
 33.1334 @@ -1058,28 +1109,32 @@
 33.1335   * @return <code>true</code>, if the actual remote file is bein recorded.
 33.1336   */
 33.1337  gboolean
 33.1338 -gmyth_recorder_is_recording( GMythRecorder *recorder) {
 33.1339 +gmyth_recorder_is_recording (GMythRecorder * recorder)
 33.1340 +{
 33.1341      gboolean ret = TRUE;
 33.1342  
 33.1343 -    g_return_val_if_fail( recorder != NULL, FALSE );
 33.1344 +    g_return_val_if_fail (recorder != NULL, FALSE);
 33.1345  
 33.1346 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1347 -    GString *message = g_string_new("");
 33.1348 -    
 33.1349 -    g_mutex_lock( recorder->mutex );
 33.1350 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1351 +    GString *message = g_string_new ("");
 33.1352  
 33.1353 -    g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1354 -            recorder->recorder_num);
 33.1355 -    gmyth_string_list_append_string(str_list, message);
 33.1356 -    gmyth_string_list_append_char_array(str_list, "IS_RECORDING");
 33.1357 +    g_mutex_lock (recorder->mutex);
 33.1358  
 33.1359 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1360 +    g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1361 +        recorder->recorder_num);
 33.1362 +    gmyth_string_list_append_string (str_list, message);
 33.1363 +    gmyth_string_list_append_char_array (str_list, "IS_RECORDING");
 33.1364  
 33.1365 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1366 -        GString *str=  NULL;
 33.1367 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad")!= 0) {
 33.1368 -            gint is_rec = gmyth_string_list_get_int( str_list, 0);
 33.1369 -            if ( is_rec != 0)
 33.1370 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1371 +
 33.1372 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1373 +        GString *str = NULL;
 33.1374 +
 33.1375 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
 33.1376 +            && strcmp (str->str, "bad") != 0) {
 33.1377 +            gint is_rec = gmyth_string_list_get_int (str_list, 0);
 33.1378 +
 33.1379 +            if (is_rec != 0)
 33.1380                  ret = TRUE;
 33.1381              else
 33.1382                  ret = FALSE;
 33.1383 @@ -1087,12 +1142,13 @@
 33.1384          g_string_free (str, TRUE);
 33.1385      }
 33.1386  
 33.1387 -    gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
 33.1388 +    gmyth_debug ("%s, stream is %s being recorded!\n", ret ? "YES" : "NO",
 33.1389 +        ret ? "" : "NOT");
 33.1390      //g_static_mutex_unlock (&mutex);
 33.1391 -    
 33.1392 -    g_mutex_unlock( recorder->mutex );
 33.1393  
 33.1394 -    if ( str_list != NULL )
 33.1395 +    g_mutex_unlock (recorder->mutex);
 33.1396 +
 33.1397 +    if (str_list != NULL)
 33.1398          g_object_unref (str_list);
 33.1399  
 33.1400      g_string_free (message, TRUE);
 33.1401 @@ -1109,27 +1165,30 @@
 33.1402   * @return <code>true</code>, if the recording had been actually closed.
 33.1403   */
 33.1404  gboolean
 33.1405 -gmyth_recorder_finish_recording( GMythRecorder *recorder) {
 33.1406 +gmyth_recorder_finish_recording (GMythRecorder * recorder)
 33.1407 +{
 33.1408      gboolean ret = TRUE;
 33.1409  
 33.1410 -    g_return_val_if_fail( recorder != NULL, FALSE );
 33.1411 +    g_return_val_if_fail (recorder != NULL, FALSE);
 33.1412  
 33.1413 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1414 -    GString *message = g_string_new("");
 33.1415 -    
 33.1416 -    g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1417 -            recorder->recorder_num);
 33.1418 -    gmyth_string_list_append_string(str_list, message);
 33.1419 -    gmyth_string_list_append_char_array(str_list, "FINISH_RECORDING");
 33.1420 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1421 +    GString *message = g_string_new ("");
 33.1422  
 33.1423 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1424 +    g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1425 +        recorder->recorder_num);
 33.1426 +    gmyth_string_list_append_string (str_list, message);
 33.1427 +    gmyth_string_list_append_char_array (str_list, "FINISH_RECORDING");
 33.1428  
 33.1429 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1430 -        GString *str=  NULL;
 33.1431 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && 
 33.1432 -                strcmp( str->str, "ok")!= 0) {
 33.1433 -            gint is_rec = gmyth_string_list_get_int( str_list, 0);
 33.1434 -            if ( is_rec != 0)
 33.1435 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1436 +
 33.1437 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1438 +        GString *str = NULL;
 33.1439 +
 33.1440 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
 33.1441 +            strcmp (str->str, "ok") != 0) {
 33.1442 +            gint is_rec = gmyth_string_list_get_int (str_list, 0);
 33.1443 +
 33.1444 +            if (is_rec != 0)
 33.1445                  ret = TRUE;
 33.1446              else
 33.1447                  ret = FALSE;
 33.1448 @@ -1137,12 +1196,13 @@
 33.1449          g_string_free (str, TRUE);
 33.1450      }
 33.1451  
 33.1452 -    gmyth_debug( "%s, stream is %s finished!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
 33.1453 +    gmyth_debug ("%s, stream is %s finished!\n", ret ? "YES" : "NO",
 33.1454 +        ret ? "" : "NOT");
 33.1455      //g_static_mutex_unlock (&mutex);
 33.1456  
 33.1457 -    if ( str_list != NULL )
 33.1458 +    if (str_list != NULL)
 33.1459          g_object_unref (str_list);
 33.1460 -    
 33.1461 +
 33.1462      g_string_free (message, TRUE);
 33.1463  
 33.1464      return ret;
 33.1465 @@ -1157,27 +1217,30 @@
 33.1466   * @return <code>true</code>, if the recording had been actually stopped.
 33.1467   */
 33.1468  gboolean
 33.1469 -gmyth_recorder_stop_playing( GMythRecorder *recorder) {
 33.1470 +gmyth_recorder_stop_playing (GMythRecorder * recorder)
 33.1471 +{
 33.1472      gboolean ret = TRUE;
 33.1473  
 33.1474 -    g_return_val_if_fail( recorder != NULL, FALSE );
 33.1475 +    g_return_val_if_fail (recorder != NULL, FALSE);
 33.1476  
 33.1477 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1478 -    GString *message = g_string_new("");
 33.1479 -    
 33.1480 -    g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1481 -            recorder->recorder_num);
 33.1482 -    gmyth_string_list_append_string(str_list, message);
 33.1483 -    gmyth_string_list_append_char_array(str_list, "STOP_PLAYING");
 33.1484 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1485 +    GString *message = g_string_new ("");
 33.1486  
 33.1487 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1488 +    g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
 33.1489 +        recorder->recorder_num);
 33.1490 +    gmyth_string_list_append_string (str_list, message);
 33.1491 +    gmyth_string_list_append_char_array (str_list, "STOP_PLAYING");
 33.1492  
 33.1493 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1494 -        GString *str=  NULL;
 33.1495 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && 
 33.1496 -                strcmp( str->str, "ok")!= 0) {
 33.1497 -            gint is_rec = gmyth_string_list_get_int( str_list, 0);
 33.1498 -            if ( is_rec != 0)
 33.1499 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1500 +
 33.1501 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1502 +        GString *str = NULL;
 33.1503 +
 33.1504 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
 33.1505 +            strcmp (str->str, "ok") != 0) {
 33.1506 +            gint is_rec = gmyth_string_list_get_int (str_list, 0);
 33.1507 +
 33.1508 +            if (is_rec != 0)
 33.1509                  ret = TRUE;
 33.1510              else
 33.1511                  ret = FALSE;
 33.1512 @@ -1185,11 +1248,12 @@
 33.1513          g_string_free (str, TRUE);
 33.1514      }
 33.1515  
 33.1516 -    gmyth_debug( "%s, stream is %s stopped!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
 33.1517 +    gmyth_debug ("%s, stream is %s stopped!\n", ret ? "YES" : "NO",
 33.1518 +        ret ? "" : "NOT");
 33.1519  
 33.1520 -    if ( str_list != NULL )
 33.1521 +    if (str_list != NULL)
 33.1522          g_object_unref (str_list);
 33.1523 -    
 33.1524 +
 33.1525      g_string_free (message, TRUE);
 33.1526  
 33.1527      return ret;
 33.1528 @@ -1203,25 +1267,28 @@
 33.1529   * @return <code>true</code>, if the tuner had been freed.
 33.1530   */
 33.1531  gboolean
 33.1532 -gmyth_recorder_free_tuner( GMythRecorder *recorder ) {
 33.1533 +gmyth_recorder_free_tuner (GMythRecorder * recorder)
 33.1534 +{
 33.1535      gboolean ret = TRUE;
 33.1536  
 33.1537 -    g_return_val_if_fail( recorder != NULL, FALSE );
 33.1538 +    g_return_val_if_fail (recorder != NULL, FALSE);
 33.1539  
 33.1540 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1541 -    GString *message = g_string_new("");
 33.1542 -    
 33.1543 -    g_string_printf( message, "%s %d", "FREE_TUNER", recorder->recorder_num );
 33.1544 -    gmyth_string_list_append_string(str_list, message);
 33.1545 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1546 +    GString *message = g_string_new ("");
 33.1547  
 33.1548 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1549 +    g_string_printf (message, "%s %d", "FREE_TUNER", recorder->recorder_num);
 33.1550 +    gmyth_string_list_append_string (str_list, message);
 33.1551  
 33.1552 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1553 -        GString *str=  NULL;
 33.1554 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && 
 33.1555 -                g_ascii_strncasecmp( str->str, "ok", 2 ) != 0 ) {
 33.1556 -            gint is_rec = gmyth_string_list_get_int( str_list, 0);
 33.1557 -            if ( is_rec != 0)
 33.1558 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1559 +
 33.1560 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1561 +        GString *str = NULL;
 33.1562 +
 33.1563 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
 33.1564 +            g_ascii_strncasecmp (str->str, "ok", 2) != 0) {
 33.1565 +            gint is_rec = gmyth_string_list_get_int (str_list, 0);
 33.1566 +
 33.1567 +            if (is_rec != 0)
 33.1568                  ret = TRUE;
 33.1569              else
 33.1570                  ret = FALSE;
 33.1571 @@ -1229,11 +1296,12 @@
 33.1572          g_string_free (str, TRUE);
 33.1573      }
 33.1574  
 33.1575 -    gmyth_debug( "%s, tuner is %s freed!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
 33.1576 +    gmyth_debug ("%s, tuner is %s freed!\n", ret ? "YES" : "NO",
 33.1577 +        ret ? "" : "NOT");
 33.1578  
 33.1579 -    if ( str_list != NULL )
 33.1580 +    if (str_list != NULL)
 33.1581          g_object_unref (str_list);
 33.1582 -    
 33.1583 +
 33.1584      g_string_free (message, TRUE);
 33.1585  
 33.1586      return ret;
 33.1587 @@ -1248,38 +1316,39 @@
 33.1588   * @return The framerate (double value) of the current video.
 33.1589   */
 33.1590  gdouble
 33.1591 -gmyth_recorder_get_framerate (GMythRecorder *recorder ) 
 33.1592 +gmyth_recorder_get_framerate (GMythRecorder * recorder)
 33.1593  {
 33.1594      gdouble fr = 0.0f;
 33.1595 -    GString *query = g_string_new( GMYTHTV_RECORDER_HEADER);
 33.1596 +    GString *query = g_string_new (GMYTHTV_RECORDER_HEADER);
 33.1597  
 33.1598 -    GMythStringList *str_list = gmyth_string_list_new();
 33.1599 -    
 33.1600 -    g_mutex_lock( recorder->mutex );
 33.1601 +    GMythStringList *str_list = gmyth_string_list_new ();
 33.1602  
 33.1603 -    g_string_append_printf( query, " %d", recorder->recorder_num);
 33.1604 +    g_mutex_lock (recorder->mutex);
 33.1605  
 33.1606 -    gmyth_string_list_append_string(str_list, query);
 33.1607 -    gmyth_string_list_append_char_array( str_list, "GET_FRAMERATE");
 33.1608 +    g_string_append_printf (query, " %d", recorder->recorder_num);
 33.1609  
 33.1610 -    gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
 33.1611 +    gmyth_string_list_append_string (str_list, query);
 33.1612 +    gmyth_string_list_append_char_array (str_list, "GET_FRAMERATE");
 33.1613  
 33.1614 -    if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
 33.1615 -        GString *str=  NULL;
 33.1616 -        if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strstr( str->str, "bad")== NULL)
 33.1617 -            fr = g_ascii_strtod( str->str, NULL );
 33.1618 -        
 33.1619 -        g_string_free( str, TRUE );
 33.1620 +    gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
 33.1621 +
 33.1622 +    if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
 33.1623 +        GString *str = NULL;
 33.1624 +
 33.1625 +        if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
 33.1626 +            && strstr (str->str, "bad") == NULL)
 33.1627 +            fr = g_ascii_strtod (str->str, NULL);
 33.1628 +
 33.1629 +        g_string_free (str, TRUE);
 33.1630      }
 33.1631 +#ifndef GMYTHTV_ENABLE_DEBUG
 33.1632 +    gmyth_debug ("[%s] Got file position = %f\n", __FUNCTION__, fr);
 33.1633 +#endif
 33.1634  
 33.1635 -#ifndef GMYTHTV_ENABLE_DEBUG
 33.1636 -    gmyth_debug( "[%s] Got file position = %f\n", __FUNCTION__, fr);
 33.1637 -#endif
 33.1638 -    
 33.1639 -    g_mutex_unlock( recorder->mutex );
 33.1640 +    g_mutex_unlock (recorder->mutex);
 33.1641  
 33.1642 -    if (str_list!=NULL)
 33.1643 -        g_object_unref(str_list);
 33.1644 +    if (str_list != NULL)
 33.1645 +        g_object_unref (str_list);
 33.1646  
 33.1647      g_string_free (query, TRUE);
 33.1648  
    34.1 --- a/gmyth/src/gmyth_recorder.h	Tue May 22 19:21:42 2007 +0100
    34.2 +++ b/gmyth/src/gmyth_recorder.h	Wed May 23 16:11:29 2007 +0100
    34.3 @@ -11,22 +11,22 @@
    34.4   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    34.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    34.6   *
    34.7 - *//*
    34.8 - * 
    34.9 - * This program is free software; you can redistribute it and/or modify
   34.10 - * it under the terms of the GNU Lesser General Public License as published by
   34.11 - * the Free Software Foundation; either version 2 of the License, or
   34.12 - * (at your option) any later version.
   34.13 - *
   34.14 - * This program is distributed in the hope that it will be useful,
   34.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   34.17 - * GNU General Public License for more details.
   34.18 - *
   34.19 - * You should have received a copy of the GNU Lesser General Public License
   34.20 - * along with this program; if not, write to the Free Software
   34.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   34.22 - */
   34.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   34.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   34.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   34.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   34.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   34.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   34.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   34.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   34.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   34.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   34.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   34.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   34.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   34.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   34.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   34.39  
   34.40  #ifndef __GMYTH_RECORDER_H__
   34.41  #define __GMYTH_RECORDER_H__
   34.42 @@ -44,24 +44,21 @@
   34.43  #include <unistd.h>
   34.44  
   34.45  G_BEGIN_DECLS
   34.46 -
   34.47  #define GMYTH_RECORDER_TYPE               (gmyth_recorder_get_type ())
   34.48  #define GMYTH_RECORDER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECORDER_TYPE, GMythRecorder))
   34.49  #define GMYTH_RECORDER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECORDER_TYPE, GMythRecorderClass))
   34.50  #define IS_GMYTH_RECORDER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_RECORDER_TYPE))
   34.51  #define IS_GMYTH_RECORDER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECORDER_TYPE))
   34.52  #define GMYTH_RECORDER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_RECORDER_TYPE, GMythRecorderClass))
   34.53 -
   34.54 -
   34.55 -typedef struct _GMythRecorder         GMythRecorder;
   34.56 -typedef struct _GMythRecorderClass    GMythRecorderClass;
   34.57 +typedef struct _GMythRecorder GMythRecorder;
   34.58 +typedef struct _GMythRecorderClass GMythRecorderClass;
   34.59  
   34.60  struct _GMythRecorderClass
   34.61  {
   34.62 -  GObjectClass parent_class;
   34.63 +    GObjectClass parent_class;
   34.64  
   34.65 -  /* callbacks */
   34.66 -  /* no one for now */
   34.67 +    /* callbacks */
   34.68 +    /* no one for now */
   34.69  };
   34.70  
   34.71  struct _GMythRecorder
   34.72 @@ -70,86 +67,86 @@
   34.73  
   34.74      /* socket descriptor */
   34.75      GMythSocket *myth_socket;
   34.76 -    
   34.77 +
   34.78      gint recorder_num;
   34.79      GString *hostname;
   34.80      gint port;
   34.81 -    
   34.82 -    GList* progs_info_list;
   34.83 -    
   34.84 +
   34.85 +    GList *progs_info_list;
   34.86 +
   34.87      GMutex *mutex;
   34.88  };
   34.89  
   34.90 -typedef enum _GMythRecorderChannelChangeDirection {
   34.91 -	CHANNEL_DIRECTION_UP = 0,
   34.92 -	CHANNEL_DIRECTION_DOWN,
   34.93 -	CHANNEL_DIRECTION_FAVORITE,
   34.94 -	CHANNEL_DIRECTION_SAME
   34.95 +typedef enum _GMythRecorderChannelChangeDirection
   34.96 +{
   34.97 +    CHANNEL_DIRECTION_UP = 0,
   34.98 +    CHANNEL_DIRECTION_DOWN,
   34.99 +    CHANNEL_DIRECTION_FAVORITE,
  34.100 +    CHANNEL_DIRECTION_SAME
  34.101  } GMythRecorderChannelChangeDirection;
  34.102  
  34.103 -typedef enum _GMythRecorderBrowseDirection {
  34.104 -	BROWSE_DIRECTION_SAME = 0,     	  /* Stay in the same place */
  34.105 - 	BROWSE_DIRECTION_UP,          		/* Move up one slot (down one channel) */
  34.106 -	BROWSE_DIRECTION_DOWN,        		/* Move down one slot (up one channel) */
  34.107 -	BROWSE_DIRECTION_LEFT,        		/* Move left one slot (down one time slot) */
  34.108 -	BROWSE_DIRECTION_RIGHT,       		/* Move right one slot (up one time slot) */
  34.109 -	BROWSE_DIRECTION_FAVORITE    			/* Move to the next favorite slot */
  34.110 +typedef enum _GMythRecorderBrowseDirection
  34.111 +{
  34.112 +    BROWSE_DIRECTION_SAME = 0,  /* Stay in the same place */
  34.113 +    BROWSE_DIRECTION_UP,        /* Move up one slot (down one channel) */
  34.114 +    BROWSE_DIRECTION_DOWN,      /* Move down one slot (up one channel) */
  34.115 +    BROWSE_DIRECTION_LEFT,      /* Move left one slot (down one time slot) */
  34.116 +    BROWSE_DIRECTION_RIGHT,     /* Move right one slot (up one time slot) */
  34.117 +    BROWSE_DIRECTION_FAVORITE   /* Move to the next favorite slot */
  34.118  } GMythRecorderBrowseDirection;
  34.119  
  34.120 -GType   gmyth_recorder_get_type   	(void);
  34.121 +GType gmyth_recorder_get_type (void);
  34.122  
  34.123 -GMythRecorder* gmyth_recorder_new    (int num,
  34.124 -	                                     GString *hostname,
  34.125 -	                                     gshort port);
  34.126 -	                                     
  34.127 -void		 gmyth_recorder_close  (GMythRecorder *recorder);
  34.128 +GMythRecorder *gmyth_recorder_new (int num, GString * hostname, gshort port);
  34.129  
  34.130 -gboolean gmyth_recorder_setup     (GMythRecorder *recorder);
  34.131 -gboolean gmyth_recorder_spawntv   (GMythRecorder *recorder,
  34.132 -                                         GString *tvchain_id);
  34.133 -                                         
  34.134 -gboolean gmyth_recorder_spawntv_no_tvchain (GMythRecorder *recorder);
  34.135 +void gmyth_recorder_close (GMythRecorder * recorder);
  34.136  
  34.137 -gboolean gmyth_recorder_stop_livetv (GMythRecorder *recorder);
  34.138 +gboolean gmyth_recorder_setup (GMythRecorder * recorder);
  34.139 +gboolean gmyth_recorder_spawntv (GMythRecorder * recorder,
  34.140 +    GString * tvchain_id);
  34.141  
  34.142 -gboolean gmyth_recorder_send_frontend_ready_command (GMythRecorder *recorder);
  34.143 +gboolean gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder);
  34.144  
  34.145 -gboolean gmyth_recorder_check_channel (GMythRecorder *recorder, gint channel);
  34.146 +gboolean gmyth_recorder_stop_livetv (GMythRecorder * recorder);
  34.147  
  34.148 -gboolean gmyth_recorder_check_channel_name (GMythRecorder *recorder, gchar* channel);
  34.149 +gboolean gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder);
  34.150  
  34.151 -gboolean gmyth_recorder_set_channel   (GMythRecorder *recorder,
  34.152 -                                       gint channel);
  34.153 -                                         
  34.154 -gboolean gmyth_recorder_set_channel_name (GMythRecorder *recorder, 
  34.155 -																					const gchar* channel);
  34.156 -																					
  34.157 -gboolean gmyth_recorder_change_channel (GMythRecorder *recorder, 
  34.158 -												const GMythRecorderChannelChangeDirection direction);
  34.159 +gboolean gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel);
  34.160  
  34.161 -GList*  gmyth_recorder_get_channel_list(GMythRecorder *recorder );
  34.162 -																					
  34.163 -gboolean gmyth_recorder_pause_recording ( GMythRecorder *recorder );
  34.164 +gboolean gmyth_recorder_check_channel_name (GMythRecorder * recorder,
  34.165 +    gchar * channel);
  34.166  
  34.167 -GMythProgramInfo *gmyth_recorder_get_current_program_info ( GMythRecorder *recorder );
  34.168 +gboolean gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel);
  34.169  
  34.170 -GMythProgramInfo *gmyth_recorder_get_next_program_info ( GMythRecorder *recorder,
  34.171 -												const GMythRecorderBrowseDirection direction);
  34.172 -												
  34.173 -GMythRecorder *gmyth_recorder_get_recorder_from_num ( gint rec_id );
  34.174 +gboolean gmyth_recorder_set_channel_name (GMythRecorder * recorder,
  34.175 +    const gchar * channel);
  34.176  
  34.177 -gint64 	 gmyth_recorder_get_file_position ( GMythRecorder *recorder );
  34.178 +gboolean gmyth_recorder_change_channel (GMythRecorder * recorder,
  34.179 +    const GMythRecorderChannelChangeDirection direction);
  34.180  
  34.181 -gboolean gmyth_recorder_is_recording ( GMythRecorder *recorder );
  34.182 +GList *gmyth_recorder_get_channel_list (GMythRecorder * recorder);
  34.183  
  34.184 -gboolean 	gmyth_recorder_finish_recording ( GMythRecorder *recorder );
  34.185 +gboolean gmyth_recorder_pause_recording (GMythRecorder * recorder);
  34.186  
  34.187 -gboolean    gmyth_recorder_stop_playing( GMythRecorder *recorder);
  34.188 +GMythProgramInfo *gmyth_recorder_get_current_program_info (GMythRecorder *
  34.189 +    recorder);
  34.190  
  34.191 -gboolean    gmyth_recorder_free_tuner( GMythRecorder *recorder);
  34.192 +GMythProgramInfo *gmyth_recorder_get_next_program_info (GMythRecorder *
  34.193 +    recorder, const GMythRecorderBrowseDirection direction);
  34.194  
  34.195 -gdouble     gmyth_recorder_get_framerate( GMythRecorder *recorder );
  34.196 +GMythRecorder *gmyth_recorder_get_recorder_from_num (gint rec_id);
  34.197 +
  34.198 +gint64 gmyth_recorder_get_file_position (GMythRecorder * recorder);
  34.199 +
  34.200 +gboolean gmyth_recorder_is_recording (GMythRecorder * recorder);
  34.201 +
  34.202 +gboolean gmyth_recorder_finish_recording (GMythRecorder * recorder);
  34.203 +
  34.204 +gboolean gmyth_recorder_stop_playing (GMythRecorder * recorder);
  34.205 +
  34.206 +gboolean gmyth_recorder_free_tuner (GMythRecorder * recorder);
  34.207 +
  34.208 +gdouble gmyth_recorder_get_framerate (GMythRecorder * recorder);
  34.209  
  34.210  G_END_DECLS
  34.211 -
  34.212  #endif /* __GMYTH_REMOTE_ENCODER_H__ */
    35.1 --- a/gmyth/src/gmyth_recprofile.c	Tue May 22 19:21:42 2007 +0100
    35.2 +++ b/gmyth/src/gmyth_recprofile.c	Wed May 23 16:11:29 2007 +0100
    35.3 @@ -26,7 +26,7 @@
    35.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    35.5   */
    35.6  
    35.7 - 
    35.8 +
    35.9  #ifdef HAVE_CONFIG_H
   35.10  #include "config.h"
   35.11  #endif
   35.12 @@ -40,52 +40,51 @@
   35.13  #include "gmyth_debug.h"
   35.14  #include "gmyth_http.h"
   35.15  
   35.16 -static void gmyth_recprofile_class_init          (GMythRecProfileClass *klass);
   35.17 -static void gmyth_recprofile_init                (GMythRecProfile *object);
   35.18 +static void gmyth_recprofile_class_init (GMythRecProfileClass * klass);
   35.19 +static void gmyth_recprofile_init (GMythRecProfile * object);
   35.20  
   35.21 -static void gmyth_recprofile_dispose  (GObject *object);
   35.22 -static void gmyth_recprofile_finalize (GObject *object);
   35.23 +static void gmyth_recprofile_dispose (GObject * object);
   35.24 +static void gmyth_recprofile_finalize (GObject * object);
   35.25  
   35.26 -G_DEFINE_TYPE(GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT)
   35.27 -
   35.28 -static void
   35.29 -gmyth_recprofile_class_init (GMythRecProfileClass *klass)
   35.30 +G_DEFINE_TYPE (GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT)
   35.31 +     static void gmyth_recprofile_class_init (GMythRecProfileClass * klass)
   35.32  {
   35.33      GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   35.34 -    gobject_class->dispose  = gmyth_recprofile_dispose;
   35.35 +
   35.36 +    gobject_class->dispose = gmyth_recprofile_dispose;
   35.37      gobject_class->finalize = gmyth_recprofile_finalize;
   35.38  }
   35.39  
   35.40  static void
   35.41 -gmyth_recprofile_init (GMythRecProfile *recprofile)
   35.42 +gmyth_recprofile_init (GMythRecProfile * recprofile)
   35.43  {
   35.44  }
   35.45  
   35.46  static void
   35.47 -gmyth_recprofile_dispose (GObject *object)
   35.48 +gmyth_recprofile_dispose (GObject * object)
   35.49  {
   35.50 -    GMythRecProfile *recprofile = GMYTH_RECPROFILE(object);
   35.51 +    GMythRecProfile *recprofile = GMYTH_RECPROFILE (object);
   35.52  
   35.53      if (recprofile->name)
   35.54 -        g_free(recprofile->name);
   35.55 +        g_free (recprofile->name);
   35.56  
   35.57      if (recprofile->group)
   35.58 -        g_free(recprofile->group);
   35.59 +        g_free (recprofile->group);
   35.60  
   35.61      if (recprofile->vcodec)
   35.62 -        g_free(recprofile->vcodec);
   35.63 +        g_free (recprofile->vcodec);
   35.64  
   35.65      if (recprofile->acodec)
   35.66 -        g_free(recprofile->acodec);
   35.67 +        g_free (recprofile->acodec);
   35.68  
   35.69      if (recprofile->options)
   35.70 -        g_free(recprofile->options);
   35.71 +        g_free (recprofile->options);
   35.72  
   35.73      G_OBJECT_CLASS (gmyth_recprofile_parent_class)->dispose (object);
   35.74  }
   35.75  
   35.76  static void
   35.77 -gmyth_recprofile_finalize (GObject *object)
   35.78 +gmyth_recprofile_finalize (GObject * object)
   35.79  {
   35.80      g_signal_handlers_destroy (object);
   35.81      G_OBJECT_CLASS (gmyth_recprofile_parent_class)->finalize (object);
   35.82 @@ -96,11 +95,11 @@
   35.83   * 
   35.84   * @return a new instance of GMythRecProfile.
   35.85   **/
   35.86 -GMythRecProfile*
   35.87 +GMythRecProfile *
   35.88  gmyth_recprofile_new (void)
   35.89  {
   35.90 -    GMythRecProfile *recprofile = GMYTH_RECPROFILE\
   35.91 -                            (g_object_new(GMYTH_RECPROFILE_TYPE, NULL));
   35.92 +    GMythRecProfile *recprofile = GMYTH_RECPROFILE
   35.93 +        (g_object_new (GMYTH_RECPROFILE_TYPE, NULL));
   35.94  
   35.95      recprofile->id = 0;
   35.96      recprofile->name = NULL;
   35.97 @@ -121,9 +120,10 @@
   35.98   * @return GSList
   35.99   *
  35.100   **/
  35.101 -GSList* gmyth_recprofile_get_profile_list (GMythBackendInfo *backend_info)
  35.102 +GSList *
  35.103 +gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info)
  35.104  {
  35.105 -    return gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders");
  35.106 +    return gmyth_http_retrieve_rec_profiles (backend_info, "Transcoders");
  35.107  }
  35.108  
  35.109  /**
  35.110 @@ -135,8 +135,9 @@
  35.111   * @return gint representing the result
  35.112   *
  35.113   **/
  35.114 -gint gmyth_recprofile_create_profile (GMythBackendInfo *backend_info,
  35.115 -                                      GMythRecProfile* profile)
  35.116 +gint
  35.117 +gmyth_recprofile_create_profile (GMythBackendInfo * backend_info,
  35.118 +    GMythRecProfile * profile)
  35.119  {
  35.120      return gmyth_http_create_rec_profile (backend_info, profile);
  35.121  }
  35.122 @@ -150,10 +151,10 @@
  35.123   * @return gint representing the result
  35.124   *
  35.125   **/
  35.126 -gint gmyth_recprofile_del_profile_list (GMythBackendInfo *backend_info,
  35.127 -                                        gint id)
  35.128 +gint
  35.129 +gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info, gint id)
  35.130  {
  35.131 -    return gmyth_http_del_rec_profile(backend_info, id);
  35.132 +    return gmyth_http_del_rec_profile (backend_info, id);
  35.133  }
  35.134  
  35.135  /**
  35.136 @@ -165,7 +166,8 @@
  35.137   * @return gint representing the result
  35.138   *
  35.139   **/
  35.140 -gint gmyth_recprofile_set_id (GMythRecProfile* rec, gint id)
  35.141 +gint
  35.142 +gmyth_recprofile_set_id (GMythRecProfile * rec, gint id)
  35.143  {
  35.144      rec->id = id;
  35.145      return 0;
  35.146 @@ -181,27 +183,23 @@
  35.147   * @return gint representing the result
  35.148   *
  35.149   **/
  35.150 -gint gmyth_recprofile_set (GMythRecProfile* rec, 
  35.151 -                           gchar* member, gchar* value)
  35.152 +gint
  35.153 +gmyth_recprofile_set (GMythRecProfile * rec, gchar * member, gchar * value)
  35.154  {
  35.155      int ret = 0;
  35.156 -    if (value != NULL)
  35.157 -    {
  35.158 -        if (g_ascii_strcasecmp(member, "name") == 0)
  35.159 -            rec->name = g_strndup(value, strlen(value));
  35.160 -        else
  35.161 -        if (g_ascii_strcasecmp(member, "group") == 0)
  35.162 -            rec->group = g_strndup(value, strlen(value));
  35.163 -        else
  35.164 -        if (g_ascii_strcasecmp(member, "vcodec") == 0)
  35.165 -            rec->vcodec = g_strndup(value, strlen(value));
  35.166 -        else
  35.167 -        if (g_ascii_strcasecmp(member, "acodec") == 0)
  35.168 -            rec->acodec = g_strndup(value, strlen(value));
  35.169 +
  35.170 +    if (value != NULL) {
  35.171 +        if (g_ascii_strcasecmp (member, "name") == 0)
  35.172 +            rec->name = g_strndup (value, strlen (value));
  35.173 +        else if (g_ascii_strcasecmp (member, "group") == 0)
  35.174 +            rec->group = g_strndup (value, strlen (value));
  35.175 +        else if (g_ascii_strcasecmp (member, "vcodec") == 0)
  35.176 +            rec->vcodec = g_strndup (value, strlen (value));
  35.177 +        else if (g_ascii_strcasecmp (member, "acodec") == 0)
  35.178 +            rec->acodec = g_strndup (value, strlen (value));
  35.179          else
  35.180              ret = -1;
  35.181 -    }
  35.182 -    else 
  35.183 +    } else
  35.184          ret = -1;
  35.185  
  35.186      return ret;
  35.187 @@ -216,9 +214,10 @@
  35.188   * @return gint representing the result
  35.189   *
  35.190   **/
  35.191 -gint gmyth_recprofile_set_name (GMythRecProfile* rec, gchar* name)
  35.192 +gint
  35.193 +gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name)
  35.194  {
  35.195 -    return gmyth_recprofile_set(rec, "name", name);
  35.196 +    return gmyth_recprofile_set (rec, "name", name);
  35.197  }
  35.198  
  35.199  /**
  35.200 @@ -230,9 +229,10 @@
  35.201   * @return gint representing the result
  35.202   *
  35.203   **/
  35.204 -gint gmyth_recprofile_set_group (GMythRecProfile* rec, gchar* group)
  35.205 +gint
  35.206 +gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group)
  35.207  {
  35.208 -    return gmyth_recprofile_set(rec, "group", group);
  35.209 +    return gmyth_recprofile_set (rec, "group", group);
  35.210  }
  35.211  
  35.212  /**
  35.213 @@ -244,9 +244,10 @@
  35.214   * @return gint representing the result
  35.215   *
  35.216   **/
  35.217 -gint gmyth_recprofile_set_vcodec (GMythRecProfile* rec, gchar* vcodec)
  35.218 +gint
  35.219 +gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec)
  35.220  {
  35.221 -    return gmyth_recprofile_set(rec, "vcodec", vcodec);
  35.222 +    return gmyth_recprofile_set (rec, "vcodec", vcodec);
  35.223  }
  35.224  
  35.225  /**
  35.226 @@ -258,8 +259,8 @@
  35.227   * @return gint representing the result
  35.228   *
  35.229   **/
  35.230 -gint gmyth_recprofile_set_acodec (GMythRecProfile* rec, gchar* acodec)
  35.231 +gint
  35.232 +gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec)
  35.233  {
  35.234 -    return gmyth_recprofile_set(rec, "acodec", acodec);
  35.235 +    return gmyth_recprofile_set (rec, "acodec", acodec);
  35.236  }
  35.237 -
    36.1 --- a/gmyth/src/gmyth_recprofile.h	Tue May 22 19:21:42 2007 +0100
    36.2 +++ b/gmyth/src/gmyth_recprofile.h	Wed May 23 16:11:29 2007 +0100
    36.3 @@ -37,33 +37,31 @@
    36.4  #include "gmyth_socket.h"
    36.5  
    36.6  G_BEGIN_DECLS
    36.7 -
    36.8  #define GMYTH_RECPROFILE_TYPE               (gmyth_recprofile_get_type ())
    36.9  #define GMYTH_RECPROFILE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_RECPROFILE_TYPE, GMythRecProfile))
   36.10  #define GMYTH_RECPROFILE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECPROFILE_TYPE, GMythRecProfileClass))
   36.11  #define IS_GMYTH_RECPROFILE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_RECPROFILE_TYPE))
   36.12  #define IS_GMYTH_RECPROFILE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_RECPROFILE_TYPE))
   36.13  #define GMYTH_RECPROFILE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_RECPROFILE_TYPE, GMythRecProfileClass))
   36.14 -
   36.15 -typedef struct _Options                 Options;
   36.16 -typedef struct _GMythRecProfile         GMythRecProfile;
   36.17 -typedef struct _GMythRecProfileClass    GMythRecProfileClass;
   36.18 +typedef struct _Options Options;
   36.19 +typedef struct _GMythRecProfile GMythRecProfile;
   36.20 +typedef struct _GMythRecProfileClass GMythRecProfileClass;
   36.21  
   36.22  struct _GMythRecProfileClass
   36.23  {
   36.24 -  GObjectClass parent_class;
   36.25 -  gint teste;
   36.26 -  /* callbacks */
   36.27 +    GObjectClass parent_class;
   36.28 +    gint teste;
   36.29 +    /* callbacks */
   36.30  };
   36.31  
   36.32  struct _GMythRecProfile
   36.33  {
   36.34 -    gint	id;
   36.35 -    gchar* name;
   36.36 -    gchar* group;
   36.37 -    gchar* vcodec;
   36.38 -    gchar* acodec;
   36.39 -    Options* options;
   36.40 +    gint id;
   36.41 +    gchar *name;
   36.42 +    gchar *group;
   36.43 +    gchar *vcodec;
   36.44 +    gchar *acodec;
   36.45 +    Options *options;
   36.46  };
   36.47  
   36.48  struct _Options
   36.49 @@ -87,14 +85,14 @@
   36.50      gint hardwaremjpegquality;
   36.51      gint hardwaremjpeghdecimation;
   36.52      gint hardwaremjpegvdecimation;
   36.53 -    gchar* mpeg2streamtype;
   36.54 -    gchar* mpeg2aspectratio;
   36.55 +    gchar *mpeg2streamtype;
   36.56 +    gchar *mpeg2aspectratio;
   36.57      gint mpeg2bitrate;
   36.58      gint mpeg2maxbitrate;
   36.59      gint samplerate;
   36.60      gint mp3quality;
   36.61      gint volume;
   36.62 -    gchar* mpeg2audtype;
   36.63 +    gchar *mpeg2audtype;
   36.64      gint mpeg2audbitratel1;
   36.65      gint mpeg2audbitratel2;
   36.66      gint mpeg2audvolume;
   36.67 @@ -102,22 +100,21 @@
   36.68  
   36.69  GType gmyth_recprofile_type (void);
   36.70  
   36.71 -GMythRecProfile* gmyth_recprofile_new (void);
   36.72 +GMythRecProfile *gmyth_recprofile_new (void);
   36.73  
   36.74 -GSList* gmyth_recprofile_get_profile_list (GMythBackendInfo *backend_info);
   36.75 +GSList *gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info);
   36.76  
   36.77 -gint gmyth_recprofile_create_profile (GMythBackendInfo *backend_info,\
   36.78 -                                      GMythRecProfile* profile);
   36.79 +gint gmyth_recprofile_create_profile (GMythBackendInfo * backend_info,
   36.80 +    GMythRecProfile * profile);
   36.81  
   36.82 -gint gmyth_recprofile_del_profile_list (GMythBackendInfo *backend_info,\
   36.83 -                                        gint id);
   36.84 +gint gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info,
   36.85 +    gint id);
   36.86  
   36.87 -gint gmyth_recprofile_set_acodec (GMythRecProfile* rec, gchar* acodec);
   36.88 -gint gmyth_recprofile_set_vcodec (GMythRecProfile* rec, gchar* vcodec);
   36.89 -gint gmyth_recprofile_set_group (GMythRecProfile* rec, gchar* group);
   36.90 -gint gmyth_recprofile_set_name (GMythRecProfile* rec, gchar* name);
   36.91 -gint gmyth_recprofile_set_id (GMythRecProfile* rec, gint id);
   36.92 +gint gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec);
   36.93 +gint gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec);
   36.94 +gint gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group);
   36.95 +gint gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name);
   36.96 +gint gmyth_recprofile_set_id (GMythRecProfile * rec, gint id);
   36.97  
   36.98  G_END_DECLS
   36.99 -
  36.100  #endif /*_GMYTH_RECPROFILE_H*/
    37.1 --- a/gmyth/src/gmyth_remote_util.c	Tue May 22 19:21:42 2007 +0100
    37.2 +++ b/gmyth/src/gmyth_remote_util.c	Wed May 23 16:11:29 2007 +0100
    37.3 @@ -9,29 +9,29 @@
    37.4   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    37.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    37.6   *
    37.7 - *//*
    37.8 - * 
    37.9 - * This program is free software; you can redistribute it and/or modify
   37.10 - * it under the terms of the GNU Lesser General Public License as published by
   37.11 - * the Free Software Foundation; either version 2 of the License, or
   37.12 - * (at your option) any later version.
   37.13 - *
   37.14 - * This program is distributed in the hope that it will be useful,
   37.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   37.17 - * GNU General Public License for more details.
   37.18 - *
   37.19 - * You should have received a copy of the GNU Lesser General Public License
   37.20 - * along with this program; if not, write to the Free Software
   37.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   37.22 - */
   37.23 - 
   37.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   37.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   37.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   37.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   37.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   37.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   37.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   37.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   37.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   37.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   37.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   37.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   37.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   37.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   37.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   37.40 +
   37.41  #ifdef HAVE_CONFIG_H
   37.42  #include "config.h"
   37.43  #endif
   37.44  
   37.45  #include "gmyth_remote_util.h"
   37.46 - 
   37.47 +
   37.48  #include "gmyth_recorder.h"
   37.49  #include "gmyth_stringlist.h"
   37.50  #include "gmyth_debug.h"
   37.51 @@ -44,42 +44,44 @@
   37.52   * 
   37.53   * @return the remote encoder instance available, or NULL if any error happens.
   37.54   */
   37.55 -GMythRecorder*
   37.56 -remote_request_next_free_recorder (GMythSocket *socket, gint curr)
   37.57 +GMythRecorder *
   37.58 +remote_request_next_free_recorder (GMythSocket * socket, gint curr)
   37.59  {
   37.60      GMythRecorder *recorder = NULL;
   37.61      GString *hostname;
   37.62      gint num, port;
   37.63 -	
   37.64 -    GMythStringList *strlist = gmyth_string_list_new();
   37.65 -	
   37.66 -    gmyth_debug ("[%s] Request next free recorder in the backend", __FUNCTION__);
   37.67 -	
   37.68 +
   37.69 +    GMythStringList *strlist = gmyth_string_list_new ();
   37.70 +
   37.71 +    gmyth_debug ("[%s] Request next free recorder in the backend",
   37.72 +        __FUNCTION__);
   37.73 +
   37.74      gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER");
   37.75      gmyth_string_list_append_int (strlist, curr);
   37.76  
   37.77 -    if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) {
   37.78 -    	g_warning ("GET_NEXT_FREE_RECORDER request error!\n");
   37.79 +    if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) {
   37.80 +        g_warning ("GET_NEXT_FREE_RECORDER request error!\n");
   37.81          return NULL;
   37.82      }
   37.83  
   37.84      num = gmyth_string_list_get_int (strlist, 0);
   37.85      hostname = gmyth_string_list_get_string (strlist, 1);
   37.86      port = gmyth_string_list_get_int (strlist, 2);
   37.87 -    
   37.88 -    if ( num < 0 || port < 0 )
   37.89 -    	goto clean_up;
   37.90  
   37.91 -    gmyth_debug ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d", 
   37.92 -				__FUNCTION__, num, hostname->str, port);
   37.93 -	
   37.94 +    if (num < 0 || port < 0)
   37.95 +        goto clean_up;
   37.96 +
   37.97 +    gmyth_debug
   37.98 +        ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d",
   37.99 +        __FUNCTION__, num, hostname->str, port);
  37.100 +
  37.101      recorder = gmyth_recorder_new (num, hostname, port);
  37.102  
  37.103 -clean_up:
  37.104 +  clean_up:
  37.105  
  37.106      g_string_free (hostname, TRUE);
  37.107      g_object_unref (strlist);
  37.108 -	
  37.109 +
  37.110      return recorder;
  37.111  }
  37.112  
  37.113 @@ -91,33 +93,33 @@
  37.114   * @return the number of remote encoders instance available, or 0 if no one is actually free..
  37.115   */
  37.116  gint
  37.117 -gmyth_remote_util_get_free_recorder_count (GMythSocket *socket)
  37.118 +gmyth_remote_util_get_free_recorder_count (GMythSocket * socket)
  37.119  {
  37.120      gint num_recs = 0;
  37.121 -	
  37.122 -    GMythStringList *strlist = gmyth_string_list_new();
  37.123 -	
  37.124 -    gmyth_debug ("[%s] Request next free recorder in the backend", __FUNCTION__);
  37.125 -	
  37.126 +
  37.127 +    GMythStringList *strlist = gmyth_string_list_new ();
  37.128 +
  37.129 +    gmyth_debug ("[%s] Request next free recorder in the backend",
  37.130 +        __FUNCTION__);
  37.131 +
  37.132      gmyth_string_list_append_char_array (strlist, "GET_FREE_RECORDER_COUNT");
  37.133  
  37.134 -    if (!gmyth_socket_sendreceive_stringlist(socket, strlist)) {
  37.135 -    	gmyth_debug ("GET_FREE_RECORDER_COUNT request error!");
  37.136 -      return 0;
  37.137 +    if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) {
  37.138 +        gmyth_debug ("GET_FREE_RECORDER_COUNT request error!");
  37.139 +        return 0;
  37.140      }
  37.141 -    
  37.142 +
  37.143      num_recs = gmyth_string_list_get_int (strlist, 0);
  37.144 -    
  37.145 -    if ( num_recs < 0 )
  37.146 -    	goto clean_up;
  37.147  
  37.148 -    gmyth_debug ("[%s] Free recorder info received: num recorders: %d", 
  37.149 -				__FUNCTION__, num_recs);	
  37.150 +    if (num_recs < 0)
  37.151 +        goto clean_up;
  37.152  
  37.153 -clean_up:
  37.154 -	
  37.155 +    gmyth_debug ("[%s] Free recorder info received: num recorders: %d",
  37.156 +        __FUNCTION__, num_recs);
  37.157 +
  37.158 +  clean_up:
  37.159 +
  37.160      g_object_unref (strlist);
  37.161 -	
  37.162 +
  37.163      return num_recs;
  37.164  }
  37.165 -
    38.1 --- a/gmyth/src/gmyth_remote_util.h	Tue May 22 19:21:42 2007 +0100
    38.2 +++ b/gmyth/src/gmyth_remote_util.h	Wed May 23 16:11:29 2007 +0100
    38.3 @@ -8,22 +8,22 @@
    38.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    38.5   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    38.6   *
    38.7 - *//*
    38.8 - * 
    38.9 - * This program is free software; you can redistribute it and/or modify
   38.10 - * it under the terms of the GNU Lesser General Public License as published by
   38.11 - * the Free Software Foundation; either version 2 of the License, or
   38.12 - * (at your option) any later version.
   38.13 - *
   38.14 - * This program is distributed in the hope that it will be useful,
   38.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   38.17 - * GNU General Public License for more details.
   38.18 - *
   38.19 - * You should have received a copy of the GNU Lesser General Public License
   38.20 - * along with this program; if not, write to the Free Software
   38.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   38.22 - */
   38.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   38.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   38.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   38.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   38.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   38.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   38.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   38.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   38.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   38.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   38.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   38.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   38.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   38.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   38.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   38.39  
   38.40  #ifndef __REMOTE_UTIL_H__
   38.41  #define __REMOTE_UTIL_H__
   38.42 @@ -33,10 +33,9 @@
   38.43  #include "gmyth_socket.h"
   38.44  
   38.45  G_BEGIN_DECLS
   38.46 -
   38.47 -GMythRecorder* remote_request_next_free_recorder (GMythSocket *socket, gint curr);
   38.48 -gint					 gmyth_remote_util_get_free_recorder_count (GMythSocket *socket);
   38.49 +    GMythRecorder * remote_request_next_free_recorder (GMythSocket * socket,
   38.50 +    gint curr);
   38.51 +gint gmyth_remote_util_get_free_recorder_count (GMythSocket * socket);
   38.52  
   38.53  G_END_DECLS
   38.54 -
   38.55  #endif
    39.1 --- a/gmyth/src/gmyth_scheduler.c	Tue May 22 19:21:42 2007 +0100
    39.2 +++ b/gmyth/src/gmyth_scheduler.c	Wed May 23 16:11:29 2007 +0100
    39.3 @@ -9,23 +9,23 @@
    39.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    39.5   * @author Alexsandro Jose Virginio dos Santos <alexsandro.santos@indt.org.br>
    39.6   *
    39.7 - *//*
    39.8 - * 
    39.9 - * This program is free software; you can redistribute it and/or modify
   39.10 - * it under the terms of the GNU Lesser General Public License as published by
   39.11 - * the Free Software Foundation; either version 2 of the License, or
   39.12 - * (at your option) any later version.
   39.13 - *
   39.14 - * This program is distributed in the hope that it will be useful,
   39.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   39.17 - * GNU General Public License for more details.
   39.18 - *
   39.19 - * You should have received a copy of the GNU Lesser General Public License
   39.20 - * along with this program; if not, write to the Free Software
   39.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   39.22 - */
   39.23 - 
   39.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   39.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   39.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   39.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   39.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   39.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   39.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   39.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   39.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   39.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   39.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   39.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   39.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   39.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   39.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   39.40 +
   39.41  #ifdef HAVE_CONFIG_H
   39.42  #include "config.h"
   39.43  #endif
   39.44 @@ -40,36 +40,34 @@
   39.45  #include "gmyth_socket.h"
   39.46  #include "gmyth_debug.h"
   39.47  
   39.48 -static void gmyth_scheduler_class_init  (GMythSchedulerClass *klass);
   39.49 -static void gmyth_scheduler_init        (GMythScheduler *object);
   39.50 +static void gmyth_scheduler_class_init (GMythSchedulerClass * klass);
   39.51 +static void gmyth_scheduler_init (GMythScheduler * object);
   39.52  
   39.53 -static void gmyth_scheduler_dispose  (GObject *object);
   39.54 -static void gmyth_scheduler_finalize (GObject *object);
   39.55 +static void gmyth_scheduler_dispose (GObject * object);
   39.56 +static void gmyth_scheduler_finalize (GObject * object);
   39.57  
   39.58 -static gint get_record_id_from_database (GMythScheduler *scheduler);
   39.59 -static gboolean update_backend  (GMythScheduler *scheduler, gint record_id);
   39.60 +static gint get_record_id_from_database (GMythScheduler * scheduler);
   39.61 +static gboolean update_backend (GMythScheduler * scheduler, gint record_id);
   39.62  
   39.63 -G_DEFINE_TYPE(GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT)
   39.64 -    
   39.65 -static void
   39.66 -gmyth_scheduler_class_init (GMythSchedulerClass *klass)
   39.67 +G_DEFINE_TYPE (GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT)
   39.68 +     static void gmyth_scheduler_class_init (GMythSchedulerClass * klass)
   39.69  {
   39.70      GObjectClass *gobject_class;
   39.71  
   39.72      gobject_class = (GObjectClass *) klass;
   39.73  
   39.74 -    gobject_class->dispose  = gmyth_scheduler_dispose;
   39.75 -    gobject_class->finalize = gmyth_scheduler_finalize;	
   39.76 +    gobject_class->dispose = gmyth_scheduler_dispose;
   39.77 +    gobject_class->finalize = gmyth_scheduler_finalize;
   39.78  }
   39.79  
   39.80  static void
   39.81 -gmyth_scheduler_init (GMythScheduler *sched)
   39.82 +gmyth_scheduler_init (GMythScheduler * sched)
   39.83  {
   39.84 -    sched->recordid =0;
   39.85 +    sched->recordid = 0;
   39.86      sched->type = 0;
   39.87      sched->search = 0;
   39.88 -    sched->profile = g_string_new("");
   39.89 -    
   39.90 +    sched->profile = g_string_new ("");
   39.91 +
   39.92      sched->dupin = 0;
   39.93      sched->dupmethod = 0;
   39.94      sched->autoexpire = 0;
   39.95 @@ -81,27 +79,27 @@
   39.96      sched->autouserjob2 = 0;
   39.97      sched->autouserjob3 = 0;
   39.98      sched->autouserjob4 = 0;
   39.99 -    
  39.100 +
  39.101      sched->startoffset = 0;
  39.102      sched->endoffset = 0;
  39.103      sched->maxepisodes = 0;
  39.104      sched->maxnewest = 0;
  39.105  
  39.106      sched->recpriority = 0;
  39.107 -    sched->recgroup = g_string_new("");
  39.108 -    sched->playgroup = g_string_new("");
  39.109 -    
  39.110 +    sched->recgroup = g_string_new ("");
  39.111 +    sched->playgroup = g_string_new ("");
  39.112 +
  39.113      sched->prefinput = 0;
  39.114      sched->inactive = 0;
  39.115 -    
  39.116 -    sched->search_type = g_string_new("");
  39.117 -    sched->search_what = g_string_new("");
  39.118 -    
  39.119 +
  39.120 +    sched->search_type = g_string_new ("");
  39.121 +    sched->search_what = g_string_new ("");
  39.122 +
  39.123      sched->msqlquery = gmyth_query_new ();
  39.124  }
  39.125  
  39.126  static void
  39.127 -gmyth_scheduler_dispose  (GObject *object)
  39.128 +gmyth_scheduler_dispose (GObject * object)
  39.129  {
  39.130      GMythScheduler *scheduler = GMYTH_SCHEDULER (object);
  39.131  
  39.132 @@ -125,7 +123,7 @@
  39.133  }
  39.134  
  39.135  static void
  39.136 -gmyth_scheduler_finalize (GObject *object)
  39.137 +gmyth_scheduler_finalize (GObject * object)
  39.138  {
  39.139      g_signal_handlers_destroy (object);
  39.140  
  39.141 @@ -136,17 +134,18 @@
  39.142   * 
  39.143   * @return a new instance of GMythScheduler.
  39.144   */
  39.145 -GMythScheduler*
  39.146 +GMythScheduler *
  39.147  gmyth_scheduler_new ()
  39.148  {
  39.149 -    GMythScheduler *scheduler = 
  39.150 -        GMYTH_SCHEDULER (g_object_new(GMYTH_SCHEDULER_TYPE, NULL));
  39.151 -    
  39.152 +    GMythScheduler *scheduler =
  39.153 +        GMYTH_SCHEDULER (g_object_new (GMYTH_SCHEDULER_TYPE, NULL));
  39.154 +
  39.155      return scheduler;
  39.156  }
  39.157  
  39.158  gboolean
  39.159 -gmyth_scheduler_connect (GMythScheduler *scheduler, GMythBackendInfo *backend_info)
  39.160 +gmyth_scheduler_connect (GMythScheduler * scheduler,
  39.161 +    GMythBackendInfo * backend_info)
  39.162  {
  39.163      return gmyth_scheduler_connect_with_timeout (scheduler, backend_info, 0);
  39.164  }
  39.165 @@ -158,24 +157,24 @@
  39.166   * @return true if connection was success, false if failed.
  39.167   */
  39.168  gboolean
  39.169 -gmyth_scheduler_connect_with_timeout (GMythScheduler *scheduler,
  39.170 -	       GMythBackendInfo *backend_info, guint timeout)
  39.171 +gmyth_scheduler_connect_with_timeout (GMythScheduler * scheduler,
  39.172 +    GMythBackendInfo * backend_info, guint timeout)
  39.173  {
  39.174 -    assert(scheduler);
  39.175 +    assert (scheduler);
  39.176      g_return_val_if_fail (backend_info != NULL, FALSE);
  39.177 -    
  39.178 +
  39.179      if (scheduler->backend_info)
  39.180          g_object_unref (scheduler->backend_info);
  39.181 -    
  39.182 +
  39.183      scheduler->backend_info = g_object_ref (backend_info);
  39.184  
  39.185      if (scheduler->msqlquery == NULL) {
  39.186          g_warning ("[%s] GMythScheduler db initializing", __FUNCTION__);
  39.187 -        scheduler->msqlquery = gmyth_query_new ();		
  39.188 +        scheduler->msqlquery = gmyth_query_new ();
  39.189      }
  39.190  
  39.191 -    if (!gmyth_query_connect_with_timeout (scheduler->msqlquery, 
  39.192 -			    scheduler->backend_info, timeout)) {
  39.193 +    if (!gmyth_query_connect_with_timeout (scheduler->msqlquery,
  39.194 +            scheduler->backend_info, timeout)) {
  39.195          g_warning ("[%s] Error while connecting to db", __FUNCTION__);
  39.196          return FALSE;
  39.197      }
  39.198 @@ -189,9 +188,9 @@
  39.199   * @return true if disconnection was success, false if failed.
  39.200   */
  39.201  gboolean
  39.202 -gmyth_scheduler_disconnect (GMythScheduler *scheduler)
  39.203 +gmyth_scheduler_disconnect (GMythScheduler * scheduler)
  39.204  {
  39.205 -    assert(scheduler);
  39.206 +    assert (scheduler);
  39.207  
  39.208      if (scheduler->msqlquery != NULL) {
  39.209          gmyth_query_disconnect (scheduler->msqlquery);
  39.210 @@ -207,60 +206,64 @@
  39.211   * @return The amount of schedules retrieved from database, or -1 if error.
  39.212   */
  39.213  gint
  39.214 -gmyth_scheduler_get_schedule_list ( GMythScheduler *scheduler, GList **schedule_list)
  39.215 +gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
  39.216 +    GList ** schedule_list)
  39.217  {
  39.218      ScheduleInfo *schedule;
  39.219      MYSQL_RES *msql_res;
  39.220      GString *query_str = g_string_new ("");
  39.221      gchar *date_time = NULL;
  39.222 -    
  39.223 -    assert(scheduler);
  39.224 -    
  39.225 -    g_string_printf (query_str, 
  39.226 -    	"SELECT recordid,programid,chanid,starttime,startdate,"
  39.227 -    	"endtime,enddate,title,subtitle,description,category FROM record;");
  39.228 +
  39.229 +    assert (scheduler);
  39.230 +
  39.231 +    g_string_printf (query_str,
  39.232 +        "SELECT recordid,programid,chanid,starttime,startdate,"
  39.233 +        "endtime,enddate,title,subtitle,description,category FROM record;");
  39.234  
  39.235      if (scheduler->msqlquery == NULL) {
  39.236 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.237 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.238 +            __FUNCTION__);
  39.239          return -1;
  39.240      }
  39.241 -    msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.242 +    msql_res =
  39.243 +        gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.244  
  39.245      if (msql_res == NULL) {
  39.246          g_warning ("DB retrieval of schedule list failed");
  39.247          return -1;
  39.248      } else {
  39.249          MYSQL_ROW row;
  39.250 +
  39.251          *schedule_list = NULL;
  39.252 -        
  39.253 -        while((row = mysql_fetch_row (msql_res)) != NULL) {
  39.254 -            schedule = g_new0(ScheduleInfo, 1);
  39.255 -        	
  39.256 -            schedule->schedule_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
  39.257 +
  39.258 +        while ((row = mysql_fetch_row (msql_res)) != NULL) {
  39.259 +            schedule = g_new0 (ScheduleInfo, 1);
  39.260 +
  39.261 +            schedule->schedule_id = (guint) g_ascii_strtoull (row[0], NULL, 10);
  39.262              schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
  39.263              schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
  39.264 -            
  39.265 +
  39.266              /* generate a time_t from a time and a date db field */
  39.267              date_time = g_strdup_printf ("%sT%s", row[4], row[3]);
  39.268              schedule->start_time = gmyth_util_string_to_time_val (date_time);
  39.269              g_free (date_time);
  39.270 -            
  39.271 +
  39.272              /* generate a time_t from a time and a date db field */
  39.273              date_time = g_strdup_printf ("%sT%s", row[6], row[5]);
  39.274              schedule->end_time = gmyth_util_string_to_time_val (date_time);
  39.275              g_free (date_time);
  39.276  
  39.277 -            schedule->title       = g_string_new (row[7]);
  39.278 -            schedule->subtitle    = g_string_new (row[8]);
  39.279 +            schedule->title = g_string_new (row[7]);
  39.280 +            schedule->subtitle = g_string_new (row[8]);
  39.281              schedule->description = g_string_new (row[9]);
  39.282 -            schedule->category    = g_string_new (row[10]);
  39.283 +            schedule->category = g_string_new (row[10]);
  39.284  
  39.285              (*schedule_list) = g_list_append (*(schedule_list), schedule);
  39.286          }
  39.287      }
  39.288  
  39.289      mysql_free_result (msql_res);
  39.290 -    g_string_free(query_str, TRUE);
  39.291 +    g_string_free (query_str, TRUE);
  39.292  
  39.293      return (*schedule_list == NULL) ? 0 : g_list_length (*schedule_list);
  39.294  }
  39.295 @@ -272,73 +275,81 @@
  39.296   * @return The amount of recorded retrieved from database, or -1 if error.
  39.297   */
  39.298  gint
  39.299 -gmyth_scheduler_get_recorded_list (GMythScheduler *scheduler, GList **recorded_list)
  39.300 +gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler,
  39.301 +    GList ** recorded_list)
  39.302  {
  39.303      RecordedInfo *record;
  39.304      MYSQL_RES *msql_res;
  39.305      GString *query_str = g_string_new ("");
  39.306 -	
  39.307 -    assert(scheduler);
  39.308 -    
  39.309 -    g_string_printf (query_str, 
  39.310 -    	"SELECT recordid,programid,chanid,starttime,progstart,"
  39.311 -    	"endtime,progend,title,subtitle,description,category,"
  39.312 +
  39.313 +    assert (scheduler);
  39.314 +
  39.315 +    g_string_printf (query_str,
  39.316 +        "SELECT recordid,programid,chanid,starttime,progstart,"
  39.317 +        "endtime,progend,title,subtitle,description,category,"
  39.318          "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
  39.319  
  39.320      if (scheduler->msqlquery == NULL) {
  39.321 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.322 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.323 +            __FUNCTION__);
  39.324          return -1;
  39.325      }
  39.326  
  39.327 -    msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.328 +    msql_res =
  39.329 +        gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.330  
  39.331      if (msql_res == NULL) {
  39.332          g_warning ("DB retrieval of recording list failed");
  39.333          return -1;
  39.334      } else {
  39.335          MYSQL_ROW row;
  39.336 +
  39.337          (*recorded_list) = NULL;
  39.338 -        
  39.339 -        while((row = mysql_fetch_row (msql_res))!=NULL){
  39.340 -            record = g_new0(RecordedInfo, 1);
  39.341 -            
  39.342 -            record->record_id  = (guint) g_ascii_strtoull (row[0], NULL, 10);
  39.343 +
  39.344 +        while ((row = mysql_fetch_row (msql_res)) != NULL) {
  39.345 +            record = g_new0 (RecordedInfo, 1);
  39.346 +
  39.347 +            record->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10);
  39.348              record->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
  39.349              record->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
  39.350 -            
  39.351 +
  39.352              record->start_time = gmyth_util_string_to_time_val (row[3]);
  39.353 -            record->end_time   = gmyth_util_string_to_time_val (row[5]);
  39.354 -	
  39.355 -            record->title       = g_string_new (row[7]);
  39.356 -            record->subtitle    = g_string_new (row[8]);
  39.357 +            record->end_time = gmyth_util_string_to_time_val (row[5]);
  39.358 +
  39.359 +            record->title = g_string_new (row[7]);
  39.360 +            record->subtitle = g_string_new (row[8]);
  39.361              record->description = g_string_new (row[9]);
  39.362 -            record->category    = g_string_new (row[10]);
  39.363 -            record->filesize    = g_ascii_strtoull (row[11], NULL, 10);
  39.364 -            record->basename    = g_string_new (row[12]);
  39.365 +            record->category = g_string_new (row[10]);
  39.366 +            record->filesize = g_ascii_strtoull (row[11], NULL, 10);
  39.367 +            record->basename = g_string_new (row[12]);
  39.368  
  39.369              (*recorded_list) = g_list_append ((*recorded_list), record);
  39.370          }
  39.371      }
  39.372 -    
  39.373 +
  39.374      mysql_free_result (msql_res);
  39.375 -    g_string_free(query_str, TRUE);
  39.376 +    g_string_free (query_str, TRUE);
  39.377  
  39.378      return (*recorded_list == NULL) ? 0 : g_list_length (*recorded_list);
  39.379  }
  39.380  
  39.381  static void
  39.382 -_set_value (GMythQuery *myth_query, char* field, gchar* value, gint rec_id)
  39.383 +_set_value (GMythQuery * myth_query, char *field, gchar * value, gint rec_id)
  39.384  {
  39.385 -    gchar* query = g_strdup_printf ("UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;", rec_id, field, value, rec_id);
  39.386 +    gchar *query =
  39.387 +        g_strdup_printf
  39.388 +        ("UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;",
  39.389 +        rec_id, field, value, rec_id);
  39.390  
  39.391      gmyth_query_process_statement (myth_query, query);
  39.392 -    g_free (query);    
  39.393 +    g_free (query);
  39.394  }
  39.395  
  39.396  static void
  39.397 -_set_int_value (GMythQuery *myth_query, char* field, gint value, gint rec_id)
  39.398 +_set_int_value (GMythQuery * myth_query, char *field, gint value, gint rec_id)
  39.399  {
  39.400      gchar *str_value = g_strdup_printf ("%d", value);
  39.401 +
  39.402      _set_value (myth_query, field, str_value, rec_id);
  39.403      g_free (str_value);
  39.404  }
  39.405 @@ -352,32 +363,38 @@
  39.406   * @return gboolean returns FALSE if some error occurs, TRUE otherwise
  39.407   */
  39.408  gboolean
  39.409 -gmyth_scheduler_add_schedule (GMythScheduler *scheduler,
  39.410 -                              ScheduleInfo *schedule_info)
  39.411 +gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
  39.412 +    ScheduleInfo * schedule_info)
  39.413  {
  39.414      MYSQL_RES *msql_res;
  39.415      gchar *query_str = "INSERT record (recordid) VALUE (0);";
  39.416      gchar *station = NULL;
  39.417      gulong rec_id;
  39.418 -    
  39.419 -    assert(scheduler);
  39.420 -    
  39.421 +
  39.422 +    assert (scheduler);
  39.423 +
  39.424      if (scheduler->msqlquery == NULL) {
  39.425 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.426 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.427 +            __FUNCTION__);
  39.428          return FALSE;
  39.429      }
  39.430  
  39.431 -    msql_res = gmyth_query_process_statement_with_increment (scheduler->msqlquery, query_str, &rec_id);
  39.432 +    msql_res =
  39.433 +        gmyth_query_process_statement_with_increment (scheduler->msqlquery,
  39.434 +        query_str, &rec_id);
  39.435      mysql_free_result (msql_res);
  39.436 -    
  39.437 +
  39.438      // Retrieves the station info
  39.439 -    query_str = g_strdup_printf ("SELECT callsign FROM channel WHERE chanid = \"%d\";", schedule_info->channel_id);
  39.440 +    query_str =
  39.441 +        g_strdup_printf ("SELECT callsign FROM channel WHERE chanid = \"%d\";",
  39.442 +        schedule_info->channel_id);
  39.443      msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str);
  39.444      if (msql_res == NULL) {
  39.445          g_warning ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
  39.446          return FALSE;
  39.447      } else {
  39.448          MYSQL_ROW row;
  39.449 +
  39.450          if ((row = mysql_fetch_row (msql_res)) != NULL) {
  39.451              station = g_strdup (row[0]);
  39.452          }
  39.453 @@ -386,14 +403,22 @@
  39.454      g_free (query_str);
  39.455  
  39.456      // _set_value (field, value, id);
  39.457 -    _set_int_value (scheduler->msqlquery, "chanid", schedule_info->channel_id, rec_id);
  39.458 +    _set_int_value (scheduler->msqlquery, "chanid", schedule_info->channel_id,
  39.459 +        rec_id);
  39.460      _set_value (scheduler->msqlquery, "station", station, rec_id);
  39.461 -    _set_value (scheduler->msqlquery, "title", schedule_info->title->str, rec_id);
  39.462 +    _set_value (scheduler->msqlquery, "title", schedule_info->title->str,
  39.463 +        rec_id);
  39.464      /// subtitle, description    
  39.465 -    _set_value (scheduler->msqlquery, "starttime", gmyth_util_time_to_string_only_time( schedule_info->start_time), rec_id);
  39.466 -    _set_value (scheduler->msqlquery, "startdate", gmyth_util_time_to_string_only_date( schedule_info->start_time), rec_id);
  39.467 -    _set_value (scheduler->msqlquery, "endtime", gmyth_util_time_to_string_only_time( schedule_info->end_time), rec_id);
  39.468 -    _set_value (scheduler->msqlquery, "enddate", gmyth_util_time_to_string_only_date( schedule_info->end_time), rec_id);
  39.469 +    _set_value (scheduler->msqlquery, "starttime",
  39.470 +        gmyth_util_time_to_string_only_time (schedule_info->
  39.471 +            start_time), rec_id);
  39.472 +    _set_value (scheduler->msqlquery, "startdate",
  39.473 +        gmyth_util_time_to_string_only_date (schedule_info->
  39.474 +            start_time), rec_id);
  39.475 +    _set_value (scheduler->msqlquery, "endtime",
  39.476 +        gmyth_util_time_to_string_only_time (schedule_info->end_time), rec_id);
  39.477 +    _set_value (scheduler->msqlquery, "enddate",
  39.478 +        gmyth_util_time_to_string_only_date (schedule_info->end_time), rec_id);
  39.479      /// category, series id, program id
  39.480      //_set_value (scheduler->msqlquery, "findday", (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, rec_id);
  39.481      //_set_value (scheduler->msqlquery, "findtime", gmyth_util_time_to_string_only_time( schedule_info->start_time), rec_id);
  39.482 @@ -404,8 +429,8 @@
  39.483      _set_value (scheduler->msqlquery, "recpriority", "0", rec_id);
  39.484      _set_value (scheduler->msqlquery, "startoffset", "0", rec_id);
  39.485      _set_value (scheduler->msqlquery, "endoffset", "0", rec_id);
  39.486 -    _set_value (scheduler->msqlquery, "dupmethod", "6", rec_id); // ?
  39.487 -    _set_value (scheduler->msqlquery, "dupin", "15", rec_id); // ?
  39.488 +    _set_value (scheduler->msqlquery, "dupmethod", "6", rec_id);    // ?
  39.489 +    _set_value (scheduler->msqlquery, "dupin", "15", rec_id);   // ?
  39.490  
  39.491      _set_value (scheduler->msqlquery, "prefinput", "0", rec_id);
  39.492      _set_value (scheduler->msqlquery, "inactive", "0", rec_id);
  39.493 @@ -428,7 +453,7 @@
  39.494      schedule_info->schedule_id = rec_id;
  39.495  
  39.496      /* Notify the backend of changes */
  39.497 -    return update_backend(scheduler, rec_id);
  39.498 +    return update_backend (scheduler, rec_id);
  39.499  }
  39.500  
  39.501  /** Requests the Mysql database in the backend to remove an existing schedule.
  39.502 @@ -438,31 +463,32 @@
  39.503   * @return gboolean TRUE if success, FALSE if error
  39.504   */
  39.505  gboolean
  39.506 -gmyth_scheduler_delete_schedule (GMythScheduler *scheduler, gint record_id)
  39.507 +gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint record_id)
  39.508  {
  39.509  
  39.510      MYSQL_RES *msql_res;
  39.511      GString *query_str = g_string_new ("");
  39.512  
  39.513 -    assert(scheduler);
  39.514 -    
  39.515 +    assert (scheduler);
  39.516 +
  39.517      if (scheduler->msqlquery == NULL) {
  39.518 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.519 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.520 +            __FUNCTION__);
  39.521          return FALSE;
  39.522      }
  39.523 +    //========================================
  39.524 +    g_string_printf (query_str,
  39.525 +        "DELETE FROM record WHERE recordid=%d", record_id);
  39.526  
  39.527 -    //========================================
  39.528 -    g_string_printf (query_str, 
  39.529 -    	"DELETE FROM record WHERE recordid=%d", record_id);
  39.530 +    msql_res =
  39.531 +        gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.532  
  39.533 -    msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.534  
  39.535 -    
  39.536      mysql_free_result (msql_res);
  39.537 -    g_string_free(query_str, TRUE);
  39.538 -    
  39.539 +    g_string_free (query_str, TRUE);
  39.540 +
  39.541      // Notify the backend of the changes
  39.542 -    return update_backend(scheduler, record_id);
  39.543 +    return update_backend (scheduler, record_id);
  39.544  }
  39.545  
  39.546  /** Requests the Mysql database in the backend to remove an existing recorded item.
  39.547 @@ -472,33 +498,34 @@
  39.548   * @return gboolean TRUE if success, FALSE if error
  39.549   */
  39.550  gboolean
  39.551 -gmyth_scheduler_delete_recorded (GMythScheduler *scheduler, gint record_id)
  39.552 +gmyth_scheduler_delete_recorded (GMythScheduler * scheduler, gint record_id)
  39.553  {
  39.554  
  39.555      MYSQL_RES *msql_res;
  39.556  
  39.557      GString *query_str = g_string_new ("");
  39.558  
  39.559 -    assert(scheduler);
  39.560 -    
  39.561 +    assert (scheduler);
  39.562 +
  39.563      if (scheduler->msqlquery == NULL) {
  39.564 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.565 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.566 +            __FUNCTION__);
  39.567          return FALSE;
  39.568      }
  39.569 -
  39.570      //========================================
  39.571 -    g_string_printf (query_str, 
  39.572 -    	"DELETE FROM recorded WHERE recordid=%d", record_id);
  39.573 +    g_string_printf (query_str,
  39.574 +        "DELETE FROM recorded WHERE recordid=%d", record_id);
  39.575  
  39.576      // FIXME: Mythtv implementation runs also: DELETE FROM oldfind WHERE recordid = x
  39.577  
  39.578 -    msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.579 -    
  39.580 +    msql_res =
  39.581 +        gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.582 +
  39.583      mysql_free_result (msql_res);
  39.584 -    g_string_free(query_str, TRUE);
  39.585 -    
  39.586 +    g_string_free (query_str, TRUE);
  39.587 +
  39.588      // Notify the backend of the changes
  39.589 -    return update_backend(scheduler, record_id);
  39.590 +    return update_backend (scheduler, record_id);
  39.591  }
  39.592  
  39.593  /** Retrieves an existing recorded item information from database. The information
  39.594 @@ -510,44 +537,46 @@
  39.595   * @return A GMythProgramInfo struct with the requested record item
  39.596   * information, or NULL if error.
  39.597   */
  39.598 -GMythProgramInfo*
  39.599 -gmyth_scheduler_get_recorded (GMythScheduler *scheduler, 
  39.600 -                              GString *channel, GTimeVal* starttime)
  39.601 +GMythProgramInfo *
  39.602 +gmyth_scheduler_get_recorded (GMythScheduler * scheduler,
  39.603 +    GString * channel, GTimeVal * starttime)
  39.604  {
  39.605      MYSQL_RES *msql_res;
  39.606      GMythProgramInfo *proginfo = NULL;
  39.607 -    GString *query_str = g_string_new("");
  39.608 +    GString *query_str = g_string_new ("");
  39.609      gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime);
  39.610  
  39.611 -    assert(scheduler);
  39.612 +    assert (scheduler);
  39.613  
  39.614      gmyth_debug ("[%s] channel: %s", __FUNCTION__, channel->str);
  39.615 -    
  39.616 +
  39.617      if (scheduler->msqlquery == NULL) {
  39.618 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.619 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.620 +            __FUNCTION__);
  39.621          return NULL;
  39.622      }
  39.623  
  39.624 -    g_string_printf (query_str, "SELECT recorded.chanid,starttime,endtime,title, "
  39.625 -                  "subtitle,description,channel.channum, "
  39.626 -                  "channel.callsign,channel.name,channel.commfree, "
  39.627 -                  "channel.outputfilters,seriesid,programid,filesize, "
  39.628 -                  "lastmodified,stars,previouslyshown,originalairdate, "
  39.629 -                  "hostname,recordid,transcoder,playgroup, "
  39.630 -                  "recorded.recpriority,progstart,progend,basename,recgroup "
  39.631 -                  "FROM recorded "
  39.632 -                  "LEFT JOIN channel "
  39.633 -                  "ON recorded.chanid = channel.chanid "
  39.634 -                  "WHERE recorded.chanid = \"%s\" "
  39.635 -                  "AND starttime = \"%s\" ;",
  39.636 -                  channel->str, time_str);
  39.637 +    g_string_printf (query_str,
  39.638 +        "SELECT recorded.chanid,starttime,endtime,title, "
  39.639 +        "subtitle,description,channel.channum, "
  39.640 +        "channel.callsign,channel.name,channel.commfree, "
  39.641 +        "channel.outputfilters,seriesid,programid,filesize, "
  39.642 +        "lastmodified,stars,previouslyshown,originalairdate, "
  39.643 +        "hostname,recordid,transcoder,playgroup, "
  39.644 +        "recorded.recpriority,progstart,progend,basename,recgroup "
  39.645 +        "FROM recorded " "LEFT JOIN channel "
  39.646 +        "ON recorded.chanid = channel.chanid "
  39.647 +        "WHERE recorded.chanid = \"%s\" "
  39.648 +        "AND starttime = \"%s\" ;", channel->str, time_str);
  39.649  
  39.650 -    msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.651 +    msql_res =
  39.652 +        gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
  39.653  
  39.654 -    if (msql_res /*&& query.size() > 0*/) {
  39.655 +    if (msql_res /*&& query.size() > 0 */ ) {
  39.656          MYSQL_ROW msql_row = mysql_fetch_row (msql_res);
  39.657 +
  39.658          if (msql_row) {
  39.659 -            proginfo = gmyth_program_info_new();
  39.660 +            proginfo = gmyth_program_info_new ();
  39.661  
  39.662              proginfo->chanid = g_string_new (msql_row[0]);
  39.663              proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]);
  39.664 @@ -561,13 +590,15 @@
  39.665              proginfo->chanstr = g_string_new (msql_row[6]);
  39.666              proginfo->chansign = g_string_new (msql_row[7]);
  39.667              proginfo->channame = g_string_new (msql_row[0]);
  39.668 -            proginfo->chancommfree = (gint) g_ascii_strtoull (msql_row[9], NULL, 10);
  39.669 +            proginfo->chancommfree =
  39.670 +                (gint) g_ascii_strtoull (msql_row[9], NULL, 10);
  39.671              proginfo->chanOutputFilters = g_string_new (msql_row[10]);
  39.672              proginfo->seriesid = g_string_new (msql_row[11]);
  39.673              proginfo->programid = g_string_new (msql_row[12]);
  39.674              proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10);
  39.675  
  39.676 -            proginfo->lastmodified = gmyth_util_string_to_time_val (msql_row[14]);      
  39.677 +            proginfo->lastmodified =
  39.678 +                gmyth_util_string_to_time_val (msql_row[14]);
  39.679              proginfo->stars = g_ascii_strtod (msql_row[15], NULL);
  39.680              proginfo->repeat = (gint) g_ascii_strtoull (msql_row[16], NULL, 10);
  39.681  
  39.682 @@ -575,29 +606,33 @@
  39.683                  proginfo->originalAirDate = 0;
  39.684                  proginfo->hasAirDate = FALSE;
  39.685              } else {
  39.686 -                proginfo->originalAirDate = gmyth_util_string_to_time_val (msql_row[17]);
  39.687 +                proginfo->originalAirDate =
  39.688 +                    gmyth_util_string_to_time_val (msql_row[17]);
  39.689                  proginfo->hasAirDate = TRUE;
  39.690              }
  39.691  
  39.692 -            proginfo->hostname = g_string_new (msql_row[18]);                
  39.693 -            proginfo->recordid = (gint) g_ascii_strtoull (msql_row[19], NULL, 10);
  39.694 -            proginfo->transcoder = (gint) g_ascii_strtoull (msql_row[20], NULL, 10);
  39.695 +            proginfo->hostname = g_string_new (msql_row[18]);
  39.696 +            proginfo->recordid =
  39.697 +                (gint) g_ascii_strtoull (msql_row[19], NULL, 10);
  39.698 +            proginfo->transcoder =
  39.699 +                (gint) g_ascii_strtoull (msql_row[20], NULL, 10);
  39.700              //proginfo->spread = -1;
  39.701              //proginfo->programflags = proginfo->getProgramFlags();
  39.702  
  39.703              proginfo->recgroup = g_string_new (msql_row[26]);
  39.704              proginfo->playgroup = g_string_new (msql_row[21]);
  39.705 -            proginfo->recpriority = (gint) g_ascii_strtoull (msql_row[22], NULL, 10);
  39.706 +            proginfo->recpriority =
  39.707 +                (gint) g_ascii_strtoull (msql_row[22], NULL, 10);
  39.708  
  39.709 -            proginfo->pathname = g_string_new (g_strdup(msql_row[25]));
  39.710 +            proginfo->pathname = g_string_new (g_strdup (msql_row[25]));
  39.711  
  39.712              gmyth_debug ("One program info loaded from mysql database\n");
  39.713          }
  39.714      }
  39.715  
  39.716      mysql_free_result (msql_res);
  39.717 -    g_string_free(query_str, TRUE);
  39.718 -    g_free(time_str);
  39.719 +    g_string_free (query_str, TRUE);
  39.720 +    g_free (time_str);
  39.721  
  39.722      return proginfo;
  39.723  }
  39.724 @@ -608,28 +643,29 @@
  39.725   * @return gint record_id if success, -1 otherwise 
  39.726   */
  39.727  static gint
  39.728 -get_record_id_from_database (GMythScheduler *scheduler)
  39.729 +get_record_id_from_database (GMythScheduler * scheduler)
  39.730  {
  39.731      gint record_id;
  39.732  
  39.733 -    assert(scheduler);
  39.734 -    
  39.735 +    assert (scheduler);
  39.736 +
  39.737      if (scheduler->msqlquery == NULL) {
  39.738 -        g_warning ("[%s] Scheduler db connection not initialized", __FUNCTION__);
  39.739 +        g_warning ("[%s] Scheduler db connection not initialized",
  39.740 +            __FUNCTION__);
  39.741          return 0;
  39.742      }
  39.743  
  39.744      record_id = mysql_insert_id (scheduler->msqlquery->conn);
  39.745  
  39.746      return record_id;
  39.747 -}	
  39.748 -	
  39.749 +}
  39.750 +
  39.751  /** Notifies the backend of an update in the db.
  39.752   * 
  39.753   * @param record_id the id of the modified recording.
  39.754   */
  39.755  static gboolean
  39.756 -update_backend(GMythScheduler *scheduler, gint record_id)//fixme: put void and discovery record_id inside
  39.757 +update_backend (GMythScheduler * scheduler, gint record_id) //fixme: put void and discovery record_id inside
  39.758  {
  39.759      GMythSocket *socket;
  39.760      GMythStringList *strlist = gmyth_string_list_new ();
  39.761 @@ -640,26 +676,28 @@
  39.762      gmyth_string_list_append_string (strlist, datastr);
  39.763  
  39.764      socket = gmyth_socket_new ();
  39.765 -    if (gmyth_socket_connect_to_backend (socket, scheduler->backend_info->hostname,
  39.766 -			    scheduler->backend_info->port, TRUE)) {
  39.767 +    if (gmyth_socket_connect_to_backend
  39.768 +        (socket, scheduler->backend_info->hostname,
  39.769 +            scheduler->backend_info->port, TRUE)) {
  39.770          ret = (gmyth_socket_sendreceive_stringlist (socket, strlist) > 0);
  39.771      } else {
  39.772          g_warning ("[%s] Connection to backend failed!", __FUNCTION__);
  39.773      }
  39.774 -    
  39.775 -    g_string_free(datastr, TRUE);
  39.776 -    g_object_unref(strlist);
  39.777 +
  39.778 +    g_string_free (datastr, TRUE);
  39.779 +    g_object_unref (strlist);
  39.780  
  39.781      return ret;
  39.782  }
  39.783  
  39.784  void
  39.785 -gmyth_scheduler_recorded_info_get_preview (RecordedInfo *info, GByteArray* data)
  39.786 +gmyth_scheduler_recorded_info_get_preview (RecordedInfo * info,
  39.787 +    GByteArray * data)
  39.788  {
  39.789  }
  39.790  
  39.791  void
  39.792 -gmyth_recorded_info_free (RecordedInfo *info)
  39.793 +gmyth_recorded_info_free (RecordedInfo * info)
  39.794  {
  39.795      if (info->title != NULL)
  39.796          g_string_free (info->title, TRUE);
  39.797 @@ -688,13 +726,13 @@
  39.798  static void
  39.799  free_recorded_info_item (gpointer data, gpointer user_data)
  39.800  {
  39.801 -    RecordedInfo *info = (RecordedInfo*) data;
  39.802 +    RecordedInfo *info = (RecordedInfo *) data;
  39.803  
  39.804      gmyth_recorded_info_free (info);
  39.805  }
  39.806  
  39.807  void
  39.808 -gmyth_recorded_info_list_free (GList *list)
  39.809 +gmyth_recorded_info_list_free (GList * list)
  39.810  {
  39.811      g_return_if_fail (list != NULL);
  39.812  
  39.813 @@ -703,7 +741,7 @@
  39.814  }
  39.815  
  39.816  void
  39.817 -gmyth_schedule_info_free (ScheduleInfo *info)
  39.818 +gmyth_schedule_info_free (ScheduleInfo * info)
  39.819  {
  39.820  
  39.821      g_return_if_fail (info != NULL);
  39.822 @@ -732,13 +770,13 @@
  39.823  static void
  39.824  free_schedule_info_item (gpointer data, gpointer user_data)
  39.825  {
  39.826 -    ScheduleInfo *info = (ScheduleInfo*) data;
  39.827 +    ScheduleInfo *info = (ScheduleInfo *) data;
  39.828  
  39.829      gmyth_schedule_info_free (info);
  39.830  }
  39.831  
  39.832  void
  39.833 -gmyth_schedule_info_list_free (GList *list)
  39.834 +gmyth_schedule_info_list_free (GList * list)
  39.835  {
  39.836      g_return_if_fail (list != NULL);
  39.837  
    40.1 --- a/gmyth/src/gmyth_scheduler.h	Tue May 22 19:21:42 2007 +0100
    40.2 +++ b/gmyth/src/gmyth_scheduler.h	Wed May 23 16:11:29 2007 +0100
    40.3 @@ -9,22 +9,22 @@
    40.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    40.5   * @author Alexsandro Jose Virginio dos Santos <alexsandro.santos@indt.org.br>
    40.6   *
    40.7 - *//*
    40.8 - * 
    40.9 - * This program is free software; you can redistribute it and/or modify
   40.10 - * it under the terms of the GNU Lesser General Public License as published by
   40.11 - * the Free Software Foundation; either version 2 of the License, or
   40.12 - * (at your option) any later version.
   40.13 - *
   40.14 - * This program is distributed in the hope that it will be useful,
   40.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   40.17 - * GNU General Public License for more details.
   40.18 - *
   40.19 - * You should have received a copy of the GNU Lesser General Public License
   40.20 - * along with this program; if not, write to the Free Software
   40.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   40.22 - */
   40.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   40.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   40.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   40.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   40.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   40.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   40.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   40.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   40.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   40.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   40.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   40.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   40.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   40.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   40.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   40.39  
   40.40  #ifndef __GMYTH_SCHEDULER_H__
   40.41  #define __GMYTH_SCHEDULER_H__
   40.42 @@ -37,17 +37,14 @@
   40.43  #include "gmyth_backendinfo.h"
   40.44  
   40.45  G_BEGIN_DECLS
   40.46 -
   40.47  #define GMYTH_SCHEDULER_TYPE               (gmyth_scheduler_get_type ())
   40.48  #define GMYTH_SCHEDULER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SCHEDULER_TYPE, GMythScheduler))
   40.49  #define GMYTH_SCHEDULER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass))
   40.50  #define IS_GMYTH_SCHEDULER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_SCHEDULER_TYPE))
   40.51  #define IS_GMYTH_SCHEDULER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SCHEDULER_TYPE))
   40.52  #define GMYTH_SCHEDULER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SCHEDULER_TYPE, GMythSchedulerClass))
   40.53 -
   40.54 -
   40.55 -typedef struct _GMythScheduler         GMythScheduler;
   40.56 -typedef struct _GMythSchedulerClass    GMythSchedulerClass;
   40.57 +typedef struct _GMythScheduler GMythScheduler;
   40.58 +typedef struct _GMythSchedulerClass GMythSchedulerClass;
   40.59  
   40.60  struct _GMythSchedulerClass
   40.61  {
   40.62 @@ -65,42 +62,43 @@
   40.63      unsigned long type;
   40.64      unsigned long search;
   40.65      GString *profile;
   40.66 -    
   40.67 +
   40.68      long dupin;
   40.69      long dupmethod;
   40.70      long autoexpire;
   40.71      short int autotranscode;
   40.72      long transcoder;
   40.73 -    
   40.74 +
   40.75      short int autocommflag;
   40.76      short int autouserjob1;
   40.77      short int autouserjob2;
   40.78      short int autouserjob3;
   40.79      short int autouserjob4;
   40.80 -    
   40.81 +
   40.82      long startoffset;
   40.83      long endoffset;
   40.84      long maxepisodes;
   40.85      long maxnewest;
   40.86 -    
   40.87 +
   40.88      long recpriority;
   40.89      GString *recgroup;
   40.90      GString *playgroup;
   40.91 -    
   40.92 +
   40.93      long prefinput;
   40.94      short int inactive;
   40.95 -    
   40.96 +
   40.97      GString *search_type;
   40.98      GString *search_what;
   40.99 -    
  40.100 +
  40.101      GMythQuery *msqlquery;
  40.102      GMythBackendInfo *backend_info;
  40.103  };
  40.104  
  40.105 -typedef struct {
  40.106 -    guint    schedule_id;
  40.107 -    guint    program_id;
  40.108 -    guint    channel_id;
  40.109 +typedef struct
  40.110 +{
  40.111 +    guint schedule_id;
  40.112 +    guint program_id;
  40.113 +    guint channel_id;
  40.114  
  40.115      GTimeVal *start_time;
  40.116      GTimeVal *end_time;
  40.117 @@ -112,61 +110,60 @@
  40.118  
  40.119  } ScheduleInfo;
  40.120  
  40.121 -typedef struct {
  40.122 -    guint    record_id;
  40.123 -    guint    program_id;
  40.124 -    guint    channel_id;
  40.125 +typedef struct
  40.126 +{
  40.127 +    guint record_id;
  40.128 +    guint program_id;
  40.129 +    guint channel_id;
  40.130  
  40.131 -    GTimeVal*  start_time;
  40.132 -    GTimeVal*  end_time;
  40.133 +    GTimeVal *start_time;
  40.134 +    GTimeVal *end_time;
  40.135  
  40.136      GString *title;
  40.137      GString *subtitle;
  40.138      GString *description;
  40.139      GString *category;
  40.140 -    
  40.141 +
  40.142      GString *basename;
  40.143  
  40.144      guint64 filesize;
  40.145 -    
  40.146 +
  40.147  } RecordedInfo;
  40.148  
  40.149  
  40.150 -GType           gmyth_scheduler_get_type (void);
  40.151 +GType gmyth_scheduler_get_type (void);
  40.152  
  40.153 -GMythScheduler* gmyth_scheduler_new ();
  40.154 -gboolean        gmyth_scheduler_connect      (GMythScheduler *scheduler, 
  40.155 -                                              GMythBackendInfo *backend_info);
  40.156 -gboolean        gmyth_scheduler_connect_with_timeout      (GMythScheduler *scheduler, 
  40.157 -                                       		GMythBackendInfo *backend_info, guint timeout);
  40.158 -gboolean        gmyth_scheduler_disconnect   (GMythScheduler *scheduler);
  40.159 +GMythScheduler *gmyth_scheduler_new ();
  40.160 +gboolean gmyth_scheduler_connect (GMythScheduler * scheduler,
  40.161 +    GMythBackendInfo * backend_info);
  40.162 +gboolean gmyth_scheduler_connect_with_timeout (GMythScheduler * scheduler,
  40.163 +    GMythBackendInfo * backend_info, guint timeout);
  40.164 +gboolean gmyth_scheduler_disconnect (GMythScheduler * scheduler);
  40.165  
  40.166 -gint            gmyth_scheduler_get_schedule_list (GMythScheduler *scheduler, 
  40.167 -                                                   GList **sched_list);
  40.168 -gint            gmyth_scheduler_get_recorded_list (GMythScheduler *scheduler, 
  40.169 -                                                   GList **rec_list);
  40.170 +gint gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
  40.171 +    GList ** sched_list);
  40.172 +gint gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler,
  40.173 +    GList ** rec_list);
  40.174  
  40.175 -GMythProgramInfo* gmyth_scheduler_get_recorded (GMythScheduler *scheduler, 
  40.176 -                                        		GString *channel, GTimeVal* starttime);
  40.177 +GMythProgramInfo *gmyth_scheduler_get_recorded (GMythScheduler * scheduler,
  40.178 +    GString * channel, GTimeVal * starttime);
  40.179  
  40.180 -gint            gmyth_scheduler_add_schedule(GMythScheduler *scheduler, 
  40.181 -                                             ScheduleInfo *schedule_info);
  40.182 +gint gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
  40.183 +    ScheduleInfo * schedule_info);
  40.184  
  40.185 -gint            gmyth_scheduler_delete_schedule (GMythScheduler *scheduler, 
  40.186 -                                                 gint record_id);
  40.187 -gint            gmyth_scheduler_delete_recorded (GMythScheduler *scheduler, 
  40.188 -                                                 gint record_id);
  40.189 +gint gmyth_scheduler_delete_schedule (GMythScheduler * scheduler,
  40.190 +    gint record_id);
  40.191 +gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler,
  40.192 +    gint record_id);
  40.193  
  40.194 -void            gmyth_scheduler_recorded_info_get_preview (RecordedInfo *info, 
  40.195 -                                                           GByteArray* data);
  40.196 +void gmyth_scheduler_recorded_info_get_preview (RecordedInfo * info,
  40.197 +    GByteArray * data);
  40.198  
  40.199 -void            gmyth_recorded_info_free (RecordedInfo *info);
  40.200 -void            gmyth_schedule_info_free (ScheduleInfo *info);
  40.201 +void gmyth_recorded_info_free (RecordedInfo * info);
  40.202 +void gmyth_schedule_info_free (ScheduleInfo * info);
  40.203  
  40.204 -void		gmyth_recorded_info_list_free (GList *list);
  40.205 -void		gmyth_schedule_info_list_free (GList *list);
  40.206 +void gmyth_recorded_info_list_free (GList * list);
  40.207 +void gmyth_schedule_info_list_free (GList * list);
  40.208  
  40.209  G_END_DECLS
  40.210 -
  40.211  #endif /* __GMYTH_SCHEDULER_H__ */
  40.212 -
    41.1 --- a/gmyth/src/gmyth_socket.c	Tue May 22 19:21:42 2007 +0100
    41.2 +++ b/gmyth/src/gmyth_socket.c	Wed May 23 16:11:29 2007 +0100
    41.3 @@ -13,22 +13,22 @@
    41.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    41.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br> 
    41.6   *
    41.7 - *//*
    41.8 - * 
    41.9 - * This program is free software; you can redistribute it and/or modify
   41.10 - * it under the terms of the GNU Lesser General Public License as published by
   41.11 - * the Free Software Foundation; either version 2 of the License, or
   41.12 - * (at your option) any later version.
   41.13 - *
   41.14 - * This program is distributed in the hope that it will be useful,
   41.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   41.17 - * GNU General Public License for more details.
   41.18 - *
   41.19 - * You should have received a copy of the GNU Lesser General Public License
   41.20 - * along with this program; if not, write to the Free Software
   41.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   41.22 - */
   41.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   41.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   41.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   41.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   41.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   41.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   41.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   41.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   41.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   41.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   41.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   41.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   41.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   41.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   41.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   41.39  
   41.40  #ifdef HAVE_CONFIG_H
   41.41  #include "config.h"
   41.42 @@ -36,7 +36,7 @@
   41.43  
   41.44  #include "gmyth_socket.h"
   41.45  
   41.46 -#include <glib.h> 
   41.47 +#include <glib.h>
   41.48  #include <glib/gprintf.h>
   41.49  
   41.50  #include <arpa/inet.h>
   41.51 @@ -74,33 +74,31 @@
   41.52  
   41.53  /*static GStaticRWLock rwlock = G_STATIC_RW_LOCK_INIT;*/
   41.54  
   41.55 -static gchar* local_hostname = NULL;
   41.56 +static gchar *local_hostname = NULL;
   41.57  
   41.58 -static void gmyth_socket_class_init          (GMythSocketClass *klass);
   41.59 -static void gmyth_socket_init                (GMythSocket *object);
   41.60 +static void gmyth_socket_class_init (GMythSocketClass * klass);
   41.61 +static void gmyth_socket_init (GMythSocket * object);
   41.62  
   41.63 -static void gmyth_socket_dispose  (GObject *object);
   41.64 -static void gmyth_socket_finalize (GObject *object);
   41.65 +static void gmyth_socket_dispose (GObject * object);
   41.66 +static void gmyth_socket_finalize (GObject * object);
   41.67  
   41.68 -G_DEFINE_TYPE(GMythSocket, gmyth_socket, G_TYPE_OBJECT)
   41.69 -
   41.70 -static void
   41.71 -gmyth_socket_class_init (GMythSocketClass *klass)
   41.72 +G_DEFINE_TYPE (GMythSocket, gmyth_socket, G_TYPE_OBJECT)
   41.73 +     static void gmyth_socket_class_init (GMythSocketClass * klass)
   41.74  {
   41.75      GObjectClass *gobject_class;
   41.76  
   41.77      gobject_class = (GObjectClass *) klass;
   41.78  
   41.79 -    gobject_class->dispose  = gmyth_socket_dispose;
   41.80 -    gobject_class->finalize = gmyth_socket_finalize;	
   41.81 +    gobject_class->dispose = gmyth_socket_dispose;
   41.82 +    gobject_class->finalize = gmyth_socket_finalize;
   41.83  }
   41.84  
   41.85  static void
   41.86 -gmyth_socket_init (GMythSocket *gmyth_socket)
   41.87 +gmyth_socket_init (GMythSocket * gmyth_socket)
   41.88  {
   41.89 -	
   41.90 -	/* gmyth_socket->local_hostname = NULL; */
   41.91 -	
   41.92 +
   41.93 +    /* gmyth_socket->local_hostname = NULL; */
   41.94 +
   41.95  }
   41.96  
   41.97  /** Gets the some important address translation info, from the client socket
   41.98 @@ -109,28 +107,30 @@
   41.99   * @return gint that represents the error number from getaddrinfo(). 
  41.100   */
  41.101  static gint
  41.102 -gmyth_socket_toaddrinfo (const gchar *addr, gint port, struct addrinfo **addrInfo )
  41.103 +gmyth_socket_toaddrinfo (const gchar * addr, gint port,
  41.104 +    struct addrinfo **addrInfo)
  41.105  {
  41.106      struct addrinfo hints;
  41.107      gchar *portStr = NULL;
  41.108      gint errorn = EADDRNOTAVAIL;
  41.109 - 
  41.110 -    g_return_val_if_fail ( addr != NULL, -1 );
  41.111  
  41.112 -    memset ( &hints, 0, sizeof(struct addrinfo) );
  41.113 +    g_return_val_if_fail (addr != NULL, -1);
  41.114 +
  41.115 +    memset (&hints, 0, sizeof (struct addrinfo));
  41.116      hints.ai_family = AF_INET;
  41.117      hints.ai_socktype = SOCK_STREAM;
  41.118      /* hints.ai_flags = AI_NUMERICHOST; */
  41.119 -    
  41.120 -    if ( port != -1 )	
  41.121 -        portStr = g_strdup_printf ( "%d", port );
  41.122 +
  41.123 +    if (port != -1)
  41.124 +        portStr = g_strdup_printf ("%d", port);
  41.125      else
  41.126          portStr = NULL;
  41.127  
  41.128      gmyth_debug ("Getting name resolution for: %s, %d\n", addr, port);
  41.129  
  41.130 -    if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) {
  41.131 -		gmyth_debug( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) );
  41.132 +    if ((errorn = getaddrinfo (addr, portStr, &hints, addrInfo)) != 0) {
  41.133 +        gmyth_debug ("[%s] Socket ERROR: %s\n", __FUNCTION__,
  41.134 +            gai_strerror (errorn));
  41.135      }
  41.136  
  41.137      g_free (portStr);
  41.138 @@ -160,79 +160,83 @@
  41.139   * @return List with all the local net interfaces. 
  41.140   */
  41.141  GList *
  41.142 -gmyth_socket_get_local_addrs( GList *current_connections )
  41.143 +gmyth_socket_get_local_addrs (GList * current_connections)
  41.144  {
  41.145  
  41.146 -	GList *local_addrs = NULL;
  41.147 -	FILE *fd;
  41.148 -	gint s;
  41.149 -	gchar buffer[256+1];
  41.150 -	gchar ifaddr[20+1];
  41.151 -	gchar *ifname;
  41.152 -	gchar *sep;
  41.153 -	
  41.154 -	s = socket(AF_INET, SOCK_DGRAM, 0);
  41.155 -	if (s < 0)
  41.156 -		return 0;
  41.157 -	fd = fopen(PATH_PROC_NET_DEV, "r");
  41.158 -	fgets(buffer, sizeof(buffer)-1, fd);
  41.159 -	fgets(buffer, sizeof(buffer)-1, fd);
  41.160 -	while (!feof(fd)) {
  41.161 -		ifname = buffer;
  41.162 +    GList *local_addrs = NULL;
  41.163 +    FILE *fd;
  41.164 +    gint s;
  41.165 +    gchar buffer[256 + 1];
  41.166 +    gchar ifaddr[20 + 1];
  41.167 +    gchar *ifname;
  41.168 +    gchar *sep;
  41.169  
  41.170 -		if (fgets(buffer, sizeof(buffer)-1, fd) == NULL)
  41.171 -			break;
  41.172 -		sep = strrchr(buffer, ':');
  41.173 -		if (sep)
  41.174 -			*sep = 0;
  41.175 -		while (*ifname == ' ')
  41.176 -			ifname++;
  41.177 -		struct ifreq req;
  41.178 -		strcpy(req.ifr_name, ifname);
  41.179 -		if (ioctl(s, SIOCGIFFLAGS, &req) < 0)
  41.180 -			continue;
  41.181 -		if (!(req.ifr_flags & IFF_UP))
  41.182 -			continue;
  41.183 -		if (req.ifr_flags & IFF_LOOPBACK)
  41.184 -			continue;
  41.185 -		if (ioctl(s, SIOCGIFADDR, &req) < 0)
  41.186 -			continue;
  41.187 -		g_strlcpy( ifaddr, inet_ntoa(((struct sockaddr_in*)&req.ifr_addr)->sin_addr), sizeof(struct ifaddr)-1 );
  41.188 -		local_addrs = g_list_append( local_addrs, g_strdup( ifaddr ) );
  41.189 +    s = socket (AF_INET, SOCK_DGRAM, 0);
  41.190 +    if (s < 0)
  41.191 +        return 0;
  41.192 +    fd = fopen (PATH_PROC_NET_DEV, "r");
  41.193 +    fgets (buffer, sizeof (buffer) - 1, fd);
  41.194 +    fgets (buffer, sizeof (buffer) - 1, fd);
  41.195 +    while (!feof (fd)) {
  41.196 +        ifname = buffer;
  41.197  
  41.198 -		gmyth_debug( "( from the /proc/net/dev) Interface name: %s, address: %s\n", 
  41.199 -								ifname, ifaddr );
  41.200 -	}
  41.201 -	fclose(fd);
  41.202 -	close(s);
  41.203 -	return local_addrs;
  41.204 +        if (fgets (buffer, sizeof (buffer) - 1, fd) == NULL)
  41.205 +            break;
  41.206 +        sep = strrchr (buffer, ':');
  41.207 +        if (sep)
  41.208 +            *sep = 0;
  41.209 +        while (*ifname == ' ')
  41.210 +            ifname++;
  41.211 +        struct ifreq req;
  41.212 +
  41.213 +        strcpy (req.ifr_name, ifname);
  41.214 +        if (ioctl (s, SIOCGIFFLAGS, &req) < 0)
  41.215 +            continue;
  41.216 +        if (!(req.ifr_flags & IFF_UP))
  41.217 +            continue;
  41.218 +        if (req.ifr_flags & IFF_LOOPBACK)
  41.219 +            continue;
  41.220 +        if (ioctl (s, SIOCGIFADDR, &req) < 0)
  41.221 +            continue;
  41.222 +        g_strlcpy (ifaddr,
  41.223 +            inet_ntoa (((struct sockaddr_in *) &req.ifr_addr)->
  41.224 +                sin_addr), sizeof (struct ifaddr) - 1);
  41.225 +        local_addrs = g_list_append (local_addrs, g_strdup (ifaddr));
  41.226 +
  41.227 +        gmyth_debug
  41.228 +            ("( from the /proc/net/dev) Interface name: %s, address: %s\n",
  41.229 +            ifname, ifaddr);
  41.230 +    }
  41.231 +    fclose (fd);
  41.232 +    close (s);
  41.233 +    return local_addrs;
  41.234  }
  41.235  
  41.236  /**
  41.237   * Get only the local addresses from the primary interface
  41.238   */
  41.239  gchar *
  41.240 -gmyth_socket_get_primary_addr(void)
  41.241 +gmyth_socket_get_primary_addr (void)
  41.242  {
  41.243 -	gchar *if_eth0 = g_new0( gchar, sizeof(struct ifaddr)-1 );
  41.244 -	GList *if_tmp = NULL;
  41.245 -	
  41.246 -	GList *interfs = gmyth_socket_get_local_addrs( NULL );
  41.247 -	
  41.248 -	if ( interfs != NULL && ( g_list_length( interfs ) > 0 ) ) 
  41.249 -	{
  41.250 -		// get the first occurrence (primary interface) 
  41.251 -		if_tmp = g_list_first( interfs );
  41.252 -		
  41.253 -		if ( if_tmp != NULL )
  41.254 -			g_strlcpy (if_eth0, (gchar *)if_tmp->data, sizeof(struct ifaddr)-1 );
  41.255 +    gchar *if_eth0 = g_new0 (gchar, sizeof (struct ifaddr) - 1);
  41.256 +    GList *if_tmp = NULL;
  41.257  
  41.258 -	}
  41.259 -	
  41.260 -	if ( interfs != NULL )
  41.261 -		g_list_free( interfs );
  41.262 -	
  41.263 -	return if_eth0;
  41.264 +    GList *interfs = gmyth_socket_get_local_addrs (NULL);
  41.265 +
  41.266 +    if (interfs != NULL && (g_list_length (interfs) > 0)) {
  41.267 +        // get the first occurrence (primary interface) 
  41.268 +        if_tmp = g_list_first (interfs);
  41.269 +
  41.270 +        if (if_tmp != NULL)
  41.271 +            g_strlcpy (if_eth0, (gchar *) if_tmp->data,
  41.272 +                sizeof (struct ifaddr) - 1);
  41.273 +
  41.274 +    }
  41.275 +
  41.276 +    if (interfs != NULL)
  41.277 +        g_list_free (interfs);
  41.278 +
  41.279 +    return if_eth0;
  41.280  }
  41.281  
  41.282  /** This function retrieves the local hostname of the 
  41.283 @@ -247,52 +251,53 @@
  41.284      gint res = gethostname (hname, 50);
  41.285  
  41.286      if (res == -1) {
  41.287 -		gmyth_debug ("Error while getting hostname");
  41.288 -		return g_string_new ("default");
  41.289 +        gmyth_debug ("Error while getting hostname");
  41.290 +        return g_string_new ("default");
  41.291      }
  41.292  
  41.293      return g_string_new (hname);
  41.294  
  41.295 -#if 0	
  41.296 +#if 0
  41.297      GString *str = NULL;
  41.298 -    
  41.299 -    if ( local_hostname != NULL && strlen(local_hostname) > 0 )
  41.300 -    	return g_string_new( local_hostname );
  41.301  
  41.302 -    gchar *localaddr = NULL; 
  41.303 +    if (local_hostname != NULL && strlen (local_hostname) > 0)
  41.304 +        return g_string_new (local_hostname);
  41.305 +
  41.306 +    gchar *localaddr = NULL;
  41.307      gboolean found_addr = FALSE;
  41.308 -    struct addrinfo* addr_info_data = NULL, *addr_info0 = NULL;
  41.309 -    struct sockaddr_in* sa = NULL;
  41.310 +    struct addrinfo *addr_info_data = NULL, *addr_info0 = NULL;
  41.311 +    struct sockaddr_in *sa = NULL;
  41.312      gchar localhostname[MAXHOSTNAMELEN];
  41.313  
  41.314  
  41.315 -    if (gethostname (localhostname, MAXHOSTNAMELEN) != 0 ) {
  41.316 -    	gmyth_debug ( "Error on gethostname" );
  41.317 +    if (gethostname (localhostname, MAXHOSTNAMELEN) != 0) {
  41.318 +        gmyth_debug ("Error on gethostname");
  41.319      }
  41.320 -    localhostname[MAXHOSTNAMELEN-1] = 0;
  41.321 +    localhostname[MAXHOSTNAMELEN - 1] = 0;
  41.322  
  41.323 -    gint err = gmyth_socket_toaddrinfo (localhostname, -1,  &addr_info_data );
  41.324 -    
  41.325 -    if ( err == EADDRNOTAVAIL )
  41.326 -    {
  41.327 -    	gmyth_debug( "[%s] Address (%s) not available. (reason = %d)\n", __FUNCTION__, localhostname, err );
  41.328 -    	return str;
  41.329 +    gint err = gmyth_socket_toaddrinfo (localhostname, -1, &addr_info_data);
  41.330 +
  41.331 +    if (err == EADDRNOTAVAIL) {
  41.332 +        gmyth_debug ("[%s] Address (%s) not available. (reason = %d)\n",
  41.333 +            __FUNCTION__, localhostname, err);
  41.334 +        return str;
  41.335      }
  41.336 -    
  41.337 -    g_mutex_lock( gmyth_socket->mutex );    	
  41.338 +
  41.339 +    g_mutex_lock (gmyth_socket->mutex);
  41.340  
  41.341      addr_info0 = addr_info_data;
  41.342  
  41.343 -    while( addr_info0 != NULL && addr_info0->ai_addr != NULL && 
  41.344 -	    ( sa = (struct sockaddr_in*)addr_info0->ai_addr ) != NULL && !found_addr ) {
  41.345 -    	localaddr = inet_ntoa( sa->sin_addr );
  41.346 +    while (addr_info0 != NULL && addr_info0->ai_addr != NULL &&
  41.347 +        (sa = (struct sockaddr_in *) addr_info0->ai_addr) != NULL
  41.348 +        && !found_addr) {
  41.349 +        localaddr = inet_ntoa (sa->sin_addr);
  41.350  
  41.351 -	    if ( localaddr != NULL && ( g_strrstr( localaddr, "127" ) == NULL ) ) {
  41.352 -	        str = g_string_new (localaddr);
  41.353 -	        found_addr = TRUE;
  41.354 -		g_free (localaddr);
  41.355 -	        break;
  41.356 -	    }
  41.357 +        if (localaddr != NULL && (g_strrstr (localaddr, "127") == NULL)) {
  41.358 +            str = g_string_new (localaddr);
  41.359 +            found_addr = TRUE;
  41.360 +            g_free (localaddr);
  41.361 +            break;
  41.362 +        }
  41.363  /*
  41.364  	    if (localaddr != NULL) {
  41.365  		g_free (localaddr);
  41.366 @@ -300,59 +305,60 @@
  41.367  	    }
  41.368  	    */
  41.369  
  41.370 -	    addr_info0 = addr_info0->ai_next;
  41.371 +        addr_info0 = addr_info0->ai_next;
  41.372      };
  41.373 -    
  41.374 +
  41.375      freeaddrinfo (addr_info_data);
  41.376      addr_info_data = NULL;
  41.377 -    
  41.378 -    if ( found_addr == FALSE ) {
  41.379 -        gchar *prim_addr = gmyth_socket_get_primary_addr();
  41.380  
  41.381 -    	if ( prim_addr != NULL ) {
  41.382 -		gmyth_debug("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
  41.383 -    	        __FUNCTION__, prim_addr );
  41.384 -      
  41.385 -	        str = g_string_new (prim_addr);
  41.386 -	        g_free (prim_addr);
  41.387 -    	} else {
  41.388 -        	str = g_string_new (localhostname);
  41.389 -    	}
  41.390 +    if (found_addr == FALSE) {
  41.391 +        gchar *prim_addr = gmyth_socket_get_primary_addr ();
  41.392 +
  41.393 +        if (prim_addr != NULL) {
  41.394 +            gmyth_debug
  41.395 +                ("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
  41.396 +                __FUNCTION__, prim_addr);
  41.397 +
  41.398 +            str = g_string_new (prim_addr);
  41.399 +            g_free (prim_addr);
  41.400 +        } else {
  41.401 +            str = g_string_new (localhostname);
  41.402 +        }
  41.403      }
  41.404  
  41.405      g_mutex_unlock (gmyth_socket->mutex);
  41.406 -    
  41.407 -    if ( str != NULL && str->str != NULL )
  41.408 -    	local_hostname = g_strdup( str->str );
  41.409 +
  41.410 +    if (str != NULL && str->str != NULL)
  41.411 +        local_hostname = g_strdup (str->str);
  41.412  
  41.413      return str;
  41.414 -#endif    
  41.415 +#endif
  41.416  }
  41.417  
  41.418  static void
  41.419 -gmyth_socket_dispose  (GObject *object)
  41.420 +gmyth_socket_dispose (GObject * object)
  41.421  {
  41.422 -    GMythSocket *gmyth_socket = GMYTH_SOCKET(object);
  41.423 +    GMythSocket *gmyth_socket = GMYTH_SOCKET (object);
  41.424  
  41.425      /* disconnect socket */
  41.426      gmyth_socket_close_connection (gmyth_socket);
  41.427 -    
  41.428 +
  41.429      g_free (gmyth_socket->hostname);
  41.430 -    
  41.431 +
  41.432      g_free (local_hostname);
  41.433 -    
  41.434 +
  41.435      local_hostname = NULL;
  41.436 -    
  41.437 -    if ( gmyth_socket->mutex != NULL ) {
  41.438 -    	g_mutex_free( gmyth_socket->mutex );
  41.439 -    	gmyth_socket->mutex = NULL; 
  41.440 +
  41.441 +    if (gmyth_socket->mutex != NULL) {
  41.442 +        g_mutex_free (gmyth_socket->mutex);
  41.443 +        gmyth_socket->mutex = NULL;
  41.444      }
  41.445  
  41.446      G_OBJECT_CLASS (gmyth_socket_parent_class)->dispose (object);
  41.447  }
  41.448  
  41.449  static void
  41.450 -gmyth_socket_finalize (GObject *object)
  41.451 +gmyth_socket_finalize (GObject * object)
  41.452  {
  41.453      g_signal_handlers_destroy (object);
  41.454  
  41.455 @@ -363,14 +369,15 @@
  41.456   * 
  41.457   * @return a new instance of GMythSocket.
  41.458   */
  41.459 -GMythSocket*
  41.460 +GMythSocket *
  41.461  gmyth_socket_new ()
  41.462  {
  41.463 -    GMythSocket *gmyth_socket = GMYTH_SOCKET (g_object_new(GMYTH_SOCKET_TYPE, NULL));
  41.464 +    GMythSocket *gmyth_socket =
  41.465 +        GMYTH_SOCKET (g_object_new (GMYTH_SOCKET_TYPE, NULL));
  41.466  
  41.467      gmyth_socket->mythtv_version = MYTHTV_VERSION_DEFAULT;
  41.468 -    
  41.469 -    gmyth_socket->mutex = g_mutex_new();
  41.470 +
  41.471 +    gmyth_socket->mutex = g_mutex_new ();
  41.472  
  41.473      return gmyth_socket;
  41.474  }
  41.475 @@ -384,86 +391,96 @@
  41.476   * @param err		Error message number.
  41.477   * @return Any numerical value below 0, if an error had been found.
  41.478   */
  41.479 -static gint 
  41.480 -gmyth_socket_try_connect ( gint fd, struct sockaddr *remote, gint len,
  41.481 -               struct timeval *timeout, gint *err)
  41.482 +static gint
  41.483 +gmyth_socket_try_connect (gint fd, struct sockaddr *remote, gint len,
  41.484 +    struct timeval *timeout, gint * err)
  41.485  {
  41.486 -	  /*g_return_val_if_fail( timeout != NULL, 0 );*/	  
  41.487 -	  gint saveflags, ret, back_err;
  41.488 -	  
  41.489 -	  fd_set fd_w;
  41.490 -	
  41.491 -	  saveflags = fcntl( fd, F_GETFL, 0 );
  41.492 -	  if( saveflags < 0 ) {
  41.493 -	    gmyth_debug( "[%s] Problems when getting socket flags on fcntl.\n", __FUNCTION__ );
  41.494 -	    *err=errno;
  41.495 -	    return -1;
  41.496 -	  }
  41.497 -	
  41.498 -	  /* Set non blocking */
  41.499 -	  if( fcntl( fd, F_SETFL, saveflags | O_NONBLOCK ) < 0) {
  41.500 -	  	gmyth_debug( "[%s] Problems when setting non-blocking using fcntl.\n", __FUNCTION__ );
  41.501 -	    *err=errno;
  41.502 -	    return -1;
  41.503 -	  }
  41.504 -	
  41.505 -	  /* This will return immediately */
  41.506 -	  *err= connect ( fd, remote, len );
  41.507 -		back_err=errno;
  41.508 -	
  41.509 -		/* restore flags */
  41.510 -	  if( fcntl( fd, F_SETFL, saveflags ) < 0) {
  41.511 -	    gmyth_debug( "[%s] Problems when trying to restore flags with fcntl.\n", __FUNCTION__ );
  41.512 -	    *err=errno;
  41.513 -	    return -1;
  41.514 -	  }
  41.515 -	
  41.516 -	  /* return unless the connection was successful or the connect is
  41.517 -	     still in progress. */
  41.518 -	  if( *err < 0 && back_err != EINPROGRESS) {
  41.519 -	    gmyth_debug( "[%s] Connection unsucessfully (it is not in progress).\n", __FUNCTION__ );
  41.520 -	    *err = errno;
  41.521 -	    return -1;
  41.522 -	  }
  41.523 -	
  41.524 -	  FD_ZERO( &fd_w );
  41.525 -	  FD_SET( fd, &fd_w );
  41.526 -	
  41.527 -	  *err = select( FD_SETSIZE, NULL, &fd_w, NULL, timeout);
  41.528 -	  if ( *err < 0 ) {
  41.529 -	    gmyth_debug( "[%s] Connection unsucessfull (timed out).\n", __FUNCTION__ );
  41.530 -	    *err=errno;
  41.531 -	    return -1;
  41.532 -	  }
  41.533 -	
  41.534 -	  /* 0 means it timeout out & no fds changed */
  41.535 -	  if(*err==0) {
  41.536 -	  	gmyth_debug( "[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n", 
  41.537 -	  				__FUNCTION__, *err );
  41.538 -	    close(fd);
  41.539 -	    *err=ETIMEDOUT;
  41.540 -	    return -1;
  41.541 -	  }
  41.542 -	
  41.543 -	  /* Get the return code from the connect */
  41.544 -	  len = sizeof( ret );
  41.545 -	  *err=getsockopt( fd, SOL_SOCKET, SO_ERROR, &ret, (socklen_t *) &len);
  41.546 -	  
  41.547 -	  if( *err < 0 ) {
  41.548 -	    gmyth_debug( "[%s] Connection unsucessfull.\n", __FUNCTION__ );
  41.549 -	    *err=errno;
  41.550 -	    return -1;
  41.551 -	  }
  41.552 -	
  41.553 -	  /* ret=0 means success, otherwise it contains the errno */
  41.554 -	  if (ret) {
  41.555 -	  	gmyth_debug( "[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n", __FUNCTION__ );
  41.556 -	    *err=ret;
  41.557 -	    return -1;
  41.558 -	  }
  41.559 -	
  41.560 -	  *err=0;
  41.561 -	  return 0;
  41.562 +    /*g_return_val_if_fail( timeout != NULL, 0 ); */
  41.563 +    gint saveflags, ret, back_err;
  41.564 +
  41.565 +    fd_set fd_w;
  41.566 +
  41.567 +    saveflags = fcntl (fd, F_GETFL, 0);
  41.568 +    if (saveflags < 0) {
  41.569 +        gmyth_debug ("[%s] Problems when getting socket flags on fcntl.\n",
  41.570 +            __FUNCTION__);
  41.571 +        *err = errno;
  41.572 +        return -1;
  41.573 +    }
  41.574 +
  41.575 +    /* Set non blocking */
  41.576 +    if (fcntl (fd, F_SETFL, saveflags | O_NONBLOCK) < 0) {
  41.577 +        gmyth_debug ("[%s] Problems when setting non-blocking using fcntl.\n",
  41.578 +            __FUNCTION__);
  41.579 +        *err = errno;
  41.580 +        return -1;
  41.581 +    }
  41.582 +
  41.583 +    /* This will return immediately */
  41.584 +    *err = connect (fd, remote, len);
  41.585 +    back_err = errno;
  41.586 +
  41.587 +    /* restore flags */
  41.588 +    if (fcntl (fd, F_SETFL, saveflags) < 0) {
  41.589 +        gmyth_debug
  41.590 +            ("[%s] Problems when trying to restore flags with fcntl.\n",
  41.591 +            __FUNCTION__);
  41.592 +        *err = errno;
  41.593 +        return -1;
  41.594 +    }
  41.595 +
  41.596 +    /* return unless the connection was successful or the connect is
  41.597 +       still in progress. */
  41.598 +    if (*err < 0 && back_err != EINPROGRESS) {
  41.599 +        gmyth_debug
  41.600 +            ("[%s] Connection unsucessfully (it is not in progress).\n",
  41.601 +            __FUNCTION__);
  41.602 +        *err = errno;
  41.603 +        return -1;
  41.604 +    }
  41.605 +
  41.606 +    FD_ZERO (&fd_w);
  41.607 +    FD_SET (fd, &fd_w);
  41.608 +
  41.609 +    *err = select (FD_SETSIZE, NULL, &fd_w, NULL, timeout);
  41.610 +    if (*err < 0) {
  41.611 +        gmyth_debug ("[%s] Connection unsucessfull (timed out).\n",
  41.612 +            __FUNCTION__);
  41.613 +        *err = errno;
  41.614 +        return -1;
  41.615 +    }
  41.616 +
  41.617 +    /* 0 means it timeout out & no fds changed */
  41.618 +    if (*err == 0) {
  41.619 +        gmyth_debug
  41.620 +            ("[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n",
  41.621 +            __FUNCTION__, *err);
  41.622 +        close (fd);
  41.623 +        *err = ETIMEDOUT;
  41.624 +        return -1;
  41.625 +    }
  41.626 +
  41.627 +    /* Get the return code from the connect */
  41.628 +    len = sizeof (ret);
  41.629 +    *err = getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, (socklen_t *) & len);
  41.630 +
  41.631 +    if (*err < 0) {
  41.632 +        gmyth_debug ("[%s] Connection unsucessfull.\n", __FUNCTION__);
  41.633 +        *err = errno;
  41.634 +        return -1;
  41.635 +    }
  41.636 +
  41.637 +    /* ret=0 means success, otherwise it contains the errno */
  41.638 +    if (ret) {
  41.639 +        gmyth_debug
  41.640 +            ("[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n",
  41.641 +            __FUNCTION__);
  41.642 +        *err = ret;
  41.643 +        return -1;
  41.644 +    }
  41.645 +
  41.646 +    *err = 0;
  41.647 +    return 0;
  41.648  }
  41.649  
  41.650  /** Connects to the backend.
  41.651 @@ -476,21 +493,21 @@
  41.652  
  41.653  
  41.654  gboolean
  41.655 -gmyth_socket_connect (GMythSocket *gmyth_socket,
  41.656 -	const gchar *hostname, gint port)
  41.657 +gmyth_socket_connect (GMythSocket * gmyth_socket,
  41.658 +    const gchar * hostname, gint port)
  41.659  {
  41.660 -    return gmyth_socket_connect_with_timeout (gmyth_socket,
  41.661 -		    hostname, port, 0);
  41.662 +    return gmyth_socket_connect_with_timeout (gmyth_socket, hostname, port, 0);
  41.663  }
  41.664  
  41.665  gboolean
  41.666 -gmyth_socket_connect_with_timeout (GMythSocket *gmyth_socket,
  41.667 -	const gchar *hostname, gint port, guint timeout)
  41.668 +gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket,
  41.669 +    const gchar * hostname, gint port, guint timeout)
  41.670  {
  41.671      struct addrinfo *addr_info_data = NULL, *addr_info0 = NULL;
  41.672      struct linger ling;
  41.673      gchar *tmp_str;
  41.674 -    gint ret_code = 0; /* -1 */
  41.675 +    gint ret_code = 0;          /* -1 */
  41.676 +
  41.677      /* FIXME: add as function parameter */
  41.678      gint err;
  41.679      gint errno;
  41.680 @@ -498,34 +515,37 @@
  41.681  
  41.682      gmyth_debug ("CONNECTING %s:%d", hostname, port);
  41.683  
  41.684 -    if ( hostname == NULL )
  41.685 -        gmyth_debug ( "Invalid hostname parameter!\n");
  41.686 +    if (hostname == NULL)
  41.687 +        gmyth_debug ("Invalid hostname parameter!\n");
  41.688  
  41.689      /* store hostname and port number */
  41.690      gmyth_debug ("CONNECTING %s:%d", hostname, port);
  41.691  
  41.692 -    errno = gmyth_socket_toaddrinfo ( hostname, port, &addr_info_data );
  41.693 +    errno = gmyth_socket_toaddrinfo (hostname, port, &addr_info_data);
  41.694  
  41.695 -    g_return_val_if_fail( addr_info_data != NULL && hostname != NULL, FALSE );
  41.696 +    g_return_val_if_fail (addr_info_data != NULL && hostname != NULL, FALSE);
  41.697  
  41.698      /* hack to avoid deleting the hostname when
  41.699       * gmyth_socket->hostname == hostname */
  41.700      tmp_str = gmyth_socket->hostname;
  41.701  
  41.702 -    gmyth_socket->hostname = g_strdup( hostname );
  41.703 +    gmyth_socket->hostname = g_strdup (hostname);
  41.704      gmyth_socket->port = port;
  41.705  
  41.706      g_free (tmp_str);
  41.707  
  41.708 -    for ( addr_info0 = addr_info_data; addr_info0; addr_info0 = addr_info_data->ai_next ) {
  41.709 +    for (addr_info0 = addr_info_data; addr_info0;
  41.710 +        addr_info0 = addr_info_data->ai_next) {
  41.711          /* init socket descriptor */
  41.712 -        gmyth_socket->sd = socket( addr_info0->ai_family, addr_info0->ai_socktype,
  41.713 -                         addr_info0->ai_protocol );
  41.714 +        gmyth_socket->sd =
  41.715 +            socket (addr_info0->ai_family, addr_info0->ai_socktype,
  41.716 +            addr_info0->ai_protocol);
  41.717  
  41.718 -        if ( gmyth_socket->sd < 0 )
  41.719 +        if (gmyth_socket->sd < 0)
  41.720              continue;
  41.721  
  41.722          struct timeval *timeout_val = g_new0 (struct timeval, 1);
  41.723 +
  41.724          if (timeout != 0) {
  41.725              timeout_val->tv_sec = timeout;
  41.726              timeout_val->tv_usec = 0;
  41.727 @@ -533,21 +553,22 @@
  41.728              timeout_val->tv_sec = 5;
  41.729              timeout_val->tv_usec = 100;
  41.730          }
  41.731 -        
  41.732 -        if (gmyth_socket_try_connect (gmyth_socket->sd, (struct sockaddr *)addr_info0->ai_addr,
  41.733 -                addr_info0->ai_addrlen, timeout_val, &ret_code ) < 0 ) {
  41.734 -            gmyth_debug( "[%s] Error connecting to backend!\n", __FUNCTION__ );
  41.735 +
  41.736 +        if (gmyth_socket_try_connect
  41.737 +            (gmyth_socket->sd, (struct sockaddr *) addr_info0->ai_addr,
  41.738 +                addr_info0->ai_addrlen, timeout_val, &ret_code) < 0) {
  41.739 +            gmyth_debug ("[%s] Error connecting to backend!\n", __FUNCTION__);
  41.740              if (ret_code == ETIMEDOUT)
  41.741 -                gmyth_debug( "[%s]\tBackend host unreachable!\n", __FUNCTION__ );
  41.742 +                gmyth_debug ("[%s]\tBackend host unreachable!\n", __FUNCTION__);
  41.743  
  41.744              close (gmyth_socket->sd);
  41.745              gmyth_socket->sd = -1;
  41.746 -            gmyth_debug ("ERROR: %s\n", gai_strerror(ret_code));
  41.747 -    	    g_free (timeout_val);
  41.748 +            gmyth_debug ("ERROR: %s\n", gai_strerror (ret_code));
  41.749 +            g_free (timeout_val);
  41.750              continue;
  41.751          }
  41.752  
  41.753 -	    g_free (timeout_val);
  41.754 +        g_free (timeout_val);
  41.755  
  41.756          /* only will be reached if none of the error above occurred */
  41.757          break;
  41.758 @@ -560,39 +581,42 @@
  41.759          g_io_channel_unref (gmyth_socket->sd_io_ch);
  41.760          gmyth_socket->sd_io_ch = NULL;
  41.761      }
  41.762 -   
  41.763 -    	 
  41.764 +
  41.765 +
  41.766      memset (&ling, 0, sizeof (struct linger));
  41.767      ling.l_onoff = TRUE;
  41.768      ling.l_linger = 1;
  41.769 -    
  41.770 -    err = setsockopt(gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger));
  41.771 -	  
  41.772 -    if( err < 0 ) {
  41.773 -        gmyth_debug( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ );
  41.774 -	    err=errno;
  41.775 +
  41.776 +    err =
  41.777 +        setsockopt (gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling,
  41.778 +        sizeof (struct linger));
  41.779 +
  41.780 +    if (err < 0) {
  41.781 +        gmyth_debug ("[%s] Setting connection unsucessfull.\n", __FUNCTION__);
  41.782 +        err = errno;
  41.783          ret = FALSE;
  41.784          goto cleanup;
  41.785 -    } 
  41.786 +    }
  41.787  
  41.788      gmyth_socket->sd_io_ch = g_io_channel_unix_new (gmyth_socket->sd);
  41.789 -    
  41.790 +
  41.791      g_io_channel_set_close_on_unref (gmyth_socket->sd_io_ch, TRUE);
  41.792      //g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL );
  41.793 -    
  41.794 -    GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch);    
  41.795 -		/* unset the nonblock flag */
  41.796 -		flags &= ~G_IO_FLAG_NONBLOCK;
  41.797 -		/* unset the nonblocking stuff for some time, because GNUTLS doesn't like
  41.798 -		 * that */
  41.799 -		g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL);
  41.800  
  41.801 -    ret = ( ret_code == 0 ) ? TRUE : FALSE ;
  41.802 +    GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch);
  41.803  
  41.804 -cleanup:
  41.805 -    if ( !ret )
  41.806 -    	gmyth_debug("GMythSocket error - return code error!");
  41.807 -    	
  41.808 +    /* unset the nonblock flag */
  41.809 +    flags &= ~G_IO_FLAG_NONBLOCK;
  41.810 +    /* unset the nonblocking stuff for some time, because GNUTLS doesn't like
  41.811 +     * that */
  41.812 +    g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL);
  41.813 +
  41.814 +    ret = (ret_code == 0) ? TRUE : FALSE;
  41.815 +
  41.816 +  cleanup:
  41.817 +    if (!ret)
  41.818 +        gmyth_debug ("GMythSocket error - return code error!");
  41.819 +
  41.820      return ret;
  41.821  }
  41.822  
  41.823 @@ -601,9 +625,9 @@
  41.824   * @param gmyth_socket The GMythSocket instance.
  41.825   */
  41.826  GIOChannel *
  41.827 -gmyth_socket_get_io_channel( GMythSocket *gmyth_socket )
  41.828 +gmyth_socket_get_io_channel (GMythSocket * gmyth_socket)
  41.829  {
  41.830 -    g_return_val_if_fail( gmyth_socket != NULL, NULL );
  41.831 +    g_return_val_if_fail (gmyth_socket != NULL, NULL);
  41.832  
  41.833      return gmyth_socket->sd_io_ch;
  41.834  }
  41.835 @@ -614,16 +638,18 @@
  41.836   * @return TRUE if the socket is able to read, FALSE if not.
  41.837   */
  41.838  gboolean
  41.839 -gmyth_socket_is_able_to_read( GMythSocket *gmyth_socket )
  41.840 +gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket)
  41.841  {
  41.842      gboolean ret = TRUE;
  41.843  
  41.844      /* verify if the input (read) buffer is ready to receive data */
  41.845 -    GIOCondition io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
  41.846 +    GIOCondition io_cond =
  41.847 +        g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
  41.848  
  41.849 -    if ( ( io_cond & G_IO_IN ) == 0 ) {
  41.850 -	gmyth_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__);
  41.851 -	ret = FALSE;
  41.852 +    if ((io_cond & G_IO_IN) == 0) {
  41.853 +        gmyth_debug ("[%s] IO channel is not able to send data!\n",
  41.854 +            __FUNCTION__);
  41.855 +        ret = FALSE;
  41.856      }
  41.857  
  41.858      return ret;
  41.859 @@ -636,16 +662,18 @@
  41.860   * @return TRUE if the socket is able to write, FALSE if not.
  41.861   */
  41.862  gboolean
  41.863 -gmyth_socket_is_able_to_write( GMythSocket *gmyth_socket )
  41.864 +gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket)
  41.865  {
  41.866      gboolean ret = TRUE;
  41.867  
  41.868      /* verify if the input (read) buffer is ready to receive data */
  41.869 -    GIOCondition io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
  41.870 +    GIOCondition io_cond =
  41.871 +        g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
  41.872  
  41.873 -    if ( ( ( io_cond & G_IO_OUT ) == 0 ) || ( ( io_cond & G_IO_HUP ) == 0 ) ) {
  41.874 -	gmyth_debug ("[%s] IO channel is not able to send data!\n", __FUNCTION__);
  41.875 -	ret = FALSE;
  41.876 +    if (((io_cond & G_IO_OUT) == 0) || ((io_cond & G_IO_HUP) == 0)) {
  41.877 +        gmyth_debug ("[%s] IO channel is not able to send data!\n",
  41.878 +            __FUNCTION__);
  41.879 +        ret = FALSE;
  41.880      }
  41.881  
  41.882      return ret;
  41.883 @@ -658,66 +686,71 @@
  41.884   * @param command The string command to be sent.
  41.885   */
  41.886  gboolean
  41.887 -gmyth_socket_send_command(GMythSocket *gmyth_socket, GString *command) 
  41.888 +gmyth_socket_send_command (GMythSocket * gmyth_socket, GString * command)
  41.889  {
  41.890      gboolean ret = TRUE;
  41.891  
  41.892      GIOStatus io_status = G_IO_STATUS_NORMAL;
  41.893 +
  41.894      //GIOCondition io_cond;
  41.895 -    GError* error = NULL;   
  41.896 -    
  41.897 +    GError *error = NULL;
  41.898 +
  41.899      gchar *buffer = NULL;
  41.900  
  41.901      gsize bytes_written = 0;
  41.902 -    
  41.903 -    g_return_val_if_fail( gmyth_socket->sd_io_ch != NULL, FALSE );
  41.904  
  41.905 -    if( command == NULL || ( command->len <= 0 ) || command->str == NULL ) {
  41.906 -		gmyth_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__);
  41.907 -		ret = FALSE;
  41.908 -		goto done;
  41.909 +    g_return_val_if_fail (gmyth_socket->sd_io_ch != NULL, FALSE);
  41.910 +
  41.911 +    if (command == NULL || (command->len <= 0) || command->str == NULL) {
  41.912 +        gmyth_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__);
  41.913 +        ret = FALSE;
  41.914 +        goto done;
  41.915      }
  41.916  
  41.917 -    g_mutex_lock( gmyth_socket->mutex );
  41.918 +    g_mutex_lock (gmyth_socket->mutex);
  41.919      gmyth_debug ("Sending command to backend: %s\n", command->str);
  41.920  
  41.921 -    buffer = g_strnfill( BUFLEN, ' ' );
  41.922 -    g_snprintf( buffer, MYTH_PROTOCOL_FIELD_SIZE+1, "%-8d", command->len);
  41.923 +    buffer = g_strnfill (BUFLEN, ' ');
  41.924 +    g_snprintf (buffer, MYTH_PROTOCOL_FIELD_SIZE + 1, "%-8d", command->len);
  41.925  
  41.926 -    command = g_string_prepend(command, buffer);
  41.927 +    command = g_string_prepend (command, buffer);
  41.928  
  41.929 -    /* write bytes to socket */    
  41.930 -    io_status = g_io_channel_write_chars( gmyth_socket->sd_io_ch, command->str, 
  41.931 -	    command->len, &bytes_written, &error );
  41.932 +    /* write bytes to socket */
  41.933 +    io_status = g_io_channel_write_chars (gmyth_socket->sd_io_ch, command->str,
  41.934 +        command->len, &bytes_written, &error);
  41.935  
  41.936  
  41.937 -    if( (io_status == G_IO_STATUS_ERROR) || ( bytes_written <= 0 ) ) {
  41.938 -		gmyth_debug ("[%s] Error while writing to socket", __FUNCTION__);
  41.939 -		ret = FALSE;
  41.940 -    } else if ( bytes_written < command->len ) {
  41.941 -		gmyth_debug ("[%s] Not all data was written socket", __FUNCTION__);
  41.942 -		ret = FALSE;
  41.943 +    if ((io_status == G_IO_STATUS_ERROR) || (bytes_written <= 0)) {
  41.944 +        gmyth_debug ("[%s] Error while writing to socket", __FUNCTION__);
  41.945 +        ret = FALSE;
  41.946 +    } else if (bytes_written < command->len) {
  41.947 +        gmyth_debug ("[%s] Not all data was written socket", __FUNCTION__);
  41.948 +        ret = FALSE;
  41.949      }
  41.950  
  41.951 -    io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
  41.952 +    io_status = g_io_channel_flush (gmyth_socket->sd_io_ch, &error);
  41.953  
  41.954 -    if ( ( bytes_written != command->len ) || ( io_status == G_IO_STATUS_ERROR ) )
  41.955 -    {
  41.956 -		gmyth_debug ("[%s] Some problem occurred when sending data to the socket\n", __FUNCTION__);
  41.957 -	
  41.958 -		ret = TRUE;
  41.959 +    if ((bytes_written != command->len)
  41.960 +        || (io_status == G_IO_STATUS_ERROR)) {
  41.961 +        gmyth_debug
  41.962 +            ("[%s] Some problem occurred when sending data to the socket\n",
  41.963 +            __FUNCTION__);
  41.964 +
  41.965 +        ret = TRUE;
  41.966      }
  41.967  
  41.968 -    g_mutex_unlock( gmyth_socket->mutex );
  41.969 -done:
  41.970 -    if ( error != NULL ) {
  41.971 -		gmyth_debug( "[%s] Error found reading data from IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message );
  41.972 -		ret = FALSE;
  41.973 -		g_error_free( error );
  41.974 +    g_mutex_unlock (gmyth_socket->mutex);
  41.975 +  done:
  41.976 +    if (error != NULL) {
  41.977 +        gmyth_debug
  41.978 +            ("[%s] Error found reading data from IO channel: (%d, %s)\n",
  41.979 +            __FUNCTION__, error->code, error->message);
  41.980 +        ret = FALSE;
  41.981 +        g_error_free (error);
  41.982      }
  41.983  
  41.984 -    if ( buffer!= NULL )
  41.985 -		g_free( buffer );
  41.986 +    if (buffer != NULL)
  41.987 +        g_free (buffer);
  41.988  
  41.989      return ret;
  41.990  }
  41.991 @@ -733,45 +766,46 @@
  41.992   * 										backend connection. 
  41.993   */
  41.994  static gboolean
  41.995 -gmyth_socket_connect_to_backend_and_events (GMythSocket *gmyth_socket, 
  41.996 -	const gchar *hostname_backend, gint port, gboolean blocking_client,
  41.997 -	gboolean with_events)
  41.998 +gmyth_socket_connect_to_backend_and_events (GMythSocket * gmyth_socket,
  41.999 +    const gchar * hostname_backend,
 41.1000 +    gint port, gboolean blocking_client, gboolean with_events)
 41.1001  {
 41.1002      if (!gmyth_socket_connect (gmyth_socket, hostname_backend, port)) {
 41.1003 -		gmyth_debug ("[%s] Could not open socket to backend machine [%s]\n", __FUNCTION__,
 41.1004 -					hostname_backend );
 41.1005 -		return FALSE;
 41.1006 +        gmyth_debug ("[%s] Could not open socket to backend machine [%s]\n",
 41.1007 +            __FUNCTION__, hostname_backend);
 41.1008 +        return FALSE;
 41.1009      }
 41.1010  
 41.1011 -    if ( gmyth_socket_check_protocol_version (gmyth_socket) ) {
 41.1012 +    if (gmyth_socket_check_protocol_version (gmyth_socket)) {
 41.1013          GString *result;
 41.1014 -        GString *base_str = g_string_new("");	
 41.1015 +        GString *base_str = g_string_new ("");
 41.1016          GString *hostname = NULL;
 41.1017  
 41.1018 -        hostname = gmyth_socket_get_local_hostname();
 41.1019 +        hostname = gmyth_socket_get_local_hostname ();
 41.1020          if (hostname == NULL) {
 41.1021              gmyth_debug ("Hostname not available, setting to n800frontend\n");
 41.1022              hostname = g_string_new ("n800frontend");
 41.1023          }
 41.1024 -        
 41.1025 -        g_string_printf(base_str, "ANN %s %s %u", 
 41.1026 -		    (blocking_client ? "Playback" : "Monitor"),
 41.1027 -    		hostname->str, with_events);
 41.1028 +
 41.1029 +        g_string_printf (base_str, "ANN %s %s %u",
 41.1030 +            (blocking_client ? "Playback" : "Monitor"),
 41.1031 +            hostname->str, with_events);
 41.1032  
 41.1033          gmyth_socket_send_command (gmyth_socket, base_str);
 41.1034          result = gmyth_socket_receive_response (gmyth_socket);
 41.1035 -        
 41.1036 +
 41.1037          if (result != NULL) {
 41.1038              gmyth_debug ("Response received from backend: %s", result->str);
 41.1039              g_string_free (result, TRUE);
 41.1040          }
 41.1041 -        
 41.1042 +
 41.1043          g_string_free (hostname, TRUE);
 41.1044          g_string_free (base_str, TRUE);
 41.1045 -        
 41.1046 +
 41.1047          return TRUE;
 41.1048      } else {
 41.1049 -        gmyth_debug ("[%s] GMythSocket could not connect to the backend", __FUNCTION__);
 41.1050 +        gmyth_debug ("[%s] GMythSocket could not connect to the backend",
 41.1051 +            __FUNCTION__);
 41.1052          return FALSE;
 41.1053      }
 41.1054  }
 41.1055 @@ -785,16 +819,16 @@
 41.1056   * @param blocking_client A flag to choose between blocking and non-blocking 
 41.1057   */
 41.1058  gboolean
 41.1059 -gmyth_socket_connect_to_backend (GMythSocket *gmyth_socket, 
 41.1060 -	const gchar *hostname_backend, gint port, gboolean blocking_client)
 41.1061 +gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket,
 41.1062 +    const gchar * hostname_backend, gint port, gboolean blocking_client)
 41.1063  {
 41.1064 -    if (!gmyth_socket_connect_to_backend_and_events ( gmyth_socket, hostname_backend, port,
 41.1065 -    		blocking_client, FALSE) ) {
 41.1066 -		gmyth_debug ("Could not open socket to backend machine [%s]\n",
 41.1067 -					hostname_backend );
 41.1068 -		return FALSE;
 41.1069 +    if (!gmyth_socket_connect_to_backend_and_events
 41.1070 +        (gmyth_socket, hostname_backend, port, blocking_client, FALSE)) {
 41.1071 +        gmyth_debug ("Could not open socket to backend machine [%s]\n",
 41.1072 +            hostname_backend);
 41.1073 +        return FALSE;
 41.1074      }
 41.1075 -    
 41.1076 +
 41.1077      return TRUE;
 41.1078  
 41.1079  }
 41.1080 @@ -808,16 +842,17 @@
 41.1081   * @param blocking_client A flag to choose between blocking and non-blocking 
 41.1082   */
 41.1083  gboolean
 41.1084 -gmyth_socket_connect_to_backend_events (GMythSocket *gmyth_socket, 
 41.1085 -	const gchar *hostname_backend, gint port, gboolean blocking_client)
 41.1086 +gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket,
 41.1087 +    const gchar * hostname_backend, gint port, gboolean blocking_client)
 41.1088  {
 41.1089 -    if (!gmyth_socket_connect_to_backend_and_events ( gmyth_socket, hostname_backend, port,
 41.1090 -    		blocking_client, TRUE) ) {
 41.1091 -		gmyth_debug ("Could not open socket to backend machine in order to receive events [%s]\n",
 41.1092 -					hostname_backend );
 41.1093 -		return FALSE;
 41.1094 +    if (!gmyth_socket_connect_to_backend_and_events
 41.1095 +        (gmyth_socket, hostname_backend, port, blocking_client, TRUE)) {
 41.1096 +        gmyth_debug
 41.1097 +            ("Could not open socket to backend machine in order to receive events [%s]\n",
 41.1098 +            hostname_backend);
 41.1099 +        return FALSE;
 41.1100      }
 41.1101 -    
 41.1102 +
 41.1103      return TRUE;
 41.1104  }
 41.1105  
 41.1106 @@ -826,22 +861,22 @@
 41.1107   * @param gmyth_socket The GMythSocket instance.
 41.1108   */
 41.1109  void
 41.1110 -gmyth_socket_close_connection (GMythSocket *gmyth_socket)
 41.1111 +gmyth_socket_close_connection (GMythSocket * gmyth_socket)
 41.1112  {
 41.1113 -	/*
 41.1114 -	if ( gmyth_socket->sd != -1 ) {
 41.1115 -    close (gmyth_socket->sd);	
 41.1116 -    gmyth_socket->sd = -1;
 41.1117 -	}
 41.1118 -	*/
 41.1119 +    /*
 41.1120 +       if ( gmyth_socket->sd != -1 ) {
 41.1121 +       close (gmyth_socket->sd);    
 41.1122 +       gmyth_socket->sd = -1;
 41.1123 +       }
 41.1124 +     */
 41.1125  
 41.1126 -  if (gmyth_socket->sd_io_ch != NULL) {
 41.1127 -  	g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL);
 41.1128 -    g_io_channel_unref (gmyth_socket->sd_io_ch);
 41.1129 -    gmyth_socket->sd_io_ch = NULL;
 41.1130 -    gmyth_socket->sd = -1;
 41.1131 -  }
 41.1132 -  
 41.1133 +    if (gmyth_socket->sd_io_ch != NULL) {
 41.1134 +        g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL);
 41.1135 +        g_io_channel_unref (gmyth_socket->sd_io_ch);
 41.1136 +        gmyth_socket->sd_io_ch = NULL;
 41.1137 +        gmyth_socket->sd = -1;
 41.1138 +    }
 41.1139 +
 41.1140  }
 41.1141  
 41.1142  
 41.1143 @@ -855,7 +890,8 @@
 41.1144   * @return The actual MythTV the client is connected to.
 41.1145   */
 41.1146  gint
 41.1147 -gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, gint mythtv_version)
 41.1148 +gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket,
 41.1149 +    gint mythtv_version)
 41.1150  {
 41.1151      GString *response = NULL;
 41.1152      GString *payload = NULL;
 41.1153 @@ -865,37 +901,41 @@
 41.1154  
 41.1155      assert (gmyth_socket);
 41.1156  
 41.1157 -try_new_version:
 41.1158 +  try_new_version:
 41.1159      payload = g_string_new ("MYTH_PROTO_VERSION");
 41.1160 -    g_string_append_printf( payload, " %d", mythtv_version );
 41.1161 +    g_string_append_printf (payload, " %d", mythtv_version);
 41.1162  
 41.1163 -    gmyth_socket_send_command(gmyth_socket, payload);
 41.1164 -    response = gmyth_socket_receive_response(gmyth_socket);
 41.1165 +    gmyth_socket_send_command (gmyth_socket, payload);
 41.1166 +    response = gmyth_socket_receive_response (gmyth_socket);
 41.1167  
 41.1168      if (response == NULL) {
 41.1169 -		gmyth_debug ("[%s] Check protocol version error! Not answered!", __FUNCTION__);
 41.1170 -		res = FALSE;	
 41.1171 -		goto done;
 41.1172 +        gmyth_debug ("[%s] Check protocol version error! Not answered!",
 41.1173 +            __FUNCTION__);
 41.1174 +        res = FALSE;
 41.1175 +        goto done;
 41.1176      }
 41.1177  
 41.1178      res = g_str_has_prefix (response->str, "ACCEPT");
 41.1179      if (!res) {
 41.1180 -        gmyth_debug ("[%s] Protocol version request error: %s", __FUNCTION__, response->str);
 41.1181 +        gmyth_debug ("[%s] Protocol version request error: %s", __FUNCTION__,
 41.1182 +            response->str);
 41.1183          /* get the version number returned by the REJECT message */
 41.1184 -        if ( ( res = g_str_has_prefix (response->str, "REJECT") ) == TRUE ) {
 41.1185 +        if ((res = g_str_has_prefix (response->str, "REJECT")) == TRUE) {
 41.1186              gchar *new_version = NULL;
 41.1187 -            new_version = g_strrstr( response->str, "]" );
 41.1188 -            if (new_version!=NULL) {
 41.1189 -                ++new_version; /* skip ']' character */
 41.1190 -                if ( new_version != NULL ) {
 41.1191 -                    gmyth_debug ( "[%s] got MythTV version = %s.\n", 
 41.1192 -                            __FUNCTION__, new_version );
 41.1193 -                    mythtv_version = (gint)g_ascii_strtoull (new_version, NULL, 10 );
 41.1194 +
 41.1195 +            new_version = g_strrstr (response->str, "]");
 41.1196 +            if (new_version != NULL) {
 41.1197 +                ++new_version;  /* skip ']' character */
 41.1198 +                if (new_version != NULL) {
 41.1199 +                    gmyth_debug ("[%s] got MythTV version = %s.\n",
 41.1200 +                        __FUNCTION__, new_version);
 41.1201 +                    mythtv_version =
 41.1202 +                        (gint) g_ascii_strtoull (new_version, NULL, 10);
 41.1203                      /* do reconnection to the socket (socket is closed if the MythTV version was wrong) */
 41.1204 -                    gmyth_socket_connect( gmyth_socket, gmyth_socket->hostname, 
 41.1205 -                            gmyth_socket->port );
 41.1206 +                    gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname,
 41.1207 +                        gmyth_socket->port);
 41.1208                      new_version = NULL;
 41.1209 -                    if ( --max_iterations > 0 ) {
 41.1210 +                    if (--max_iterations > 0) {
 41.1211                          g_string_free (payload, TRUE);
 41.1212                          g_string_free (response, TRUE);
 41.1213                          goto try_new_version;
 41.1214 @@ -905,14 +945,14 @@
 41.1215              }
 41.1216          }
 41.1217      }
 41.1218 -    
 41.1219 +
 41.1220      /* change the return value to a valid one */
 41.1221 -    if ( res ) {
 41.1222 -    	mythtv_new_version = mythtv_version;
 41.1223 -    	gmyth_socket->mythtv_version = mythtv_new_version;
 41.1224 +    if (res) {
 41.1225 +        mythtv_new_version = mythtv_version;
 41.1226 +        gmyth_socket->mythtv_version = mythtv_new_version;
 41.1227      }
 41.1228  
 41.1229 -done:
 41.1230 +  done:
 41.1231      g_string_free (payload, TRUE);
 41.1232      g_string_free (response, TRUE);
 41.1233  
 41.1234 @@ -925,11 +965,12 @@
 41.1235   * @return TRUE if supports, FALSE if not.
 41.1236   */
 41.1237  gboolean
 41.1238 -gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket)
 41.1239 +gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket)
 41.1240  {
 41.1241 -    return ( ( gmyth_socket->mythtv_version = 
 41.1242 -    		gmyth_socket_check_protocol_version_number ( gmyth_socket, 
 41.1243 -    							MYTHTV_VERSION_DEFAULT ) ) != MYTHTV_CANNOT_NEGOTIATE_VERSION );
 41.1244 +    return ((gmyth_socket->mythtv_version =
 41.1245 +            gmyth_socket_check_protocol_version_number (gmyth_socket,
 41.1246 +                MYTHTV_VERSION_DEFAULT))
 41.1247 +        != MYTHTV_CANNOT_NEGOTIATE_VERSION);
 41.1248  }
 41.1249  
 41.1250  /** Returns the Mythtv backend supported version.
 41.1251 @@ -938,9 +979,9 @@
 41.1252   * @return The actual MythTV version number.
 41.1253   */
 41.1254  gint
 41.1255 -gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket) 
 41.1256 +gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket)
 41.1257  {
 41.1258 -	return gmyth_socket->mythtv_version;
 41.1259 +    return gmyth_socket->mythtv_version;
 41.1260  }
 41.1261  
 41.1262  /** Receives a backend answer after a gmyth_socket_send_command_call ().
 41.1263 @@ -948,108 +989,111 @@
 41.1264   * @param gmyth_socket The GMythSocket instance.
 41.1265   * @return The response received, or NULL if error or nothing was received.
 41.1266   */
 41.1267 -GString*
 41.1268 -gmyth_socket_receive_response(GMythSocket *gmyth_socket)
 41.1269 +GString *
 41.1270 +gmyth_socket_receive_response (GMythSocket * gmyth_socket)
 41.1271  {
 41.1272      GIOStatus io_status = G_IO_STATUS_NORMAL;
 41.1273 -    GError* error = NULL;
 41.1274 +    GError *error = NULL;
 41.1275      gchar *buffer = NULL;
 41.1276  
 41.1277      GString *str = NULL;
 41.1278  
 41.1279      gsize bytes_read = 0;
 41.1280 -    gint  len = 0;
 41.1281 -    
 41.1282 -    if ( gmyth_socket == NULL )
 41.1283 +    gint len = 0;
 41.1284 +
 41.1285 +    if (gmyth_socket == NULL)
 41.1286          return NULL;
 41.1287  
 41.1288      GIOCondition io_cond;
 41.1289  
 41.1290      /* verify if the input (read) buffer is ready to receive data */
 41.1291 -    g_mutex_lock( gmyth_socket->mutex );
 41.1292 -    
 41.1293 +    g_mutex_lock (gmyth_socket->mutex);
 41.1294 +
 41.1295      buffer = g_strnfill (MYTH_PROTOCOL_FIELD_SIZE, ' ');
 41.1296 -    if ( NULL == gmyth_socket->sd_io_ch ) {
 41.1297 -        gmyth_socket_connect( gmyth_socket, gmyth_socket->hostname, gmyth_socket->port );
 41.1298 +    if (NULL == gmyth_socket->sd_io_ch) {
 41.1299 +        gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname,
 41.1300 +            gmyth_socket->port);
 41.1301      }
 41.1302 - 		 		
 41.1303 +
 41.1304      io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
 41.1305 -    /* 		
 41.1306 -    if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) )
 41.1307 -        gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd ); 
 41.1308 -     */	
 41.1309 - 
 41.1310 -    if ( gmyth_socket->sd_io_ch->is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 )*/ )
 41.1311 -    	io_status = g_io_channel_read_chars (gmyth_socket->sd_io_ch, 
 41.1312 -                                             buffer,
 41.1313 -                                             MYTH_PROTOCOL_FIELD_SIZE,
 41.1314 -                                             &bytes_read, 
 41.1315 -                                             &error);
 41.1316 +    /*          
 41.1317 +       if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) )
 41.1318 +       gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd ); 
 41.1319 +     */
 41.1320 +
 41.1321 +    if (gmyth_socket->sd_io_ch->
 41.1322 +        is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 ) */ )
 41.1323 +        io_status =
 41.1324 +            g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer,
 41.1325 +            MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, &error);
 41.1326      else
 41.1327 -    	return g_string_new("");
 41.1328 +        return g_string_new ("");
 41.1329  
 41.1330      /* verify if the input (read) buffer is ready to receive data */
 41.1331      io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
 41.1332 -		
 41.1333 +
 41.1334      //if ( ( io_cond & G_IO_IN ) == 0 ) 
 41.1335 -        // return NULL;		
 41.1336 +    // return NULL;         
 41.1337  
 41.1338 -    gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read );
 41.1339 +    gmyth_debug ("[%s] Bytes read = %d\n", __FUNCTION__, bytes_read);
 41.1340  
 41.1341 -    if( (io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0) ) {
 41.1342 -        gmyth_debug ("[%s] Error in mythprotocol response from backend\n", __FUNCTION__);
 41.1343 -    	str = NULL;
 41.1344 -	    //return NULL;
 41.1345 -    } else if ( buffer != NULL && strlen(buffer) > 0 ) {
 41.1346 +    if ((io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0)) {
 41.1347 +        gmyth_debug ("[%s] Error in mythprotocol response from backend\n",
 41.1348 +            __FUNCTION__);
 41.1349 +        str = NULL;
 41.1350 +        //return NULL;
 41.1351 +    } else if (buffer != NULL && strlen (buffer) > 0) {
 41.1352  
 41.1353 -    	//io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
 41.1354 -    	/* verify if the input (read) buffer is ready to receive data */
 41.1355 -    	//io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
 41.1356 -	
 41.1357 +        //io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
 41.1358 +        /* verify if the input (read) buffer is ready to receive data */
 41.1359 +        //io_cond = g_io_channel_get_buffer_condition( gmyth_socket->sd_io_ch );
 41.1360 +
 41.1361          //if ( ( io_cond & G_IO_IN ) != 0 ) {
 41.1362 -            //gchar *buffer_aux = NULL;
 41.1363 +        //gchar *buffer_aux = NULL;
 41.1364  
 41.1365          /* removes trailing whitespace */
 41.1366          //buffer_aux = g_strstrip (buffer);
 41.1367 -        len = (gint)g_ascii_strtoull ( g_strstrip (buffer), NULL, 10 );
 41.1368 +        len = (gint) g_ascii_strtoull (g_strstrip (buffer), NULL, 10);
 41.1369  
 41.1370          g_free (buffer);
 41.1371 -            
 41.1372 +
 41.1373          /*            
 41.1374 -        if (buffer_aux != NULL) {
 41.1375 -            g_free (buffer_aux);
 41.1376 -            buffer_aux = NULL;
 41.1377 -        }
 41.1378 -        */
 41.1379 +           if (buffer_aux != NULL) {
 41.1380 +           g_free (buffer_aux);
 41.1381 +           buffer_aux = NULL;
 41.1382 +           }
 41.1383 +         */
 41.1384  
 41.1385 -        buffer = g_new0 (gchar, len+1);
 41.1386 -	
 41.1387 +        buffer = g_new0 (gchar, len + 1);
 41.1388 +
 41.1389          bytes_read = 0;
 41.1390 -        if ( !( gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL) )
 41.1391 -	        return NULL;
 41.1392 +        if (!(gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL))
 41.1393 +            return NULL;
 41.1394  
 41.1395 -        if ( gmyth_socket->sd_io_ch->is_readable )
 41.1396 -            io_status = g_io_channel_read_chars( gmyth_socket->sd_io_ch, buffer,
 41.1397 -                                                 len, &bytes_read, &error);
 41.1398 +        if (gmyth_socket->sd_io_ch->is_readable)
 41.1399 +            io_status =
 41.1400 +                g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer, len,
 41.1401 +                &bytes_read, &error);
 41.1402          else
 41.1403 -            return g_string_new("");
 41.1404 -		    	
 41.1405 +            return g_string_new ("");
 41.1406 +
 41.1407          buffer[bytes_read] = '\0';
 41.1408 -			//}
 41.1409 +        //}
 41.1410      }
 41.1411  
 41.1412 -    g_mutex_unlock( gmyth_socket->mutex );
 41.1413 +    g_mutex_unlock (gmyth_socket->mutex);
 41.1414      //g_static_rw_lock_reader_unlock (&rwlock);
 41.1415  
 41.1416      gmyth_debug ("Response received from backend: ----- {%s}\n", buffer);
 41.1417 -    if ( ( bytes_read != len ) || ( io_status == G_IO_STATUS_ERROR ) )
 41.1418 +    if ((bytes_read != len) || (io_status == G_IO_STATUS_ERROR))
 41.1419          str = NULL;
 41.1420      else
 41.1421          str = g_string_new (buffer);
 41.1422  
 41.1423 -    if ( error != NULL ) {
 41.1424 -        gmyth_debug( "[%s] Error found receiving response from the IO channel: (%d, %s)\n",
 41.1425 -                __FUNCTION__, error->code, error->message );
 41.1426 +    if (error != NULL) {
 41.1427 +        gmyth_debug
 41.1428 +            ("[%s] Error found receiving response from the IO channel: (%d, %s)\n",
 41.1429 +            __FUNCTION__, error->code, error->message);
 41.1430          str = NULL;
 41.1431          g_error_free (error);
 41.1432      }
 41.1433 @@ -1065,40 +1109,42 @@
 41.1434   * @return TRUE if command was sent, FALSE if any error happens.
 41.1435   */
 41.1436  gboolean
 41.1437 -gmyth_socket_write_stringlist( GMythSocket *gmyth_socket, GMythStringList* str_list )
 41.1438 +gmyth_socket_write_stringlist (GMythSocket * gmyth_socket,
 41.1439 +    GMythStringList * str_list)
 41.1440  {
 41.1441  
 41.1442      GList *tmp_list = NULL;
 41.1443      GPtrArray *ptr_array = NULL;
 41.1444      gchar *str_array = NULL;
 41.1445  
 41.1446 -    g_mutex_lock( gmyth_socket->mutex );
 41.1447 +    g_mutex_lock (gmyth_socket->mutex);
 41.1448      //g_static_rw_lock_writer_lock (&rwlock);
 41.1449  
 41.1450 -    ptr_array = g_ptr_array_sized_new (g_list_length(str_list->glist));
 41.1451 +    ptr_array = g_ptr_array_sized_new (g_list_length (str_list->glist));
 41.1452  
 41.1453      // FIXME: change this implementation!
 41.1454      tmp_list = str_list->glist;
 41.1455 -    for(; tmp_list; tmp_list = tmp_list->next) {
 41.1456 -        if ( tmp_list->data != NULL ) {
 41.1457 -	        g_ptr_array_add(ptr_array, ((GString*)tmp_list->data)->str);
 41.1458 +    for (; tmp_list; tmp_list = tmp_list->next) {
 41.1459 +        if (tmp_list->data != NULL) {
 41.1460 +            g_ptr_array_add (ptr_array, ((GString *) tmp_list->data)->str);
 41.1461          } else {
 41.1462              g_ptr_array_add (ptr_array, "");
 41.1463          }
 41.1464      }
 41.1465 -    g_ptr_array_add(ptr_array, NULL); // g_str_joinv() needs a NULL terminated string
 41.1466 +    g_ptr_array_add (ptr_array, NULL);  // g_str_joinv() needs a NULL terminated string
 41.1467  
 41.1468      str_array = g_strjoinv (MYTH_SEPARATOR, (gchar **) (ptr_array->pdata));
 41.1469  
 41.1470 -    g_mutex_unlock( gmyth_socket->mutex );
 41.1471 +    g_mutex_unlock (gmyth_socket->mutex);
 41.1472      //g_static_rw_lock_writer_unlock (&rwlock);
 41.1473  
 41.1474 -    gmyth_debug ( "[%s] Sending socket request: %s\n", __FUNCTION__, str_array );
 41.1475 +    gmyth_debug ("[%s] Sending socket request: %s\n", __FUNCTION__, str_array);
 41.1476  
 41.1477 -    // Sends message to backend	
 41.1478 +    // Sends message to backend 
 41.1479      // TODO: implement looping to send remaining data, and add timeout testing!    
 41.1480 -    GString *command = g_string_new(str_array);
 41.1481 -    gmyth_socket_send_command(gmyth_socket, command);
 41.1482 +    GString *command = g_string_new (str_array);
 41.1483 +
 41.1484 +    gmyth_socket_send_command (gmyth_socket, command);
 41.1485  
 41.1486      g_string_free (command, TRUE);
 41.1487  
 41.1488 @@ -1117,26 +1163,28 @@
 41.1489   * @return The number of received strings.
 41.1490   */
 41.1491  gint
 41.1492 -gmyth_socket_read_stringlist (GMythSocket *gmyth_socket, GMythStringList* str_list)
 41.1493 +gmyth_socket_read_stringlist (GMythSocket * gmyth_socket,
 41.1494 +    GMythStringList * str_list)
 41.1495  {
 41.1496 -    GString *response; 
 41.1497 +    GString *response;
 41.1498      gint i;
 41.1499  
 41.1500 -	gmyth_string_list_clear_all (str_list);
 41.1501 +    gmyth_string_list_clear_all (str_list);
 41.1502  
 41.1503 -    response = gmyth_socket_receive_response(gmyth_socket);
 41.1504 -    if ( response != NULL && response->str != NULL && response->len > 0 ) {
 41.1505 +    response = gmyth_socket_receive_response (gmyth_socket);
 41.1506 +    if (response != NULL && response->str != NULL && response->len > 0) {
 41.1507          gchar **str_array;
 41.1508 -	    g_mutex_lock( gmyth_socket->mutex );
 41.1509 -	
 41.1510 -	    str_array = g_strsplit (response->str, MYTH_SEPARATOR, -1);
 41.1511 -	
 41.1512 -	    for ( i=0; i< g_strv_length (str_array); i++ ) {
 41.1513 -	    	//if ( str_array[i] != NULL && strlen( str_array[i] ) > 0 )
 41.1514 -				gmyth_string_list_append_char_array ( str_list, str_array[i] );
 41.1515 -	    }
 41.1516 -	    
 41.1517 -	    g_mutex_unlock( gmyth_socket->mutex );
 41.1518 +
 41.1519 +        g_mutex_lock (gmyth_socket->mutex);
 41.1520 +
 41.1521 +        str_array = g_strsplit (response->str, MYTH_SEPARATOR, -1);
 41.1522 +
 41.1523 +        for (i = 0; i < g_strv_length (str_array); i++) {
 41.1524 +            //if ( str_array[i] != NULL && strlen( str_array[i] ) > 0 )
 41.1525 +            gmyth_string_list_append_char_array (str_list, str_array[i]);
 41.1526 +        }
 41.1527 +
 41.1528 +        g_mutex_unlock (gmyth_socket->mutex);
 41.1529          g_strfreev (str_array);
 41.1530      }
 41.1531  
 41.1532 @@ -1155,7 +1203,8 @@
 41.1533   * error happens.
 41.1534   */
 41.1535  gint
 41.1536 -gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket, GMythStringList *str_list)
 41.1537 +gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket,
 41.1538 +    GMythStringList * str_list)
 41.1539  {
 41.1540      gmyth_socket_write_stringlist (gmyth_socket, str_list);
 41.1541  
    42.1 --- a/gmyth/src/gmyth_socket.h	Tue May 22 19:21:42 2007 +0100
    42.2 +++ b/gmyth/src/gmyth_socket.h	Wed May 23 16:11:29 2007 +0100
    42.3 @@ -13,22 +13,22 @@
    42.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    42.5   * @author Rosfran Lins Borges <rosfran.borges@indt.org.br> 
    42.6   *
    42.7 - *//*
    42.8 - * 
    42.9 - * This program is free software; you can redistribute it and/or modify
   42.10 - * it under the terms of the GNU Lesser General Public License as published by
   42.11 - * the Free Software Foundation; either version 2 of the License, or
   42.12 - * (at your option) any later version.
   42.13 - *
   42.14 - * This program is distributed in the hope that it will be useful,
   42.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   42.17 - * GNU General Public License for more details.
   42.18 - *
   42.19 - * You should have received a copy of the GNU Lesser General Public License
   42.20 - * along with this program; if not, write to the Free Software
   42.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   42.22 - */
   42.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   42.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   42.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   42.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   42.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   42.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   42.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   42.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   42.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   42.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   42.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   42.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   42.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   42.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   42.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   42.39  
   42.40  #ifndef __GMYTH_SOCKET_H__
   42.41  #define __GMYTH_SOCKET_H__
   42.42 @@ -44,88 +44,82 @@
   42.43  #include "gmyth_stringlist.h"
   42.44  
   42.45  G_BEGIN_DECLS
   42.46 -
   42.47  #define GMYTH_SOCKET_TYPE               (gmyth_socket_get_type ())
   42.48  #define GMYTH_SOCKET(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE, GMythSocket))
   42.49  #define GMYTH_SOCKET_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE, GMythSocketClass))
   42.50  #define IS_GMYTH_SOCKET(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_SOCKET_TYPE))
   42.51  #define IS_GMYTH_SOCKET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE))
   42.52  #define GMYTH_SOCKET_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SOCKET_TYPE, GMythSocketClass))
   42.53 -
   42.54 -
   42.55 -typedef struct _GMythSocket         GMythSocket;
   42.56 -typedef struct _GMythSocketClass    GMythSocketClass;
   42.57 +typedef struct _GMythSocket GMythSocket;
   42.58 +typedef struct _GMythSocketClass GMythSocketClass;
   42.59  
   42.60  struct _GMythSocketClass
   42.61  {
   42.62 -	GObjectClass parent_class;
   42.63 +    GObjectClass parent_class;
   42.64  
   42.65 -	/* callbacks */
   42.66 -	/* no one for now */
   42.67 +    /* callbacks */
   42.68 +    /* no one for now */
   42.69  };
   42.70  
   42.71  struct _GMythSocket
   42.72  {
   42.73 -	GObject 		parent;
   42.74 -	
   42.75 -	GMutex 			*mutex;
   42.76 +    GObject parent;
   42.77  
   42.78 -	/* socket descriptor */
   42.79 -	gint 				sd;
   42.80 -	GIOChannel 	*sd_io_ch;
   42.81 +    GMutex *mutex;
   42.82  
   42.83 -	gchar 			*hostname;
   42.84 -	gint 				port;
   42.85 -	gint 				mythtv_version;
   42.86 +    /* socket descriptor */
   42.87 +    gint sd;
   42.88 +    GIOChannel *sd_io_ch;
   42.89 +
   42.90 +    gchar *hostname;
   42.91 +    gint port;
   42.92 +    gint mythtv_version;
   42.93  };
   42.94  
   42.95  /* used when no protocol version number was negotiated */
   42.96  #define	MYTHTV_CANNOT_NEGOTIATE_VERSION		0
   42.97  
   42.98 -GType           gmyth_socket_get_type (void);
   42.99 +GType gmyth_socket_get_type (void);
  42.100  
  42.101 -GMythSocket *   gmyth_socket_new ();
  42.102 +GMythSocket *gmyth_socket_new ();
  42.103  
  42.104 -GIOChannel *    gmyth_socket_get_io_channel (GMythSocket *gmyth_socket );
  42.105 +GIOChannel *gmyth_socket_get_io_channel (GMythSocket * gmyth_socket);
  42.106  
  42.107 -gboolean        gmyth_socket_is_able_to_read (GMythSocket *gmyth_socket );
  42.108 -gboolean        gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket );
  42.109 +gboolean gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket);
  42.110 +gboolean gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket);
  42.111  
  42.112 -gboolean        gmyth_socket_send_command (GMythSocket *gmyth_socket, 
  42.113 -                                           GString *command);
  42.114 -GString *       gmyth_socket_receive_response (GMythSocket *gmyth_socket);
  42.115 -gint            gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket, 
  42.116 -                                                     GMythStringList *str_list);
  42.117 +gboolean gmyth_socket_send_command (GMythSocket * gmyth_socket,
  42.118 +    GString * command);
  42.119 +GString *gmyth_socket_receive_response (GMythSocket * gmyth_socket);
  42.120 +gint gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket,
  42.121 +    GMythStringList * str_list);
  42.122  
  42.123 -gboolean        gmyth_socket_connect (GMythSocket *gmyth_socket,
  42.124 -                                      const gchar *hostname, gint port);
  42.125 -gboolean        gmyth_socket_connect_with_timeout (GMythSocket *gmyth_socket,
  42.126 -                           const gchar *hostname, gint port, guint timeout);
  42.127 +gboolean gmyth_socket_connect (GMythSocket * gmyth_socket,
  42.128 +    const gchar * hostname, gint port);
  42.129 +gboolean gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket,
  42.130 +    const gchar * hostname, gint port, guint timeout);
  42.131  
  42.132 -gboolean        gmyth_socket_connect_to_backend (GMythSocket *gmyth_socket, 
  42.133 -                           const gchar *hostname_backend, gint port, 
  42.134 -                           gboolean blocking_client);
  42.135 +gboolean gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket,
  42.136 +    const gchar * hostname_backend, gint port, gboolean blocking_client);
  42.137  
  42.138 -gboolean        gmyth_socket_connect_to_backend_events (GMythSocket *gmyth_socket, 
  42.139 -                           const gchar *hostname_backend, gint port, 
  42.140 -                           gboolean blocking_client);
  42.141 +gboolean gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket,
  42.142 +    const gchar * hostname_backend, gint port, gboolean blocking_client);
  42.143  
  42.144 -gchar           *gmyth_socket_get_primary_addr(void);
  42.145 +gchar *gmyth_socket_get_primary_addr (void);
  42.146  
  42.147 -GString         *gmyth_socket_get_local_hostname (void);
  42.148 +GString *gmyth_socket_get_local_hostname (void);
  42.149  
  42.150 -void            gmyth_socket_close_connection (GMythSocket *gmyth_socket);
  42.151 +void gmyth_socket_close_connection (GMythSocket * gmyth_socket);
  42.152  
  42.153 -gboolean		gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket);
  42.154 -gint            gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, 
  42.155 -                                                            gint mythtv_version);
  42.156 +gboolean gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket);
  42.157 +gint gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket,
  42.158 +    gint mythtv_version);
  42.159  
  42.160 -gint			gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket);
  42.161 +gint gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket);
  42.162  
  42.163 -gboolean		gmyth_socket_write_stringlist(GMythSocket *gmyth_socket, 
  42.164 -                                              GMythStringList* str_list);
  42.165 -gint			gmyth_socket_read_stringlist(GMythSocket *gmyth_socket, 
  42.166 -                                             GMythStringList* str_list);
  42.167 +gboolean gmyth_socket_write_stringlist (GMythSocket * gmyth_socket,
  42.168 +    GMythStringList * str_list);
  42.169 +gint gmyth_socket_read_stringlist (GMythSocket * gmyth_socket,
  42.170 +    GMythStringList * str_list);
  42.171  G_END_DECLS
  42.172 -
  42.173  #endif /* __GMYTH_SOCKET_H__ */
    43.1 --- a/gmyth/src/gmyth_stringlist.c	Tue May 22 19:21:42 2007 +0100
    43.2 +++ b/gmyth/src/gmyth_stringlist.c	Wed May 23 16:11:29 2007 +0100
    43.3 @@ -9,74 +9,72 @@
    43.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    43.5   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    43.6   *
    43.7 - *//*
    43.8 - * 
    43.9 - * This program is free software; you can redistribute it and/or modify
   43.10 - * it under the terms of the GNU Lesser General Public License as published by
   43.11 - * the Free Software Foundation; either version 2 of the License, or
   43.12 - * (at your option) any later version.
   43.13 - *
   43.14 - * This program is distributed in the hope that it will be useful,
   43.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   43.17 - * GNU General Public License for more details.
   43.18 - *
   43.19 - * You should have received a copy of the GNU Lesser General Public License
   43.20 - * along with this program; if not, write to the Free Software
   43.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   43.22 - */
   43.23 - 
   43.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   43.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   43.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   43.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   43.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   43.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   43.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   43.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   43.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   43.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   43.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   43.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   43.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   43.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   43.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   43.40 +
   43.41  #ifdef HAVE_CONFIG_H
   43.42  #include "config.h"
   43.43  #endif
   43.44  
   43.45  #include "gmyth_stringlist.h"
   43.46 - 
   43.47 +
   43.48  #include "gmyth_debug.h"
   43.49  
   43.50 -static void gmyth_string_list_class_init          (GMythStringListClass *klass);
   43.51 -static void gmyth_string_list_init                (GMythStringList *object);
   43.52 +static void gmyth_string_list_class_init (GMythStringListClass * klass);
   43.53 +static void gmyth_string_list_init (GMythStringList * object);
   43.54  
   43.55 -static void gmyth_string_list_dispose  (GObject *object);
   43.56 -static void gmyth_string_list_finalize (GObject *object);
   43.57 +static void gmyth_string_list_dispose (GObject * object);
   43.58 +static void gmyth_string_list_finalize (GObject * object);
   43.59  
   43.60 -G_DEFINE_TYPE(GMythStringList, gmyth_string_list, G_TYPE_OBJECT)
   43.61 -    
   43.62 -static void
   43.63 -gmyth_string_list_class_init (GMythStringListClass *klass)
   43.64 +G_DEFINE_TYPE (GMythStringList, gmyth_string_list, G_TYPE_OBJECT)
   43.65 +     static void gmyth_string_list_class_init (GMythStringListClass * klass)
   43.66  {
   43.67 -	GObjectClass *gobject_class;
   43.68 +    GObjectClass *gobject_class;
   43.69  
   43.70      gobject_class = (GObjectClass *) klass;
   43.71 -	
   43.72 -    gobject_class->dispose  = gmyth_string_list_dispose;
   43.73 -    gobject_class->finalize = gmyth_string_list_finalize;	
   43.74 +
   43.75 +    gobject_class->dispose = gmyth_string_list_dispose;
   43.76 +    gobject_class->finalize = gmyth_string_list_finalize;
   43.77  }
   43.78  
   43.79  static void
   43.80 -gmyth_string_list_init (GMythStringList *gmyth_string_list)
   43.81 +gmyth_string_list_init (GMythStringList * gmyth_string_list)
   43.82  {
   43.83 -	gmyth_string_list->glist = NULL;
   43.84 +    gmyth_string_list->glist = NULL;
   43.85  }
   43.86  
   43.87  static void
   43.88 -gmyth_string_list_dispose  (GObject *object)
   43.89 +gmyth_string_list_dispose (GObject * object)
   43.90  {
   43.91 -    GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
   43.92 +    GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (object);
   43.93  
   43.94 -    gmyth_string_list_clear_all(gmyth_string_list);
   43.95 +    gmyth_string_list_clear_all (gmyth_string_list);
   43.96  
   43.97      G_OBJECT_CLASS (gmyth_string_list_parent_class)->dispose (object);
   43.98  }
   43.99  
  43.100  static void
  43.101 -gmyth_string_list_finalize (GObject *object)
  43.102 +gmyth_string_list_finalize (GObject * object)
  43.103  {
  43.104 -	//GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
  43.105 +    //GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
  43.106  
  43.107 -	g_signal_handlers_destroy (object);
  43.108 +    g_signal_handlers_destroy (object);
  43.109  
  43.110 -	G_OBJECT_CLASS (gmyth_string_list_parent_class)->finalize (object);
  43.111 +    G_OBJECT_CLASS (gmyth_string_list_parent_class)->finalize (object);
  43.112  }
  43.113  
  43.114  /** Creates a new instance of GStringList.
  43.115 @@ -86,7 +84,8 @@
  43.116  GMythStringList *
  43.117  gmyth_string_list_new ()
  43.118  {
  43.119 -    GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (g_object_new (GMYTH_STRING_LIST_TYPE, NULL));
  43.120 +    GMythStringList *gmyth_string_list =
  43.121 +        GMYTH_STRING_LIST (g_object_new (GMYTH_STRING_LIST_TYPE, NULL));
  43.122  
  43.123      return gmyth_string_list;
  43.124  }
  43.125 @@ -98,16 +97,16 @@
  43.126   * 
  43.127   * @return The appended guint64 converted to a GString object.
  43.128   */
  43.129 -GString*
  43.130 -gmyth_string_list_append_int ( GMythStringList *strlist, const gint value )
  43.131 +GString *
  43.132 +gmyth_string_list_append_int (GMythStringList * strlist, const gint value)
  43.133  {
  43.134 -	GString *value_str = g_string_new ("");
  43.135 +    GString *value_str = g_string_new ("");
  43.136  
  43.137 -	g_string_printf (value_str, "%d", value);
  43.138 +    g_string_printf (value_str, "%d", value);
  43.139  
  43.140 -	strlist->glist = g_list_append (strlist->glist, value_str);
  43.141 +    strlist->glist = g_list_append (strlist->glist, value_str);
  43.142  
  43.143 -	return value_str;	
  43.144 +    return value_str;
  43.145  }
  43.146  
  43.147  /** Appends a guint64 to the string list.
  43.148 @@ -117,31 +116,32 @@
  43.149   * 
  43.150   * @return The appended guint64 converted to a GString object.
  43.151   */
  43.152 -GString*
  43.153 -gmyth_string_list_append_uint64 ( GMythStringList *strlist, const guint64 value)
  43.154 +GString *
  43.155 +gmyth_string_list_append_uint64 (GMythStringList * strlist, const guint64 value)
  43.156  {
  43.157 -	GString *tmp_str1 = g_string_new ("");
  43.158 -	GString *tmp_str2 = g_string_new ("");
  43.159 -	gmyth_debug ( "value = %llu.\n", value);
  43.160 +    GString *tmp_str1 = g_string_new ("");
  43.161 +    GString *tmp_str2 = g_string_new ("");
  43.162  
  43.163 -	gulong l2 = ( (guint64)value & 0xffffffff  );
  43.164 -	gulong l1 = ( (guint64)value >> 32 );
  43.165 -  
  43.166 -	/* high order part of guint64 value */
  43.167 -	g_string_printf (tmp_str1, "%lu", l1);
  43.168 -	
  43.169 -	gmyth_debug( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
  43.170 +    gmyth_debug ("value = %llu.\n", value);
  43.171  
  43.172 -	strlist->glist = g_list_append( strlist->glist, tmp_str1 );
  43.173 +    gulong l2 = ((guint64) value & 0xffffffff);
  43.174 +    gulong l1 = ((guint64) value >> 32);
  43.175  
  43.176 - 	/* low order part of guint64 value */
  43.177 -	g_string_printf (tmp_str2, "%lu", l2);
  43.178 +    /* high order part of guint64 value */
  43.179 +    g_string_printf (tmp_str1, "%lu", l1);
  43.180  
  43.181 -	gmyth_debug( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
  43.182 +    gmyth_debug ("[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str);
  43.183  
  43.184 -	strlist->glist = g_list_append( strlist->glist, tmp_str2 );
  43.185 +    strlist->glist = g_list_append (strlist->glist, tmp_str1);
  43.186  
  43.187 -	return tmp_str2;	
  43.188 +    /* low order part of guint64 value */
  43.189 +    g_string_printf (tmp_str2, "%lu", l2);
  43.190 +
  43.191 +    gmyth_debug ("[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str);
  43.192 +
  43.193 +    strlist->glist = g_list_append (strlist->glist, tmp_str2);
  43.194 +
  43.195 +    return tmp_str2;
  43.196  }
  43.197  
  43.198  /** Appends a gint64 to the string list.
  43.199 @@ -151,31 +151,32 @@
  43.200   * 
  43.201   * @return The appended gint64 converted to a GString object.
  43.202   */
  43.203 -GString*
  43.204 -gmyth_string_list_append_int64 ( GMythStringList *strlist, const gint64 value)
  43.205 +GString *
  43.206 +gmyth_string_list_append_int64 (GMythStringList * strlist, const gint64 value)
  43.207  {
  43.208 -	GString *tmp_str1 = g_string_new ("");
  43.209 -	GString *tmp_str2 = g_string_new ("");
  43.210 -	gmyth_debug ( "value = %lld.\n", value );
  43.211 +    GString *tmp_str1 = g_string_new ("");
  43.212 +    GString *tmp_str2 = g_string_new ("");
  43.213  
  43.214 -	glong l2 = ( (gint64)value & 0xffffffff  );
  43.215 -	glong l1 = ( (gint64)value >> 32 );
  43.216 -  
  43.217 -	/* high order part of gint64 value */
  43.218 -	g_string_printf (tmp_str1, "%ld", l1);
  43.219 -	
  43.220 -	gmyth_debug( "[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
  43.221 +    gmyth_debug ("value = %lld.\n", value);
  43.222  
  43.223 -	strlist->glist = g_list_append( strlist->glist, tmp_str1 );
  43.224 +    glong l2 = ((gint64) value & 0xffffffff);
  43.225 +    glong l1 = ((gint64) value >> 32);
  43.226  
  43.227 - 	/* low order part of gint64 value */
  43.228 -	g_string_printf (tmp_str2, "%ld", l2);
  43.229 +    /* high order part of gint64 value */
  43.230 +    g_string_printf (tmp_str1, "%ld", l1);
  43.231  
  43.232 -	gmyth_debug( "[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
  43.233 +    gmyth_debug ("[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str);
  43.234  
  43.235 -	strlist->glist = g_list_append( strlist->glist, tmp_str2 );
  43.236 +    strlist->glist = g_list_append (strlist->glist, tmp_str1);
  43.237  
  43.238 -	return tmp_str2;
  43.239 +    /* low order part of gint64 value */
  43.240 +    g_string_printf (tmp_str2, "%ld", l2);
  43.241 +
  43.242 +    gmyth_debug ("[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str);
  43.243 +
  43.244 +    strlist->glist = g_list_append (strlist->glist, tmp_str2);
  43.245 +
  43.246 +    return tmp_str2;
  43.247  }
  43.248  
  43.249  /** Appends a char array to the string list.
  43.250 @@ -185,18 +186,19 @@
  43.251   * 
  43.252   * @return The appended char array converted to a GString object.
  43.253   */
  43.254 -GString*
  43.255 -gmyth_string_list_append_char_array ( GMythStringList *strlist, const gchar* value )
  43.256 +GString *
  43.257 +gmyth_string_list_append_char_array (GMythStringList * strlist,
  43.258 +    const gchar * value)
  43.259  {
  43.260 -	GString *tmp_str = NULL;
  43.261 -	
  43.262 -	g_return_val_if_fail( strlist != NULL, NULL );
  43.263 -	
  43.264 -	tmp_str = g_string_new (value);
  43.265 +    GString *tmp_str = NULL;
  43.266  
  43.267 -	strlist->glist = g_list_append (strlist->glist, tmp_str);
  43.268 +    g_return_val_if_fail (strlist != NULL, NULL);
  43.269  
  43.270 -	return tmp_str;		
  43.271 +    tmp_str = g_string_new (value);
  43.272 +
  43.273 +    strlist->glist = g_list_append (strlist->glist, tmp_str);
  43.274 +
  43.275 +    return tmp_str;
  43.276  }
  43.277  
  43.278  /** Appends a string to the string list.
  43.279 @@ -206,13 +208,14 @@
  43.280   * 
  43.281   * @return The appended string itself. 
  43.282   */
  43.283 -GString*
  43.284 -gmyth_string_list_append_string ( GMythStringList *strlist, GString *value )
  43.285 +GString *
  43.286 +gmyth_string_list_append_string (GMythStringList * strlist, GString * value)
  43.287  {
  43.288 -    g_return_val_if_fail (strlist != NULL, NULL );
  43.289 +    g_return_val_if_fail (strlist != NULL, NULL);
  43.290  
  43.291      if (value != NULL) {
  43.292 -        strlist->glist = g_list_append (strlist->glist, g_string_new (value->str));
  43.293 +        strlist->glist =
  43.294 +            g_list_append (strlist->glist, g_string_new (value->str));
  43.295      } else {
  43.296          strlist->glist = g_list_append (strlist->glist, NULL);
  43.297      }
  43.298 @@ -227,19 +230,20 @@
  43.299   * @return The integer value.
  43.300   */
  43.301  gint
  43.302 -gmyth_string_list_get_int ( GMythStringList *strlist, const gint index )
  43.303 +gmyth_string_list_get_int (GMythStringList * strlist, const gint index)
  43.304  {
  43.305 -	//TODO: Create static method check_index()
  43.306 -	GString *tmp_str = NULL;
  43.307 -	
  43.308 -	g_return_val_if_fail( strlist != NULL, 0 );
  43.309 +    //TODO: Create static method check_index()
  43.310 +    GString *tmp_str = NULL;
  43.311  
  43.312 -	tmp_str = (GString *) g_list_nth_data (strlist->glist, index);
  43.313 +    g_return_val_if_fail (strlist != NULL, 0);
  43.314  
  43.315 -	if ( NULL == tmp_str || NULL == tmp_str->str || strlen( tmp_str->str ) <= 0 )
  43.316 -		return 0;
  43.317 -	
  43.318 -	return (gint) ( /* 0x00000000ffffffffL &  (gint64)*/g_ascii_strtoull ( tmp_str->str, NULL, 10 ) );
  43.319 +    tmp_str = (GString *) g_list_nth_data (strlist->glist, index);
  43.320 +
  43.321 +    if (NULL == tmp_str || NULL == tmp_str->str || strlen (tmp_str->str) <= 0)
  43.322 +        return 0;
  43.323 +
  43.324 +    return (gint) (             /* 0x00000000ffffffffL &  (gint64) */
  43.325 +        g_ascii_strtoull (tmp_str->str, NULL, 10));
  43.326  }
  43.327  
  43.328  /** Gets a guint64 value from the string list at the given position.
  43.329 @@ -252,39 +256,47 @@
  43.330   * @return The guint64 value.
  43.331   */
  43.332  guint64
  43.333 -gmyth_string_list_get_uint64 ( GMythStringList *strlist, const gint index )
  43.334 +gmyth_string_list_get_uint64 (GMythStringList * strlist, const gint index)
  43.335  {
  43.336 -	//TODO: Create static method check_index()
  43.337 -	guint64 ret_value = 0;
  43.338 -	guint64 l2 = 0;
  43.339 +    //TODO: Create static method check_index()
  43.340 +    guint64 ret_value = 0;
  43.341 +    guint64 l2 = 0;
  43.342  
  43.343 -	g_return_val_if_fail( strlist != NULL, 0 );
  43.344 -  
  43.345 -	const GString *tmp_str1 = (GString *) g_list_nth_data (strlist->glist, index);
  43.346 -	const GString *tmp_str2 = (GString *) g_list_nth_data (strlist->glist, index+1);
  43.347 +    g_return_val_if_fail (strlist != NULL, 0);
  43.348  
  43.349 -	if ( tmp_str1 != NULL )
  43.350 -		gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__, tmp_str1->str );
  43.351 -	if ( tmp_str2 == NULL || strlen( tmp_str2->str ) > 0 ) {
  43.352 -	} else {
  43.353 -		gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str );
  43.354 -	}
  43.355 -	
  43.356 -	guint64 l1 = ( (guint64)g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff*/  );
  43.357 -	if ( tmp_str2 != NULL && tmp_str2->str != NULL && strlen(tmp_str2->str) > 0 ) {
  43.358 -		l2 = ( (guint64)g_ascii_strtoull (tmp_str2->str, NULL, 10) /*& 0xffffffff*/  );
  43.359 -	} else {
  43.360 -		l2 = l1;
  43.361 -		l1 = 0;
  43.362 -	}
  43.363 +    const GString *tmp_str1 =
  43.364 +        (GString *) g_list_nth_data (strlist->glist, index);
  43.365 +    const GString *tmp_str2 =
  43.366 +        (GString *) g_list_nth_data (strlist->glist, index + 1);
  43.367  
  43.368 -	gmyth_debug ( "[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2 );
  43.369 -	
  43.370 -	ret_value = ((guint64)(l2) /*& 0xffffffff*/) | ((guint64)l1 << 32);
  43.371 -  
  43.372 -	gmyth_debug( "[%s] returning uint64 value = %llu\n", __FUNCTION__, ret_value );	
  43.373 -	
  43.374 -	return ret_value;
  43.375 +    if (tmp_str1 != NULL)
  43.376 +        gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__,
  43.377 +            tmp_str1->str);
  43.378 +    if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) {
  43.379 +    } else {
  43.380 +        gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str);
  43.381 +    }
  43.382 +
  43.383 +    guint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10)  /*& 0xffffffff */
  43.384 +        );
  43.385 +
  43.386 +    if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) {
  43.387 +        l2 = ((guint64) g_ascii_strtoull (tmp_str2->str, NULL, 10)
  43.388 +            /*& 0xffffffff */
  43.389 +            );
  43.390 +    } else {
  43.391 +        l2 = l1;
  43.392 +        l1 = 0;
  43.393 +    }
  43.394 +
  43.395 +    gmyth_debug ("[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2);
  43.396 +
  43.397 +    ret_value = ((guint64) (l2) /*& 0xffffffff */ ) | ((guint64) l1 << 32);
  43.398 +
  43.399 +    gmyth_debug ("[%s] returning uint64 value = %llu\n", __FUNCTION__,
  43.400 +        ret_value);
  43.401 +
  43.402 +    return ret_value;
  43.403  }
  43.404  
  43.405  /** Gets a gint64 value from the string list at the given position.
  43.406 @@ -297,39 +309,47 @@
  43.407   * @return The gint64 value.
  43.408   */
  43.409  gint64
  43.410 -gmyth_string_list_get_int64 ( GMythStringList *strlist, const gint index )
  43.411 +gmyth_string_list_get_int64 (GMythStringList * strlist, const gint index)
  43.412  {
  43.413 -	//TODO: Create static method check_index()
  43.414 -	gint64 ret_value = 0;
  43.415 -	gint64 l2 = 0;
  43.416 +    //TODO: Create static method check_index()
  43.417 +    gint64 ret_value = 0;
  43.418 +    gint64 l2 = 0;
  43.419  
  43.420 -	g_return_val_if_fail( strlist != NULL, 0 );
  43.421 -  
  43.422 -	const GString *tmp_str1 = (GString *) g_list_nth_data (strlist->glist, index);
  43.423 -	const GString *tmp_str2 = (GString *) g_list_nth_data (strlist->glist, index+1);
  43.424 +    g_return_val_if_fail (strlist != NULL, 0);
  43.425  
  43.426 -	if ( tmp_str1 != NULL )
  43.427 -		gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__, tmp_str1->str );
  43.428 -	if ( tmp_str2 == NULL || strlen( tmp_str2->str ) > 0 ) {
  43.429 -	} else {
  43.430 -		gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str );
  43.431 -	}
  43.432 -	
  43.433 -	gint64 l1 = ( (guint64)g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff*/  );
  43.434 -	if ( tmp_str2 != NULL && tmp_str2->str != NULL && strlen(tmp_str2->str) > 0 ) {
  43.435 -		l2 = ( (gint64)g_ascii_strtoull (tmp_str2->str, NULL, 10) /*& 0xffffffff*/  );
  43.436 -	} else {
  43.437 -		l2 = l1;
  43.438 -		l1 = 0;
  43.439 -	}
  43.440 +    const GString *tmp_str1 =
  43.441 +        (GString *) g_list_nth_data (strlist->glist, index);
  43.442 +    const GString *tmp_str2 =
  43.443 +        (GString *) g_list_nth_data (strlist->glist, index + 1);
  43.444  
  43.445 -	gmyth_debug ( "[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2 );
  43.446 -	
  43.447 -	ret_value = ((gint64)(l2) /*& 0xffffffff*/) | ((gint64)l1 << 32);
  43.448 -  
  43.449 -	gmyth_debug( "[%s] returning int64 value = %lld\n", __FUNCTION__, ret_value );	
  43.450 -	
  43.451 -	return ret_value;
  43.452 +    if (tmp_str1 != NULL)
  43.453 +        gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__,
  43.454 +            tmp_str1->str);
  43.455 +    if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) {
  43.456 +    } else {
  43.457 +        gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str);
  43.458 +    }
  43.459 +
  43.460 +    gint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10)   /*& 0xffffffff */
  43.461 +        );
  43.462 +
  43.463 +    if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) {
  43.464 +        l2 = ((gint64) g_ascii_strtoull (tmp_str2->str, NULL, 10)
  43.465 +            /*& 0xffffffff */
  43.466 +            );
  43.467 +    } else {
  43.468 +        l2 = l1;
  43.469 +        l1 = 0;
  43.470 +    }
  43.471 +
  43.472 +    gmyth_debug ("[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2);
  43.473 +
  43.474 +    ret_value = ((gint64) (l2) /*& 0xffffffff */ ) | ((gint64) l1 << 32);
  43.475 +
  43.476 +    gmyth_debug ("[%s] returning int64 value = %lld\n", __FUNCTION__,
  43.477 +        ret_value);
  43.478 +
  43.479 +    return ret_value;
  43.480  }
  43.481  
  43.482  
  43.483 @@ -339,14 +359,14 @@
  43.484   * @param index the string position in the list, starting with zero.
  43.485   * @return A pointer to the string data.
  43.486   */
  43.487 -GString*
  43.488 -gmyth_string_list_get_string ( GMythStringList *strlist, const gint index )
  43.489 +GString *
  43.490 +gmyth_string_list_get_string (GMythStringList * strlist, const gint index)
  43.491  {
  43.492      GString *ret;
  43.493  
  43.494      if (!strlist || !(strlist->glist)) {
  43.495 -	gmyth_debug ("%s received Null arguments", __FUNCTION__);
  43.496 -	return NULL;
  43.497 +        gmyth_debug ("%s received Null arguments", __FUNCTION__);
  43.498 +        return NULL;
  43.499      }
  43.500  
  43.501      ret = (GString *) g_list_nth_data (strlist->glist, index);
  43.502 @@ -356,10 +376,10 @@
  43.503  
  43.504  
  43.505  static void
  43.506 -gmyth_string_list_clear_element( GString *str_elem, void *data_aux )
  43.507 +gmyth_string_list_clear_element (GString * str_elem, void *data_aux)
  43.508  {
  43.509      if (str_elem != NULL)
  43.510 -        g_string_free( str_elem, TRUE );
  43.511 +        g_string_free (str_elem, TRUE);
  43.512  }
  43.513  
  43.514  /** Removes all strings from the string list.
  43.515 @@ -367,10 +387,11 @@
  43.516   * @param strlist The GMythStringList instance.
  43.517   */
  43.518  void
  43.519 -gmyth_string_list_clear_all ( GMythStringList *strlist )
  43.520 +gmyth_string_list_clear_all (GMythStringList * strlist)
  43.521  {
  43.522 -    if ( strlist != NULL && strlist->glist ) {
  43.523 -        g_list_foreach( strlist->glist, (GFunc)gmyth_string_list_clear_element, NULL );
  43.524 +    if (strlist != NULL && strlist->glist) {
  43.525 +        g_list_foreach (strlist->glist,
  43.526 +            (GFunc) gmyth_string_list_clear_element, NULL);
  43.527          g_list_free (strlist->glist);
  43.528          strlist->glist = NULL;
  43.529      }
  43.530 @@ -382,10 +403,10 @@
  43.531   * @return the string list length.
  43.532   */
  43.533  gint
  43.534 -gmyth_string_list_length ( GMythStringList *strlist )
  43.535 +gmyth_string_list_length (GMythStringList * strlist)
  43.536  {
  43.537 -    if ( !(strlist != NULL && strlist->glist != NULL) )
  43.538 -	return 0;
  43.539 +    if (!(strlist != NULL && strlist->glist != NULL))
  43.540 +        return 0;
  43.541  
  43.542      return g_list_length (strlist->glist);
  43.543  }
    44.1 --- a/gmyth/src/gmyth_stringlist.h	Tue May 22 19:21:42 2007 +0100
    44.2 +++ b/gmyth/src/gmyth_stringlist.h	Wed May 23 16:11:29 2007 +0100
    44.3 @@ -9,22 +9,22 @@
    44.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    44.5   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    44.6   *
    44.7 - *//*
    44.8 - * 
    44.9 - * This program is free software; you can redistribute it and/or modify
   44.10 - * it under the terms of the GNU Lesser General Public License as published by
   44.11 - * the Free Software Foundation; either version 2 of the License, or
   44.12 - * (at your option) any later version.
   44.13 - *
   44.14 - * This program is distributed in the hope that it will be useful,
   44.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   44.17 - * GNU General Public License for more details.
   44.18 - *
   44.19 - * You should have received a copy of the GNU Lesser General Public License
   44.20 - * along with this program; if not, write to the Free Software
   44.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   44.22 - */
   44.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   44.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   44.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   44.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   44.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   44.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   44.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   44.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   44.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   44.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   44.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   44.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   44.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   44.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   44.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   44.39  
   44.40  #ifndef GMYTH_STRING_LIST_H_
   44.41  #define GMYTH_STRING_LIST_H_
   44.42 @@ -39,24 +39,21 @@
   44.43  #include <unistd.h>
   44.44  
   44.45  G_BEGIN_DECLS
   44.46 -
   44.47  #define GMYTH_STRING_LIST_TYPE               (gmyth_string_list_get_type ())
   44.48  #define GMYTH_STRING_LIST(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_STRING_LIST_TYPE, GMythStringList))
   44.49  #define GMYTH_STRING_LIST_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_STRING_LIST_TYPE, GMythStringListClass))
   44.50  #define IS_GMYTH_STRING_LIST(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_STRING_LIST_TYPE))
   44.51  #define IS_GMYTH_STRING_LIST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_STRING_LIST_TYPE))
   44.52  #define GMYTH_STRING_LIST_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_STRING_LIST_TYPE, GMythStringListClass))
   44.53 -
   44.54 -
   44.55 -typedef struct _GMythStringList         GMythStringList;
   44.56 -typedef struct _GMythStringListClass    GMythStringListClass;
   44.57 +typedef struct _GMythStringList GMythStringList;
   44.58 +typedef struct _GMythStringListClass GMythStringListClass;
   44.59  
   44.60  struct _GMythStringListClass
   44.61  {
   44.62 -  GObjectClass parent_class;
   44.63 +    GObjectClass parent_class;
   44.64  
   44.65 -  /* callbacks */
   44.66 -  /* no one for now */
   44.67 +    /* callbacks */
   44.68 +    /* no one for now */
   44.69  };
   44.70  
   44.71  struct _GMythStringList
   44.72 @@ -64,38 +61,40 @@
   44.73      GObject parent;
   44.74  
   44.75      /* string list */
   44.76 -    GList *glist;  
   44.77 +    GList *glist;
   44.78  };
   44.79  
   44.80  
   44.81 -GType               gmyth_string_list_get_type (void);
   44.82 +GType gmyth_string_list_get_type (void);
   44.83  
   44.84 -GMythStringList *   gmyth_string_list_new (void);
   44.85 +GMythStringList *gmyth_string_list_new (void);
   44.86  
   44.87 -void                gmyth_string_list_clear_all (GMythStringList *strlist);
   44.88 -int                 gmyth_string_list_length (GMythStringList *strlist);
   44.89 +void gmyth_string_list_clear_all (GMythStringList * strlist);
   44.90 +int gmyth_string_list_length (GMythStringList * strlist);
   44.91  
   44.92 -GString *           gmyth_string_list_append_int (GMythStringList *strlist, 
   44.93 -                                                  const gint value);
   44.94 -GString *           gmyth_string_list_append_uint64 (GMythStringList *strlist, 
   44.95 -                                                     const guint64 value);
   44.96 +GString *gmyth_string_list_append_int (GMythStringList * strlist,
   44.97 +    const gint value);
   44.98 +GString *gmyth_string_list_append_uint64 (GMythStringList * strlist,
   44.99 +    const guint64 value);
  44.100  
  44.101 -GString *           gmyth_string_list_append_int64 (GMythStringList *strlist, 
  44.102 -                                                     const gint64 value);
  44.103 +GString *gmyth_string_list_append_int64 (GMythStringList * strlist,
  44.104 +    const gint64 value);
  44.105  
  44.106 -GString *           gmyth_string_list_append_char_array (GMythStringList *strlist, 
  44.107 -                                                         const char* value);
  44.108 -GString *           gmyth_string_list_append_string (GMythStringList *strlist, 
  44.109 -                                                     GString *value);
  44.110 +GString *gmyth_string_list_append_char_array (GMythStringList * strlist,
  44.111 +    const char *value);
  44.112 +GString *gmyth_string_list_append_string (GMythStringList * strlist,
  44.113 +    GString * value);
  44.114  
  44.115 -int                 gmyth_string_list_get_int (GMythStringList *strlist, const gint index);
  44.116 -guint64             gmyth_string_list_get_uint64 (GMythStringList *strlist, const gint index);
  44.117 -gint64             gmyth_string_list_get_int64 (GMythStringList *strlist, const gint index);
  44.118 -GString *           gmyth_string_list_get_string (GMythStringList *strlist, const gint index);
  44.119 +int gmyth_string_list_get_int (GMythStringList * strlist, const gint index);
  44.120 +guint64 gmyth_string_list_get_uint64 (GMythStringList * strlist,
  44.121 +    const gint index);
  44.122 +gint64 gmyth_string_list_get_int64 (GMythStringList * strlist,
  44.123 +    const gint index);
  44.124 +GString *gmyth_string_list_get_string (GMythStringList * strlist,
  44.125 +    const gint index);
  44.126  
  44.127  #define gmyth_string_list_get_char_array(strlist, index) \
  44.128              (gmyth_string_list_get_string(strlist, index))->str
  44.129  
  44.130  G_END_DECLS
  44.131 -
  44.132 -#endif /*GMYTH_STRING_LIST_H_*/
  44.133 +#endif /*GMYTH_STRING_LIST_H_ */
    45.1 --- a/gmyth/src/gmyth_transcoder.c	Tue May 22 19:21:42 2007 +0100
    45.2 +++ b/gmyth/src/gmyth_transcoder.c	Wed May 23 16:11:29 2007 +0100
    45.3 @@ -26,7 +26,7 @@
    45.4   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    45.5   */
    45.6  
    45.7 - 
    45.8 +
    45.9  #ifdef HAVE_CONFIG_H
   45.10  #include "config.h"
   45.11  #endif
   45.12 @@ -41,32 +41,31 @@
   45.13  #include "gmyth_jobqueue.h"
   45.14  #include "gmyth_transcoder.h"
   45.15  
   45.16 -static void gmyth_transcoder_class_init          (GMythTranscoderClass *klass);
   45.17 -static void gmyth_transcoder_init                (GMythTranscoder *object);
   45.18 +static void gmyth_transcoder_class_init (GMythTranscoderClass * klass);
   45.19 +static void gmyth_transcoder_init (GMythTranscoder * object);
   45.20  
   45.21 -static void gmyth_transcoder_dispose  (GObject *object);
   45.22 -static void gmyth_transcoder_finalize (GObject *object);
   45.23 +static void gmyth_transcoder_dispose (GObject * object);
   45.24 +static void gmyth_transcoder_finalize (GObject * object);
   45.25  
   45.26 -G_DEFINE_TYPE(GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT)
   45.27 -
   45.28 -static void
   45.29 -gmyth_transcoder_class_init (GMythTranscoderClass *klass)
   45.30 +G_DEFINE_TYPE (GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT)
   45.31 +     static void gmyth_transcoder_class_init (GMythTranscoderClass * klass)
   45.32  {
   45.33      GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   45.34 -    gobject_class->dispose  = gmyth_transcoder_dispose;
   45.35 +
   45.36 +    gobject_class->dispose = gmyth_transcoder_dispose;
   45.37      gobject_class->finalize = gmyth_transcoder_finalize;
   45.38  }
   45.39  
   45.40  static void
   45.41 -gmyth_transcoder_init (GMythTranscoder *transcoder)
   45.42 +gmyth_transcoder_init (GMythTranscoder * transcoder)
   45.43  {
   45.44      transcoder->started = FALSE;
   45.45  }
   45.46  
   45.47  static void
   45.48 -gmyth_transcoder_dispose  (GObject *object)
   45.49 +gmyth_transcoder_dispose (GObject * object)
   45.50  {
   45.51 -    GMythTranscoder *transcoder = GMYTH_TRANSCODER(object);
   45.52 +    GMythTranscoder *transcoder = GMYTH_TRANSCODER (object);
   45.53  
   45.54      g_free (transcoder->output_filename);
   45.55      g_free (transcoder->filename);
   45.56 @@ -74,13 +73,13 @@
   45.57      g_free (transcoder->starttime);
   45.58  
   45.59      if (transcoder->backend_info)
   45.60 -	g_object_unref (transcoder->backend_info);
   45.61 +        g_object_unref (transcoder->backend_info);
   45.62  
   45.63      G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object);
   45.64  }
   45.65  
   45.66  static void
   45.67 -gmyth_transcoder_finalize (GObject *object)
   45.68 +gmyth_transcoder_finalize (GObject * object)
   45.69  {
   45.70      g_signal_handlers_destroy (object);
   45.71      G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object);
   45.72 @@ -91,11 +90,11 @@
   45.73   * 
   45.74   * @return a new instance of GMythTranscoder.
   45.75   **/
   45.76 -GMythTranscoder*
   45.77 -gmyth_transcoder_new (GMythBackendInfo *backend_info)
   45.78 +GMythTranscoder *
   45.79 +gmyth_transcoder_new (GMythBackendInfo * backend_info)
   45.80  {
   45.81 -    GMythTranscoder *transcoder = GMYTH_TRANSCODER\
   45.82 -                                 (g_object_new(GMYTH_TRANSCODER_TYPE, NULL));
   45.83 +    GMythTranscoder *transcoder = GMYTH_TRANSCODER
   45.84 +        (g_object_new (GMYTH_TRANSCODER_TYPE, NULL));
   45.85  
   45.86      if (backend_info != NULL) {
   45.87          g_object_ref (backend_info);
   45.88 @@ -113,40 +112,39 @@
   45.89   * @return gchar* with file or iso format
   45.90   *
   45.91   **/
   45.92 -static gchar* 
   45.93 -gmyth_transcoder_date_change_format (gchar* date_s, int format)
   45.94 +static gchar *
   45.95 +gmyth_transcoder_date_change_format (gchar * date_s, int format)
   45.96  {
   45.97 -    if (date_s != NULL)
   45.98 -    {
   45.99 -        gint length = strlen(date_s);
  45.100 +    if (date_s != NULL) {
  45.101 +        gint length = strlen (date_s);
  45.102  
  45.103          //create the right date format
  45.104 -        gchar* src = (gchar*)g_malloc0(sizeof(gchar) * length);
  45.105 -        strncpy(src, date_s, length);
  45.106 +        gchar *src = (gchar *) g_malloc0 (sizeof (gchar) * length);
  45.107  
  45.108 -        gchar* dst;
  45.109 +        strncpy (src, date_s, length);
  45.110  
  45.111 -        if (format == DATE_FILE)
  45.112 -        {
  45.113 -            dst = (gchar*)g_malloc0(sizeof(gchar) * 16);
  45.114 -            snprintf(dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src+5,\
  45.115 -                    src+7, src+9, src+11, src+13);
  45.116 +        gchar *dst;
  45.117 +
  45.118 +        if (format == DATE_FILE) {
  45.119 +            dst = (gchar *) g_malloc0 (sizeof (gchar) * 16);
  45.120 +            snprintf (dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src + 5,
  45.121 +                src + 7, src + 9, src + 11, src + 13);
  45.122              dst[15] = '\0';
  45.123          } else if (format == DATE_ISO) {
  45.124 -            dst = (gchar*)g_malloc0(sizeof(gchar) * 20);
  45.125 -            snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src+4,\
  45.126 -                    src+6, src+8, src+10, src+12);
  45.127 +            dst = (gchar *) g_malloc0 (sizeof (gchar) * 20);
  45.128 +            snprintf (dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src + 4,
  45.129 +                src + 6, src + 8, src + 10, src + 12);
  45.130              dst[19] = '\0';
  45.131          }
  45.132  
  45.133 -        gchar* ret = g_strdup(dst);
  45.134 +        gchar *ret = g_strdup (dst);
  45.135  
  45.136 -        g_free(src);
  45.137 -        g_free(dst);
  45.138 +        g_free (src);
  45.139 +        g_free (dst);
  45.140  
  45.141          return ret;
  45.142 -    }
  45.143 -    else return NULL;
  45.144 +    } else
  45.145 +        return NULL;
  45.146  }
  45.147  
  45.148  /**
  45.149 @@ -157,12 +155,12 @@
  45.150   * @return void set's up the var to value
  45.151   *
  45.152   **/
  45.153 -void 
  45.154 -gmyth_transcoder_set_output (GMythTranscoder* transcoder,
  45.155 -                             gboolean value, const gchar* outputfile)
  45.156 +void
  45.157 +gmyth_transcoder_set_output (GMythTranscoder * transcoder,
  45.158 +    gboolean value, const gchar * outputfile)
  45.159  {
  45.160      transcoder->output = value;
  45.161 -    transcoder->output_filename = g_strdup(outputfile);
  45.162 +    transcoder->output_filename = g_strdup (outputfile);
  45.163  }
  45.164  
  45.165  /**
  45.166 @@ -172,23 +170,24 @@
  45.167   * @return void set's up the var to value
  45.168   *
  45.169   **/
  45.170 -void 
  45.171 -gmyth_transcoder_set_filename (GMythTranscoder* transcoder, const gchar* file)
  45.172 +void
  45.173 +gmyth_transcoder_set_filename (GMythTranscoder * transcoder, const gchar * file)
  45.174  {
  45.175      // fixme: if this method is called twice, memory will not be dealocated
  45.176      // one transcoder can be used only for one file request?
  45.177 -    if (file != NULL)
  45.178 -    {
  45.179 -        gchar** splited = g_strsplit(file, "_", 2);
  45.180 +    if (file != NULL) {
  45.181 +        gchar **splited = g_strsplit (file, "_", 2);
  45.182  
  45.183          // Get chanid
  45.184 -        sscanf (splited[0],"%d", &(transcoder->chanid));
  45.185 +        sscanf (splited[0], "%d", &(transcoder->chanid));
  45.186  
  45.187          // Get starttime
  45.188 -        gchar** date = g_strsplit(splited[1], ".", 2);
  45.189 -        transcoder->starttime = gmyth_transcoder_date_change_format(date[0], DATE_ISO);
  45.190 +        gchar **date = g_strsplit (splited[1], ".", 2);
  45.191  
  45.192 -        transcoder->filename = g_strdup(file);
  45.193 +        transcoder->starttime =
  45.194 +            gmyth_transcoder_date_change_format (date[0], DATE_ISO);
  45.195 +
  45.196 +        transcoder->filename = g_strdup (file);
  45.197      }
  45.198  }
  45.199  
  45.200 @@ -203,48 +202,48 @@
  45.201   *
  45.202   **/
  45.203  gint
  45.204 -gmyth_transcoder_set_profile (GMythTranscoder* trans,
  45.205 -                              const gchar* value)
  45.206 +gmyth_transcoder_set_profile (GMythTranscoder * trans, const gchar * value)
  45.207  {
  45.208      g_return_val_if_fail (value != NULL, -1);
  45.209  
  45.210 -    trans->profile = g_strndup(value, strlen(value));
  45.211 +    trans->profile = g_strndup (value, strlen (value));
  45.212  
  45.213      return 0;
  45.214  }
  45.215  
  45.216  gboolean
  45.217 -gmyth_transcoder_start (GMythTranscoder* trans)
  45.218 +gmyth_transcoder_start (GMythTranscoder * trans)
  45.219  {
  45.220      g_return_val_if_fail (trans != NULL, FALSE);
  45.221      g_return_val_if_fail (trans->backend_info != NULL, FALSE);
  45.222      g_return_val_if_fail (trans->filename != NULL, FALSE);
  45.223  
  45.224 -    if (trans->started == FALSE) { // not started yet
  45.225 -	if (!gmyth_util_file_exists (trans->backend_info, trans->filename)) {
  45.226 +    if (trans->started == FALSE) {  // not started yet
  45.227 +        if (!gmyth_util_file_exists (trans->backend_info, trans->filename)) {
  45.228              gmyth_debug ("File %s does not exist", trans->filename);
  45.229 -	}
  45.230 -        trans->started = gmyth_jobqueue_add_job(trans, "JOB_TRANSCODE");
  45.231 -	if (trans->started == FALSE)
  45.232 -	    gmyth_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename);
  45.233 +        }
  45.234 +        trans->started = gmyth_jobqueue_add_job (trans, "JOB_TRANSCODE");
  45.235 +        if (trans->started == FALSE)
  45.236 +            gmyth_debug ("Error while starting GMythTranscoder to file: %s",
  45.237 +                trans->output_filename);
  45.238      } else {
  45.239 -	    gmyth_debug ("GMythTransfer already started!");
  45.240 +        gmyth_debug ("GMythTransfer already started!");
  45.241      }
  45.242  
  45.243      return trans->started;
  45.244  }
  45.245  
  45.246  gboolean
  45.247 -gmyth_transcoder_pause (GMythTranscoder* trans)
  45.248 +gmyth_transcoder_pause (GMythTranscoder * trans)
  45.249  {
  45.250      g_return_val_if_fail (trans != NULL, FALSE);
  45.251      g_return_val_if_fail (trans->started == TRUE, FALSE);
  45.252 -    
  45.253 +
  45.254      return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE");
  45.255  }
  45.256  
  45.257  gboolean
  45.258 -gmyth_transcoder_resume (GMythTranscoder* trans)
  45.259 +gmyth_transcoder_resume (GMythTranscoder * trans)
  45.260  {
  45.261      g_return_val_if_fail (trans != NULL, FALSE);
  45.262  
  45.263 @@ -252,7 +251,7 @@
  45.264  }
  45.265  
  45.266  gboolean
  45.267 -gmyth_transcoder_cancel (GMythTranscoder* trans)
  45.268 +gmyth_transcoder_cancel (GMythTranscoder * trans)
  45.269  {
  45.270      g_return_val_if_fail (trans != NULL, FALSE);
  45.271      g_return_val_if_fail (trans->started == TRUE, FALSE);
  45.272 @@ -264,9 +263,9 @@
  45.273  
  45.274  //fixme: implement this method
  45.275  gint
  45.276 -gmyth_transcoder_get_progress (GMythTranscoder* trans)
  45.277 +gmyth_transcoder_get_progress (GMythTranscoder * trans)
  45.278  {
  45.279      static int fixme = 0;
  45.280 -    
  45.281 -    return (fixme++)%101;
  45.282 +
  45.283 +    return (fixme++) % 101;
  45.284  }
    46.1 --- a/gmyth/src/gmyth_transcoder.h	Tue May 22 19:21:42 2007 +0100
    46.2 +++ b/gmyth/src/gmyth_transcoder.h	Wed May 23 16:11:29 2007 +0100
    46.3 @@ -39,28 +39,22 @@
    46.4  #include "gmyth_recprofile.h"
    46.5  
    46.6  G_BEGIN_DECLS
    46.7 -
    46.8  #define GMYTH_TRANSCODER_TYPE               (gmyth_transcoder_get_type ())
    46.9  #define GMYTH_TRANSCODER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoder))
   46.10  #define GMYTH_TRANSCODER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass))
   46.11  #define IS_GMYTH_TRANSCODER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_TRANSCODER_TYPE))
   46.12  #define IS_GMYTH_TRANSCODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE))
   46.13  #define GMYTH_TRANSCODER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass))
   46.14 -
   46.15  #define DATE_ISO 0
   46.16  #define DATE_FILE 1
   46.17 -
   46.18 -
   46.19 -
   46.20 -
   46.21 -typedef struct _GMythTranscoder         GMythTranscoder;
   46.22 -typedef struct _GMythTranscoderClass    GMythTranscoderClass;
   46.23 +typedef struct _GMythTranscoder GMythTranscoder;
   46.24 +typedef struct _GMythTranscoderClass GMythTranscoderClass;
   46.25  
   46.26  struct _GMythTranscoderClass
   46.27  {
   46.28 -  GObjectClass parent_class;
   46.29 +    GObjectClass parent_class;
   46.30  
   46.31 -  /* callbacks */
   46.32 +    /* callbacks */
   46.33  };
   46.34  
   46.35  /**
   46.36 @@ -76,32 +70,33 @@
   46.37      gboolean started;
   46.38  
   46.39      /* private begin */
   46.40 -    gchar* output_filename;
   46.41 -    gchar* filename;
   46.42 -    gchar* profile;
   46.43 +    gchar *output_filename;
   46.44 +    gchar *filename;
   46.45 +    gchar *profile;
   46.46      /* private end */
   46.47  
   46.48 -    gchar* starttime;
   46.49 +    gchar *starttime;
   46.50  
   46.51      gint chanid;
   46.52  
   46.53 -    GMythBackendInfo* backend_info;
   46.54 +    GMythBackendInfo *backend_info;
   46.55  };
   46.56  
   46.57  GType gmyth_transcoder_type (void);
   46.58  
   46.59 -GMythTranscoder*    gmyth_transcoder_new            (GMythBackendInfo* backend_info);
   46.60 -void                gmyth_transcoder_set_output     (GMythTranscoder* transcode,
   46.61 -                                                     gboolean value, const gchar* outputfile);
   46.62 -void                gmyth_transcoder_set_filename   (GMythTranscoder* transcode, const gchar* file);
   46.63 -gint                gmyth_transcoder_set_profile    (GMythTranscoder* trans, const gchar* value);
   46.64 -gboolean            gmyth_transcoder_start          (GMythTranscoder* trans);
   46.65 -gboolean            gmyth_transcoder_pause          (GMythTranscoder* trans);
   46.66 -gboolean            gmyth_transcoder_resume         (GMythTranscoder* trans);
   46.67 -gboolean            gmyth_transcoder_cancel         (GMythTranscoder* trans);
   46.68 -gint                gmyth_transcoder_get_progress   (GMythTranscoder* trans);
   46.69 +GMythTranscoder *gmyth_transcoder_new (GMythBackendInfo * backend_info);
   46.70 +void gmyth_transcoder_set_output (GMythTranscoder * transcode,
   46.71 +    gboolean value, const gchar * outputfile);
   46.72 +void gmyth_transcoder_set_filename (GMythTranscoder * transcode,
   46.73 +    const gchar * file);
   46.74 +gint gmyth_transcoder_set_profile (GMythTranscoder * trans,
   46.75 +    const gchar * value);
   46.76 +gboolean gmyth_transcoder_start (GMythTranscoder * trans);
   46.77 +gboolean gmyth_transcoder_pause (GMythTranscoder * trans);
   46.78 +gboolean gmyth_transcoder_resume (GMythTranscoder * trans);
   46.79 +gboolean gmyth_transcoder_cancel (GMythTranscoder * trans);
   46.80 +gint gmyth_transcoder_get_progress (GMythTranscoder * trans);
   46.81  
   46.82  
   46.83  G_END_DECLS
   46.84 -
   46.85  #endif /*_GMYTH_TRANSCODER_H*/
    47.1 --- a/gmyth/src/gmyth_tvchain.c	Tue May 22 19:21:42 2007 +0100
    47.2 +++ b/gmyth/src/gmyth_tvchain.c	Wed May 23 16:11:29 2007 +0100
    47.3 @@ -9,23 +9,23 @@
    47.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    47.5   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    47.6   *
    47.7 - *//*
    47.8 - * 
    47.9 - * This program is free software; you can redistribute it and/or modify
   47.10 - * it under the terms of the GNU Lesser General Public License as published by
   47.11 - * the Free Software Foundation; either version 2 of the License, or
   47.12 - * (at your option) any later version.
   47.13 - *
   47.14 - * This program is distributed in the hope that it will be useful,
   47.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   47.17 - * GNU General Public License for more details.
   47.18 - *
   47.19 - * You should have received a copy of the GNU Lesser General Public License
   47.20 - * along with this program; if not, write to the Free Software
   47.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   47.22 - */
   47.23 - 
   47.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   47.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   47.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   47.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   47.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   47.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   47.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   47.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   47.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   47.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   47.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   47.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   47.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   47.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   47.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   47.39 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   47.40 +
   47.41  #ifdef HAVE_CONFIG_H
   47.42  #include "config.h"
   47.43  #endif
   47.44 @@ -44,72 +44,71 @@
   47.45  #include "gmyth_scheduler.h"
   47.46  #include "gmyth_debug.h"
   47.47  
   47.48 -static void gmyth_tvchain_class_init          (GMythTVChainClass *klass);
   47.49 -static void gmyth_tvchain_init                (GMythTVChain *object);
   47.50 +static void gmyth_tvchain_class_init (GMythTVChainClass * klass);
   47.51 +static void gmyth_tvchain_init (GMythTVChain * object);
   47.52  
   47.53 -static void gmyth_tvchain_dispose  (GObject *object);
   47.54 -static void gmyth_tvchain_finalize (GObject *object);
   47.55 +static void gmyth_tvchain_dispose (GObject * object);
   47.56 +static void gmyth_tvchain_finalize (GObject * object);
   47.57  
   47.58 -static void free_tvchain_entry(gpointer data, gpointer user_data);
   47.59 +static void free_tvchain_entry (gpointer data, gpointer user_data);
   47.60  
   47.61 -G_DEFINE_TYPE(GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT)
   47.62 +G_DEFINE_TYPE (GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT)
   47.63 +     static void gmyth_tvchain_class_init (GMythTVChainClass * klass)
   47.64 +{
   47.65 +    GObjectClass *gobject_class;
   47.66  
   47.67 -static void
   47.68 -gmyth_tvchain_class_init (GMythTVChainClass *klass)
   47.69 -{
   47.70 -	GObjectClass *gobject_class;
   47.71 +    gobject_class = (GObjectClass *) klass;
   47.72  
   47.73 -	gobject_class = (GObjectClass *) klass;
   47.74 -
   47.75 -	gobject_class->dispose  = gmyth_tvchain_dispose;
   47.76 -	gobject_class->finalize = gmyth_tvchain_finalize;	
   47.77 +    gobject_class->dispose = gmyth_tvchain_dispose;
   47.78 +    gobject_class->finalize = gmyth_tvchain_finalize;
   47.79  }
   47.80  
   47.81  static void
   47.82 -gmyth_tvchain_init (GMythTVChain *tvchain)
   47.83 -{	
   47.84 -	tvchain->tvchain_id = NULL;
   47.85 +gmyth_tvchain_init (GMythTVChain * tvchain)
   47.86 +{
   47.87 +    tvchain->tvchain_id = NULL;
   47.88  
   47.89 -	tvchain->cur_chanid = g_string_new ("");
   47.90 -	tvchain->cur_startts = NULL;
   47.91 -	
   47.92 -	tvchain->mutex = g_mutex_new();
   47.93 +    tvchain->cur_chanid = g_string_new ("");
   47.94 +    tvchain->cur_startts = NULL;
   47.95 +
   47.96 +    tvchain->mutex = g_mutex_new ();
   47.97  }
   47.98  
   47.99 -GMythTVChain*
  47.100 +GMythTVChain *
  47.101  gmyth_tvchain_new ()
  47.102  {
  47.103 -	GMythTVChain *tvchain = GMYTH_TVCHAIN ( g_object_new( GMYTH_TVCHAIN_TYPE, NULL ) );
  47.104 +    GMythTVChain *tvchain =
  47.105 +        GMYTH_TVCHAIN (g_object_new (GMYTH_TVCHAIN_TYPE, NULL));
  47.106  
  47.107 -	return tvchain;
  47.108 +    return tvchain;
  47.109  }
  47.110  
  47.111  static void
  47.112 -gmyth_tvchain_dispose  (GObject *object)
  47.113 +gmyth_tvchain_dispose (GObject * object)
  47.114  {
  47.115 -    GMythTVChain *tvchain = GMYTH_TVCHAIN(object);
  47.116 +    GMythTVChain *tvchain = GMYTH_TVCHAIN (object);
  47.117  
  47.118      if (tvchain->tvchain_id != NULL) {
  47.119 -        g_string_free( tvchain->tvchain_id, TRUE );
  47.120 +        g_string_free (tvchain->tvchain_id, TRUE);
  47.121          tvchain->tvchain_id = NULL;
  47.122      }
  47.123 -    
  47.124 -    if ( tvchain->mutex != NULL ) {
  47.125 -    	g_mutex_free( tvchain->mutex );
  47.126 -    	tvchain->mutex = NULL;
  47.127 +
  47.128 +    if (tvchain->mutex != NULL) {
  47.129 +        g_mutex_free (tvchain->mutex);
  47.130 +        tvchain->mutex = NULL;
  47.131      }
  47.132  
  47.133      if (tvchain->tvchain_list != NULL) {
  47.134          g_list_foreach (tvchain->tvchain_list, free_tvchain_entry, NULL);
  47.135 -        g_list_free( tvchain->tvchain_list );
  47.136 +        g_list_free (tvchain->tvchain_list);
  47.137      }
  47.138  
  47.139      if (tvchain->cur_chanid != NULL) {
  47.140 -        g_string_free( tvchain->cur_chanid, TRUE );
  47.141 +        g_string_free (tvchain->cur_chanid, TRUE);
  47.142          tvchain->cur_chanid = NULL;
  47.143      }
  47.144  
  47.145 -    if ( tvchain->backend_info) {
  47.146 +    if (tvchain->backend_info) {
  47.147          g_object_unref (tvchain->backend_info);
  47.148          tvchain->backend_info = NULL;
  47.149      }
  47.150 @@ -119,7 +118,7 @@
  47.151  }
  47.152  
  47.153  static void
  47.154 -gmyth_tvchain_finalize (GObject *object)
  47.155 +gmyth_tvchain_finalize (GObject * object)
  47.156  {
  47.157      g_signal_handlers_destroy (object);
  47.158  
  47.159 @@ -132,7 +131,8 @@
  47.160   * @param hostname The local hostname used to generate the tvchain id.
  47.161   */
  47.162  gboolean
  47.163 -gmyth_tvchain_initialize (GMythTVChain *tvchain, GMythBackendInfo *backend_info)
  47.164 +gmyth_tvchain_initialize (GMythTVChain * tvchain,
  47.165 +    GMythBackendInfo * backend_info)
  47.166  {
  47.167      const char *hostname;
  47.168  
  47.169 @@ -143,26 +143,29 @@
  47.170      tvchain->backend_info = backend_info;
  47.171  
  47.172      hostname = gmyth_backend_info_get_hostname (backend_info);
  47.173 -    
  47.174 +
  47.175      if (tvchain->tvchain_id == NULL) {
  47.176 -	    gchar *isodate = NULL;
  47.177 -    	GTimeVal *cur_time = g_new0( GTimeVal, 1 );
  47.178 -    	//struct tm* gmyth_util_time_val_to_date ( const GTimeVal* time )
  47.179 +        gchar *isodate = NULL;
  47.180 +        GTimeVal *cur_time = g_new0 (GTimeVal, 1);
  47.181  
  47.182 -	    g_get_current_time(cur_time);
  47.183 -    	isodate = gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%dT%H:%M:%S", 
  47.184 -                                                                   cur_time );
  47.185 +        //struct tm* gmyth_util_time_val_to_date ( const GTimeVal* time )
  47.186  
  47.187 -	    tvchain->tvchain_id = g_string_sized_new (7 + strlen (hostname) + strlen(isodate));
  47.188 -    	g_string_printf(tvchain->tvchain_id, 
  47.189 -	    	"live-%s-%s", hostname, isodate);
  47.190 +        g_get_current_time (cur_time);
  47.191 +        isodate =
  47.192 +            gmyth_util_time_to_isoformat_from_time_val_fmt
  47.193 +            ("%Y-%m-%dT%H:%M:%S", cur_time);
  47.194  
  47.195 -    	gmyth_debug ("[%s] tv_chain_id: %s", __FUNCTION__, tvchain->tvchain_id->str);
  47.196 +        tvchain->tvchain_id =
  47.197 +            g_string_sized_new (7 + strlen (hostname) + strlen (isodate));
  47.198 +        g_string_printf (tvchain->tvchain_id, "live-%s-%s", hostname, isodate);
  47.199  
  47.200 -	    g_free(isodate);	    
  47.201 -	    g_free( cur_time );
  47.202 +        gmyth_debug ("[%s] tv_chain_id: %s", __FUNCTION__,
  47.203 +            tvchain->tvchain_id->str);
  47.204 +
  47.205 +        g_free (isodate);
  47.206 +        g_free (cur_time);
  47.207      } else {
  47.208 -    	gmyth_debug ("[%s] TVchain already initialized", __FUNCTION__);
  47.209 +        gmyth_debug ("[%s] TVchain already initialized", __FUNCTION__);
  47.210      }
  47.211  
  47.212      return TRUE;
  47.213 @@ -173,12 +176,12 @@
  47.214   * @param tvchain The GMythTVChain instance.
  47.215   * @return The tvchain id.
  47.216   */
  47.217 -GString*
  47.218 -gmyth_tvchain_get_id (GMythTVChain *tvchain)
  47.219 +GString *
  47.220 +gmyth_tvchain_get_id (GMythTVChain * tvchain)
  47.221  {
  47.222 -	g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_id != NULL, NULL );
  47.223 +    g_return_val_if_fail (tvchain != NULL && tvchain->tvchain_id != NULL, NULL);
  47.224  
  47.225 -	return tvchain->tvchain_id;
  47.226 +    return tvchain->tvchain_id;
  47.227  }
  47.228  
  47.229  /** Reloads all tvchain entries in the database.
  47.230 @@ -187,101 +190,110 @@
  47.231   * @return  TRUE if success, or FALSE if error.
  47.232   */
  47.233  gboolean
  47.234 -gmyth_tvchain_reload_all (GMythTVChain *tvchain)
  47.235 +gmyth_tvchain_reload_all (GMythTVChain * tvchain)
  47.236  {
  47.237 -	MYSQL_ROW msql_row;
  47.238 -	MYSQL_RES *msql_res = NULL;
  47.239 -	GMythQuery *gmyth_query = NULL;
  47.240 -	gboolean ret = TRUE;
  47.241 -	GString *stmt_str = NULL;
  47.242 +    MYSQL_ROW msql_row;
  47.243 +    MYSQL_RES *msql_res = NULL;
  47.244 +    GMythQuery *gmyth_query = NULL;
  47.245 +    gboolean ret = TRUE;
  47.246 +    GString *stmt_str = NULL;
  47.247  
  47.248 -	g_mutex_lock( tvchain->mutex );
  47.249 -	
  47.250 -	/* gets the initial size of the TVChain entries list */
  47.251 -	guint prev_size = g_list_length (tvchain->tvchain_list);
  47.252 +    g_mutex_lock (tvchain->mutex);
  47.253  
  47.254 -	gmyth_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str);
  47.255 +    /* gets the initial size of the TVChain entries list */
  47.256 +    guint prev_size = g_list_length (tvchain->tvchain_list);
  47.257  
  47.258 -	if ( tvchain != NULL && tvchain->tvchain_list != NULL ) {
  47.259 -		g_list_free (tvchain->tvchain_list);
  47.260 -		tvchain->tvchain_list = NULL;
  47.261 -	}
  47.262 +    gmyth_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str);
  47.263  
  47.264 -	/* TODO: Reuse gmyth_query already connected from context */
  47.265 -	gmyth_query = gmyth_query_new ();
  47.266 -	if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
  47.267 -		gmyth_debug ("[%s] Could not connect to db", __FUNCTION__);
  47.268 -		g_mutex_unlock( tvchain->mutex );
  47.269 -		ret = FALSE;
  47.270 -		goto done;
  47.271 -	}
  47.272 +    if (tvchain != NULL && tvchain->tvchain_list != NULL) {
  47.273 +        g_list_free (tvchain->tvchain_list);
  47.274 +        tvchain->tvchain_list = NULL;
  47.275 +    }
  47.276  
  47.277 -	stmt_str = g_string_new ("");
  47.278 -	g_string_printf (stmt_str, 
  47.279 -			"SELECT chanid, starttime, endtime, discontinuity, "
  47.280 -			"chainpos, hostprefix, cardtype, channame, input "
  47.281 -			"FROM tvchain "
  47.282 -			"WHERE chainid = \"%s\" ORDER BY chainpos;",
  47.283 -			tvchain->tvchain_id->str);
  47.284 +    /* TODO: Reuse gmyth_query already connected from context */
  47.285 +    gmyth_query = gmyth_query_new ();
  47.286 +    if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
  47.287 +        gmyth_debug ("[%s] Could not connect to db", __FUNCTION__);
  47.288 +        g_mutex_unlock (tvchain->mutex);
  47.289 +        ret = FALSE;
  47.290 +        goto done;
  47.291 +    }
  47.292  
  47.293 -	msql_res = gmyth_query_process_statement(gmyth_query, stmt_str->str);
  47.294 -	if (msql_res != NULL) {
  47.295 +    stmt_str = g_string_new ("");
  47.296 +    g_string_printf (stmt_str,
  47.297 +        "SELECT chanid, starttime, endtime, discontinuity, "
  47.298 +        "chainpos, hostprefix, cardtype, channame, input "
  47.299 +        "FROM tvchain "
  47.300 +        "WHERE chainid = \"%s\" ORDER BY chainpos;", tvchain->tvchain_id->str);
  47.301  
  47.302 -		while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
  47.303 -			struct LiveTVChainEntry *entry = g_new0 (struct LiveTVChainEntry, 1);
  47.304 -			entry->chanid = g_string_new (msql_row[0]);
  47.305 -			entry->starttime = gmyth_util_string_to_time_val ((const gchar*) msql_row[1]);
  47.306 -			entry->endtime = gmyth_util_string_to_time_val ((const gchar*) msql_row[2]);
  47.307 -			entry->discontinuity = g_ascii_strtoull (msql_row[3], NULL, 10 ) != 0;
  47.308 -			entry->hostprefix = g_string_new (msql_row[5]);
  47.309 -			entry->cardtype = g_string_new (msql_row[6]);
  47.310 -			entry->channum = g_string_new (msql_row[7]);
  47.311 -			entry->inputname = g_string_new (msql_row[8]);
  47.312 +    msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
  47.313 +    if (msql_res != NULL) {
  47.314  
  47.315 -			//m_maxpos = query.value(4).toInt() + 1;
  47.316 -			gmyth_debug( "[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n", __FUNCTION__, entry->channum->str, entry->chanid->str, 
  47.317 -					(gchar*)msql_row[1], (gchar*)msql_row[2] );
  47.318 -			
  47.319 -			/* add this to get the actual start timestamp of the last recording */
  47.320 -			if ( tvchain->cur_startts < entry->starttime )
  47.321 -				tvchain->cur_startts = entry->starttime;
  47.322 +        while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
  47.323 +            struct LiveTVChainEntry *entry =
  47.324 +                g_new0 (struct LiveTVChainEntry, 1);
  47.325 +            entry->chanid = g_string_new (msql_row[0]);
  47.326 +            entry->starttime =
  47.327 +                gmyth_util_string_to_time_val ((const gchar *) msql_row[1]);
  47.328 +            entry->endtime =
  47.329 +                gmyth_util_string_to_time_val ((const gchar *) msql_row[2]);
  47.330 +            entry->discontinuity =
  47.331 +                g_ascii_strtoull (msql_row[3], NULL, 10) != 0;
  47.332 +            entry->hostprefix = g_string_new (msql_row[5]);
  47.333 +            entry->cardtype = g_string_new (msql_row[6]);
  47.334 +            entry->channum = g_string_new (msql_row[7]);
  47.335 +            entry->inputname = g_string_new (msql_row[8]);
  47.336  
  47.337 -			tvchain->tvchain_list = g_list_append (tvchain->tvchain_list, entry);			
  47.338 -		}
  47.339 -	} else {
  47.340 -		gmyth_debug ("gmyth_tvchain_reload_all query error!\n");
  47.341 -		g_mutex_unlock( tvchain->mutex );
  47.342 +            //m_maxpos = query.value(4).toInt() + 1;
  47.343 +            gmyth_debug
  47.344 +                ("[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n",
  47.345 +                __FUNCTION__, entry->channum->str, entry->chanid->str,
  47.346 +                (gchar *) msql_row[1], (gchar *) msql_row[2]);
  47.347  
  47.348 -		ret = FALSE;
  47.349 -		goto done;
  47.350 -	}
  47.351 +            /* add this to get the actual start timestamp of the last recording */
  47.352 +            if (tvchain->cur_startts < entry->starttime)
  47.353 +                tvchain->cur_startts = entry->starttime;
  47.354  
  47.355 -	g_mutex_unlock( tvchain->mutex );
  47.356 -	
  47.357 -	tvchain->cur_pos = gmyth_tvchain_program_is_at (tvchain, tvchain->cur_chanid, tvchain->cur_startts);
  47.358 -	gmyth_debug( "[%s] TVChain current position = %d.\n", __FUNCTION__, tvchain->cur_pos );
  47.359 +            tvchain->tvchain_list =
  47.360 +                g_list_append (tvchain->tvchain_list, entry);
  47.361 +        }
  47.362 +    } else {
  47.363 +        gmyth_debug ("gmyth_tvchain_reload_all query error!\n");
  47.364 +        g_mutex_unlock (tvchain->mutex);
  47.365  
  47.366 -	if (tvchain->cur_pos < 0)
  47.367 -		tvchain->cur_pos = 0;
  47.368 +        ret = FALSE;
  47.369 +        goto done;
  47.370 +    }
  47.371  
  47.372 -	//    if (m_switchid >= 0)
  47.373 -	//        m_switchid = ProgramIsAt(m_switchentry.chanid,m_switchentry.starttime);
  47.374 +    g_mutex_unlock (tvchain->mutex);
  47.375  
  47.376 -	if (prev_size != g_list_length (tvchain->tvchain_list)) {
  47.377 -		gmyth_debug ("[%s] Added new recording", __FUNCTION__);
  47.378 -	}	
  47.379 +    tvchain->cur_pos =
  47.380 +        gmyth_tvchain_program_is_at (tvchain, tvchain->cur_chanid,
  47.381 +        tvchain->cur_startts);
  47.382 +    gmyth_debug ("[%s] TVChain current position = %d.\n", __FUNCTION__,
  47.383 +        tvchain->cur_pos);
  47.384  
  47.385 -done:
  47.386 -	if ( stmt_str != NULL )
  47.387 -		g_string_free (stmt_str, TRUE);
  47.388 +    if (tvchain->cur_pos < 0)
  47.389 +        tvchain->cur_pos = 0;
  47.390  
  47.391 -	if ( msql_res != NULL )
  47.392 -		mysql_free_result (msql_res);
  47.393 +    //    if (m_switchid >= 0)
  47.394 +    //        m_switchid = ProgramIsAt(m_switchentry.chanid,m_switchentry.starttime);
  47.395  
  47.396 -	if ( gmyth_query != NULL )
  47.397 -		g_object_unref (gmyth_query);
  47.398 +    if (prev_size != g_list_length (tvchain->tvchain_list)) {
  47.399 +        gmyth_debug ("[%s] Added new recording", __FUNCTION__);
  47.400 +    }
  47.401  
  47.402 -	return ret;
  47.403 +  done:
  47.404 +    if (stmt_str != NULL)
  47.405 +        g_string_free (stmt_str, TRUE);
  47.406 +
  47.407 +    if (msql_res != NULL)
  47.408 +        mysql_free_result (msql_res);
  47.409 +
  47.410 +    if (gmyth_query != NULL)
  47.411 +        g_object_unref (gmyth_query);
  47.412 +
  47.413 +    return ret;
  47.414  }
  47.415  
  47.416  /** 
  47.417 @@ -292,7 +304,7 @@
  47.418   * @return  A program info listage.
  47.419   */
  47.420  GList *
  47.421 -gmyth_tvchain_get_program_info_list (GMythTVChain *tvchain)
  47.422 +gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain)
  47.423  {
  47.424      GList *prog_list = NULL;
  47.425      MYSQL_ROW msql_row;
  47.426 @@ -300,8 +312,8 @@
  47.427      GMythQuery *gmyth_query = NULL;
  47.428      GString *stmt_str = NULL;
  47.429  
  47.430 -    g_mutex_lock( tvchain->mutex );
  47.431 -    
  47.432 +    g_mutex_lock (tvchain->mutex);
  47.433 +
  47.434      gmyth_query = gmyth_query_new ();
  47.435      if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
  47.436          gmyth_debug ("Could not connect to db.");
  47.437 @@ -309,39 +321,41 @@
  47.438      }
  47.439  
  47.440      stmt_str = g_string_new ("");
  47.441 -    g_string_printf (stmt_str, 
  47.442 -            "SELECT channum, icon "
  47.443 -            "FROM channel "
  47.444 -            "ORDER BY channum;");
  47.445 +    g_string_printf (stmt_str,
  47.446 +        "SELECT channum, icon " "FROM channel " "ORDER BY channum;");
  47.447  
  47.448 -    msql_res = gmyth_query_process_statement(gmyth_query, stmt_str->str);
  47.449 +    msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
  47.450      if (msql_res != NULL) {
  47.451  
  47.452          while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
  47.453 -            GMythProgramInfo *entry = gmyth_program_info_new();
  47.454 +            GMythProgramInfo *entry = gmyth_program_info_new ();
  47.455 +
  47.456              entry->channame = g_string_new (msql_row[0]);
  47.457              entry->chansign = g_string_new (msql_row[1]);
  47.458  
  47.459 -            gmyth_debug( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", entry->channame->str, 
  47.460 -                    entry->chansign->str, (gchar*)msql_row[0], (gchar*)msql_row[1] );
  47.461 -            
  47.462 -            prog_list = g_list_append (prog_list, entry);           
  47.463 +            gmyth_debug
  47.464 +                ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
  47.465 +                entry->channame->str, entry->chansign->str,
  47.466 +                (gchar *) msql_row[0], (gchar *) msql_row[1]);
  47.467 +
  47.468 +            prog_list = g_list_append (prog_list, entry);
  47.469          }
  47.470      } else {
  47.471 -        gmyth_debug ("Query error when trying to get the channel list from database!\n");
  47.472 +        gmyth_debug
  47.473 +            ("Query error when trying to get the channel list from database!\n");
  47.474          goto done;
  47.475      }
  47.476  
  47.477 -done:
  47.478 -    g_mutex_unlock( tvchain->mutex );
  47.479 +  done:
  47.480 +    g_mutex_unlock (tvchain->mutex);
  47.481  
  47.482 -    if ( stmt_str != NULL )
  47.483 +    if (stmt_str != NULL)
  47.484          g_string_free (stmt_str, TRUE);
  47.485  
  47.486 -    if ( msql_res != NULL )
  47.487 +    if (msql_res != NULL)
  47.488          mysql_free_result (msql_res);
  47.489  
  47.490 -    if ( gmyth_query != NULL )
  47.491 +    if (gmyth_query != NULL)
  47.492          g_object_unref (gmyth_query);
  47.493  
  47.494      return prog_list;
  47.495 @@ -356,7 +370,8 @@
  47.496   * @return  A program info listage, based on a given channel name.
  47.497   */
  47.498  GList *
  47.499 -gmyth_tvchain_get_program_info_from_channel (GMythTVChain *tvchain, const gchar* channel)
  47.500 +gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain,
  47.501 +    const gchar * channel)
  47.502  {
  47.503      GList *prog_list = NULL;
  47.504      MYSQL_ROW msql_row;
  47.505 @@ -364,8 +379,8 @@
  47.506      GMythQuery *gmyth_query = NULL;
  47.507      GString *stmt_str = NULL;
  47.508  
  47.509 -    g_mutex_lock( tvchain->mutex );
  47.510 -    
  47.511 +    g_mutex_lock (tvchain->mutex);
  47.512 +
  47.513      gmyth_query = gmyth_query_new ();
  47.514      if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
  47.515          gmyth_debug ("Could not connect to db.");
  47.516 @@ -373,40 +388,42 @@
  47.517      }
  47.518  
  47.519      stmt_str = g_string_new ("");
  47.520 -    g_string_printf (stmt_str, 
  47.521 -            "SELECT channum, icon "
  47.522 -            "FROM channel "
  47.523 -            "WHERE channum = \"%s\" ORDER BY channum;",
  47.524 -            channel);
  47.525 +    g_string_printf (stmt_str,
  47.526 +        "SELECT channum, icon "
  47.527 +        "FROM channel " "WHERE channum = \"%s\" ORDER BY channum;", channel);
  47.528  
  47.529 -    msql_res = gmyth_query_process_statement(gmyth_query, stmt_str->str);
  47.530 +    msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
  47.531      if (msql_res != NULL) {
  47.532  
  47.533          while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
  47.534 -            GMythProgramInfo *entry = gmyth_program_info_new();
  47.535 +            GMythProgramInfo *entry = gmyth_program_info_new ();
  47.536 +
  47.537              entry->channame = g_string_new (msql_row[0]);
  47.538              entry->chansign = g_string_new (msql_row[1]);
  47.539  
  47.540 -            gmyth_debug( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n", entry->channame->str, 
  47.541 -                    entry->chansign->str, (gchar*)msql_row[0], (gchar*)msql_row[1] );
  47.542 -            
  47.543 -            prog_list = g_list_append (prog_list, entry);           
  47.544 +            gmyth_debug
  47.545 +                ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
  47.546 +                entry->channame->str, entry->chansign->str,
  47.547 +                (gchar *) msql_row[0], (gchar *) msql_row[1]);
  47.548 +
  47.549 +            prog_list = g_list_append (prog_list, entry);
  47.550          }
  47.551      } else {
  47.552 -        gmyth_debug ("Query error when trying to get the channel list from database!\n");
  47.553 +        gmyth_debug
  47.554 +            ("Query error when trying to get the channel list from database!\n");
  47.555          goto done;
  47.556      }
  47.557  
  47.558 -done:
  47.559 -    g_mutex_unlock( tvchain->mutex );
  47.560 +  done:
  47.561 +    g_mutex_unlock (tvchain->mutex);
  47.562  
  47.563 -    if ( stmt_str != NULL )
  47.564 +    if (stmt_str != NULL)
  47.565          g_string_free (stmt_str, TRUE);
  47.566  
  47.567 -    if ( msql_res != NULL )
  47.568 +    if (msql_res != NULL)
  47.569          mysql_free_result (msql_res);
  47.570  
  47.571 -    if ( gmyth_query != NULL )
  47.572 +    if (gmyth_query != NULL)
  47.573          g_object_unref (gmyth_query);
  47.574  
  47.575      return prog_list;
  47.576 @@ -423,28 +440,28 @@
  47.577   * @return The position of the related program info in the TV chain.
  47.578   */
  47.579  gint
  47.580 -gmyth_tvchain_program_is_at (GMythTVChain *tvchain, GString *chanid, GTimeVal* startts)
  47.581 +gmyth_tvchain_program_is_at (GMythTVChain * tvchain, GString * chanid,
  47.582 +    GTimeVal * startts)
  47.583  {
  47.584 -	gint count = 0;
  47.585 -	struct LiveTVChainEntry *entry;
  47.586 -	GList *tmp_list = tvchain->tvchain_list;
  47.587 -	guint list_size = g_list_length (tvchain->tvchain_list);
  47.588 +    gint count = 0;
  47.589 +    struct LiveTVChainEntry *entry;
  47.590 +    GList *tmp_list = tvchain->tvchain_list;
  47.591 +    guint list_size = g_list_length (tvchain->tvchain_list);
  47.592  
  47.593 -	g_mutex_lock( tvchain->mutex );
  47.594 -	
  47.595 -	for (; tmp_list && ( count < list_size ); tmp_list = tvchain->tvchain_list->next, count++)
  47.596 -	{
  47.597 -		entry = (struct LiveTVChainEntry*) tmp_list->data;
  47.598 -		if ( !g_strncasecmp (entry->chanid->str, chanid->str, chanid->len)
  47.599 -				&& entry->starttime == startts )
  47.600 -		{
  47.601 -			g_mutex_unlock( tvchain->mutex );
  47.602 -			return count;
  47.603 -		}
  47.604 -	}
  47.605 -	g_mutex_unlock( tvchain->mutex );
  47.606 +    g_mutex_lock (tvchain->mutex);
  47.607  
  47.608 -	return -1;	
  47.609 +    for (; tmp_list && (count < list_size);
  47.610 +        tmp_list = tvchain->tvchain_list->next, count++) {
  47.611 +        entry = (struct LiveTVChainEntry *) tmp_list->data;
  47.612 +        if (!g_strncasecmp (entry->chanid->str, chanid->str, chanid->len)
  47.613 +            && entry->starttime == startts) {
  47.614 +            g_mutex_unlock (tvchain->mutex);
  47.615 +            return count;
  47.616 +        }
  47.617 +    }
  47.618 +    g_mutex_unlock (tvchain->mutex);
  47.619 +
  47.620 +    return -1;
  47.621  }
  47.622  
  47.623  /** Get the program info associated to the tvchain.
  47.624 @@ -454,17 +471,17 @@
  47.625   * 
  47.626   * @return The program info structure.
  47.627   */
  47.628 -GMythProgramInfo*
  47.629 -gmyth_tvchain_get_program_at (GMythTVChain *tvchain, gint index)
  47.630 +GMythProgramInfo *
  47.631 +gmyth_tvchain_get_program_at (GMythTVChain * tvchain, gint index)
  47.632  {
  47.633 -	struct LiveTVChainEntry *entry;
  47.634 +    struct LiveTVChainEntry *entry;
  47.635  
  47.636 -	entry = gmyth_tvchain_get_entry_at (tvchain, index);
  47.637 +    entry = gmyth_tvchain_get_entry_at (tvchain, index);
  47.638  
  47.639 -	if (entry)
  47.640 -		return gmyth_tvchain_entry_to_program (tvchain, entry);	
  47.641 +    if (entry)
  47.642 +        return gmyth_tvchain_entry_to_program (tvchain, entry);
  47.643  
  47.644 -	return NULL;
  47.645 +    return NULL;
  47.646  }
  47.647  
  47.648  /** Gets a LiveTVChainEntry associated to the tvchain by its index.
  47.649 @@ -473,31 +490,36 @@
  47.650   * @param index The tvchain entry index
  47.651   * @return The LiveTVchainEntry structure.
  47.652   */
  47.653 -struct LiveTVChainEntry*
  47.654 -gmyth_tvchain_get_entry_at (GMythTVChain *tvchain, gint index)
  47.655 +struct LiveTVChainEntry *
  47.656 +gmyth_tvchain_get_entry_at (GMythTVChain * tvchain, gint index)
  47.657  {
  47.658 -	struct LiveTVChainEntry* chain_entry = NULL;
  47.659 +    struct LiveTVChainEntry *chain_entry = NULL;
  47.660  
  47.661 -	g_return_val_if_fail( tvchain != NULL && tvchain->tvchain_list != NULL, NULL );
  47.662 -	
  47.663 -	g_mutex_lock( tvchain->mutex );
  47.664 -	
  47.665 -	gint size = g_list_length (tvchain->tvchain_list);
  47.666 -	gint new_index = (index < 0 || index >= size) ? size - 1 : index;
  47.667 +    g_return_val_if_fail (tvchain != NULL
  47.668 +        && tvchain->tvchain_list != NULL, NULL);
  47.669  
  47.670 -	if (new_index >= 0) 
  47.671 -		chain_entry = (struct LiveTVChainEntry*) g_list_nth_data (tvchain->tvchain_list, new_index);
  47.672 +    g_mutex_lock (tvchain->mutex);
  47.673  
  47.674 -	g_mutex_unlock( tvchain->mutex );
  47.675 -	
  47.676 -	if ( chain_entry != NULL ) {
  47.677 -		gmyth_debug ("[%s] Got TV Chain entry at %d.\n", __FUNCTION__, new_index );
  47.678 +    gint size = g_list_length (tvchain->tvchain_list);
  47.679 +    gint new_index = (index < 0 || index >= size) ? size - 1 : index;
  47.680  
  47.681 -	} else {
  47.682 -		gmyth_debug ("[%s] failed to get entry at index %d", __FUNCTION__, index);
  47.683 -	}
  47.684 +    if (new_index >= 0)
  47.685 +        chain_entry =
  47.686 +            (struct LiveTVChainEntry *) g_list_nth_data (tvchain->
  47.687 +            tvchain_list, new_index);
  47.688  
  47.689 -	return chain_entry;
  47.690 +    g_mutex_unlock (tvchain->mutex);
  47.691 +
  47.692 +    if (chain_entry != NULL) {
  47.693 +        gmyth_debug ("[%s] Got TV Chain entry at %d.\n", __FUNCTION__,
  47.694 +            new_index);
  47.695 +
  47.696 +    } else {
  47.697 +        gmyth_debug ("[%s] failed to get entry at index %d", __FUNCTION__,
  47.698 +            index);
  47.699 +    }
  47.700 +
  47.701 +    return chain_entry;
  47.702  }
  47.703  
  47.704  /** 
  47.705 @@ -508,36 +530,40 @@
  47.706   * 
  47.707   * @return The program info.
  47.708   */
  47.709 -GMythProgramInfo*
  47.710 -gmyth_tvchain_entry_to_program (GMythTVChain *tvchain, struct LiveTVChainEntry *entry)
  47.711 +GMythProgramInfo *
  47.712 +gmyth_tvchain_entry_to_program (GMythTVChain * tvchain,
  47.713 +    struct LiveTVChainEntry * entry)
  47.714  {
  47.715 -	GMythProgramInfo *proginfo = NULL;
  47.716 +    GMythProgramInfo *proginfo = NULL;
  47.717  
  47.718 -	g_return_val_if_fail( tvchain != NULL, NULL );
  47.719 +    g_return_val_if_fail (tvchain != NULL, NULL);
  47.720  
  47.721 -	if ( !entry || !tvchain ) {
  47.722 -		gmyth_debug ("gmyth_tvchain_entry_to_program() received NULL argument");
  47.723 -		return NULL;
  47.724 -	}
  47.725 +    if (!entry || !tvchain) {
  47.726 +        gmyth_debug ("gmyth_tvchain_entry_to_program() received NULL argument");
  47.727 +        return NULL;
  47.728 +    }
  47.729  
  47.730 -	GMythScheduler *scheduler = gmyth_scheduler_new ();
  47.731 +    GMythScheduler *scheduler = gmyth_scheduler_new ();
  47.732  
  47.733 -	gmyth_scheduler_connect( scheduler, tvchain->backend_info );
  47.734 -	proginfo = gmyth_scheduler_get_recorded (scheduler, 
  47.735 -			entry->chanid, entry->starttime);
  47.736 -	gmyth_scheduler_disconnect( scheduler );
  47.737 +    gmyth_scheduler_connect (scheduler, tvchain->backend_info);
  47.738 +    proginfo = gmyth_scheduler_get_recorded (scheduler,
  47.739 +        entry->chanid, entry->starttime);
  47.740 +    gmyth_scheduler_disconnect (scheduler);
  47.741  
  47.742 -	if (proginfo) {
  47.743 -		proginfo->pathname = g_string_prepend (proginfo->pathname, entry->hostprefix->str);
  47.744 -	} else {
  47.745 -		gmyth_debug ("tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!", entry->chanid->str, entry->starttime->tv_sec);
  47.746 -	}
  47.747 +    if (proginfo) {
  47.748 +        proginfo->pathname =
  47.749 +            g_string_prepend (proginfo->pathname, entry->hostprefix->str);
  47.750 +    } else {
  47.751 +        gmyth_debug
  47.752 +            ("tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!",
  47.753 +            entry->chanid->str, entry->starttime->tv_sec);
  47.754 +    }
  47.755  
  47.756 -	return proginfo;
  47.757 +    return proginfo;
  47.758  }
  47.759  
  47.760  static void
  47.761 -free_tvchain_entry(gpointer data, gpointer user_data)
  47.762 +free_tvchain_entry (gpointer data, gpointer user_data)
  47.763  {
  47.764      struct LiveTVChainEntry *entry;
  47.765  
  47.766 @@ -554,7 +580,7 @@
  47.767      }
  47.768  
  47.769      if (entry->endtime != NULL) {
  47.770 -       g_free (entry->endtime);
  47.771 +        g_free (entry->endtime);
  47.772      }
  47.773  
  47.774      if (entry->hostprefix) {
  47.775 @@ -573,5 +599,5 @@
  47.776          g_string_free (entry->inputname, TRUE);
  47.777      }
  47.778  
  47.779 -    g_free(entry);
  47.780 +    g_free (entry);
  47.781  }
    48.1 --- a/gmyth/src/gmyth_tvchain.h	Tue May 22 19:21:42 2007 +0100
    48.2 +++ b/gmyth/src/gmyth_tvchain.h	Wed May 23 16:11:29 2007 +0100
    48.3 @@ -9,22 +9,22 @@
    48.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    48.5   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    48.6   *
    48.7 - *//*
    48.8 - * 
    48.9 - * This program is free software; you can redistribute it and/or modify
   48.10 - * it under the terms of the GNU Lesser General Public License as published by
   48.11 - * the Free Software Foundation; either version 2 of the License, or
   48.12 - * (at your option) any later version.
   48.13 - *
   48.14 - * This program is distributed in the hope that it will be useful,
   48.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   48.17 - * GNU General Public License for more details.
   48.18 - *
   48.19 - * You should have received a copy of the GNU Lesser General Public License
   48.20 - * along with this program; if not, write to the Free Software
   48.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   48.22 - */
   48.23 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              *//*
   48.24 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * 
   48.25 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   48.26 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   48.27 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   48.28 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * (at your option) any later version.
   48.29 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   48.30 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   48.31 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.32 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   48.33 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * GNU General Public License for more details.
   48.34 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 *
   48.35 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   48.36 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   48.37 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   48.38 +                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
   48.39  
   48.40  #ifndef LIVETVCHAIN_H_
   48.41  #define LIVETVCHAIN_H_
   48.42 @@ -36,27 +36,24 @@
   48.43  #include "gmyth_backendinfo.h"
   48.44  
   48.45  G_BEGIN_DECLS
   48.46 -
   48.47  #define GMYTH_TVCHAIN_TYPE               (gmyth_tvchain_get_type ())
   48.48  #define GMYTH_TVCHAIN(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TVCHAIN_TYPE, GMythTVChain))
   48.49  #define GMYTH_TVCHAIN_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TVCHAIN_TYPE, GMythTVChainClass))
   48.50  #define IS_GMYTH_TVCHAIN(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_TVCHAIN_TYPE))
   48.51  #define IS_GMYTH_TVCHAIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TVCHAIN_TYPE))
   48.52  #define GMYTH_TVCHAIN_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_TVCHAIN_TYPE, GMythTVChainClass))
   48.53 -
   48.54 -
   48.55 -typedef struct _GMythTVChain         GMythTVChain;
   48.56 -typedef struct _GMythTVChainClass    GMythTVChainClass;
   48.57 +typedef struct _GMythTVChain GMythTVChain;
   48.58 +typedef struct _GMythTVChainClass GMythTVChainClass;
   48.59  
   48.60  
   48.61  struct LiveTVChainEntry
   48.62  {
   48.63      GString *chanid;
   48.64  
   48.65 -    GTimeVal* starttime;
   48.66 -    GTimeVal* endtime;
   48.67 -    
   48.68 -    gboolean discontinuity; // if true, can't play smooth from last entry
   48.69 +    GTimeVal *starttime;
   48.70 +    GTimeVal *endtime;
   48.71 +
   48.72 +    gboolean discontinuity;     // if true, can't play smooth from last entry
   48.73      GString *hostprefix;
   48.74      GString *cardtype;
   48.75      GString *channum;
   48.76 @@ -74,43 +71,43 @@
   48.77  
   48.78  struct _GMythTVChain
   48.79  {
   48.80 -  GObject parent;
   48.81 +    GObject parent;
   48.82  
   48.83 -	GString *tvchain_id;
   48.84 -	GList   *tvchain_list;
   48.85 -	
   48.86 -	GTimeVal*  cur_startts;
   48.87 -	GString *cur_chanid;
   48.88 -	gint     cur_pos;
   48.89 +    GString *tvchain_id;
   48.90 +    GList *tvchain_list;
   48.91  
   48.92 -  GMythBackendInfo *backend_info;
   48.93 -  
   48.94 -  GMutex *mutex;
   48.95 +    GTimeVal *cur_startts;
   48.96 +    GString *cur_chanid;
   48.97 +    gint cur_pos;
   48.98 +
   48.99 +    GMythBackendInfo *backend_info;
  48.100 +
  48.101 +    GMutex *mutex;
  48.102  };
  48.103  
  48.104 -GType       	gmyth_tvchain_get_type (void);
  48.105 +GType gmyth_tvchain_get_type (void);
  48.106  
  48.107 -GMythTVChain* gmyth_tvchain_new ();
  48.108 +GMythTVChain *gmyth_tvchain_new ();
  48.109  
  48.110 -gboolean      gmyth_tvchain_initialize    (GMythTVChain *tvchain, 
  48.111 -                                         GMythBackendInfo *backend_info);
  48.112 -gboolean    	gmyth_tvchain_reload_all    (GMythTVChain *tvchain);
  48.113 -GString*    	gmyth_tvchain_get_id        (GMythTVChain *tvchain);
  48.114 -gint         	gmyth_tvchain_program_is_at (GMythTVChain *tvchain, 
  48.115 -                                         GString *chanid, GTimeVal* startts);
  48.116 +gboolean gmyth_tvchain_initialize (GMythTVChain * tvchain,
  48.117 +    GMythBackendInfo * backend_info);
  48.118 +gboolean gmyth_tvchain_reload_all (GMythTVChain * tvchain);
  48.119 +GString *gmyth_tvchain_get_id (GMythTVChain * tvchain);
  48.120 +gint gmyth_tvchain_program_is_at (GMythTVChain * tvchain,
  48.121 +    GString * chanid, GTimeVal * startts);
  48.122  
  48.123 -struct LiveTVChainEntry* gmyth_tvchain_get_entry_at (GMythTVChain *tvchain, 
  48.124 -                                                     gint index);
  48.125 +struct LiveTVChainEntry *gmyth_tvchain_get_entry_at (GMythTVChain * tvchain,
  48.126 +    gint index);
  48.127  
  48.128 -GMythProgramInfo*   gmyth_tvchain_entry_to_program (GMythTVChain *tvchain, 
  48.129 -                                                    struct LiveTVChainEntry *entry);
  48.130 -GMythProgramInfo*   gmyth_tvchain_get_program_at (GMythTVChain *tvchain, gint index);
  48.131 +GMythProgramInfo *gmyth_tvchain_entry_to_program (GMythTVChain * tvchain,
  48.132 +    struct LiveTVChainEntry *entry);
  48.133 +GMythProgramInfo *gmyth_tvchain_get_program_at (GMythTVChain * tvchain,
  48.134 +    gint index);
  48.135  
  48.136 -GList*              gmyth_tvchain_get_program_info_from_channel (GMythTVChain *tvchain, 
  48.137 -                                         const gchar* channel);
  48.138 +GList *gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain,
  48.139 +    const gchar * channel);
  48.140  
  48.141 -GList*              gmyth_tvchain_get_program_info_list (GMythTVChain *tvchain);
  48.142 +GList *gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain);
  48.143  
  48.144  G_END_DECLS
  48.145 -
  48.146 -#endif /*LIVETVCHAIN_H_*/
  48.147 +#endif /*LIVETVCHAIN_H_ */
    49.1 --- a/gmyth/src/gmyth_uri.c	Tue May 22 19:21:42 2007 +0100
    49.2 +++ b/gmyth/src/gmyth_uri.c	Wed May 23 16:11:29 2007 +0100
    49.3 @@ -10,23 +10,23 @@
    49.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    49.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    49.6   *
    49.7 - *//*
    49.8 - * 
    49.9 - * This program is free software; you can redistribute it and/or modify
   49.10 - * it under the terms of the GNU Lesser General Public License as published by
   49.11 - * the Free Software Foundation; either version 2 of the License, or
   49.12 - * (at your option) any later version.
   49.13 - *
   49.14 - * This program is distributed in the hope that it will be useful,
   49.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   49.17 - * GNU General Public License for more details.
   49.18 - *
   49.19 - * You should have received a copy of the GNU Lesser General Public License
   49.20 - * along with this program; if not, write to the Free Software
   49.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   49.22 - */
   49.23 - 
   49.24 +                                                                                                                                                                                                                                                                                                                                                                                              *//*
   49.25 +                                                                                                                                                                                                 * 
   49.26 +                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   49.27 +                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   49.28 +                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   49.29 +                                                                                                                                                                                                 * (at your option) any later version.
   49.30 +                                                                                                                                                                                                 *
   49.31 +                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   49.32 +                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.33 +                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   49.34 +                                                                                                                                                                                                 * GNU General Public License for more details.
   49.35 +                                                                                                                                                                                                 *
   49.36 +                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   49.37 +                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   49.38 +                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   49.39 +                                                                                                                                                                                                 */
   49.40 +
   49.41  #ifdef HAVE_CONFIG_H
   49.42  #include "config.h"
   49.43  #endif
   49.44 @@ -40,90 +40,89 @@
   49.45  
   49.46  #include "gmyth_debug.h"
   49.47  
   49.48 -static void gmyth_uri_class_init          (GMythURIClass *klass);
   49.49 -static void gmyth_uri_init                (GMythURI *object);
   49.50 +static void gmyth_uri_class_init (GMythURIClass * klass);
   49.51 +static void gmyth_uri_init (GMythURI * object);
   49.52  
   49.53 -static void gmyth_uri_dispose  (GObject *object);
   49.54 -static void gmyth_uri_finalize (GObject *object);
   49.55 +static void gmyth_uri_dispose (GObject * object);
   49.56 +static void gmyth_uri_finalize (GObject * object);
   49.57  
   49.58 -static void gmyth_uri_parser_setup_and_new(GMythURI *uri, const gchar *value);
   49.59 -static gchar* gmyth_uri_print_field(const GString* field);
   49.60 +static void gmyth_uri_parser_setup_and_new (GMythURI * uri,
   49.61 +    const gchar * value);
   49.62 +static gchar *gmyth_uri_print_field (const GString * field);
   49.63  
   49.64 -G_DEFINE_TYPE(GMythURI, gmyth_uri, G_TYPE_OBJECT)
   49.65 -
   49.66 -static void
   49.67 -gmyth_uri_class_init (GMythURIClass *klass)
   49.68 +G_DEFINE_TYPE (GMythURI, gmyth_uri, G_TYPE_OBJECT)
   49.69 +     static void gmyth_uri_class_init (GMythURIClass * klass)
   49.70  {
   49.71 -	GObjectClass *gobject_class;
   49.72 +    GObjectClass *gobject_class;
   49.73  
   49.74      gobject_class = (GObjectClass *) klass;
   49.75 -	
   49.76 -    gobject_class->dispose  = gmyth_uri_dispose;
   49.77 -    gobject_class->finalize = gmyth_uri_finalize;	
   49.78 +
   49.79 +    gobject_class->dispose = gmyth_uri_dispose;
   49.80 +    gobject_class->finalize = gmyth_uri_finalize;
   49.81  }
   49.82  
   49.83  static void
   49.84 -gmyth_uri_init (GMythURI *gmyth_uri)
   49.85 +gmyth_uri_init (GMythURI * gmyth_uri)
   49.86  {
   49.87  }
   49.88  
   49.89  static void
   49.90 -gmyth_uri_dispose  (GObject *object)
   49.91 +gmyth_uri_dispose (GObject * object)
   49.92  {
   49.93 -	GMythURI *gmyth_uri = GMYTH_URI(object);
   49.94 +    GMythURI *gmyth_uri = GMYTH_URI (object);
   49.95  
   49.96 -	if ( gmyth_uri->host != NULL ) {
   49.97 -		g_string_free( gmyth_uri->host, TRUE );
   49.98 -		gmyth_uri->host = NULL;
   49.99 -	}
  49.100 -	
  49.101 -	if ( gmyth_uri->protocol != NULL ) {
  49.102 -		g_string_free( gmyth_uri->protocol, TRUE );
  49.103 -		gmyth_uri->protocol = NULL;
  49.104 -	}
  49.105 -	
  49.106 -	if ( gmyth_uri->path != NULL ) {
  49.107 -		g_string_free( gmyth_uri->path, TRUE );
  49.108 -		gmyth_uri->path = NULL;
  49.109 -	}
  49.110 -	
  49.111 -	if ( gmyth_uri->fragment != NULL ) {
  49.112 -		g_string_free( gmyth_uri->fragment, TRUE );
  49.113 -		gmyth_uri->fragment = NULL;
  49.114 -	}
  49.115 -	
  49.116 -	if ( gmyth_uri->user != NULL ) {
  49.117 -		g_string_free( gmyth_uri->user, TRUE );
  49.118 -		gmyth_uri->user = NULL;
  49.119 -	}
  49.120 -	
  49.121 -	if ( gmyth_uri->password != NULL ) {
  49.122 -		g_string_free( gmyth_uri->password, TRUE );
  49.123 -		gmyth_uri->password = NULL;
  49.124 -	}
  49.125 -	
  49.126 -	if ( gmyth_uri->query != NULL ) {
  49.127 -		g_string_free( gmyth_uri->query, TRUE );
  49.128 -		gmyth_uri->query = NULL;
  49.129 -	}	
  49.130 +    if (gmyth_uri->host != NULL) {
  49.131 +        g_string_free (gmyth_uri->host, TRUE);
  49.132 +        gmyth_uri->host = NULL;
  49.133 +    }
  49.134  
  49.135 -	if ( gmyth_uri->uri != NULL ) {
  49.136 -		g_string_free( gmyth_uri->uri, TRUE );
  49.137 -		gmyth_uri->uri = NULL;
  49.138 -	}	
  49.139 +    if (gmyth_uri->protocol != NULL) {
  49.140 +        g_string_free (gmyth_uri->protocol, TRUE);
  49.141 +        gmyth_uri->protocol = NULL;
  49.142 +    }
  49.143  
  49.144 +    if (gmyth_uri->path != NULL) {
  49.145 +        g_string_free (gmyth_uri->path, TRUE);
  49.146 +        gmyth_uri->path = NULL;
  49.147 +    }
  49.148  
  49.149 -	G_OBJECT_CLASS (gmyth_uri_parent_class)->dispose (object);
  49.150 +    if (gmyth_uri->fragment != NULL) {
  49.151 +        g_string_free (gmyth_uri->fragment, TRUE);
  49.152 +        gmyth_uri->fragment = NULL;
  49.153 +    }
  49.154 +
  49.155 +    if (gmyth_uri->user != NULL) {
  49.156 +        g_string_free (gmyth_uri->user, TRUE);
  49.157 +        gmyth_uri->user = NULL;
  49.158 +    }
  49.159 +
  49.160 +    if (gmyth_uri->password != NULL) {
  49.161 +        g_string_free (gmyth_uri->password, TRUE);
  49.162 +        gmyth_uri->password = NULL;
  49.163 +    }
  49.164 +
  49.165 +    if (gmyth_uri->query != NULL) {
  49.166 +        g_string_free (gmyth_uri->query, TRUE);
  49.167 +        gmyth_uri->query = NULL;
  49.168 +    }
  49.169 +
  49.170 +    if (gmyth_uri->uri != NULL) {
  49.171 +        g_string_free (gmyth_uri->uri, TRUE);
  49.172 +        gmyth_uri->uri = NULL;
  49.173 +    }
  49.174 +
  49.175 +
  49.176 +    G_OBJECT_CLASS (gmyth_uri_parent_class)->dispose (object);
  49.177  }
  49.178  
  49.179  static void
  49.180 -gmyth_uri_finalize (GObject *object)
  49.181 +gmyth_uri_finalize (GObject * object)
  49.182  {
  49.183 -	//GMythURI *gmyth_uri = GMYTH_URI(object);
  49.184 +    //GMythURI *gmyth_uri = GMYTH_URI(object);
  49.185  
  49.186 -	g_signal_handlers_destroy (object);
  49.187 +    g_signal_handlers_destroy (object);
  49.188  
  49.189 -	G_OBJECT_CLASS (gmyth_uri_parent_class)->finalize (object);
  49.190 +    G_OBJECT_CLASS (gmyth_uri_parent_class)->finalize (object);
  49.191  }
  49.192  
  49.193  /** 
  49.194 @@ -132,10 +131,10 @@
  49.195   * @return a new instance of GMythURI.
  49.196   */
  49.197  GMythURI *
  49.198 -gmyth_uri_new (void) 
  49.199 +gmyth_uri_new (void)
  49.200  {
  49.201      GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL));
  49.202 -    
  49.203 +
  49.204      return gmyth_uri;
  49.205  }
  49.206  
  49.207 @@ -147,12 +146,12 @@
  49.208   * @return a new instance of GMythURI.
  49.209   */
  49.210  GMythURI *
  49.211 -gmyth_uri_new_with_value (const gchar *uri_str) 
  49.212 +gmyth_uri_new_with_value (const gchar * uri_str)
  49.213  {
  49.214      GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL));
  49.215 -    
  49.216 +
  49.217      gmyth_uri_parser_setup_and_new (gmyth_uri, uri_str);
  49.218 -    
  49.219 +
  49.220      return gmyth_uri;
  49.221  }
  49.222  
  49.223 @@ -165,19 +164,19 @@
  49.224   * @return The starting offset to the given substring, or <code>-1</code> if the
  49.225   * 				 haystack function parameter doesn't contains the needle string argument.
  49.226   */
  49.227 -static gint 
  49.228 -gmyth_strstr (const gchar *haystack, const gchar *needle)
  49.229 +static gint
  49.230 +gmyth_strstr (const gchar * haystack, const gchar * needle)
  49.231  {
  49.232 -	
  49.233 -	gchar *strPos;
  49.234 -	
  49.235 -	if (haystack == NULL || needle == NULL)
  49.236 -		return -1;
  49.237 -	strPos = strstr(haystack, needle);
  49.238 -	if (strPos == NULL)
  49.239 -		return -1;
  49.240 -		
  49.241 -	return (strPos - haystack);
  49.242 +
  49.243 +    gchar *strPos;
  49.244 +
  49.245 +    if (haystack == NULL || needle == NULL)
  49.246 +        return -1;
  49.247 +    strPos = strstr (haystack, needle);
  49.248 +    if (strPos == NULL)
  49.249 +        return -1;
  49.250 +
  49.251 +    return (strPos - haystack);
  49.252  
  49.253  }
  49.254  
  49.255 @@ -189,16 +188,18 @@
  49.256   * @return <code>true</code>, if the URI is absolute.
  49.257   */
  49.258  static gboolean
  49.259 -gmyth_uri_isabsolute (const GMythURI *uri)
  49.260 +gmyth_uri_isabsolute (const GMythURI * uri)
  49.261  {
  49.262 -	gboolean ret = FALSE;
  49.263 -	
  49.264 -	g_return_val_if_fail( uri != NULL && uri->uri != NULL && uri->protocol != NULL, FALSE );
  49.265 -	
  49.266 -	if ( gmyth_strstr( uri->uri->str, GMYTH_URI_PROTOCOL_DELIM ) == 0 || strlen(uri->protocol->str) > 0 )
  49.267 -		ret = TRUE;
  49.268 -		
  49.269 -	return ret;	
  49.270 +    gboolean ret = FALSE;
  49.271 +
  49.272 +    g_return_val_if_fail (uri != NULL && uri->uri != NULL
  49.273 +        && uri->protocol != NULL, FALSE);
  49.274 +
  49.275 +    if (gmyth_strstr (uri->uri->str, GMYTH_URI_PROTOCOL_DELIM) == 0
  49.276 +        || strlen (uri->protocol->str) > 0)
  49.277 +        ret = TRUE;
  49.278 +
  49.279 +    return ret;
  49.280  }
  49.281  
  49.282  /** 
  49.283 @@ -215,34 +216,34 @@
  49.284   *         or <code>-1</code> if the no character of the list could be found.
  49.285   */
  49.286  static gint
  49.287 -gmyth_strrchr( const gchar *str, const gchar *chars, const gint nchars )
  49.288 +gmyth_strrchr (const gchar * str, const gchar * chars, const gint nchars)
  49.289  {
  49.290  
  49.291 -	gint strLen;
  49.292 -	gint i, j;
  49.293 -	
  49.294 -	if ( str == NULL || chars == NULL )
  49.295 -		return -1;
  49.296 -		
  49.297 -	strLen = strlen( str );
  49.298 -	for ( i= (strLen-1); 0 <= i; i-- ) {
  49.299 -		for ( j=0; j<nchars; j++ ) {
  49.300 -			if ( str[i] == chars[j] )
  49.301 -				return i;
  49.302 -		}
  49.303 -	}
  49.304 +    gint strLen;
  49.305 +    gint i, j;
  49.306  
  49.307 -	return -1;
  49.308 +    if (str == NULL || chars == NULL)
  49.309 +        return -1;
  49.310 +
  49.311 +    strLen = strlen (str);
  49.312 +    for (i = (strLen - 1); 0 <= i; i--) {
  49.313 +        for (j = 0; j < nchars; j++) {
  49.314 +            if (str[i] == chars[j])
  49.315 +                return i;
  49.316 +        }
  49.317 +    }
  49.318 +
  49.319 +    return -1;
  49.320  
  49.321  }
  49.322  
  49.323 -static gchar*
  49.324 -gmyth_uri_print_field( const GString* field )
  49.325 +static gchar *
  49.326 +gmyth_uri_print_field (const GString * field)
  49.327  {
  49.328 -	if ( field != NULL && field->str != NULL && strlen(field->str) > 0 )
  49.329 -		return field->str;
  49.330 -	else
  49.331 -		return "";		
  49.332 +    if (field != NULL && field->str != NULL && strlen (field->str) > 0)
  49.333 +        return field->str;
  49.334 +    else
  49.335 +        return "";
  49.336  }
  49.337  
  49.338  /** 
  49.339 @@ -253,135 +254,146 @@
  49.340   *
  49.341   */
  49.342  static void
  49.343 -gmyth_uri_parser_setup_and_new( GMythURI *uri, const gchar *value )
  49.344 +gmyth_uri_parser_setup_and_new (GMythURI * uri, const gchar * value)
  49.345  {
  49.346 -	
  49.347 -	gint 		uriLen;
  49.348 -	gint 		currIdx;
  49.349 -	gint 		protoIdx;
  49.350 -	gint 		atIdx;
  49.351 -	gint 		colonIdx;
  49.352 -	gint 		shashIdx;
  49.353 -	gint 		eIdx;
  49.354 -	gchar       *host;
  49.355 -	gint 		eblacketIdx;
  49.356 -	gint 		hostLen;
  49.357 -	gint 		sharpIdx;
  49.358 -	/*
  49.359 -	gint 		questionIdx;
  49.360 -	gint 		queryLen;
  49.361 -	*/
  49.362 -	
  49.363 -	uriLen = strlen(value);
  49.364 -	uri->uri = g_string_new( value );
  49.365 -		
  49.366 -	currIdx = 0;
  49.367 -	
  49.368 -	/*** Protocol ****/
  49.369 -	protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM);
  49.370 -	if (0 < protoIdx) {
  49.371 +
  49.372 +    gint uriLen;
  49.373 +    gint currIdx;
  49.374 +    gint protoIdx;
  49.375 +    gint atIdx;
  49.376 +    gint colonIdx;
  49.377 +    gint shashIdx;
  49.378 +    gint eIdx;
  49.379 +    gchar *host;
  49.380 +    gint eblacketIdx;
  49.381 +    gint hostLen;
  49.382 +    gint sharpIdx;
  49.383 +
  49.384 +    /*
  49.385 +       gint                 questionIdx;
  49.386 +       gint                 queryLen;
  49.387 +     */
  49.388 +
  49.389 +    uriLen = strlen (value);
  49.390 +    uri->uri = g_string_new (value);
  49.391 +
  49.392 +    currIdx = 0;
  49.393 +
  49.394 +        /*** Protocol ****/
  49.395 +    protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM);
  49.396 +    if (0 < protoIdx) {
  49.397          uri->protocol = g_string_new_len (value, protoIdx);
  49.398 -		currIdx += protoIdx + strlen( GMYTH_URI_PROTOCOL_DELIM );
  49.399 -	}
  49.400 +        currIdx += protoIdx + strlen (GMYTH_URI_PROTOCOL_DELIM);
  49.401 +    }
  49.402  
  49.403 -	/*** User (Password) ****/
  49.404 -	atIdx = gmyth_strstr( value+currIdx, GMYTH_URI_USER_DELIM );
  49.405 -	if ( 0 < atIdx ) {
  49.406 -		colonIdx = gmyth_strstr( value+currIdx, GMYTH_URI_COLON_DELIM );
  49.407 +        /*** User (Password) ****/
  49.408 +    atIdx = gmyth_strstr (value + currIdx, GMYTH_URI_USER_DELIM);
  49.409 +    if (0 < atIdx) {
  49.410 +        colonIdx = gmyth_strstr (value + currIdx, GMYTH_URI_COLON_DELIM);
  49.411  
  49.412 -		if (0 < colonIdx && colonIdx < atIdx) {
  49.413 -            uri->user = g_string_new_len (value+currIdx, colonIdx);
  49.414 -            uri->password = g_string_new_len (value+currIdx+colonIdx+1, atIdx - (colonIdx+1));
  49.415 -		}
  49.416 -		else
  49.417 -            uri->user = g_string_new_len (value+currIdx, atIdx - currIdx);
  49.418 -		currIdx += atIdx + 1;
  49.419 -	}
  49.420 +        if (0 < colonIdx && colonIdx < atIdx) {
  49.421 +            uri->user = g_string_new_len (value + currIdx, colonIdx);
  49.422 +            uri->password =
  49.423 +                g_string_new_len (value + currIdx + colonIdx + 1,
  49.424 +                atIdx - (colonIdx + 1));
  49.425 +        } else
  49.426 +            uri->user = g_string_new_len (value + currIdx, atIdx - currIdx);
  49.427 +        currIdx += atIdx + 1;
  49.428 +    }
  49.429  
  49.430 -	/*** Host (Port) ****/
  49.431 -	shashIdx = gmyth_strstr( value+currIdx, GMYTH_URI_SLASH_DELIM );
  49.432 -	if (0 < shashIdx)
  49.433 -        uri->host = g_string_new_len (value+currIdx, shashIdx);
  49.434 -	else if ( gmyth_uri_isabsolute(uri) == TRUE )
  49.435 -        uri->host = g_string_new_len (value+currIdx, strlen (value) - currIdx);
  49.436 +        /*** Host (Port) ****/
  49.437 +    shashIdx = gmyth_strstr (value + currIdx, GMYTH_URI_SLASH_DELIM);
  49.438 +    if (0 < shashIdx)
  49.439 +        uri->host = g_string_new_len (value + currIdx, shashIdx);
  49.440 +    else if (gmyth_uri_isabsolute (uri) == TRUE)
  49.441 +        uri->host =
  49.442 +            g_string_new_len (value + currIdx, strlen (value) - currIdx);
  49.443  
  49.444 -	host = gmyth_uri_get_host(uri);
  49.445 -	colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1);
  49.446 -	eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1);
  49.447 -	if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) {
  49.448 +    host = gmyth_uri_get_host (uri);
  49.449 +    colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1);
  49.450 +    eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1);
  49.451 +    if ((0 < colonIdx) && (eblacketIdx < colonIdx)) {
  49.452          GString *portStr = NULL;
  49.453 -		GString *hostStr = g_string_new  (host != NULL ? host : "");
  49.454 +        GString *hostStr = g_string_new (host != NULL ? host : "");
  49.455  
  49.456 -		hostLen = hostStr->len;
  49.457 -		/**** host ****/
  49.458 -		uri->host = g_string_erase (uri->host, 0, hostLen);
  49.459 -		uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx);
  49.460 -		if (0 < hostLen) {
  49.461 -			if (host[0] == '[' && host[hostLen-1] == ']')
  49.462 -                uri->host = g_string_new_len (hostStr->str+1, colonIdx-2);
  49.463 -		}
  49.464 -		/**** port ****/
  49.465 -		portStr = g_string_new_len (hostStr->str+colonIdx+1, hostLen-colonIdx-1);
  49.466 -		uri->port = (gint)g_ascii_strtoull( portStr->str, NULL, 10 );
  49.467 -		g_string_free (portStr, TRUE);
  49.468 -		g_string_free (hostStr, TRUE);
  49.469 -	}
  49.470 -	else {
  49.471 -        const gchar* protocol = gmyth_uri_get_protocol(uri);
  49.472 -		uri->port = GMYTH_URI_KNKOWN_PORT;
  49.473 -		if ( strcmp(protocol, GMYTH_URI_PROTOCOL_HTTP) == 0 )
  49.474 -			uri->port = GMYTH_URI_DEFAULT_HTTP_PORT;
  49.475 -		if ( strcmp(protocol, GMYTH_URI_PROTOCOL_FTP) == 0 )
  49.476 -			uri->port = GMYTH_URI_DEFAULT_FTP_PORT;
  49.477 -	}
  49.478 -	
  49.479 -	if (shashIdx > 0) currIdx += shashIdx;
  49.480 -	
  49.481 -	/*
  49.482 -		Handle relative URL
  49.483 -	*/
  49.484 -	if (gmyth_uri_isabsolute(uri) == FALSE)
  49.485 -	{
  49.486 +        hostLen = hostStr->len;
  49.487 +                /**** host ****/
  49.488 +        uri->host = g_string_erase (uri->host, 0, hostLen);
  49.489 +        uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx);
  49.490 +        if (0 < hostLen) {
  49.491 +            if (host[0] == '[' && host[hostLen - 1] == ']')
  49.492 +                uri->host = g_string_new_len (hostStr->str + 1, colonIdx - 2);
  49.493 +        }
  49.494 +                /**** port ****/
  49.495 +        portStr =
  49.496 +            g_string_new_len (hostStr->str + colonIdx + 1,
  49.497 +            hostLen - colonIdx - 1);
  49.498 +        uri->port = (gint) g_ascii_strtoull (portStr->str, NULL, 10);
  49.499 +        g_string_free (portStr, TRUE);
  49.500 +        g_string_free (hostStr, TRUE);
  49.501 +    } else {
  49.502 +        const gchar *protocol = gmyth_uri_get_protocol (uri);
  49.503  
  49.504 -		if (shashIdx != 0)
  49.505 -		{
  49.506 -			/* Add slash delimiter at the beginning of the URL,
  49.507 -			   if it doesn't exist 
  49.508 -			*/
  49.509 -			uri->path = g_string_new( GMYTH_URI_SLASH_DELIM );
  49.510 -		}
  49.511 -		uri->path = g_string_append( uri->path, value );
  49.512 -		
  49.513 -	} else {
  49.514 -		/* First set path simply to the rest of URI */
  49.515 -		uri->path = g_string_new_len (value+currIdx,  uriLen-currIdx );
  49.516 -	}
  49.517 -	
  49.518 -	//gmyth_debug( "uri value:  %s", value );
  49.519 -	uri->query = g_string_new ( g_strstr_len( value, strlen(value), GMYTH_URI_QUESTION_DELIM ) );
  49.520 -	
  49.521 -	eIdx = gmyth_strstr( value+currIdx, GMYTH_URI_QUESTION_DELIM );
  49.522 -	
  49.523 -	if ( 0 < eIdx ) {
  49.524 -		uri->query = g_string_new ( g_strstr_len( value, strlen(value), GMYTH_URI_QUESTION_DELIM ) );
  49.525 -		gmyth_debug( "query = %s", uri->query->str );
  49.526 -	}
  49.527 -	
  49.528 -	/**** Path (Query/Fragment) ****/
  49.529 -	sharpIdx = gmyth_strstr(value+currIdx, GMYTH_URI_E_DELIM);
  49.530 -	if (0 < sharpIdx) {
  49.531 -		uri->path = g_string_append_len( uri->path, value+currIdx, sharpIdx);
  49.532 -		uri->fragment = g_string_new_len (value+currIdx+sharpIdx+1, uriLen-(currIdx+sharpIdx+1));
  49.533 -	}	
  49.534 +        uri->port = GMYTH_URI_KNKOWN_PORT;
  49.535 +        if (strcmp (protocol, GMYTH_URI_PROTOCOL_HTTP) == 0)
  49.536 +            uri->port = GMYTH_URI_DEFAULT_HTTP_PORT;
  49.537 +        if (strcmp (protocol, GMYTH_URI_PROTOCOL_FTP) == 0)
  49.538 +            uri->port = GMYTH_URI_DEFAULT_FTP_PORT;
  49.539 +    }
  49.540  
  49.541 -	gmyth_debug( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "\
  49.542 -      			 "user = %s, password = %s.\n", __FUNCTION__, 
  49.543 -                 gmyth_uri_print_field( uri->host ), uri->port,
  49.544 -			     gmyth_uri_print_field( uri->path ), 
  49.545 -                 gmyth_uri_print_field( uri->query ), 
  49.546 -                 gmyth_uri_print_field( uri->fragment ), 
  49.547 -                 gmyth_uri_print_field ( uri->user ), 
  49.548 -                 gmyth_uri_print_field( uri->password ) );
  49.549 +    if (shashIdx > 0)
  49.550 +        currIdx += shashIdx;
  49.551 +
  49.552 +    /*
  49.553 +       Handle relative URL
  49.554 +     */
  49.555 +    if (gmyth_uri_isabsolute (uri) == FALSE) {
  49.556 +
  49.557 +        if (shashIdx != 0) {
  49.558 +            /* Add slash delimiter at the beginning of the URL,
  49.559 +               if it doesn't exist 
  49.560 +             */
  49.561 +            uri->path = g_string_new (GMYTH_URI_SLASH_DELIM);
  49.562 +        }
  49.563 +        uri->path = g_string_append (uri->path, value);
  49.564 +
  49.565 +    } else {
  49.566 +        /* First set path simply to the rest of URI */
  49.567 +        uri->path = g_string_new_len (value + currIdx, uriLen - currIdx);
  49.568 +    }
  49.569 +
  49.570 +    //gmyth_debug( "uri value:  %s", value );
  49.571 +    uri->query =
  49.572 +        g_string_new (g_strstr_len
  49.573 +        (value, strlen (value), GMYTH_URI_QUESTION_DELIM));
  49.574 +
  49.575 +    eIdx = gmyth_strstr (value + currIdx, GMYTH_URI_QUESTION_DELIM);
  49.576 +
  49.577 +    if (0 < eIdx) {
  49.578 +        uri->query =
  49.579 +            g_string_new (g_strstr_len
  49.580 +            (value, strlen (value), GMYTH_URI_QUESTION_DELIM));
  49.581 +        gmyth_debug ("query = %s", uri->query->str);
  49.582 +    }
  49.583 +
  49.584 +        /**** Path (Query/Fragment) ****/
  49.585 +    sharpIdx = gmyth_strstr (value + currIdx, GMYTH_URI_E_DELIM);
  49.586 +    if (0 < sharpIdx) {
  49.587 +        uri->path = g_string_append_len (uri->path, value + currIdx, sharpIdx);
  49.588 +        uri->fragment =
  49.589 +            g_string_new_len (value + currIdx + sharpIdx + 1,
  49.590 +            uriLen - (currIdx + sharpIdx + 1));
  49.591 +    }
  49.592 +
  49.593 +    gmyth_debug
  49.594 +        ("[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "
  49.595 +        "user = %s, password = %s.\n", __FUNCTION__,
  49.596 +        gmyth_uri_print_field (uri->host), uri->port,
  49.597 +        gmyth_uri_print_field (uri->path),
  49.598 +        gmyth_uri_print_field (uri->query),
  49.599 +        gmyth_uri_print_field (uri->fragment),
  49.600 +        gmyth_uri_print_field (uri->user),
  49.601 +        gmyth_uri_print_field (uri->password));
  49.602  
  49.603  }
  49.604  
  49.605 @@ -394,10 +406,11 @@
  49.606   * @return <code>true</code>, if these two URI instances are equals.
  49.607   */
  49.608  gboolean
  49.609 -gmyth_uri_is_equals( GMythURI* uri1, GMythURI* uri2 )
  49.610 +gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2)
  49.611  {
  49.612 -	return ( g_ascii_strcasecmp( gmyth_uri_get_host( uri1 ), gmyth_uri_get_host( uri2 ) ) == 0 &&
  49.613 -				gmyth_uri_get_port( uri1 ) == gmyth_uri_get_port( uri2 ) );
  49.614 +    return (g_ascii_strcasecmp
  49.615 +        (gmyth_uri_get_host (uri1), gmyth_uri_get_host (uri2)) == 0
  49.616 +        && gmyth_uri_get_port (uri1) == gmyth_uri_get_port (uri2));
  49.617  }
  49.618  
  49.619  /** 
  49.620 @@ -408,25 +421,25 @@
  49.621   * @return <code>true</code>, if the URI points to LiveTV content.
  49.622   */
  49.623  gboolean
  49.624 -gmyth_uri_is_livetv( GMythURI* uri )
  49.625 +gmyth_uri_is_livetv (GMythURI * uri)
  49.626  {
  49.627 -	gboolean ret = TRUE;
  49.628 -    
  49.629 -	g_return_val_if_fail (uri != NULL, FALSE);
  49.630 -	g_return_val_if_fail (uri->uri != NULL, FALSE);
  49.631 +    gboolean ret = TRUE;
  49.632 +
  49.633 +    g_return_val_if_fail (uri != NULL, FALSE);
  49.634 +    g_return_val_if_fail (uri->uri != NULL, FALSE);
  49.635      g_return_val_if_fail (uri->uri->str != NULL, FALSE);
  49.636 -   
  49.637 +
  49.638      if ((strstr (uri->uri->str, "channel") == NULL) ||
  49.639 -        (strstr (uri->uri->str, "livetv") == NULL)) 
  49.640 +        (strstr (uri->uri->str, "livetv") == NULL))
  49.641          ret = FALSE;
  49.642  
  49.643 -	if (ret)
  49.644 -		gmyth_debug( "This URI is a LiveTV recording..." );
  49.645 +    if (ret)
  49.646 +        gmyth_debug ("This URI is a LiveTV recording...");
  49.647      else
  49.648 -        gmyth_debug( "This URI is a stored remote recording." );
  49.649 +        gmyth_debug ("This URI is a stored remote recording.");
  49.650  
  49.651 -	return ret;
  49.652 -	
  49.653 +    return ret;
  49.654 +
  49.655  }
  49.656  
  49.657  /** 
  49.658 @@ -437,34 +450,35 @@
  49.659   * @return The channel name, got from the substring "?channel=[channel_name]"
  49.660   * 				 of the URI string.
  49.661   */
  49.662 -gchar*
  49.663 -gmyth_uri_get_channel_name( GMythURI* uri )
  49.664 +gchar *
  49.665 +gmyth_uri_get_channel_name (GMythURI * uri)
  49.666  {
  49.667 -	gchar* channel = NULL;
  49.668 -	
  49.669 -	g_return_val_if_fail( uri != NULL && uri->uri != NULL && uri->uri->str != NULL, FALSE );
  49.670 -	
  49.671 -	gchar *channel_query = g_strstr_len( gmyth_uri_get_query( uri ), strlen( gmyth_uri_get_query( uri ) ), "channel" );
  49.672 -	
  49.673 -	if ( channel_query != NULL )
  49.674 -	{
  49.675 -		gchar **chan_key_value = g_strsplit( gmyth_uri_get_query( uri ), "=", 2 );
  49.676 -		
  49.677 -		/* gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] ); */
  49.678 +    gchar *channel = NULL;
  49.679  
  49.680 -		if ( chan_key_value[1] != NULL && strlen( chan_key_value[1] ) > 0 )
  49.681 -		{
  49.682 -			channel = g_strdup( chan_key_value[1] ); 
  49.683 -		}
  49.684 +    g_return_val_if_fail (uri != NULL && uri->uri != NULL
  49.685 +        && uri->uri->str != NULL, FALSE);
  49.686  
  49.687 -		if ( chan_key_value != NULL )		
  49.688 -			g_strfreev( chan_key_value );
  49.689 -	}
  49.690 -	
  49.691 -	gmyth_debug( "Got channel decimal value from the URI: %s", channel );
  49.692 +    gchar *channel_query = g_strstr_len (gmyth_uri_get_query (uri),
  49.693 +        strlen (gmyth_uri_get_query (uri)),
  49.694 +        "channel");
  49.695  
  49.696 -	return channel;
  49.697 -	
  49.698 +    if (channel_query != NULL) {
  49.699 +        gchar **chan_key_value = g_strsplit (gmyth_uri_get_query (uri), "=", 2);
  49.700 +
  49.701 +        /* gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] ); */
  49.702 +
  49.703 +        if (chan_key_value[1] != NULL && strlen (chan_key_value[1]) > 0) {
  49.704 +            channel = g_strdup (chan_key_value[1]);
  49.705 +        }
  49.706 +
  49.707 +        if (chan_key_value != NULL)
  49.708 +            g_strfreev (chan_key_value);
  49.709 +    }
  49.710 +
  49.711 +    gmyth_debug ("Got channel decimal value from the URI: %s", channel);
  49.712 +
  49.713 +    return channel;
  49.714 +
  49.715  }
  49.716  
  49.717  /** 
  49.718 @@ -476,17 +490,16 @@
  49.719   * 				 of the URI string, or <code>-1</code> it if couldn't be converted.
  49.720   */
  49.721  gint
  49.722 -gmyth_uri_get_channel_num( GMythURI* uri )
  49.723 +gmyth_uri_get_channel_num (GMythURI * uri)
  49.724  {
  49.725 -	gchar *channel_name = gmyth_uri_get_channel_name( uri );
  49.726 -	
  49.727 -	if ( channel_name != NULL )
  49.728 -	{
  49.729 -		return g_ascii_strtoull( channel_name, NULL, 10 ); 
  49.730 -	}
  49.731 -	
  49.732 -	return -1;
  49.733 -	
  49.734 +    gchar *channel_name = gmyth_uri_get_channel_name (uri);
  49.735 +
  49.736 +    if (channel_name != NULL) {
  49.737 +        return g_ascii_strtoull (channel_name, NULL, 10);
  49.738 +    }
  49.739 +
  49.740 +    return -1;
  49.741 +
  49.742  }
  49.743  
  49.744  /** 
  49.745 @@ -497,37 +510,37 @@
  49.746   * @return <code>true</code>, if the URI points to a local file.
  49.747   */
  49.748  gboolean
  49.749 -gmyth_uri_is_local_file( const GMythURI* uri )
  49.750 +gmyth_uri_is_local_file (const GMythURI * uri)
  49.751  {
  49.752      gboolean ret = FALSE;
  49.753      gint len = -1;
  49.754 -    
  49.755 -    GString *hostname = gmyth_socket_get_local_hostname();
  49.756 -    
  49.757 -    g_return_val_if_fail( uri != NULL, FALSE );    
  49.758 -    
  49.759 -    len = strlen( gmyth_uri_get_host(uri) );
  49.760 -    
  49.761 -   // gmyth_debug("URI: host = %s, hostname = %s.", uri->host->str, hostname != NULL ? hostname->str : "[no hostname]");
  49.762 -    
  49.763 -    ret = ( NULL != hostname && ( g_ascii_strncasecmp( uri->host->str, 
  49.764 -              (hostname)->str, len ) == 0 ) /*|| 
  49.765 -        ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */ );
  49.766 -    
  49.767 -    if ( ret )
  49.768 -        gmyth_debug( "This URI is a local file..." );
  49.769 +
  49.770 +    GString *hostname = gmyth_socket_get_local_hostname ();
  49.771 +
  49.772 +    g_return_val_if_fail (uri != NULL, FALSE);
  49.773 +
  49.774 +    len = strlen (gmyth_uri_get_host (uri));
  49.775 +
  49.776 +    // gmyth_debug("URI: host = %s, hostname = %s.", uri->host->str, hostname != NULL ? hostname->str : "[no hostname]");
  49.777 +
  49.778 +    ret = (NULL != hostname && (g_ascii_strncasecmp (uri->host->str, (hostname)->str, len) == 0)    /*|| 
  49.779 +                                                                                                       ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */
  49.780 +        );
  49.781 +
  49.782 +    if (ret)
  49.783 +        gmyth_debug ("This URI is a local file...");
  49.784      else
  49.785 -        gmyth_debug( "This URI is NOT a local file..." );
  49.786 -    
  49.787 +        gmyth_debug ("This URI is NOT a local file...");
  49.788 +
  49.789      return ret;
  49.790 -    
  49.791 +
  49.792  }
  49.793  
  49.794 -char*
  49.795 -gmyth_uri_to_string (const GMythURI* uri)
  49.796 +char *
  49.797 +gmyth_uri_to_string (const GMythURI * uri)
  49.798  {
  49.799      g_return_val_if_fail (uri != NULL, NULL);
  49.800      g_return_val_if_fail (uri->uri != NULL, NULL);
  49.801 -    
  49.802 -    return g_strdup (uri->uri->str);	
  49.803 +
  49.804 +    return g_strdup (uri->uri->str);
  49.805  }
    50.1 --- a/gmyth/src/gmyth_uri.h	Tue May 22 19:21:42 2007 +0100
    50.2 +++ b/gmyth/src/gmyth_uri.h	Wed May 23 16:11:29 2007 +0100
    50.3 @@ -10,22 +10,22 @@
    50.4   * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    50.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    50.6   *
    50.7 - *//*
    50.8 - * 
    50.9 - * This program is free software; you can redistribute it and/or modify
   50.10 - * it under the terms of the GNU Lesser General Public License as published by
   50.11 - * the Free Software Foundation; either version 2 of the License, or
   50.12 - * (at your option) any later version.
   50.13 - *
   50.14 - * This program is distributed in the hope that it will be useful,
   50.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   50.17 - * GNU General Public License for more details.
   50.18 - *
   50.19 - * You should have received a copy of the GNU Lesser General Public License
   50.20 - * along with this program; if not, write to the Free Software
   50.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   50.22 - */
   50.23 +                                                                                                                                                                                                                                                                                                                                                                                              *//*
   50.24 +                                                                                                                                                                                                 * 
   50.25 +                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   50.26 +                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   50.27 +                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   50.28 +                                                                                                                                                                                                 * (at your option) any later version.
   50.29 +                                                                                                                                                                                                 *
   50.30 +                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   50.31 +                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   50.32 +                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   50.33 +                                                                                                                                                                                                 * GNU General Public License for more details.
   50.34 +                                                                                                                                                                                                 *
   50.35 +                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   50.36 +                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   50.37 +                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   50.38 +                                                                                                                                                                                                 */
   50.39  
   50.40  #ifndef _GMYTH_URI_H_
   50.41  #define _GMYTH_URI_H_
   50.42 @@ -38,16 +38,14 @@
   50.43  #include <string.h>
   50.44  
   50.45  G_BEGIN_DECLS
   50.46 -
   50.47  #define GMYTH_URI_TYPE               (gmyth_uri_get_type ())
   50.48  #define GMYTH_URI(obj)          		 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_URI_TYPE, GMythURI))
   50.49  #define GMYTH_URI_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE, GMythURIClass))
   50.50  #define IS_GMYTH_URI(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_URI_TYPE))
   50.51  #define IS_GMYTH_URI_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_URI_TYPE))
   50.52  #define GMYTH_URI_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_URI_TYPE, GMythURIClass))
   50.53 -
   50.54 -typedef struct _GMythURI         GMythURI;
   50.55 -typedef struct _GMythURIClass    GMythURIClass;
   50.56 +typedef struct _GMythURI GMythURI;
   50.57 +typedef struct _GMythURIClass GMythURIClass;
   50.58  
   50.59  /****************************************
   50.60  * Define
   50.61 @@ -80,37 +78,38 @@
   50.62  
   50.63  struct _GMythURIClass
   50.64  {
   50.65 -  GObjectClass parent_class;
   50.66 +    GObjectClass parent_class;
   50.67  
   50.68 -  /* callbacks */
   50.69 -  /* no one for now */
   50.70 +    /* callbacks */
   50.71 +    /* no one for now */
   50.72  };
   50.73  
   50.74 -struct _GMythURI {
   50.75 -	
   50.76 -	GObject parent;
   50.77 -	
   50.78 -	GString *uri;
   50.79 -	GString *host;
   50.80 -	gint port;
   50.81 -	GString *protocol;
   50.82 -	GString *path;
   50.83 -	GString *fragment;
   50.84 -	GString *user;
   50.85 -	GString *password;
   50.86 -	GString *query;
   50.87 -	
   50.88 +struct _GMythURI
   50.89 +{
   50.90 +
   50.91 +    GObject parent;
   50.92 +
   50.93 +    GString *uri;
   50.94 +    GString *host;
   50.95 +    gint port;
   50.96 +    GString *protocol;
   50.97 +    GString *path;
   50.98 +    GString *fragment;
   50.99 +    GString *user;
  50.100 +    GString *password;
  50.101 +    GString *query;
  50.102 +
  50.103  };
  50.104  
  50.105 -GType       gmyth_uri_get_type (void);
  50.106 -GMythURI*   gmyth_uri_new (void);
  50.107 -GMythURI*   gmyth_uri_new_with_value (const gchar *value);
  50.108 -gboolean 	gmyth_uri_is_equals ( GMythURI* uri1, GMythURI* uri2 );
  50.109 -gboolean	gmyth_uri_is_livetv ( GMythURI* uri );
  50.110 -gint		gmyth_uri_get_channel_num( GMythURI* uri );
  50.111 -gchar*		gmyth_uri_get_channel_name( GMythURI* uri );
  50.112 -char*       gmyth_uri_to_string (const GMythURI* uri);
  50.113 -gboolean    gmyth_uri_is_local_file( const GMythURI* uri );
  50.114 +GType gmyth_uri_get_type (void);
  50.115 +GMythURI *gmyth_uri_new (void);
  50.116 +GMythURI *gmyth_uri_new_with_value (const gchar * value);
  50.117 +gboolean gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2);
  50.118 +gboolean gmyth_uri_is_livetv (GMythURI * uri);
  50.119 +gint gmyth_uri_get_channel_num (GMythURI * uri);
  50.120 +gchar *gmyth_uri_get_channel_name (GMythURI * uri);
  50.121 +char *gmyth_uri_to_string (const GMythURI * uri);
  50.122 +gboolean gmyth_uri_is_local_file (const GMythURI * uri);
  50.123  
  50.124  #define 	gmyth_uri_get_host(urip) 			( urip->host != NULL ? urip->host->str : "" )
  50.125  #define 	gmyth_uri_get_port(urip) 			( urip->port )
  50.126 @@ -122,5 +121,4 @@
  50.127  #define 	gmyth_uri_get_query(urip) 		( urip->query != NULL ? urip->query->str : "" )
  50.128  
  50.129  G_END_DECLS
  50.130 -
  50.131  #endif /* _GMYTH_URI_H_ */
    51.1 --- a/gmyth/src/gmyth_util.c	Tue May 22 19:21:42 2007 +0100
    51.2 +++ b/gmyth/src/gmyth_util.c	Wed May 23 16:11:29 2007 +0100
    51.3 @@ -10,23 +10,23 @@
    51.4   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    51.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    51.6   *
    51.7 - *//*
    51.8 - * 
    51.9 - * This program is free software; you can redistribute it and/or modify
   51.10 - * it under the terms of the GNU Lesser General Public License as published by
   51.11 - * the Free Software Foundation; either version 2 of the License, or
   51.12 - * (at your option) any later version.
   51.13 - *
   51.14 - * This program is distributed in the hope that it will be useful,
   51.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   51.17 - * GNU General Public License for more details.
   51.18 - *
   51.19 - * You should have received a copy of the GNU Lesser General Public License
   51.20 - * along with this program; if not, write to the Free Software
   51.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   51.22 - */
   51.23 - 
   51.24 +                                                                                                                                                                                                                                                                                                                                                                                              *//*
   51.25 +                                                                                                                                                                                                 * 
   51.26 +                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   51.27 +                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   51.28 +                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   51.29 +                                                                                                                                                                                                 * (at your option) any later version.
   51.30 +                                                                                                                                                                                                 *
   51.31 +                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   51.32 +                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   51.33 +                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   51.34 +                                                                                                                                                                                                 * GNU General Public License for more details.
   51.35 +                                                                                                                                                                                                 *
   51.36 +                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   51.37 +                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   51.38 +                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   51.39 +                                                                                                                                                                                                 */
   51.40 +
   51.41  #ifdef HAVE_CONFIG_H
   51.42  #include "config.h"
   51.43  #endif
   51.44 @@ -48,14 +48,9 @@
   51.45  #include "gmyth_debug.h"
   51.46  
   51.47  #if !GLIB_CHECK_VERSION (2, 10, 0)
   51.48 -gchar *
   51.49 -g_time_val_to_iso8601 (GTimeVal *time_);
   51.50 -gboolean
   51.51 -g_time_val_from_iso8601 (const gchar *iso_date,
   51.52 -                         GTimeVal    *time_);
   51.53 -void
   51.54 -g_date_set_time_val (GDate    *date,
   51.55 -             GTimeVal *timeval);
   51.56 +gchar *g_time_val_to_iso8601 (GTimeVal * time_);
   51.57 +gboolean g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_);
   51.58 +void g_date_set_time_val (GDate * date, GTimeVal * timeval);
   51.59  
   51.60  #endif
   51.61  
   51.62 @@ -68,25 +63,25 @@
   51.63   * @param time_value the time value to be converted
   51.64   * @return GString* the converted isoformat string 
   51.65   */
   51.66 -GString*
   51.67 +GString *
   51.68  gmyth_util_time_to_isoformat (time_t time_value)
   51.69  {
   51.70 -	struct tm tm_time;
   51.71 -	GString *result;
   51.72 -	
   51.73 -	if (localtime_r(&time_value, &tm_time) == NULL) {
   51.74 -	    gmyth_debug("gmyth_util_time_to_isoformat convertion error!\n");
   51.75 -            return NULL;
   51.76 -	}
   51.77 -	
   51.78 -	result = g_string_sized_new(20);
   51.79 -	g_string_printf(result, "%04d-%02d-%02dT%02d:%02d:%02d",
   51.80 -		tm_time.tm_year + 1900, tm_time.tm_mon + 1, tm_time.tm_mday,
   51.81 -		tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec);
   51.82 -		
   51.83 -	gmyth_debug( "Result (ISO 8601) = %s", result->str );
   51.84 +    struct tm tm_time;
   51.85 +    GString *result;
   51.86  
   51.87 -	return result;
   51.88 +    if (localtime_r (&time_value, &tm_time) == NULL) {
   51.89 +        gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
   51.90 +        return NULL;
   51.91 +    }
   51.92 +
   51.93 +    result = g_string_sized_new (20);
   51.94 +    g_string_printf (result, "%04d-%02d-%02dT%02d:%02d:%02d",
   51.95 +        tm_time.tm_year + 1900, tm_time.tm_mon + 1,
   51.96 +        tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec);
   51.97 +
   51.98 +    gmyth_debug ("Result (ISO 8601) = %s", result->str);
   51.99 +
  51.100 +    return result;
  51.101  }
  51.102  
  51.103  /** Converts a time_t struct in a GString at ISO standard format 
  51.104 @@ -98,50 +93,52 @@
  51.105   * @param time_value the GTimeValue to be converted
  51.106   * @return GString* the converted isoformat string 
  51.107   */
  51.108 -gchar*
  51.109 -gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar *fmt_string, const GTimeVal* time_val )
  51.110 +gchar *
  51.111 +gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar * fmt_string,
  51.112 +    const GTimeVal * time_val)
  51.113  {
  51.114 -	gchar *result = NULL;
  51.115 -	struct tm *tm_time = NULL;
  51.116 -	time_t time;
  51.117 -	
  51.118 -	gint buffer_len = 0;
  51.119 -	
  51.120 -	g_return_val_if_fail( fmt_string != NULL, NULL );
  51.121 -		
  51.122 -	g_return_val_if_fail( time_val != NULL, NULL );
  51.123 +    gchar *result = NULL;
  51.124 +    struct tm *tm_time = NULL;
  51.125 +    time_t time;
  51.126  
  51.127 -	time = time_val->tv_sec;// + (gint)( time_val->tv_usec / G_USEC_PER_SEC );
  51.128 +    gint buffer_len = 0;
  51.129  
  51.130 -	tm_time = g_malloc0( sizeof(struct tm) );
  51.131 +    g_return_val_if_fail (fmt_string != NULL, NULL);
  51.132  
  51.133 -	if ( NULL == localtime_r( &time, tm_time ) ) {
  51.134 -		gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
  51.135 -	} else {
  51.136 -		/* we first check the return of strftime to allocate a buffer of the correct size */
  51.137 -        	buffer_len = strftime( NULL, SSIZE_MAX, fmt_string, tm_time );
  51.138 -        	if ( buffer_len > 0 ) {
  51.139 -            		result = g_malloc0( buffer_len + 1 );
  51.140 -			if( result == NULL ) {
  51.141 -                		gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
  51.142 -                		return NULL;
  51.143 -            		}
  51.144 -            		strftime( result, buffer_len + 1, fmt_string, tm_time );
  51.145 -            		gmyth_debug( "Dateline (ISO result): %s", result );
  51.146 -        	}
  51.147 -	} /* if */
  51.148 -	
  51.149 -	gmyth_debug( "Result (strftime) = %s", result );
  51.150 -	
  51.151 -	//strptime( result, "%Y-%m-%dT%H:%M:%SZ", tm_time ); 
  51.152 -	
  51.153 -	//strftime( result, strlen(result), fmt_string, tm_time );
  51.154 -	
  51.155 -	g_free (tm_time);
  51.156 +    g_return_val_if_fail (time_val != NULL, NULL);
  51.157  
  51.158 -	gmyth_debug( "Result (ISO 8601) = %s", result  );
  51.159 -	
  51.160 -	return result;			
  51.161 +    time = time_val->tv_sec;    // + (gint)( time_val->tv_usec / G_USEC_PER_SEC );
  51.162 +
  51.163 +    tm_time = g_malloc0 (sizeof (struct tm));
  51.164 +
  51.165 +    if (NULL == localtime_r (&time, tm_time)) {
  51.166 +        gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
  51.167 +    } else {
  51.168 +        /* we first check the return of strftime to allocate a buffer of the correct size */
  51.169 +        buffer_len = strftime (NULL, SSIZE_MAX, fmt_string, tm_time);
  51.170 +        if (buffer_len > 0) {
  51.171 +            result = g_malloc0 (buffer_len + 1);
  51.172 +            if (result == NULL) {
  51.173 +                gmyth_debug
  51.174 +                    ("gmyth_util_time_to_isoformat convertion error!\n");
  51.175 +                return NULL;
  51.176 +            }
  51.177 +            strftime (result, buffer_len + 1, fmt_string, tm_time);
  51.178 +            gmyth_debug ("Dateline (ISO result): %s", result);
  51.179 +        }
  51.180 +    }                           /* if */
  51.181 +
  51.182 +    gmyth_debug ("Result (strftime) = %s", result);
  51.183 +
  51.184 +    //strptime( result, "%Y-%m-%dT%H:%M:%SZ", tm_time ); 
  51.185 +
  51.186 +    //strftime( result, strlen(result), fmt_string, tm_time );
  51.187 +
  51.188 +    g_free (tm_time);
  51.189 +
  51.190 +    gmyth_debug ("Result (ISO 8601) = %s", result);
  51.191 +
  51.192 +    return result;
  51.193  }
  51.194  
  51.195  /** Converts a time_t struct in a GString at ISO standard format 
  51.196 @@ -153,14 +150,17 @@
  51.197   * @param time_value the GTimeValue to be converted
  51.198   * @return GString* the converted isoformat string 
  51.199   */
  51.200 -gchar*
  51.201 -gmyth_util_time_to_isoformat_from_time_val ( const GTimeVal* time )
  51.202 +gchar *
  51.203 +gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time)
  51.204  {
  51.205 -	gchar *result = gmyth_util_time_to_isoformat_from_time_val_fmt( "%Y-%m-%d %H:%M:%S", time );
  51.206 -	//result[10] = ' ';
  51.207 -	//result[ strlen(result) - 1] = '\0';
  51.208 -	
  51.209 -	return result;	
  51.210 +    gchar *result =
  51.211 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S",
  51.212 +        time);
  51.213 +
  51.214 +    //result[10] = ' ';
  51.215 +    //result[ strlen(result) - 1] = '\0';
  51.216 +
  51.217 +    return result;
  51.218  }
  51.219  
  51.220  /** Converts a time_t struct in a GString at ISO standard format 2 
  51.221 @@ -172,11 +172,14 @@
  51.222   * @param time_value the GTimeValue to be converted
  51.223   * @return GString* the converted isoformat string 
  51.224   */
  51.225 -gchar*
  51.226 -gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal* time )
  51.227 +gchar *
  51.228 +gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time)
  51.229  {
  51.230 -	gchar *result = gmyth_util_time_to_isoformat_from_time_val_fmt( "%Y-%m-%dT%H:%M:%S", time );
  51.231 -	return result;	
  51.232 +    gchar *result =
  51.233 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%dT%H:%M:%S",
  51.234 +        time);
  51.235 +
  51.236 +    return result;
  51.237  }
  51.238  
  51.239  /** Converts a time_t struct in a GString at ISO standard format 
  51.240 @@ -188,13 +191,14 @@
  51.241   * @param time_value the GTimeValue to be converted
  51.242   * @return GString* the converted isoformat string 
  51.243   */
  51.244 -gchar*
  51.245 -gmyth_util_time_to_string_only_date ( const GTimeVal* time )
  51.246 +gchar *
  51.247 +gmyth_util_time_to_string_only_date (const GTimeVal * time)
  51.248  {
  51.249 -	gchar *result = gmyth_util_time_to_isoformat_from_time_val_fmt( "%Y-%m-%d", time );
  51.250 -	//result[10] = ' ';
  51.251 -	//result[ strlen(result) - 1] = '\0';
  51.252 -	return result;
  51.253 +    gchar *result =
  51.254 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d", time);
  51.255 +    //result[10] = ' ';
  51.256 +    //result[ strlen(result) - 1] = '\0';
  51.257 +    return result;
  51.258  }
  51.259  
  51.260  /** Converts a time_t struct in a GString at ISO standard format 
  51.261 @@ -206,13 +210,14 @@
  51.262   * @param time_value the GTimeValue to be converted
  51.263   * @return GString* the converted isoformat string 
  51.264   */
  51.265 -gchar*
  51.266 -gmyth_util_time_to_string_only_time ( const GTimeVal* time )
  51.267 +gchar *
  51.268 +gmyth_util_time_to_string_only_time (const GTimeVal * time)
  51.269  {
  51.270 -	gchar *result = gmyth_util_time_to_isoformat_from_time_val_fmt( "%H:%M:%S", time );	 
  51.271 -	//result[10] = ' ';
  51.272 -	//result[ strlen(result) - 1] = '\0';
  51.273 -	return result;
  51.274 +    gchar *result =
  51.275 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%H:%M:%S", time);
  51.276 +    //result[10] = ' ';
  51.277 +    //result[ strlen(result) - 1] = '\0';
  51.278 +    return result;
  51.279  }
  51.280  
  51.281  /** Converts a time_t struct in a GString to the following 
  51.282 @@ -224,14 +229,15 @@
  51.283   * @param time_value the time value to be converted
  51.284   * @return GString* the converted string 
  51.285   */
  51.286 -GString*
  51.287 +GString *
  51.288  gmyth_util_time_to_string (time_t time_value)
  51.289  {
  51.290 -	GString *result = gmyth_util_time_to_isoformat (time_value);
  51.291 -	result->str[10] = ' ';	
  51.292 -	result->str[ strlen(result->str) - 1] = '\0';
  51.293 +    GString *result = gmyth_util_time_to_isoformat (time_value);
  51.294  
  51.295 -	return result;
  51.296 +    result->str[10] = ' ';
  51.297 +    result->str[strlen (result->str) - 1] = '\0';
  51.298 +
  51.299 +    return result;
  51.300  }
  51.301  
  51.302  /** Converts a time_t struct in a GString to the following 
  51.303 @@ -243,13 +249,16 @@
  51.304   * @param time_value the time value to be converted
  51.305   * @return GString* the converted string 
  51.306   */
  51.307 -gchar*
  51.308 -gmyth_util_time_to_string_from_time_val ( const GTimeVal *time_val )
  51.309 +gchar *
  51.310 +gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val)
  51.311  {
  51.312 -	gchar *result = gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d %H:%M:%S", time_val );
  51.313 -	//result[10] = ' ';
  51.314 +    gchar *result =
  51.315 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S",
  51.316 +        time_val);
  51.317  
  51.318 -	return result;
  51.319 +    //result[10] = ' ';
  51.320 +
  51.321 +    return result;
  51.322  }
  51.323  
  51.324  /** Converts a GString in the following format 
  51.325 @@ -259,28 +268,29 @@
  51.326   * @return time_t the time converted value
  51.327   */
  51.328  time_t
  51.329 -gmyth_util_string_to_time (GString* time_str)
  51.330 +gmyth_util_string_to_time (GString * time_str)
  51.331  {
  51.332 -	gint year, month, day, hour, min, sec;
  51.333 -    
  51.334 -	gmyth_debug( "[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ? 
  51.335 -					time_str->str : "[time string is NULL!]", time_str->str );
  51.336 +    gint year, month, day, hour, min, sec;
  51.337  
  51.338 -	if ( sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d",
  51.339 -			&year, &month, &day, &hour, &min, &sec) < 3 ) {
  51.340 -		gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
  51.341 -		return 0;
  51.342 -	}
  51.343 -	
  51.344 -	struct tm* tm_time = g_malloc0( sizeof(struct tm) );
  51.345 -	tm_time->tm_year = year - 1900;
  51.346 -	tm_time->tm_mon = month - 1;
  51.347 -	tm_time->tm_mday = day;
  51.348 -	tm_time->tm_hour = hour;
  51.349 -	tm_time->tm_min = min;
  51.350 -	tm_time->tm_sec = sec;
  51.351 -	
  51.352 -	return mktime( tm_time );
  51.353 +    gmyth_debug ("[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ?
  51.354 +        time_str->str : "[time string is NULL!]", time_str->str);
  51.355 +
  51.356 +    if (sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d",
  51.357 +            &year, &month, &day, &hour, &min, &sec) < 3) {
  51.358 +        gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
  51.359 +        return 0;
  51.360 +    }
  51.361 +
  51.362 +    struct tm *tm_time = g_malloc0 (sizeof (struct tm));
  51.363 +
  51.364 +    tm_time->tm_year = year - 1900;
  51.365 +    tm_time->tm_mon = month - 1;
  51.366 +    tm_time->tm_mday = day;
  51.367 +    tm_time->tm_hour = hour;
  51.368 +    tm_time->tm_min = min;
  51.369 +    tm_time->tm_sec = sec;
  51.370 +
  51.371 +    return mktime (tm_time);
  51.372  }
  51.373  
  51.374  /** Converts a GString in the following format 
  51.375 @@ -289,25 +299,26 @@
  51.376   * @param time_str the string to be converted
  51.377   * @return time_t the time converted value
  51.378   */
  51.379 -struct tm*
  51.380 -gmyth_util_time_val_to_date ( const GTimeVal* time )
  51.381 +struct tm *
  51.382 +gmyth_util_time_val_to_date (const GTimeVal * time)
  51.383  {
  51.384 -	struct tm *date = g_malloc0( sizeof( struct tm ) );
  51.385 -	time_t time_micros = time->tv_sec;// + (gint)( time->tv_usec / G_USEC_PER_SEC );
  51.386 -    
  51.387 -  if ( NULL == date ) { 
  51.388 -		gmyth_debug ( "GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n" );
  51.389 -		return NULL;
  51.390 -	}
  51.391 -	
  51.392 -	if ( NULL == localtime_r( &time_micros, date ) ) {
  51.393 -		gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" );
  51.394 -		return NULL;
  51.395 -	}
  51.396 +    struct tm *date = g_malloc0 (sizeof (struct tm));
  51.397 +    time_t time_micros = time->tv_sec;  // + (gint)( time->tv_usec / G_USEC_PER_SEC );
  51.398  
  51.399 -	gmyth_debug( "Converted from GTimeVal == %s to GDate", asctime( date ) );
  51.400 -	
  51.401 -	return date;
  51.402 +    if (NULL == date) {
  51.403 +        gmyth_debug
  51.404 +            ("GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n");
  51.405 +        return NULL;
  51.406 +    }
  51.407 +
  51.408 +    if (NULL == localtime_r (&time_micros, date)) {
  51.409 +        gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
  51.410 +        return NULL;
  51.411 +    }
  51.412 +
  51.413 +    gmyth_debug ("Converted from GTimeVal == %s to GDate", asctime (date));
  51.414 +
  51.415 +    return date;
  51.416  }
  51.417  
  51.418  /** Converts a GString in the following format 
  51.419 @@ -316,53 +327,53 @@
  51.420   * @param time_str the string to be converted
  51.421   * @return time_t the time converted value
  51.422   */
  51.423 -GTimeVal*
  51.424 -gmyth_util_string_to_time_val_fmt ( const gchar *fmt_string, const gchar* time_str )
  51.425 +GTimeVal *
  51.426 +gmyth_util_string_to_time_val_fmt (const gchar * fmt_string,
  51.427 +    const gchar * time_str)
  51.428  {
  51.429 -	GTimeVal *time = g_new0( GTimeVal, 1 );
  51.430 -	struct tm* tm_time = NULL;
  51.431 -	time_t time_micros;
  51.432 -	gchar* result;
  51.433 -    
  51.434 -	gmyth_debug( "[%s] time_str = %s. [%s]", time_str, time_str != NULL ? 
  51.435 -                 time_str : "[time string is NULL!]", time_str );
  51.436 -    
  51.437 -	if ( NULL == time_str ) 
  51.438 -      { 
  51.439 -		gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
  51.440 -		return NULL;
  51.441 -      }
  51.442 -	
  51.443 -	tm_time = g_malloc0( sizeof(struct tm) );
  51.444 -    
  51.445 -	/* we first check the return of strftime to allocate a buffer of the correct size */
  51.446 -    result = strptime( time_str, "%Y-%m-%dT%H:%M:%S", tm_time );
  51.447 -    if ( NULL == result ) {
  51.448 -      /* we first check the return of strftime to allocate a buffer of the correct size */
  51.449 -	  result = strptime( time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time );
  51.450 -	  if ( NULL == result ) {
  51.451 -	  	/* we first check the return of strftime to allocate a buffer of the correct size */
  51.452 -        result = strptime( time_str, "%Y-%m-%d %H:%M:%S", tm_time );
  51.453 -        if ( NULL == result) {
  51.454 -          result = strptime( time_str, "%Y-%m-%dT%H:%M", tm_time );
  51.455 -          if ( NULL == result ) {
  51.456 -            gmyth_debug( "Dateline (ISO result): %s", result );
  51.457 -            g_free(tm_time);
  51.458 -            return NULL;
  51.459 -            //goto done;	    
  51.460 -          }
  51.461 +    GTimeVal *time = g_new0 (GTimeVal, 1);
  51.462 +    struct tm *tm_time = NULL;
  51.463 +    time_t time_micros;
  51.464 +    gchar *result;
  51.465 +
  51.466 +    gmyth_debug ("[%s] time_str = %s. [%s]", time_str, time_str != NULL ?
  51.467 +        time_str : "[time string is NULL!]", time_str);
  51.468 +
  51.469 +    if (NULL == time_str) {
  51.470 +        gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
  51.471 +        return NULL;
  51.472 +    }
  51.473 +
  51.474 +    tm_time = g_malloc0 (sizeof (struct tm));
  51.475 +
  51.476 +    /* we first check the return of strftime to allocate a buffer of the correct size */
  51.477 +    result = strptime (time_str, "%Y-%m-%dT%H:%M:%S", tm_time);
  51.478 +    if (NULL == result) {
  51.479 +        /* we first check the return of strftime to allocate a buffer of the correct size */
  51.480 +        result = strptime (time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time);
  51.481 +        if (NULL == result) {
  51.482 +            /* we first check the return of strftime to allocate a buffer of the correct size */
  51.483 +            result = strptime (time_str, "%Y-%m-%d %H:%M:%S", tm_time);
  51.484 +            if (NULL == result) {
  51.485 +                result = strptime (time_str, "%Y-%m-%dT%H:%M", tm_time);
  51.486 +                if (NULL == result) {
  51.487 +                    gmyth_debug ("Dateline (ISO result): %s", result);
  51.488 +                    g_free (tm_time);
  51.489 +                    return NULL;
  51.490 +                    //goto done;            
  51.491 +                }
  51.492 +            }
  51.493          }
  51.494 -	  }
  51.495      }
  51.496 -    
  51.497 -    time_micros = mktime( tm_time );
  51.498 -    
  51.499 +
  51.500 +    time_micros = mktime (tm_time);
  51.501 +
  51.502      time->tv_sec = time_micros; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC );
  51.503 -    
  51.504 -    gmyth_debug( "After mktime call... = %s", asctime(tm_time) );
  51.505 -    
  51.506 +
  51.507 +    gmyth_debug ("After mktime call... = %s", asctime (tm_time));
  51.508 +
  51.509      g_free (tm_time);
  51.510 -    
  51.511 +
  51.512      return time;
  51.513  }
  51.514  
  51.515 @@ -372,12 +383,13 @@
  51.516   * @param time_str the string to be converted
  51.517   * @return time_t the time converted value
  51.518   */
  51.519 -GTimeVal*
  51.520 -gmyth_util_string_to_time_val ( const gchar* time_str )
  51.521 +GTimeVal *
  51.522 +gmyth_util_string_to_time_val (const gchar * time_str)
  51.523  {
  51.524 -	GTimeVal *time = gmyth_util_string_to_time_val_fmt ( "%Y-%m-%d %H:%M:%S", time_str );	
  51.525 -	
  51.526 -	return time;
  51.527 +    GTimeVal *time =
  51.528 +        gmyth_util_string_to_time_val_fmt ("%Y-%m-%d %H:%M:%S", time_str);
  51.529 +
  51.530 +    return time;
  51.531  }
  51.532  
  51.533  /** 
  51.534 @@ -389,25 +401,25 @@
  51.535   * @return <code>true</code>, if the remote file exists.
  51.536   */
  51.537  gboolean
  51.538 -gmyth_util_file_exists (GMythBackendInfo *backend_info, const gchar* filename)
  51.539 +gmyth_util_file_exists (GMythBackendInfo * backend_info, const gchar * filename)
  51.540  {
  51.541      GMythSocket *socket;
  51.542      gboolean res;
  51.543 -    
  51.544 +
  51.545      gmyth_debug ("Check if file %s exists", filename);
  51.546  
  51.547      g_return_val_if_fail (backend_info != NULL, FALSE);
  51.548 -    g_return_val_if_fail (filename != NULL, FALSE); 
  51.549 +    g_return_val_if_fail (filename != NULL, FALSE);
  51.550  
  51.551      socket = gmyth_socket_new ();
  51.552      res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
  51.553 -		    backend_info->port, TRUE);
  51.554 +        backend_info->port, TRUE);
  51.555  
  51.556      if (res == TRUE) {
  51.557          GMythStringList *slist;
  51.558          GMythProgramInfo *program = NULL;
  51.559  
  51.560 -        program = gmyth_program_info_new();
  51.561 +        program = gmyth_program_info_new ();
  51.562          program->pathname = g_string_new (filename);
  51.563  
  51.564          slist = gmyth_string_list_new ();
  51.565 @@ -425,7 +437,7 @@
  51.566          gmyth_socket_close_connection (socket);
  51.567      }
  51.568      g_object_unref (socket);
  51.569 -    return res;    
  51.570 +    return res;
  51.571  }
  51.572  
  51.573  /** 
  51.574 @@ -438,23 +450,23 @@
  51.575   * @return <code>true</code>, if the remote file exists.
  51.576   */
  51.577  gboolean
  51.578 -gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, 
  51.579 -						const gchar* filename, gchar** current_dir)
  51.580 +gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo * backend_info,
  51.581 +    const gchar * filename, gchar ** current_dir)
  51.582  {
  51.583      GMythSocket *socket;
  51.584      gboolean res;
  51.585 -    
  51.586 +
  51.587      *current_dir = NULL;
  51.588 -    
  51.589 +
  51.590      socket = gmyth_socket_new ();
  51.591      res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
  51.592 -		    backend_info->port, TRUE);
  51.593 +        backend_info->port, TRUE);
  51.594  
  51.595      if (res == TRUE) {
  51.596          GMythStringList *slist;
  51.597          GMythProgramInfo *program = NULL;
  51.598  
  51.599 -        program = gmyth_program_info_new();
  51.600 +        program = gmyth_program_info_new ();
  51.601          program->pathname = g_string_new (filename);
  51.602  
  51.603          slist = gmyth_string_list_new ();
  51.604 @@ -465,15 +477,16 @@
  51.605          gmyth_socket_sendreceive_stringlist (socket, slist);
  51.606  
  51.607          res = (gmyth_string_list_get_int (slist, 0) == 1);
  51.608 -        
  51.609 -        if ( ( gmyth_string_list_length( slist ) > 1 ) && 
  51.610 -        			gmyth_string_list_get_char_array (slist, 1) != NULL )
  51.611 -        	*current_dir = g_strdup( gmyth_string_list_get_char_array (slist, 1) );
  51.612 -        
  51.613 -        if ( *current_dir != NULL )
  51.614 -        	gmyth_debug( "Current directory = %s.", ( *current_dir != NULL ) 
  51.615 -        			? *current_dir : "[directory not found]" );
  51.616 -    
  51.617 +
  51.618 +        if ((gmyth_string_list_length (slist) > 1) &&
  51.619 +            gmyth_string_list_get_char_array (slist, 1) != NULL)
  51.620 +            *current_dir =
  51.621 +                g_strdup (gmyth_string_list_get_char_array (slist, 1));
  51.622 +
  51.623 +        if (*current_dir != NULL)
  51.624 +            gmyth_debug ("Current directory = %s.", (*current_dir != NULL)
  51.625 +                ? *current_dir : "[directory not found]");
  51.626 +
  51.627          g_object_unref (program);
  51.628  
  51.629          g_object_unref (slist);
  51.630 @@ -481,7 +494,7 @@
  51.631          gmyth_socket_close_connection (socket);
  51.632      }
  51.633      g_object_unref (socket);
  51.634 -    return res;    
  51.635 +    return res;
  51.636  }
  51.637  
  51.638  /** 
  51.639 @@ -493,24 +506,25 @@
  51.640   * 
  51.641   * @return The string representing the file name.
  51.642   */
  51.643 -gchar*
  51.644 -gmyth_util_create_filename( const gint chan_id, const GTimeVal* start_time )
  51.645 -{ 
  51.646 -	gchar* basename = NULL;
  51.647 -	
  51.648 -	g_return_val_if_fail( start_time != NULL, NULL );
  51.649 -	
  51.650 -  gchar *isodate = gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y%m%d%H%M%S", 
  51.651 -  				start_time );
  51.652 +gchar *
  51.653 +gmyth_util_create_filename (const gint chan_id, const GTimeVal * start_time)
  51.654 +{
  51.655 +    gchar *basename = NULL;
  51.656  
  51.657 -	basename = g_strdup_printf( "%d_%s", chan_id, isodate );
  51.658 +    g_return_val_if_fail (start_time != NULL, NULL);
  51.659  
  51.660 -	gmyth_debug ("Basename (from chan_id and start_time): %s", basename);
  51.661 +    gchar *isodate =
  51.662 +        gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y%m%d%H%M%S",
  51.663 +        start_time);
  51.664  
  51.665 -	if (isodate)
  51.666 -  	g_free(isodate);
  51.667 -  
  51.668 -	return basename;
  51.669 +    basename = g_strdup_printf ("%d_%s", chan_id, isodate);
  51.670 +
  51.671 +    gmyth_debug ("Basename (from chan_id and start_time): %s", basename);
  51.672 +
  51.673 +    if (isodate)
  51.674 +        g_free (isodate);
  51.675 +
  51.676 +    return basename;
  51.677  }
  51.678  
  51.679  /** 
  51.680 @@ -521,51 +535,56 @@
  51.681   * @return a pointer to a GList with all the channels.
  51.682   */
  51.683  GList *
  51.684 -gmyth_util_get_channel_list (GMythBackendInfo *backend_info)
  51.685 +gmyth_util_get_channel_list (GMythBackendInfo * backend_info)
  51.686  {
  51.687      GMythRecorder *recorder;
  51.688      GList *channel_list = NULL;
  51.689      gboolean res = FALSE;
  51.690 -    
  51.691 +
  51.692      gmyth_debug ("Gets channel list.");
  51.693  
  51.694      g_return_val_if_fail (backend_info != NULL, FALSE);
  51.695  
  51.696 -    recorder = gmyth_recorder_new ( 1, g_string_new( gmyth_backend_info_get_hostname( backend_info ) ), 
  51.697 -            gmyth_backend_info_get_port( backend_info ) );
  51.698 +    recorder =
  51.699 +        gmyth_recorder_new (1,
  51.700 +        g_string_new (gmyth_backend_info_get_hostname
  51.701 +            (backend_info)), gmyth_backend_info_get_port (backend_info));
  51.702      res = gmyth_recorder_setup (recorder);
  51.703  
  51.704      if (res == TRUE) {
  51.705          //GList* channel_list = gmyth_recorder_get_channel_list( recorder );        
  51.706 -        gmyth_debug( "Yeah, got channel list!!!" );
  51.707 -        GList* ch = NULL;
  51.708 -        GMythChannelInfo* channel_info = NULL;
  51.709 -        
  51.710 -        for ( ch = gmyth_recorder_get_channel_list( recorder ); ch != NULL; )
  51.711 -        {
  51.712 -            channel_info = g_malloc0( sizeof(GMythChannelInfo) );
  51.713 +        gmyth_debug ("Yeah, got channel list!!!");
  51.714 +        GList *ch = NULL;
  51.715 +        GMythChannelInfo *channel_info = NULL;
  51.716 +
  51.717 +        for (ch = gmyth_recorder_get_channel_list (recorder); ch != NULL;) {
  51.718 +            channel_info = g_malloc0 (sizeof (GMythChannelInfo));
  51.719              channel_info->channel_ID = 0;
  51.720 -            channel_info->channel_num = g_string_new ( g_strdup( (gchar*)ch->data ) );
  51.721 +            channel_info->channel_num =
  51.722 +                g_string_new (g_strdup ((gchar *) ch->data));
  51.723              channel_info->channel_name = g_string_new ("");
  51.724 -            gmyth_debug("Printing channel info... (%s)", channel_info->channel_num->str );
  51.725 -            channel_list = g_list_append( channel_list, g_memdup( channel_info, sizeof(GMythChannelInfo) ) );
  51.726 -            
  51.727 -            ch = g_list_next(ch);
  51.728 -            
  51.729 -            if ( channel_info != NULL )
  51.730 -                g_free( channel_info );
  51.731 +            gmyth_debug ("Printing channel info... (%s)",
  51.732 +                channel_info->channel_num->str);
  51.733 +            channel_list =
  51.734 +                g_list_append (channel_list,
  51.735 +                g_memdup (channel_info, sizeof (GMythChannelInfo)));
  51.736 +
  51.737 +            ch = g_list_next (ch);
  51.738 +
  51.739 +            if (channel_info != NULL)
  51.740 +                g_free (channel_info);
  51.741          }
  51.742  
  51.743      } /* if */
  51.744      else {
  51.745 -        gmyth_debug( "No, couldn't get the channel list!!!" );
  51.746 +        gmyth_debug ("No, couldn't get the channel list!!!");
  51.747      }
  51.748 -    
  51.749 -    gmyth_debug( "Got %d channels!!!", g_list_length( channel_list ) );
  51.750 -    
  51.751 -    
  51.752 +
  51.753 +    gmyth_debug ("Got %d channels!!!", g_list_length (channel_list));
  51.754 +
  51.755 +
  51.756      g_object_unref (recorder);
  51.757 -    
  51.758 +
  51.759      return channel_list;
  51.760  }
  51.761  
  51.762 @@ -577,52 +596,53 @@
  51.763   * @return The program info's listage.
  51.764   */
  51.765  GSList *
  51.766 -gmyth_util_get_all_recordings (GMythBackendInfo *backend_info)
  51.767 +gmyth_util_get_all_recordings (GMythBackendInfo * backend_info)
  51.768  {
  51.769      GSList *program_list = NULL;
  51.770      GMythSocket *socket;
  51.771 -    gboolean res;    
  51.772 -    
  51.773 +    gboolean res;
  51.774 +
  51.775      socket = gmyth_socket_new ();
  51.776      res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
  51.777 -            backend_info->port, TRUE);
  51.778 +        backend_info->port, TRUE);
  51.779  
  51.780      if (res == TRUE) {
  51.781          GMythStringList *slist = gmyth_string_list_new ();
  51.782          guint pos = 0;
  51.783 +
  51.784          gmyth_string_list_append_char_array (slist, "QUERY_RECORDINGS Play");
  51.785  
  51.786          gmyth_socket_sendreceive_stringlist (socket, slist);
  51.787  
  51.788 -        if ( slist != NULL && ( gmyth_string_list_length( slist ) > 0 ) )            
  51.789 -        {
  51.790 +        if (slist != NULL && (gmyth_string_list_length (slist) > 0)) {
  51.791              GMythProgramInfo *program = NULL;
  51.792 -            
  51.793 -            gmyth_debug( "OK! Got the program list [size=%d].", gmyth_string_list_length( slist ) );
  51.794 -            
  51.795 -            do
  51.796 -            {                
  51.797 -                program = gmyth_program_info_from_string_list_from_pos( slist, pos );
  51.798 -                
  51.799 -                if ( program != NULL )
  51.800 -                {   
  51.801 +
  51.802 +            gmyth_debug ("OK! Got the program list [size=%d].",
  51.803 +                gmyth_string_list_length (slist));
  51.804 +
  51.805 +            do {
  51.806 +                program =
  51.807 +                    gmyth_program_info_from_string_list_from_pos (slist, pos);
  51.808 +
  51.809 +                if (program != NULL) {
  51.810                      pos += 41;
  51.811 -                    
  51.812 -                    program_list = g_slist_append( program_list, program );
  51.813 +
  51.814 +                    program_list = g_slist_append (program_list, program);
  51.815                  } else
  51.816                      break;
  51.817 -                
  51.818 -            } while ( gmyth_string_list_length( slist ) > pos );
  51.819 -            
  51.820 -        } /* if */
  51.821 -    
  51.822 +
  51.823 +            }
  51.824 +            while (gmyth_string_list_length (slist) > pos);
  51.825 +
  51.826 +        }
  51.827 +        /* if */
  51.828          g_object_unref (slist);
  51.829  
  51.830          gmyth_socket_close_connection (socket);
  51.831      }
  51.832      g_object_unref (socket);
  51.833 -    
  51.834 -    return program_list;    
  51.835 +
  51.836 +    return program_list;
  51.837  }
  51.838  
  51.839  /** 
  51.840 @@ -634,37 +654,37 @@
  51.841   * @return The requested program info.
  51.842   */
  51.843  GMythProgramInfo *
  51.844 -gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, const gchar *channel)
  51.845 +gmyth_util_get_recording_from_channel (GMythBackendInfo * backend_info,
  51.846 +    const gchar * channel)
  51.847  {
  51.848      GSList *program_list = NULL;
  51.849      GMythProgramInfo *program = NULL;
  51.850 -    
  51.851 -    program_list = gmyth_util_get_all_recordings( backend_info );
  51.852  
  51.853 -    if ( program_list != NULL && g_slist_length(program_list) >0 )            
  51.854 -    {
  51.855 +    program_list = gmyth_util_get_all_recordings (backend_info);
  51.856 +
  51.857 +    if (program_list != NULL && g_slist_length (program_list) > 0) {
  51.858          GMythProgramInfo *program = NULL;
  51.859          guint pos = 0;
  51.860 -        
  51.861 -        gmyth_debug( "OK! Got the program list [size=%d].", g_slist_length( program_list ) );
  51.862 -        
  51.863 -        while ( pos < g_slist_length( program_list ) ) 
  51.864 -        {         
  51.865 -            program = (GMythProgramInfo*)g_slist_nth_data( program_list, pos );
  51.866 -            
  51.867 -            if ( program != NULL && program->channame!= NULL && 
  51.868 -                    g_ascii_strncasecmp( program->channame->str, channel, strlen(channel) ) == 0 )
  51.869 -            {   
  51.870 +
  51.871 +        gmyth_debug ("OK! Got the program list [size=%d].",
  51.872 +            g_slist_length (program_list));
  51.873 +
  51.874 +        while (pos < g_slist_length (program_list)) {
  51.875 +            program = (GMythProgramInfo *) g_slist_nth_data (program_list, pos);
  51.876 +
  51.877 +            if (program != NULL && program->channame != NULL &&
  51.878 +                g_ascii_strncasecmp (program->channame->str, channel,
  51.879 +                    strlen (channel)) == 0) {
  51.880                  break;
  51.881              }
  51.882 -            
  51.883 +
  51.884              ++pos;
  51.885 -            
  51.886 -        } /* while */
  51.887 -        
  51.888 -    } /* if */
  51.889 -    
  51.890 -    return program;    
  51.891 +
  51.892 +        }                       /* while */
  51.893 +
  51.894 +    }
  51.895 +    /* if */
  51.896 +    return program;
  51.897  }
  51.898  
  51.899  #if !GLIB_CHECK_VERSION (2, 10, 0)
  51.900 @@ -674,183 +694,171 @@
  51.901  static time_t
  51.902  mktime_utc (struct tm *tm)
  51.903  {
  51.904 -  time_t retval;
  51.905 -  
  51.906 +    time_t retval;
  51.907 +
  51.908  #ifndef HAVE_TIMEGM
  51.909 -  static const gint days_before[] =
  51.910 -  {
  51.911 -    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
  51.912 -  };
  51.913 +    static const gint days_before[] = {
  51.914 +        0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
  51.915 +    };
  51.916  #endif
  51.917  
  51.918  #ifndef HAVE_TIMEGM
  51.919 -  if (tm->tm_mon < 0 || tm->tm_mon > 11)
  51.920 -    return (time_t) -1;
  51.921 +    if (tm->tm_mon < 0 || tm->tm_mon > 11)
  51.922 +        return (time_t) - 1;
  51.923  
  51.924 -  retval = (tm->tm_year - 70) * 365;
  51.925 -  retval += (tm->tm_year - 68) / 4;
  51.926 -  retval += days_before[tm->tm_mon] + tm->tm_mday - 1;
  51.927 -  
  51.928 -  if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
  51.929 -    retval -= 1;
  51.930 -  
  51.931 -  retval = ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
  51.932 +    retval = (tm->tm_year - 70) * 365;
  51.933 +    retval += (tm->tm_year - 68) / 4;
  51.934 +    retval += days_before[tm->tm_mon] + tm->tm_mday - 1;
  51.935 +
  51.936 +    if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
  51.937 +        retval -= 1;
  51.938 +
  51.939 +    retval =
  51.940 +        ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
  51.941  #else
  51.942 -  retval = timegm (tm);
  51.943 +    retval = timegm (tm);
  51.944  #endif /* !HAVE_TIMEGM */
  51.945 -  
  51.946 -  return retval;
  51.947 +
  51.948 +    return retval;
  51.949  }
  51.950  
  51.951  gboolean
  51.952 -g_time_val_from_iso8601 (const gchar *iso_date,
  51.953 -                         GTimeVal    *time_)
  51.954 +g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_)
  51.955  {
  51.956 -  struct tm tm;
  51.957 -  long val;
  51.958 +    struct tm tm;
  51.959 +    long val;
  51.960  
  51.961 -  g_return_val_if_fail (iso_date != NULL, FALSE);
  51.962 -  g_return_val_if_fail (time_ != NULL, FALSE);
  51.963 +    g_return_val_if_fail (iso_date != NULL, FALSE);
  51.964 +    g_return_val_if_fail (time_ != NULL, FALSE);
  51.965  
  51.966 -  val = strtoul (iso_date, (char **)&iso_date, 10);
  51.967 -  if (*iso_date == '-')
  51.968 -    {
  51.969 -      /* YYYY-MM-DD */
  51.970 -      tm.tm_year = val - 1900;
  51.971 -      iso_date++;
  51.972 -      tm.tm_mon = strtoul (iso_date, (char **)&iso_date, 10) - 1;
  51.973 -      
  51.974 -      if (*iso_date++ != '-')
  51.975 -        return FALSE;
  51.976 -      
  51.977 -      tm.tm_mday = strtoul (iso_date, (char **)&iso_date, 10);
  51.978 -    }
  51.979 -  else
  51.980 -    {
  51.981 -      /* YYYYMMDD */
  51.982 -      tm.tm_mday = val % 100;
  51.983 -      tm.tm_mon = (val % 10000) / 100 - 1;
  51.984 -      tm.tm_year = val / 10000 - 1900;
  51.985 +    val = strtoul (iso_date, (char **) &iso_date, 10);
  51.986 +    if (*iso_date == '-') {
  51.987 +        /* YYYY-MM-DD */
  51.988 +        tm.tm_year = val - 1900;
  51.989 +        iso_date++;
  51.990 +        tm.tm_mon = strtoul (iso_date, (char **) &iso_date, 10) - 1;
  51.991 +
  51.992 +        if (*iso_date++ != '-')
  51.993 +            return FALSE;
  51.994 +
  51.995 +        tm.tm_mday = strtoul (iso_date, (char **) &iso_date, 10);
  51.996 +    } else {
  51.997 +        /* YYYYMMDD */
  51.998 +        tm.tm_mday = val % 100;
  51.999 +        tm.tm_mon = (val % 10000) / 100 - 1;
 51.1000 +        tm.tm_year = val / 10000 - 1900;
 51.1001      }
 51.1002  
 51.1003 -  if (*iso_date++ != 'T')
 51.1004 -    return FALSE;
 51.1005 -  
 51.1006 -  val = strtoul (iso_date, (char **)&iso_date, 10);
 51.1007 -  if (*iso_date == ':')
 51.1008 -    {
 51.1009 -      /* hh:mm:ss */
 51.1010 -      tm.tm_hour = val;
 51.1011 -      iso_date++;
 51.1012 -      tm.tm_min = strtoul (iso_date, (char **)&iso_date, 10);
 51.1013 -      
 51.1014 -      if (*iso_date++ != ':')
 51.1015 +    if (*iso_date++ != 'T')
 51.1016          return FALSE;
 51.1017 -      
 51.1018 -      tm.tm_sec = strtoul (iso_date, (char **)&iso_date, 10);
 51.1019 -    }
 51.1020 -  else
 51.1021 -    {
 51.1022 -      /* hhmmss */
 51.1023 -      tm.tm_sec = val % 100;
 51.1024 -      tm.tm_min = (val % 10000) / 100;
 51.1025 -      tm.tm_hour = val / 10000;
 51.1026 +
 51.1027 +    val = strtoul (iso_date, (char **) &iso_date, 10);
 51.1028 +    if (*iso_date == ':') {
 51.1029 +        /* hh:mm:ss */
 51.1030 +        tm.tm_hour = val;
 51.1031 +        iso_date++;
 51.1032 +        tm.tm_min = strtoul (iso_date, (char **) &iso_date, 10);
 51.1033 +
 51.1034 +        if (*iso_date++ != ':')
 51.1035 +            return FALSE;
 51.1036 +
 51.1037 +        tm.tm_sec = strtoul (iso_date, (char **) &iso_date, 10);
 51.1038 +    } else {
 51.1039 +        /* hhmmss */
 51.1040 +        tm.tm_sec = val % 100;
 51.1041 +        tm.tm_min = (val % 10000) / 100;
 51.1042 +        tm.tm_hour = val / 10000;
 51.1043      }
 51.1044  
 51.1045 -  time_->tv_sec = mktime_utc (&tm);
 51.1046 -  time_->tv_usec = 1;
 51.1047 -  
 51.1048 -  if (*iso_date == '.')
 51.1049 -    time_->tv_usec = strtoul (iso_date + 1, (char **)&iso_date, 10);
 51.1050 -    
 51.1051 -  if (*iso_date == '+' || *iso_date == '-')
 51.1052 -    {
 51.1053 -      gint sign = (*iso_date == '+') ? -1 : 1;
 51.1054 -      
 51.1055 -      val = 60 * strtoul (iso_date + 1, (char **)&iso_date, 10);
 51.1056 -      
 51.1057 -      if (*iso_date == ':')
 51.1058 -    val = 60 * val + strtoul (iso_date + 1, NULL, 10);
 51.1059 -      else
 51.1060 -        val = 60 * (val / 100) + (val % 100);
 51.1061 +    time_->tv_sec = mktime_utc (&tm);
 51.1062 +    time_->tv_usec = 1;
 51.1063  
 51.1064 -      time_->tv_sec += (time_t) (val * sign);
 51.1065 +    if (*iso_date == '.')
 51.1066 +        time_->tv_usec = strtoul (iso_date + 1, (char **) &iso_date, 10);
 51.1067 +
 51.1068 +    if (*iso_date == '+' || *iso_date == '-') {
 51.1069 +        gint sign = (*iso_date == '+') ? -1 : 1;
 51.1070 +
 51.1071 +        val = 60 * strtoul (iso_date + 1, (char **) &iso_date, 10);
 51.1072 +
 51.1073 +        if (*iso_date == ':')
 51.1074 +            val = 60 * val + strtoul (iso_date + 1, NULL, 10);
 51.1075 +        else
 51.1076 +            val = 60 * (val / 100) + (val % 100);
 51.1077 +
 51.1078 +        time_->tv_sec += (time_t) (val * sign);
 51.1079      }
 51.1080  
 51.1081 -  return TRUE;
 51.1082 +    return TRUE;
 51.1083  }
 51.1084  
 51.1085  
 51.1086  gchar *
 51.1087 -g_time_val_to_iso8601 (GTimeVal *time_)
 51.1088 +g_time_val_to_iso8601 (GTimeVal * time_)
 51.1089  {
 51.1090 -  gchar *retval;
 51.1091 +    gchar *retval;
 51.1092  
 51.1093 -  g_return_val_if_fail (time_->tv_usec >= 0 && time_->tv_usec < G_USEC_PER_SEC, NULL);
 51.1094 +    g_return_val_if_fail (time_->tv_usec >= 0
 51.1095 +        && time_->tv_usec < G_USEC_PER_SEC, NULL);
 51.1096  
 51.1097  #define ISO_8601_LEN    21
 51.1098  #define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ"
 51.1099 -  retval = g_new0 (gchar, ISO_8601_LEN + 1);
 51.1100 -  
 51.1101 -  strftime (retval, ISO_8601_LEN,
 51.1102 -        ISO_8601_FORMAT,
 51.1103 -        gmtime (&(time_->tv_sec)));
 51.1104 -  
 51.1105 -  return retval;
 51.1106 +    retval = g_new0 (gchar, ISO_8601_LEN + 1);
 51.1107 +
 51.1108 +    strftime (retval, ISO_8601_LEN, ISO_8601_FORMAT, gmtime (&(time_->tv_sec)));
 51.1109 +
 51.1110 +    return retval;
 51.1111  }
 51.1112  
 51.1113  
 51.1114  /* Hacked from glib 2.10 <gdate.c> */
 51.1115  
 51.1116 -void         
 51.1117 -g_date_set_time_t (GDate *date,
 51.1118 -           time_t timet)
 51.1119 +void
 51.1120 +g_date_set_time_t (GDate * date, time_t timet)
 51.1121  {
 51.1122 -  struct tm tm;
 51.1123 -  
 51.1124 -  g_return_if_fail (date != NULL);
 51.1125 -  
 51.1126 +    struct tm tm;
 51.1127 +
 51.1128 +    g_return_if_fail (date != NULL);
 51.1129 +
 51.1130  #ifdef HAVE_LOCALTIME_R
 51.1131 -  localtime_r (&timet, &tm);
 51.1132 +    localtime_r (&timet, &tm);
 51.1133  #else
 51.1134 -  {
 51.1135 -    struct tm *ptm = localtime (&timet);
 51.1136 +    {
 51.1137 +        struct tm *ptm = localtime (&timet);
 51.1138  
 51.1139 -    if (ptm == NULL)
 51.1140 -      {
 51.1141 -    /* Happens at least in Microsoft's C library if you pass a
 51.1142 -     * negative time_t. Use 2000-01-01 as default date.
 51.1143 -     */
 51.1144 +        if (ptm == NULL) {
 51.1145 +            /* Happens at least in Microsoft's C library if you pass a
 51.1146 +             * negative time_t. Use 2000-01-01 as default date.
 51.1147 +             */
 51.1148  #ifndef G_DISABLE_CHECKS
 51.1149 -    g_return_if_fail_warning (G_LOG_DOMAIN, "g_date_set_time", "ptm != NULL");
 51.1150 +            g_return_if_fail_warning (G_LOG_DOMAIN, "g_date_set_time",
 51.1151 +                "ptm != NULL");
 51.1152  #endif
 51.1153  
 51.1154 -    tm.tm_mon = 0;
 51.1155 -    tm.tm_mday = 1;
 51.1156 -    tm.tm_year = 100;
 51.1157 -      }
 51.1158 -    else
 51.1159 -      memcpy ((void *) &tm, (void *) ptm, sizeof(struct tm));
 51.1160 -  }
 51.1161 +            tm.tm_mon = 0;
 51.1162 +            tm.tm_mday = 1;
 51.1163 +            tm.tm_year = 100;
 51.1164 +        } else
 51.1165 +            memcpy ((void *) &tm, (void *) ptm, sizeof (struct tm));
 51.1166 +    }
 51.1167  #endif
 51.1168 -  
 51.1169 -  date->julian = FALSE;
 51.1170 -  
 51.1171 -  date->month = tm.tm_mon + 1;
 51.1172 -  date->day   = tm.tm_mday;
 51.1173 -  date->year  = tm.tm_year + 1900;
 51.1174 -  
 51.1175 -  g_return_if_fail (g_date_valid_dmy (date->day, date->month, date->year));
 51.1176 -  
 51.1177 -  date->dmy    = TRUE;
 51.1178 +
 51.1179 +    date->julian = FALSE;
 51.1180 +
 51.1181 +    date->month = tm.tm_mon + 1;
 51.1182 +    date->day = tm.tm_mday;
 51.1183 +    date->year = tm.tm_year + 1900;
 51.1184 +
 51.1185 +    g_return_if_fail (g_date_valid_dmy (date->day, date->month, date->year));
 51.1186 +
 51.1187 +    date->dmy = TRUE;
 51.1188  }
 51.1189  
 51.1190  
 51.1191  void
 51.1192 -g_date_set_time_val (GDate    *date,
 51.1193 -             GTimeVal *timeval)
 51.1194 +g_date_set_time_val (GDate * date, GTimeVal * timeval)
 51.1195  {
 51.1196 -  g_date_set_time_t (date, (time_t) timeval->tv_sec);
 51.1197 +    g_date_set_time_t (date, (time_t) timeval->tv_sec);
 51.1198  }
 51.1199  
 51.1200  
    52.1 --- a/gmyth/src/gmyth_util.h	Tue May 22 19:21:42 2007 +0100
    52.2 +++ b/gmyth/src/gmyth_util.h	Wed May 23 16:11:29 2007 +0100
    52.3 @@ -10,22 +10,22 @@
    52.4   * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
    52.5   * @author Rosfran Borges <rosfran.borges@indt.org.br>
    52.6   *
    52.7 - *//*
    52.8 - * 
    52.9 - * This program is free software; you can redistribute it and/or modify
   52.10 - * it under the terms of the GNU Lesser General Public License as published by
   52.11 - * the Free Software Foundation; either version 2 of the License, or
   52.12 - * (at your option) any later version.
   52.13 - *
   52.14 - * This program is distributed in the hope that it will be useful,
   52.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   52.17 - * GNU General Public License for more details.
   52.18 - *
   52.19 - * You should have received a copy of the GNU Lesser General Public License
   52.20 - * along with this program; if not, write to the Free Software
   52.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   52.22 - */
   52.23 +                                                                                                                                                                                                                                                                                                                                                                                              *//*
   52.24 +                                                                                                                                                                                                 * 
   52.25 +                                                                                                                                                                                                 * This program is free software; you can redistribute it and/or modify
   52.26 +                                                                                                                                                                                                 * it under the terms of the GNU Lesser General Public License as published by
   52.27 +                                                                                                                                                                                                 * the Free Software Foundation; either version 2 of the License, or
   52.28 +                                                                                                                                                                                                 * (at your option) any later version.
   52.29 +                                                                                                                                                                                                 *
   52.30 +                                                                                                                                                                                                 * This program is distributed in the hope that it will be useful,
   52.31 +                                                                                                                                                                                                 * but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.32 +                                                                                                                                                                                                 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   52.33 +                                                                                                                                                                                                 * GNU General Public License for more details.
   52.34 +                                                                                                                                                                                                 *
   52.35 +                                                                                                                                                                                                 * You should have received a copy of the GNU Lesser General Public License
   52.36 +                                                                                                                                                                                                 * along with this program; if not, write to the Free Software
   52.37 +                                                                                                                                                                                                 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   52.38 +                                                                                                                                                                                                 */
   52.39  
   52.40  #ifndef GMYTH_UTIL_H_
   52.41  #define GMYTH_UTIL_H_
   52.42 @@ -37,43 +37,44 @@
   52.43  #include "gmyth_backendinfo.h"
   52.44  #include "gmyth_programinfo.h"
   52.45  
   52.46 -G_BEGIN_DECLS
   52.47 +G_BEGIN_DECLS GString *gmyth_util_time_to_isoformat (time_t time_value);
   52.48 +GString *gmyth_util_time_to_string (time_t time_value);
   52.49 +time_t gmyth_util_string_to_time (GString * time_str);
   52.50  
   52.51 -GString 		*gmyth_util_time_to_isoformat(time_t time_value);
   52.52 -GString 		*gmyth_util_time_to_string   (time_t time_value);
   52.53 -time_t      gmyth_util_string_to_time   (GString* time_str);
   52.54 +gchar *gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar *
   52.55 +    fmt_string, const GTimeVal * time_val);
   52.56  
   52.57 -gchar* 			gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar *fmt_string, const GTimeVal* time_val );
   52.58 +GTimeVal *gmyth_util_string_to_time_val_fmt (const gchar * fmt_string,
   52.59 +    const gchar * time_str);
   52.60  
   52.61 -GTimeVal		*gmyth_util_string_to_time_val_fmt ( const gchar *fmt_string, const gchar* time_str );
   52.62 +GTimeVal *gmyth_util_string_to_time_val (const gchar * time_str);
   52.63  
   52.64 -GTimeVal		*gmyth_util_string_to_time_val ( const gchar* time_str );
   52.65 +gchar *gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time);
   52.66 +gchar *gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time);
   52.67  
   52.68 -gchar 			*gmyth_util_time_to_isoformat_from_time_val( const GTimeVal *time);
   52.69 -gchar			*gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal* time );
   52.70 +gchar *gmyth_util_time_to_string_only_date (const GTimeVal * time);
   52.71  
   52.72 -gchar				*gmyth_util_time_to_string_only_date ( const GTimeVal* time );
   52.73 +gchar *gmyth_util_time_to_string_only_time (const GTimeVal * time);
   52.74  
   52.75 -gchar				*gmyth_util_time_to_string_only_time ( const GTimeVal* time );
   52.76 +gchar *gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val);
   52.77  
   52.78 -gchar				*gmyth_util_time_to_string_from_time_val ( const GTimeVal *time_val );
   52.79 +struct tm *gmyth_util_time_val_to_date (const GTimeVal * time);
   52.80  
   52.81 -struct tm		*gmyth_util_time_val_to_date ( const GTimeVal* time );
   52.82 +gboolean gmyth_util_file_exists (GMythBackendInfo * backend_info,
   52.83 +    const gchar * filename);
   52.84  
   52.85 -gboolean 		gmyth_util_file_exists (GMythBackendInfo *backend_info, const gchar* filename);
   52.86 +gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *
   52.87 +    backend_info, const gchar * filename, gchar ** current_dir);
   52.88  
   52.89 -gboolean		gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *backend_info, 
   52.90 -											const gchar* filename, gchar** current_dir);
   52.91 +gchar *gmyth_util_create_filename (const gint chan_id,
   52.92 +    const GTimeVal * start_time);
   52.93  
   52.94 -gchar*			gmyth_util_create_filename( const gint chan_id, const GTimeVal* start_time );
   52.95 +GList *gmyth_util_get_channel_list (GMythBackendInfo * backend_info);
   52.96  
   52.97 -GList *         gmyth_util_get_channel_list (GMythBackendInfo *backend_info);
   52.98 +GSList *gmyth_util_get_all_recordings (GMythBackendInfo * backend_info);
   52.99  
  52.100 -GSList *        gmyth_util_get_all_recordings (GMythBackendInfo *backend_info);
  52.101 -
  52.102 -GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo *backend_info, 
  52.103 -                        const gchar *channel);
  52.104 +GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo *
  52.105 +    backend_info, const gchar * channel);
  52.106  
  52.107  G_END_DECLS
  52.108 -	
  52.109 -#endif /*GMYTH_UTIL_H_*/
  52.110 +#endif /*GMYTH_UTIL_H_ */
    53.1 --- a/gmyth/src/gmyth_vlc.c	Tue May 22 19:21:42 2007 +0100
    53.2 +++ b/gmyth/src/gmyth_vlc.c	Wed May 23 16:11:29 2007 +0100
    53.3 @@ -24,7 +24,7 @@
    53.4   * along with this program; if not, write to the Free Software
    53.5   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    53.6   */
    53.7 - 
    53.8 +
    53.9  #ifdef HAVE_CONFIG_H
   53.10  #include "config.h"
   53.11  #endif
   53.12 @@ -36,8 +36,8 @@
   53.13  #include "gmyth_socket.h"
   53.14  
   53.15  /* static functions */
   53.16 -static int _socket_send(int socket, gchar* msg);
   53.17 -static int _socket_recv(int socket, gchar* buf);
   53.18 +static int _socket_send (int socket, gchar * msg);
   53.19 +static int _socket_recv (int socket, gchar * buf);
   53.20  
   53.21  /** Primitive function to send a message through the socket
   53.22   *
   53.23 @@ -45,17 +45,18 @@
   53.24   * @param msg the message itself
   53.25   * @return 0 if success
   53.26   */
   53.27 -static int 
   53.28 -_socket_send(int socket, gchar* msg)
   53.29 -{  
   53.30 -  size_t size = strlen(msg) + 2; // (\n + \0)
   53.31 -    gchar* final = (gchar *)g_malloc0(sizeof(gchar) * size);
   53.32 -    g_snprintf(final, size, "%s\n", msg);
   53.33 +static int
   53.34 +_socket_send (int socket, gchar * msg)
   53.35 +{
   53.36 +    size_t size = strlen (msg) + 2; // (\n + \0)
   53.37 +    gchar *final = (gchar *) g_malloc0 (sizeof (gchar) * size);
   53.38  
   53.39 -    if (send(socket, final, strlen(final), 0) == -1)
   53.40 -      perror("GMyth_VLC: send error");
   53.41 +    g_snprintf (final, size, "%s\n", msg);
   53.42  
   53.43 -    g_free(final);
   53.44 +    if (send (socket, final, strlen (final), 0) == -1)
   53.45 +        perror ("GMyth_VLC: send error");
   53.46 +
   53.47 +    g_free (final);
   53.48      return 0;
   53.49  }
   53.50  
   53.51 @@ -66,19 +67,18 @@
   53.52   * @param buf Buffer to put the message
   53.53   * @return 0 if success
   53.54   */
   53.55 -static int 
   53.56 -_socket_recv(int socket, gchar* buf)
   53.57 +static int
   53.58 +_socket_recv (int socket, gchar * buf)
   53.59  {
   53.60 -  int numbytes = 0;
   53.61 +    int numbytes = 0;
   53.62  
   53.63 -  if ((numbytes=recv(socket, buf, BUFFER-1, 0)) == -1) 
   53.64 -  {
   53.65 -    perror("GMyth_VLC: recv error");
   53.66 -    return -1;
   53.67 -  }
   53.68 +    if ((numbytes = recv (socket, buf, BUFFER - 1, 0)) == -1) {
   53.69 +        perror ("GMyth_VLC: recv error");
   53.70 +        return -1;
   53.71 +    }
   53.72  
   53.73 -  buf[numbytes-1] = '\0';
   53.74 -  return numbytes;
   53.75 +    buf[numbytes - 1] = '\0';
   53.76 +    return numbytes;
   53.77  }
   53.78  
   53.79  
   53.80 @@ -90,20 +90,19 @@
   53.81   * @param the params for the option
   53.82   * @return 0 if success
   53.83   */
   53.84 -int 
   53.85 -gmyth_vlc_setup_output(GMythVlc *vlc, int output, \
   53.86 -                           gchar* kind, gchar* opts)
   53.87 +int
   53.88 +gmyth_vlc_setup_output (GMythVlc * vlc, int output, gchar * kind, gchar * opts)
   53.89  {
   53.90      int ret;
   53.91  
   53.92 -    size_t size = strlen(opts) + 25;
   53.93 -    gchar* msg = g_malloc0(sizeof(gchar) * size);
   53.94 -    g_snprintf(msg, size, "setup output%d %s %s", output,\
   53.95 -               kind, opts);
   53.96 +    size_t size = strlen (opts) + 25;
   53.97 +    gchar *msg = g_malloc0 (sizeof (gchar) * size);
   53.98  
   53.99 -    ret = _socket_send(vlc->sockfd, msg);
  53.100 +    g_snprintf (msg, size, "setup output%d %s %s", output, kind, opts);
  53.101  
  53.102 -    g_free(msg);
  53.103 +    ret = _socket_send (vlc->sockfd, msg);
  53.104 +
  53.105 +    g_free (msg);
  53.106      return ret;
  53.107  }
  53.108  
  53.109 @@ -115,10 +114,10 @@
  53.110   * @param file the file we want to insert in the playlist
  53.111   * @return 0 if success
  53.112   */
  53.113 -int 
  53.114 -gmyth_vlc_clean_playlist(GMythVlc *vlc)
  53.115 +int
  53.116 +gmyth_vlc_clean_playlist (GMythVlc * vlc)
  53.117  {
  53.118 -  return _socket_send(vlc->sockfd, "del all");
  53.119 +    return _socket_send (vlc->sockfd, "del all");
  53.120  }
  53.121  
  53.122  
  53.123 @@ -129,18 +128,17 @@
  53.124   * @param command play, stop or pause(just for vod)
  53.125   * @return 0 if success
  53.126   */
  53.127 -int 
  53.128 -gmyth_vlc_control_input(GMythVlc *vlc, int output, \
  53.129 -                           gchar* command)
  53.130 +int
  53.131 +gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command)
  53.132  {
  53.133      size_t size = 25;
  53.134 -    gchar* msg = g_malloc0(sizeof(gchar) * size);
  53.135 -    g_snprintf(msg, size, "control output%d %s", output,\
  53.136 -               command);
  53.137 +    gchar *msg = g_malloc0 (sizeof (gchar) * size);
  53.138  
  53.139 -    int ret = _socket_send(vlc->sockfd, msg);
  53.140 -    
  53.141 -    g_free(msg);
  53.142 +    g_snprintf (msg, size, "control output%d %s", output, command);
  53.143 +
  53.144 +    int ret = _socket_send (vlc->sockfd, msg);
  53.145 +
  53.146 +    g_free (msg);
  53.147      return ret;
  53.148  }
  53.149  
  53.150 @@ -153,12 +151,10 @@
  53.151   * @param file the file we want to insert in the playlist
  53.152   * @return 0 if success
  53.153   */
  53.154 -int 
  53.155 -gmyth_vlc_create_input(GMythVlc *vlc, int output,\
  53.156 -                           gchar* file)
  53.157 +int
  53.158 +gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file)
  53.159  {
  53.160 -    return gmyth_vlc_setup_output(vlc, output, "input",\
  53.161 -                                  file);
  53.162 +    return gmyth_vlc_setup_output (vlc, output, "input", file);
  53.163  }
  53.164  
  53.165  
  53.166 @@ -169,51 +165,44 @@
  53.167   * @param port
  53.168   * @return 0 if success
  53.169   */
  53.170 -int 
  53.171 -gmyth_vlc_create_channel(GMythVlc *vlc, gchar* type,\
  53.172 -                             int port, int vcodec)
  53.173 +int
  53.174 +gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type, int port, int vcodec)
  53.175  {
  53.176      int ret;
  53.177      size_t size = 40;
  53.178 -    gchar* msg = (gchar *)g_malloc0(sizeof(gchar) * size);
  53.179 -    g_snprintf(msg, size, "new output%d %s enabled loop", \
  53.180 -             vlc->n_outputs, type);
  53.181 +    gchar *msg = (gchar *) g_malloc0 (sizeof (gchar) * size);
  53.182  
  53.183 -    ret = _socket_send(vlc->sockfd, msg);
  53.184 +    g_snprintf (msg, size, "new output%d %s enabled loop",
  53.185 +        vlc->n_outputs, type);
  53.186  
  53.187 -    if (ret > -1)
  53.188 -    {
  53.189 -      gmyth_vlc_setup_output(vlc, vlc->n_outputs, "option", \
  53.190 -                           "sout-keep=1");
  53.191 -    
  53.192 -      g_free(msg);
  53.193 -      size = 256;
  53.194 -      msg = (gchar *)g_malloc0(sizeof(gchar) * size);
  53.195 +    ret = _socket_send (vlc->sockfd, msg);
  53.196  
  53.197 -      if ( vcodec == MPEG1 )
  53.198 +    if (ret > -1) {
  53.199 +        gmyth_vlc_setup_output (vlc, vlc->n_outputs, "option", "sout-keep=1");
  53.200  
  53.201 -        // Best transcode option for N800 (MP1V)
  53.202 -        g_snprintf(msg, size, "#transcode{vcodec=mp1v,vb=384,"
  53.203 -                              "fps=25.0,scale=1,acodec=mpga,"
  53.204 -                              "ab=64,channels=1}:duplicate{dst="
  53.205 -                              "std{access=http,mux=mpeg1,dst="
  53.206 -                              ":%d}}", port);
  53.207 -      else
  53.208 +        g_free (msg);
  53.209 +        size = 256;
  53.210 +        msg = (gchar *) g_malloc0 (sizeof (gchar) * size);
  53.211  
  53.212 -        // Best transcode option for N800 (THEORA)
  53.213 -        g_snprintf(msg, size, "#transcode{vcodec=theo,vb=384,"
  53.214 -                              "fps=25.0,scale=1,acodec=vorb,"
  53.215 -                              "ab=64,channels=1}:duplicate{dst="
  53.216 -                              "std{access=http,mux=ogg,dst="
  53.217 -                              ":%d}}", port);
  53.218 +        if (vcodec == MPEG1)
  53.219 +            // Best transcode option for N800 (MP1V)
  53.220 +            g_snprintf (msg, size, "#transcode{vcodec=mp1v,vb=384,"
  53.221 +                "fps=25.0,scale=1,acodec=mpga,"
  53.222 +                "ab=64,channels=1}:duplicate{dst="
  53.223 +                "std{access=http,mux=mpeg1,dst=" ":%d}}", port);
  53.224 +        else
  53.225 +            // Best transcode option for N800 (THEORA)
  53.226 +            g_snprintf (msg, size, "#transcode{vcodec=theo,vb=384,"
  53.227 +                "fps=25.0,scale=1,acodec=vorb,"
  53.228 +                "ab=64,channels=1}:duplicate{dst="
  53.229 +                "std{access=http,mux=ogg,dst=" ":%d}}", port);
  53.230  
  53.231 -      ret = gmyth_vlc_setup_output(vlc, vlc->n_outputs, "output", \
  53.232 -                                   msg);
  53.233 -      
  53.234 -      vlc->n_outputs++;
  53.235 +        ret = gmyth_vlc_setup_output (vlc, vlc->n_outputs, "output", msg);
  53.236 +
  53.237 +        vlc->n_outputs++;
  53.238      }
  53.239  
  53.240 -    g_free(msg);
  53.241 +    g_free (msg);
  53.242  
  53.243      return ret;
  53.244  }
  53.245 @@ -226,58 +215,51 @@
  53.246   * @param passwd the password for telnet interface
  53.247   * @return 0 if success
  53.248   */
  53.249 -int 
  53.250 -gmyth_vlc_connect(GMythVlc *vlc, GMythBackendInfo *backend_info,\
  53.251 -                      gchar* passwd, int port)
  53.252 +int
  53.253 +gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info,
  53.254 +    gchar * passwd, int port)
  53.255  {
  53.256 -    int numbytes;  
  53.257 -    
  53.258 -    if ((vlc->he=gethostbyname(backend_info->hostname)) == NULL) 
  53.259 -    { 
  53.260 -      herror("GMyth_VLC: gethostbyname error");
  53.261 -      return -1;
  53.262 -    }
  53.263 -      
  53.264 -    if ((vlc->sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) 
  53.265 -    {
  53.266 -        perror("GMyth_VLC: socket error");
  53.267 +    int numbytes;
  53.268 +
  53.269 +    if ((vlc->he = gethostbyname (backend_info->hostname)) == NULL) {
  53.270 +        herror ("GMyth_VLC: gethostbyname error");
  53.271          return -1;
  53.272      }
  53.273 -      
  53.274 +
  53.275 +    if ((vlc->sockfd = socket (PF_INET, SOCK_STREAM, 0)) == -1) {
  53.276 +        perror ("GMyth_VLC: socket error");
  53.277 +        return -1;
  53.278 +    }
  53.279      // Socket properties
  53.280 -    vlc->their_addr.sin_family = AF_INET; 
  53.281 -    vlc->their_addr.sin_port = htons(port); 
  53.282 -    vlc->their_addr.sin_addr = *((struct in_addr *)vlc->he->h_addr);
  53.283 -    memset(&(vlc->their_addr.sin_zero), '\0', 8);
  53.284 -    
  53.285 -    if (connect(vlc->sockfd, (struct sockaddr *)&(vlc->their_addr),
  53.286 -                sizeof(struct sockaddr)) == -1) 
  53.287 -    {
  53.288 -      perror("GMyth_VLC: connect error. Check VLC's telnet interface");
  53.289 -      return -1;
  53.290 +    vlc->their_addr.sin_family = AF_INET;
  53.291 +    vlc->their_addr.sin_port = htons (port);
  53.292 +    vlc->their_addr.sin_addr = *((struct in_addr *) vlc->he->h_addr);
  53.293 +    memset (&(vlc->their_addr.sin_zero), '\0', 8);
  53.294 +
  53.295 +    if (connect (vlc->sockfd, (struct sockaddr *) &(vlc->their_addr),
  53.296 +            sizeof (struct sockaddr)) == -1) {
  53.297 +        perror ("GMyth_VLC: connect error. Check VLC's telnet interface");
  53.298 +        return -1;
  53.299      }
  53.300 -
  53.301 -
  53.302      // Receive the Password's Prompt
  53.303 -    numbytes = _socket_recv(vlc->sockfd, vlc->buf);
  53.304 +    numbytes = _socket_recv (vlc->sockfd, vlc->buf);
  53.305  
  53.306      // Send the Password. We don't have to
  53.307      // care about passwords being sent in plain text
  53.308      // because telnet protocol does it.
  53.309 -    _socket_send(vlc->sockfd, passwd);
  53.310 +    _socket_send (vlc->sockfd, passwd);
  53.311  
  53.312      // Receive the Welcome msg
  53.313 -    numbytes = _socket_recv(vlc->sockfd, vlc->buf);
  53.314 +    numbytes = _socket_recv (vlc->sockfd, vlc->buf);
  53.315      if (numbytes > -1)
  53.316 -      if (strncmp(vlc->buf,"\r\nWrong password.", 17) == 0)
  53.317 -      {
  53.318 -        perror("Gmyth_VLC: passwd error. Check your passwd");
  53.319 -        return -2;
  53.320 -      }
  53.321 -    
  53.322 -    
  53.323 +        if (strncmp (vlc->buf, "\r\nWrong password.", 17) == 0) {
  53.324 +            perror ("Gmyth_VLC: passwd error. Check your passwd");
  53.325 +            return -2;
  53.326 +        }
  53.327 +
  53.328 +
  53.329      return 0;
  53.330 -} 
  53.331 +}
  53.332  
  53.333  
  53.334  /** Function to disconnect from vlc
  53.335 @@ -286,19 +268,18 @@
  53.336   * @param backend_info infos about the backend
  53.337   * @return 0 if success
  53.338   */
  53.339 -int 
  53.340 -gmyth_vlc_disconnect(GMythVlc *vlc)
  53.341 +int
  53.342 +gmyth_vlc_disconnect (GMythVlc * vlc)
  53.343  {
  53.344  
  53.345      int ret;
  53.346  
  53.347 -    ret = gmyth_vlc_clean_playlist(vlc);
  53.348 +    ret = gmyth_vlc_clean_playlist (vlc);
  53.349  
  53.350 -    if (ret > -1)
  53.351 -    {
  53.352 -      vlc->n_outputs = 0;
  53.353 -      vlc->n_inputs = 0;
  53.354 +    if (ret > -1) {
  53.355 +        vlc->n_outputs = 0;
  53.356 +        vlc->n_inputs = 0;
  53.357      }
  53.358  
  53.359 -    return close(vlc->sockfd);
  53.360 +    return close (vlc->sockfd);
  53.361  }
    54.1 --- a/gmyth/src/gmyth_vlc.h	Tue May 22 19:21:42 2007 +0100
    54.2 +++ b/gmyth/src/gmyth_vlc.h	Wed May 23 16:11:29 2007 +0100
    54.3 @@ -46,56 +46,49 @@
    54.4  #include "gmyth_util.h"
    54.5  
    54.6  G_BEGIN_DECLS
    54.7 -
    54.8  #define VLC_TELNET_PORT 4212
    54.9  #define BUFFER 512
   54.10 -
   54.11  #define MPEG1 0
   54.12  #define THEORA 1
   54.13 -
   54.14 -
   54.15  typedef struct _GMythVlc GMythVlc;
   54.16  
   54.17  struct _GMythVlc
   54.18  {
   54.19 -  int sockfd;
   54.20 +    int sockfd;
   54.21  
   54.22 -  // Number of outputs used
   54.23 -  int n_outputs;
   54.24 +    // Number of outputs used
   54.25 +    int n_outputs;
   54.26  
   54.27 -  // Number of inputs
   54.28 -  int n_inputs;
   54.29 +    // Number of inputs
   54.30 +    int n_inputs;
   54.31  
   54.32 -  // Socket vars
   54.33 -  struct hostent *he;
   54.34 -  struct sockaddr_in their_addr;
   54.35 +    // Socket vars
   54.36 +    struct hostent *he;
   54.37 +    struct sockaddr_in their_addr;
   54.38  
   54.39 -  char buf[BUFFER];
   54.40 +    char buf[BUFFER];
   54.41  };
   54.42  
   54.43  
   54.44  
   54.45 -int gmyth_vlc_setup_output(GMythVlc *vlc, int output, \
   54.46 -                           gchar* kind, gchar* opts);
   54.47 +int gmyth_vlc_setup_output (GMythVlc * vlc, int output,
   54.48 +    gchar * kind, gchar * opts);
   54.49  
   54.50  
   54.51 -int gmyth_vlc_clean_playlist(GMythVlc *vlc);
   54.52 +int gmyth_vlc_clean_playlist (GMythVlc * vlc);
   54.53  
   54.54  
   54.55 -int gmyth_vlc_control_input(GMythVlc *vlc, int output, \
   54.56 -                            gchar* command);
   54.57 +int gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command);
   54.58  
   54.59 -int gmyth_vlc_create_input(GMythVlc *vlc, int output,\
   54.60 -                           gchar* file);
   54.61 +int gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file);
   54.62  
   54.63 -int gmyth_vlc_create_channel(GMythVlc *vlc, gchar* type,\
   54.64 -                             int port, int vcodec);
   54.65 +int gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type,
   54.66 +    int port, int vcodec);
   54.67  
   54.68 -int gmyth_vlc_connect(GMythVlc *vlc, GMythBackendInfo *backend_info,\
   54.69 -                      gchar* passwd, int port);
   54.70 +int gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info,
   54.71 +    gchar * passwd, int port);
   54.72  
   54.73 -int gmyth_vlc_disconnect(GMythVlc *vlc);
   54.74 +int gmyth_vlc_disconnect (GMythVlc * vlc);
   54.75  
   54.76  G_END_DECLS
   54.77 -
   54.78  #endif /* __GMYTH_VLC_H__ */