[svn r267] Added gmyth_http to handle HTTP queries to port 6544 on the backend trunk
authormorphbr
Thu Jan 11 19:07:35 2007 +0000 (2007-01-11)
branchtrunk
changeset 2661098f58ae8e1
parent 265 c7050cb68338
child 267 55e1c59ed983
[svn r267] Added gmyth_http to handle HTTP queries to port 6544 on the backend
gmyth/src/Makefile.am
gmyth/src/gmyth.h
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_http.c
gmyth/src/gmyth_http.h
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_monitor_handler.c
gmyth/src/gmyth_recorder.c
gmyth/src/gmyth_scheduler.c
gmyth/src/gmyth_socket.c
gmyth/src/gmyth_socket.h
gmyth/src/gmyth_util.c
     1.1 --- a/gmyth/src/Makefile.am	Thu Jan 11 19:05:37 2007 +0000
     1.2 +++ b/gmyth/src/Makefile.am	Thu Jan 11 19:07:35 2007 +0000
     1.3 @@ -6,7 +6,7 @@
     1.4  	gmyth_marshal.c 			\
     1.5  	gmyth_marshal.h
     1.6  
     1.7 -libgmyth_la_SOURCES = 			\
     1.8 +libgmyth_la_SOURCES = 				\
     1.9  	gmyth_common.c				\
    1.10  	gmyth_debug.c				\
    1.11  	gmyth_epg.c 				\
    1.12 @@ -18,12 +18,13 @@
    1.13  	gmyth_query.c				\
    1.14  	gmyth_socket.c				\
    1.15  	gmyth_stringlist.c			\
    1.16 -	gmyth_monitor_handler.c		\
    1.17 -	gmyth_file_transfer.c		\
    1.18 +	gmyth_monitor_handler.c			\
    1.19 +	gmyth_file_transfer.c			\
    1.20  	gmyth_livetv.c				\
    1.21  	gmyth_backendinfo.c			\
    1.22  	gmyth_programinfo.c			\
    1.23 -	gmyth_uri.c					\
    1.24 +	gmyth_uri.c				\
    1.25 +	gmyth_http.c				\
    1.26  	$(BUILT_SOURCES)
    1.27  
    1.28  
    1.29 @@ -69,7 +70,7 @@
    1.30  	$(pkgincludedir)
    1.31  
    1.32  libgmyth_include_HEADERS =    	\
    1.33 -	gmyth.h						\
    1.34 +	gmyth.h					\
    1.35  	gmyth_common.h	 			\
    1.36  	gmyth_debug.h				\
    1.37  	gmyth_epg.h 				\
    1.38 @@ -81,11 +82,12 @@
    1.39  	gmyth_socket.h 				\
    1.40  	gmyth_remote_util.h			\
    1.41  	gmyth_stringlist.h 			\
    1.42 -	gmyth_monitor_handler.h		\
    1.43 -	gmyth_file_transfer.h		\
    1.44 +	gmyth_monitor_handler.h			\
    1.45 +	gmyth_file_transfer.h			\
    1.46  	gmyth_livetv.h				\
    1.47  	gmyth_backendinfo.h			\
    1.48  	gmyth_programinfo.h			\
    1.49 -	gmyth_uri.h
    1.50 +	gmyth_uri.h				\
    1.51 +	gmyth_http.h
    1.52  	
    1.53  CLEANFILES = $(BUILT_SOURCES)
     2.1 --- a/gmyth/src/gmyth.h	Thu Jan 11 19:05:37 2007 +0000
     2.2 +++ b/gmyth/src/gmyth.h	Thu Jan 11 19:07:35 2007 +0000
     2.3 @@ -46,5 +46,6 @@
     2.4  #include <gmyth_tvchain.h>
     2.5  #include <gmyth_uri.h>
     2.6  #include <gmyth_util.h>
     2.7 +#include <gmyth_http.h>
     2.8  
     2.9  #endif /* _GMYTH_H_ */
     3.1 --- a/gmyth/src/gmyth_file_transfer.c	Thu Jan 11 19:05:37 2007 +0000
     3.2 +++ b/gmyth/src/gmyth_file_transfer.c	Thu Jan 11 19:07:35 2007 +0000
     3.3 @@ -282,7 +282,7 @@
     3.4      transfer->control_sock = NULL;
     3.5    }
     3.6  
     3.7 -  transfer->control_sock = gmyth_socket_new();
     3.8 +  transfer->control_sock = gmyth_socket_new(6543);
     3.9  
    3.10    // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version 
    3.11    if (!gmyth_socket_connect_to_backend (transfer->control_sock,
    3.12 @@ -299,7 +299,7 @@
    3.13      transfer->sock = NULL;
    3.14    }
    3.15  
    3.16 -  transfer->sock = gmyth_socket_new ();
    3.17 +  transfer->sock = gmyth_socket_new (6543);
    3.18    gmyth_socket_connect (transfer->sock, transfer->backend_info->hostname, transfer->backend_info->port);
    3.19  
    3.20    strlist = gmyth_string_list_new();
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/gmyth/src/gmyth_http.c	Thu Jan 11 19:07:35 2007 +0000
     4.3 @@ -0,0 +1,270 @@
     4.4 +/**
     4.5 + * GMyth Library
     4.6 + *
     4.7 + * @file gmyth/gmyth_http.c
     4.8 + * 
     4.9 + * @brief <p> GMythHttp class provides a wrapper to access
    4.10 + * data from the database using http+xml
    4.11 + *
    4.12 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    4.13 + * @author Artur Duque de Souza <@indt.org.br>
    4.14 + *
    4.15 + *//*
    4.16 + * 
    4.17 + * This program is free software; you can redistribute it and/or modify
    4.18 + * it under the terms of the GNU Lesser General Public License as published by
    4.19 + * the Free Software Foundation; either version 2 of the License, or
    4.20 + * (at your option) any later version.
    4.21 + *
    4.22 + * This program is distributed in the hope that it will be useful,
    4.23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.25 + * GNU General Public License for more details.
    4.26 + *
    4.27 + * You should have received a copy of the GNU Lesser General Public License
    4.28 + * along with this program; if not, write to the Free Software
    4.29 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.30 + */
    4.31 + 
    4.32 +#ifdef HAVE_CONFIG_H
    4.33 +#include "config.h"
    4.34 +#endif
    4.35 +
    4.36 +#include <stdlib.h>
    4.37 +#include <stdio.h>
    4.38 +#include <assert.h>
    4.39 +#include <sys/select.h>
    4.40 +
    4.41 +#include "gmyth_http.h"
    4.42 +#include "gmyth_debug.h"
    4.43 +#include "gmyth_socket.h"
    4.44 +
    4.45 +static void gmyth_http_class_init (GMythHttpClass *klass);
    4.46 +static void gmyth_http_init (GMythHttp *object);
    4.47 +
    4.48 +static void gmyth_http_dispose (GObject *object);
    4.49 +static void gmyth_http_finalize (GObject *object);
    4.50 +
    4.51 +G_DEFINE_TYPE(GMythHttp, gmyth_http, G_TYPE_OBJECT)
    4.52 +
    4.53 +
    4.54 +static void gmyth_http_class_init (GMythHttpClass *klass)
    4.55 +{
    4.56 +    GObjectClass *gobject_class;
    4.57 +
    4.58 +    gobject_class = (GObjectClass *) klass;
    4.59 +    gobject_class->dispose  = gmyth_http_dispose;
    4.60 +    gobject_class->finalize = gmyth_http_finalize; 
    4.61 +}
    4.62 +
    4.63 +static void gmyth_http_init (GMythHttp *gmyth_http)
    4.64 +{
    4.65 +    gmyth_http->backend_info = NULL;
    4.66 +    gmyth_http->socket = gmyth_socket_new (MYTH_PORT_STATUS);
    4.67 +    
    4.68 +}
    4.69 +
    4.70 +static void gmyth_http_dispose (GObject *object)
    4.71 +{
    4.72 +    GMythHttp *gmyth_http = GMYTH_HTTP (object);
    4.73 +    
    4.74 +    if (gmyth_http->backend_info)
    4.75 +        g_object_unref (gmyth_http->backend_info);
    4.76 +
    4.77 +    if (gmyth_http->socket) 
    4.78 +        g_object_unref (gmyth_http->socket);
    4.79 +    
    4.80 +    G_OBJECT_CLASS (gmyth_http_parent_class)->dispose (object);
    4.81 +}
    4.82 +
    4.83 +static void gmyth_http_finalize (GObject *object)
    4.84 +{
    4.85 +    g_signal_handlers_destroy (object);
    4.86 +    G_OBJECT_CLASS (gmyth_http_parent_class)->finalize (object);
    4.87 +}
    4.88 +
    4.89 +/** Creates a new instance of GMythHttp.
    4.90 + * 
    4.91 + * @return a new instance of GMythHttp.
    4.92 + */
    4.93 +GMythHttp* gmyth_http_new ()
    4.94 +{
    4.95 +    GMythHttp *http = GMYTH_HTTP (g_object_new(GMYTH_HTTP_TYPE, NULL));
    4.96 +    return http;
    4.97 +}
    4.98 +
    4.99 +/** Creates the Header of the packet.
   4.100 + * 
   4.101 + * @param command The string of the command to be sent
   4.102 + * @return String with the header appended to the command
   4.103 + */
   4.104 +GString * gmyth_http_create_header (GString *command)
   4.105 +{
   4.106 +
   4.107 +    /* secure len to avoid buffer overflows */
   4.108 +    /* len must be big enough to support the command */
   4.109 +    gsize len = command->len + 2048;
   4.110 +    gchar *new_command = g_new0 (gchar, command->len + 2048);
   4.111 + 
   4.112 +    g_snprintf(new_command, len, 
   4.113 +                "GET /%s HTTP/1.1\r\n"
   4.114 +                "Host: 127.0.0.1:6544\r\n"
   4.115 +                "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) "
   4.116 +                    "Gecko/20061025 Firefox/1.5.0.8\r\n"
   4.117 +                "Accept: text/xml,application/xml,application/xhtml+xml,text/html;"
   4.118 +                    "q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n"
   4.119 +                "Accept-Language: en-us,en;q=0.5\r\n"
   4.120 +                "Accept-Encoding: gzip,deflate\r\n"
   4.121 +                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
   4.122 +                "Keep-Alive: 300\r\n"
   4.123 +                "Connection: keep-alive\r\n"
   4.124 +                "\r\n"
   4.125 +                , command->str);
   4.126 +
   4.127 +    GString *new = g_string_new(new_command);
   4.128 +    return new;
   4.129 +
   4.130 +}
   4.131 +
   4.132 +/** Removes the Header of the packet.
   4.133 + * 
   4.134 + * @param packet The string of the packet
   4.135 + * @return String without the header
   4.136 + */
   4.137 +GString * gmyth_http_remove_header (GString *packet)
   4.138 +{
   4.139 +}
   4.140 +
   4.141 +/** Sends a command to the backend.
   4.142 + * 
   4.143 + * @param gmyth_socket the GMythSocket instance.
   4.144 + * @param command The string command to be sent.
   4.145 + * @return gboolean If everything went ok
   4.146 + */
   4.147 +gboolean gmyth_http_send_command(GMythSocket *gmyth_socket, GString *command) 
   4.148 +{
   4.149 +    gboolean ret = TRUE;
   4.150 +
   4.151 +    GIOStatus io_status = G_IO_STATUS_NORMAL;
   4.152 +    GError* error = NULL;  
   4.153 +    
   4.154 +    gsize bytes_written = 0;
   4.155 +
   4.156 +    if( command == NULL || ( command->len <= 0 ) || command->str == NULL ) 
   4.157 +    {
   4.158 +        g_warning ("[%s] Invalid NULL command parameter!\n", __FUNCTION__);
   4.159 +        return FALSE;
   4.160 +    }
   4.161 +
   4.162 +    gmyth_debug ("[%s] Sending command to Myth_HTTP_Server: %s\n", \
   4.163 +                __FUNCTION__, command->str);
   4.164 +
   4.165 +    /* write bytes to socket */    
   4.166 +    io_status = g_io_channel_write_chars( gmyth_socket->sd_io_ch, \
   4.167 +                command->str, command->len, &bytes_written, &error );
   4.168 +
   4.169 +    /* try to catch errors */
   4.170 +    if( (io_status == G_IO_STATUS_ERROR) || ( bytes_written <= 0 ) ) 
   4.171 +    {
   4.172 +        g_warning ("[%s] Error while writing to socket", __FUNCTION__);
   4.173 +        ret = FALSE;
   4.174 +    } else if ( bytes_written < command->len ) 
   4.175 +    {
   4.176 +        g_warning ("[%s] Not all data was written socket", __FUNCTION__);
   4.177 +        ret = FALSE;
   4.178 +    }
   4.179 +
   4.180 +    io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
   4.181 +
   4.182 +    /* not all bytes were sent */
   4.183 +    if ( ( bytes_written != command->len ) || ( io_status == G_IO_STATUS_ERROR ) )
   4.184 +    {
   4.185 +        g_warning ("[%s] Problems when sending data to the socket\n", __FUNCTION__);
   4.186 +        ret = TRUE;
   4.187 +    }
   4.188 +
   4.189 +    if ( error != NULL ) 
   4.190 +    {
   4.191 +        g_printerr( "Error found reading data from IO channel");
   4.192 +        ret = FALSE;
   4.193 +        g_error_free( error );
   4.194 +    }
   4.195 +
   4.196 +    return ret;
   4.197 +}
   4.198 +
   4.199 +
   4.200 +/** Receives an http answer after a gmyth_socket_send_command ().
   4.201 + * 
   4.202 + * @param gmyth_socket The GMythSocket instance.
   4.203 + * @return The response received, or NULL if error or nothing was received.
   4.204 + */
   4.205 +GString* gmyth_http_receive_response(GMythSocket *gmyth_socket)
   4.206 +{
   4.207 +    GIOStatus io_status = G_IO_STATUS_NORMAL;
   4.208 +    GError* error = NULL;
   4.209 +    GString *str = NULL;
   4.210 +    gchar *buff = NULL;
   4.211 +    GIOCondition io_cond; 
   4.212 +
   4.213 +    gsize bytes_read = -1;
   4.214 +
   4.215 +    /* if gmyth_socket == NULL, return NULL */
   4.216 +    if ( gmyth_socket != NULL )
   4.217 +    {
   4.218 +    
   4.219 +        /* verify if there is data to read */
   4.220 +        io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
   4.221 +    
   4.222 +        if ( io_cond == G_IO_OUT ) 
   4.223 +        {
   4.224 +            /* read all data in the buffer */
   4.225 +            g_io_channel_read_to_end( gmyth_socket->sd_io_ch, &buff, &bytes_read, &error);
   4.226 +            str = g_string_new(buff);
   4.227 +            gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read );
   4.228 +        }
   4.229 +    
   4.230 +        if ( ( bytes_read < 0 ) || ( io_status == G_IO_STATUS_ERROR ) || ( error != NULL ))
   4.231 +        {
   4.232 +            g_free (buff);
   4.233 +            g_free (str);
   4.234 +            g_error_free (error);
   4.235 +            g_printerr( "[%s] Error found receiving response from the IO channel: (%d, %s)\n", __FUNCTION__, error->code, error->message );
   4.236 +            return NULL;
   4.237 +        }
   4.238 +
   4.239 +    }
   4.240 +
   4.241 +    /* everything went allright */
   4.242 +    return str;
   4.243 +}
   4.244 +
   4.245 +/** Send HTTP Command
   4.246 + *
   4.247 + * @return true or false
   4.248 + */
   4.249 +GString* gmyth_http_request (GMythHttp *gmyth_http, GString *command)
   4.250 +{
   4.251 +    gmyth_socket_connect (gmyth_http->socket, gmyth_http->backend_info->hostname, 6544);
   4.252 +
   4.253 +    GString *result = NULL;
   4.254 +    gchar *buffer = NULL;
   4.255 +
   4.256 +    buffer = g_strnfill( BUFLEN, ' ');
   4.257 +
   4.258 +    /* creates header */
   4.259 +    GString *new_command = gmyth_http_create_header(command);
   4.260 +
   4.261 +    /* sends the command throught the socket */
   4.262 +    gmyth_http_send_command (gmyth_http->socket, new_command);
   4.263 +
   4.264 +    result = gmyth_http_receive_response (gmyth_http->socket);
   4.265 +
   4.266 +    //if (result != NULL) 
   4.267 +    //    gmyth_debug ("[%s] Response received from Myth_HTTP_Server: %s", __FUNCTION__, result->str);
   4.268 +
   4.269 +    gmyth_socket_close_connection (gmyth_http->socket);
   4.270 +    g_string_free (command, TRUE);
   4.271 +
   4.272 +    return result;
   4.273 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/gmyth/src/gmyth_http.h	Thu Jan 11 19:07:35 2007 +0000
     5.3 @@ -0,0 +1,80 @@
     5.4 +/**
     5.5 + * GMyth Library
     5.6 + *
     5.7 + * @file gmyth/gmyth_http.c
     5.8 + * 
     5.9 + * @brief <p> GMythHttp class provides a wrapper to access
    5.10 + * data from the database using http+xml
    5.11 + *
    5.12 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    5.13 + * @author Artur Duque de Souza <@indt.org.br>
    5.14 + *
    5.15 + *//*
    5.16 + * 
    5.17 + * This program is free software; you can redistribute it and/or modify
    5.18 + * it under the terms of the GNU Lesser General Public License as published by
    5.19 + * the Free Software Foundation; either version 2 of the License, or
    5.20 + * (at your option) any later version.
    5.21 + *
    5.22 + * This program is distributed in the hope that it will be useful,
    5.23 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.24 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.25 + * GNU General Public License for more details.
    5.26 + *
    5.27 + * You should have received a copy of the GNU Lesser General Public License
    5.28 + * along with this program; if not, write to the Free Software
    5.29 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.30 + */
    5.31 +
    5.32 +#ifndef __GMYTH_HTTP_H__
    5.33 +#define __GMYTH_HTTP_H__
    5.34 +
    5.35 +#include <glib-object.h>
    5.36 +
    5.37 +#include "gmyth_socket.h"
    5.38 +#include "gmyth_backendinfo.h"
    5.39 +
    5.40 +#define BUFLEN 1024
    5.41 +
    5.42 +G_BEGIN_DECLS
    5.43 +
    5.44 +#define GMYTH_HTTP_TYPE               (gmyth_http_get_type ())
    5.45 +#define GMYTH_HTTP(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_HTTP_TYPE, GMythHttp))
    5.46 +#define GMYTH_HTTP_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_HTTP_TYPE, GMythHttpClass))
    5.47 +#define IS_GMYTH_HTTP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_HTTP_TYPE))
    5.48 +#define IS_GMYTH_HTTP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_HTTP_TYPE))
    5.49 +#define GMYTH_HTTP_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_HTTP_TYPE, GMythHttpClass))
    5.50 +
    5.51 +#define MYTH_PORT_STATUS 6544
    5.52 +
    5.53 +typedef struct _GMythHttp         GMythHttp;
    5.54 +typedef struct _GMythHttpClass    GMythHttpClass;
    5.55 +
    5.56 +struct _GMythHttpClass
    5.57 +{
    5.58 +  GObjectClass parent_class;
    5.59 +
    5.60 +  /* callbacks */
    5.61 +  /* no one for now */
    5.62 +};
    5.63 +
    5.64 +struct _GMythHttp
    5.65 +{
    5.66 +    GObject parent;
    5.67 +  
    5.68 +    GMythBackendInfo *backend_info;
    5.69 +    GMythSocket *socket;
    5.70 +
    5.71 +    GString *opt_socket_name; /* socket name (use built-in value) */
    5.72 +    unsigned int opt_flags; /* connection flags (none) */
    5.73 +};
    5.74 +
    5.75 +
    5.76 +GType gmyth_http_get_type (void);
    5.77 +
    5.78 +GMythHttp* gmyth_http_new ();
    5.79 +GString* gmyth_http_request (GMythHttp *gmyth_http, GString *command);
    5.80 +
    5.81 +G_END_DECLS
    5.82 +
    5.83 +#endif /* __GMYTH_HTTP_H__ */
     6.1 --- a/gmyth/src/gmyth_livetv.c	Thu Jan 11 19:05:37 2007 +0000
     6.2 +++ b/gmyth/src/gmyth_livetv.c	Thu Jan 11 19:07:35 2007 +0000
     6.3 @@ -235,7 +235,7 @@
     6.4  {
     6.5  	gboolean res = TRUE;
     6.6  
     6.7 -	GMythSocket *socket = gmyth_socket_new ();
     6.8 +	GMythSocket *socket = gmyth_socket_new (6543);
     6.9  	
    6.10  	livetv->backend_info = backend_info;
    6.11  
     7.1 --- a/gmyth/src/gmyth_monitor_handler.c	Thu Jan 11 19:05:37 2007 +0000
     7.2 +++ b/gmyth/src/gmyth_monitor_handler.c	Thu Jan 11 19:07:35 2007 +0000
     7.3 @@ -475,7 +475,7 @@
     7.4  {
     7.5    gboolean ret = TRUE;
     7.6  
     7.7 -  monitor->event_sock = gmyth_socket_new();
     7.8 +  monitor->event_sock = gmyth_socket_new(6543);
     7.9  
    7.10    /* Connects the socket, send Mythtv ANN Monitor and verify Mythtv protocol version */ 
    7.11    if (!gmyth_socket_connect_to_backend_events ( monitor->event_sock,
     8.1 --- a/gmyth/src/gmyth_recorder.c	Thu Jan 11 19:05:37 2007 +0000
     8.2 +++ b/gmyth/src/gmyth_recorder.c	Thu Jan 11 19:07:35 2007 +0000
     8.3 @@ -118,7 +118,7 @@
     8.4  
     8.5  	if (recorder->myth_socket == NULL) {
     8.6  		
     8.7 -		recorder->myth_socket = gmyth_socket_new ();
     8.8 +		recorder->myth_socket = gmyth_socket_new (6543);
     8.9  		
    8.10  		if (!gmyth_socket_connect_to_backend ( recorder->myth_socket, recorder->hostname->str, 
    8.11  					recorder->port, TRUE ) ) {
     9.1 --- a/gmyth/src/gmyth_scheduler.c	Thu Jan 11 19:05:37 2007 +0000
     9.2 +++ b/gmyth/src/gmyth_scheduler.c	Thu Jan 11 19:07:35 2007 +0000
     9.3 @@ -624,7 +624,7 @@
     9.4      g_string_append_printf (datastr, "%d", record_id);
     9.5      gmyth_string_list_append_string (strlist, datastr);
     9.6  
     9.7 -    socket = gmyth_socket_new ();
     9.8 +    socket = gmyth_socket_new (6543);
     9.9      if (gmyth_socket_connect (socket, scheduler->backend_info->hostname,
    9.10  			    scheduler->backend_info->port)) {
    9.11          gmyth_socket_sendreceive_stringlist (socket, strlist);
    10.1 --- a/gmyth/src/gmyth_socket.c	Thu Jan 11 19:05:37 2007 +0000
    10.2 +++ b/gmyth/src/gmyth_socket.c	Thu Jan 11 19:07:35 2007 +0000
    10.3 @@ -408,11 +408,11 @@
    10.4   * @return a new instance of GMythSocket.
    10.5   */
    10.6  GMythSocket*
    10.7 -gmyth_socket_new ()
    10.8 +gmyth_socket_new (int port)
    10.9  {
   10.10      GMythSocket *gmyth_socket = GMYTH_SOCKET (g_object_new(GMYTH_SOCKET_TYPE, NULL));
   10.11  
   10.12 -    gmyth_socket->port = 6543;
   10.13 +    gmyth_socket->port = port;
   10.14      
   10.15      gmyth_socket->mythtv_version = MYTHTV_VERSION_DEFAULT;
   10.16  
   10.17 @@ -967,7 +967,7 @@
   10.18  
   10.19      gsize bytes_read = 0;
   10.20      gint  len = 0;
   10.21 -    GIOCondition io_cond;
   10.22 +    GIOCondition io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
   10.23  
   10.24      g_return_val_if_fail( gmyth_socket != NULL, NULL );
   10.25  
    11.1 --- a/gmyth/src/gmyth_socket.h	Thu Jan 11 19:05:37 2007 +0000
    11.2 +++ b/gmyth/src/gmyth_socket.h	Thu Jan 11 19:07:35 2007 +0000
    11.3 @@ -69,7 +69,7 @@
    11.4  	GObject parent;
    11.5  
    11.6  	/* socket descriptor */
    11.7 -	gint sd;  
    11.8 +	gint sd;
    11.9  	GIOChannel *sd_io_ch;
   11.10  
   11.11  	gchar *hostname;
   11.12 @@ -82,7 +82,10 @@
   11.13  
   11.14  GType           gmyth_socket_get_type (void);
   11.15  
   11.16 -GMythSocket *   gmyth_socket_new ( );
   11.17 +GMythSocket *   gmyth_socket_new (gint port);
   11.18 +
   11.19 +gboolean        gmyth_socket_connect (GMythSocket *gmyth_socket, const gchar *hostname, gint port);
   11.20 +
   11.21  
   11.22  GIOChannel *    gmyth_socket_get_io_channel (GMythSocket *gmyth_socket );
   11.23  
   11.24 @@ -92,7 +95,7 @@
   11.25  gboolean        gmyth_socket_send_command (GMythSocket *gmyth_socket, 
   11.26                                             GString *command);
   11.27  GString *       gmyth_socket_receive_response (GMythSocket *gmyth_socket);
   11.28 -gint             gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket, 
   11.29 +gint            gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket, 
   11.30                                                       GMythStringList *str_list);
   11.31  
   11.32  gboolean        gmyth_socket_connect (GMythSocket *gmyth_socket,
    12.1 --- a/gmyth/src/gmyth_util.c	Thu Jan 11 19:05:37 2007 +0000
    12.2 +++ b/gmyth/src/gmyth_util.c	Thu Jan 11 19:07:35 2007 +0000
    12.3 @@ -420,7 +420,7 @@
    12.4      GMythSocket *socket;
    12.5      gboolean res;
    12.6      
    12.7 -    socket = gmyth_socket_new ();
    12.8 +    socket = gmyth_socket_new (6543);
    12.9      res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
   12.10  		    backend_info->port, TRUE);
   12.11